TridUndoable< STATECLASS > Class Template Reference

#include <TridUndoable.h>

List of all members.

Public Member Functions

 TridUndoable (int max=100)
 ~TridUndoable ()
void Push ()
void Change ()
void Undo ()
void Redo ()

Protected Attributes

unsigned int fIndex
unsigned int fMax
std::deque< STATECLASS > fStack


Detailed Description

template<class STATECLASS>
class TridUndoable< STATECLASS >

Definition at line 13 of file TridUndoable.h.


Constructor & Destructor Documentation

template<class STATECLASS>
TridUndoable< STATECLASS >::TridUndoable ( int  max = 100  )  [inline]

Definition at line 16 of file TridUndoable.h.

00016 { fMax = max; fIndex = 0; };

template<class STATECLASS>
TridUndoable< STATECLASS >::~TridUndoable (  )  [inline]

Definition at line 17 of file TridUndoable.h.

00017 {};


Member Function Documentation

template<class STATECLASS>
void TridUndoable< STATECLASS >::Change (  )  [inline]

Definition at line 28 of file TridUndoable.h.

00028                 { 
00029     if(fIndex>0) Push();
00030     fStack[fIndex].Copy(*this);
00031   };

template<class STATECLASS>
void TridUndoable< STATECLASS >::Push (  )  [inline]

Definition at line 20 of file TridUndoable.h.

Referenced by TridUndoable< TridPOV >::Change(), TridGLFrame::HandleMotion(), TridFlatGLFrame::HandleMotion(), and TridGLFrame::SetPOV().

00020               { 
00021     while(fIndex>0) { fStack.pop_front(); fIndex--; };      // Get rid of history after this one.
00022     fStack.push_front(STATECLASS(*this));                   // Push it on.
00023     while(fStack.size()>fMax) { fStack.pop_back(); };       // Clean up if we're too big.
00024   };

template<class STATECLASS>
void TridUndoable< STATECLASS >::Redo ( void   )  [inline]

Definition at line 40 of file TridUndoable.h.

00040               {
00041     if(fIndex>0) fIndex--;
00042     Copy(fStack[fIndex]);
00043   }

template<class STATECLASS>
void TridUndoable< STATECLASS >::Undo ( void   )  [inline]

Definition at line 33 of file TridUndoable.h.

00033               { 
00034     if((fIndex+1)<fStack.size()) {
00035       fIndex++;
00036       Copy(fStack[fIndex]);    
00037     }
00038   }


Member Data Documentation

template<class STATECLASS>
unsigned int TridUndoable< STATECLASS >::fIndex [protected]

Definition at line 46 of file TridUndoable.h.

Referenced by TridUndoable< TridPOV >::Change(), TridUndoable< TridPOV >::Push(), TridUndoable< TridPOV >::Redo(), TridUndoable< TridPOV >::TridUndoable(), and TridUndoable< TridPOV >::Undo().

template<class STATECLASS>
unsigned int TridUndoable< STATECLASS >::fMax [protected]

Definition at line 47 of file TridUndoable.h.

Referenced by TridUndoable< TridPOV >::Push(), and TridUndoable< TridPOV >::TridUndoable().

template<class STATECLASS>
std::deque<STATECLASS> TridUndoable< STATECLASS >::fStack [protected]

Definition at line 48 of file TridUndoable.h.

Referenced by TridUndoable< TridPOV >::Change(), TridUndoable< TridPOV >::Push(), TridUndoable< TridPOV >::Redo(), and TridUndoable< TridPOV >::Undo().


The documentation for this class was generated from the following file:
Generated on Wed Dec 10 22:50:39 2014 for loon by  doxygen 1.4.7