OpendTect-6_4  6.4
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Undo Class Reference

Class to handle undo/redo information. More...

Inheritance diagram for Undo:
[legend]

Public Member Functions

 Undo ()
 
virtual ~Undo ()
 
void removeAll ()
 
int maxLength () const
 
void setMaxLength (int)
 
int addEvent (UndoEvent *event, const char *description=0)
 
int currentEventID () const
 
int firstEventID () const
 
int lastEventID () const
 
void removeAllAfterCurrentEvent ()
 
void removeAllBeforeCurrentEvent ()
 
bool isUserInteractionEnd (int eventid) const
 
void setUserInteractionEnd (int eventid, bool=true)
 
int getNextUserInteractionEnd (int start) const
 
BufferString getDesc (int eventid) const
 
void setDesc (int eventid, const char *d)
 
BufferString unDoDesc () const
 
BufferString reDoDesc () const
 
bool canUnDo () const
 
bool unDo (int nrtimes=1, bool userinteraction=true)
 
bool canReDo () const
 
bool reDo (int nrtimes=1, bool userinteraction=true)
 
- Public Member Functions inherited from CallBacker
 CallBacker ()
 
 CallBacker (const CallBacker &)
 
virtual ~CallBacker ()
 
bool attachCB (NotifierAccess &, const CallBack &, bool onlyifnew=false)
 
bool attachCB (NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false)
 
void detachCB (NotifierAccess &, const CallBack &)
 
void detachCB (NotifierAccess *notif, const CallBack &cb)
 
bool isNotifierAttached (NotifierAccess *) const
 Only for debugging purposes, don't use. More...
 

Public Attributes

Notifier< Undochangenotifier
 
Notifier< Undoundoredochange
 

Protected Member Functions

int indexOf (int eventid) const
 
void removeOldEvents ()
 
void removeStartToAndIncluding (int)
 
- Protected Member Functions inherited from CallBacker
void detachAllNotifiers ()
 Call from the destructor of your inherited object. More...
 

Protected Attributes

int currenteventid_
 
int firsteventid_
 
int maxsize_
 
ObjectSet< UndoEventevents_
 
int userendscount_
 
Threads::Lock addlock_
 

Detailed Description

Class to handle undo/redo information.

Events that can be undone/redone are added to the Undo. One user operation may involve thousands of changes added to the history, but the user does not want to press undo a thousand times.This is managed by setting a UserInteractionEnd flag on the last event in a chain that the user started. When doing undo, one undo step is consists of all events from the current event until the next event with the UserInteraction flag set.

This means that after all user-driven events, the UserInteractionEnd should be set:

void MyClass::userPushedAButtonCB( CallBacker* )
{
doSomethingsThatAddThingsOnTheHistory();
history.setUserInteractionEnd( currentEventID() );
}

Constructor & Destructor Documentation

Undo::Undo ( )
virtual Undo::~Undo ( )
virtual

Member Function Documentation

int Undo::addEvent ( UndoEvent event,
const char *  description = 0 
)
Parameters
eventThe new event (becomes mine).
Returns
the event id.
bool Undo::canReDo ( ) const
bool Undo::canUnDo ( ) const
Note
takes redodesc with userinteraction
int Undo::currentEventID ( ) const
int Undo::firstEventID ( ) const
BufferString Undo::getDesc ( int  eventid) const
int Undo::getNextUserInteractionEnd ( int  start) const
int Undo::indexOf ( int  eventid) const
protected
bool Undo::isUserInteractionEnd ( int  eventid) const
int Undo::lastEventID ( ) const
int Undo::maxLength ( ) const

Returns maximum number of userevents.

Note
The actual number of events may be considerably higher since many events may be part of one single user event.
bool Undo::reDo ( int  nrtimes = 1,
bool  userinteraction = true 
)
BufferString Undo::reDoDesc ( ) const
void Undo::removeAll ( )
void Undo::removeAllAfterCurrentEvent ( )
void Undo::removeAllBeforeCurrentEvent ( )
void Undo::removeOldEvents ( )
protected
void Undo::removeStartToAndIncluding ( int  )
protected
void Undo::setDesc ( int  eventid,
const char *  d 
)
void Undo::setMaxLength ( int  )
void Undo::setUserInteractionEnd ( int  eventid,
bool  = true 
)
bool Undo::unDo ( int  nrtimes = 1,
bool  userinteraction = true 
)
BufferString Undo::unDoDesc ( ) const

Member Data Documentation

Threads::Lock Undo::addlock_
protected
Notifier<Undo> Undo::changenotifier
int Undo::currenteventid_
protected
ObjectSet<UndoEvent> Undo::events_
protected
int Undo::firsteventid_
protected
int Undo::maxsize_
protected
Notifier<Undo> Undo::undoredochange
int Undo::userendscount_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019