| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /****************************************************************************** 00002 * VRS - The Virtual Rendering System 00003 * Copyright (C) 2000-2008 Computer Graphics Systems Group at the 00004 * Hasso-Plattner-Institute (HPI), Potsdam, Germany. 00005 * 00006 * This library is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or (at 00009 * your option) any later version. This library is distributed in the hope 00010 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 00011 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. You should have received 00013 * a copy of the GNU Lesser+ General Public License along with this library; if 00014 * not, write to the FreeSoftware Foundation, Inc., 59 Temple Place, Suite 330, 00015 * Boston, MA, 02111-1307, USA. 00016 ******************************************************************************/ 00017 00018 // $Id: undonavigation.h 6429 2008-07-04 15:03:07Z Stefan_Maass $ 00019 00020 #ifndef VRS_SG_UNDONAVIGATION_H 00021 #define VRS_SG_UNDONAVIGATION_H 00022 00023 #include <vrs/sg/interactiontechnique.h> 00024 00025 namespace VRS { 00026 00027 template<typename ARG1, typename ARG2> class Callback2; 00028 00032 class VRS_CORE_API UndoNavigation : public InteractionTechnique { 00033 00034 public: 00035 00036 UndoNavigation(unsigned int memorySize = 500); 00037 00043 void setMemorySize(unsigned int memorySize); 00044 unsigned int getMemorySize() const; 00045 00047 void doUndo(bool on); 00049 void doRedo(bool on); 00050 00052 typedef VRS::Callback2<bool,bool> UndoRedoAvailableCallback; 00054 00055 void setUndoRedoAvailableCallback(SO<UndoRedoAvailableCallback> callback); 00056 00058 static const KeyFunctionID UndoKey; // default is Strg-z 00059 static const KeyFunctionID RedoKey; // default to Strg-Shift-Z 00060 00061 virtual void onTimer(SO<TimeEvent> event, double secondsSinceLastTimeEvent); 00062 virtual void onKey(SO<KeyEvent> event, KeyFunctionID id); 00063 00065 void onEventPassive(SO<Event> event, bool modeActive); 00066 00067 VRS_TYPEINFO(UndoNavigation, InteractionTechnique); 00068 VRS_SERIALIZABLE(UndoNavigation); 00069 00070 private: 00071 void activateRewind(); 00072 void notifyUndoRedoAvailable(bool undoAvailable, bool redoAvailable); 00073 00074 struct VRS_CORE_API Keyframe { 00075 Vector from; 00076 Vector to; 00077 double timeStamp; 00078 VRS_SERIALIZABLE_NO_SO_CLASS(Keyframe); 00079 }; 00080 00081 // an array of recorded views with time stamps. 00082 SO<Array<Keyframe> > m_keyframes; 00083 00084 unsigned int m_memorySize; 00085 mutable double m_recordingTimeStamp; 00086 mutable double m_elapsedTime; 00087 00088 bool doUndo_; 00089 bool doRedo_; 00090 SO<UndoRedoAvailableCallback> undoRedoAvailableCallback_; 00091 00092 // when rewinding the navigation, m_rewinding is true and m_rewindPosition indicates the currently applied timestamp 00093 bool m_rewinding; 00094 double m_rewindPosition; 00095 Vector m_lastSetFrom; 00096 Vector m_lastSetTo; 00097 }; 00098 00099 } // namespace VRS 00100 00101 00102 #endif // VRS_SG_UNDONAVIGATION_H