OpendTect  6.6
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 ()
 
int addEvent (UndoEvent *event, const char *description=0)
 
bool canReDo () const
 
bool canUnDo () const
 
int currentEventID () const
 
int firstEventID () const
 
BufferString getDesc (int eventid) const
 
int getNextUserInteractionEnd (int start) const
 
bool isUserInteractionEnd (int eventid) const
 
int lastEventID () const
 
int maxLength () const
 
bool reDo (int nrtimes=1, bool userinteraction=true)
 
BufferString reDoDesc () const
 
void removeAll ()
 
void removeAllAfterCurrentEvent ()
 
void removeAllBeforeCurrentEvent ()
 
void setDesc (int eventid, const char *d)
 
void setMaxLength (int)
 
void setUserInteractionEnd (int eventid, bool=true)
 
bool unDo (int nrtimes=1, bool userinteraction=true)
 
BufferString unDoDesc () const
 
- Public Member Functions inherited from CallBacker
 CallBacker ()
 
 CallBacker (const CallBacker &)
 
virtual ~CallBacker ()
 
bool attachCB (const NotifierAccess &, const CallBack &, bool onlyifnew=false) const
 
bool attachCB (const NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false) const
 
void detachAllNotifiers () const
 Call from the destructor of your inherited object. More...
 
void detachCB (const NotifierAccess &, const CallBack &) const
 
void detachCB (const NotifierAccess *notif, const CallBack &cb) const
 
virtual bool isCapsule () const
 
bool isNotifierAttached (const NotifierAccess *) const
 Only for debugging purposes, don't use. More...
 
void stopReceivingNotifications () const
 

Public Attributes

Notifier< Undochangenotifier
 
Notifier< Undoundoredochange
 

Protected Member Functions

int indexOf (int eventid) const
 
void removeOldEvents ()
 
void removeStartToAndIncluding (int)
 

Protected Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from CallBacker
static void createReceiverForCurrentThread ()
 
static void removeReceiverForCurrentThread ()
 

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() );
}
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:185
int currentEventID() const

<>

Constructor & Destructor Documentation

◆ Undo()

Undo::Undo ( )

◆ ~Undo()

virtual Undo::~Undo ( )
virtual

Member Function Documentation

◆ addEvent()

int Undo::addEvent ( UndoEvent event,
const char *  description = 0 
)
Parameters
eventThe new event (becomes mine).
description
Returns
the event id.

◆ canReDo()

bool Undo::canReDo ( ) const

◆ canUnDo()

bool Undo::canUnDo ( ) const
Note
takes redodesc with userinteraction

◆ currentEventID()

int Undo::currentEventID ( ) const

◆ firstEventID()

int Undo::firstEventID ( ) const

◆ getDesc()

BufferString Undo::getDesc ( int  eventid) const

◆ getNextUserInteractionEnd()

int Undo::getNextUserInteractionEnd ( int  start) const

◆ indexOf()

int Undo::indexOf ( int  eventid) const
protected

◆ isUserInteractionEnd()

bool Undo::isUserInteractionEnd ( int  eventid) const

◆ lastEventID()

int Undo::lastEventID ( ) const

◆ maxLength()

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.

◆ reDo()

bool Undo::reDo ( int  nrtimes = 1,
bool  userinteraction = true 
)

◆ reDoDesc()

BufferString Undo::reDoDesc ( ) const

◆ removeAll()

void Undo::removeAll ( )

◆ removeAllAfterCurrentEvent()

void Undo::removeAllAfterCurrentEvent ( )

◆ removeAllBeforeCurrentEvent()

void Undo::removeAllBeforeCurrentEvent ( )

◆ removeOldEvents()

void Undo::removeOldEvents ( )
protected

◆ removeStartToAndIncluding()

void Undo::removeStartToAndIncluding ( int  )
protected

◆ setDesc()

void Undo::setDesc ( int  eventid,
const char *  d 
)

◆ setMaxLength()

void Undo::setMaxLength ( int  )

◆ setUserInteractionEnd()

void Undo::setUserInteractionEnd ( int  eventid,
bool  = true 
)

◆ unDo()

bool Undo::unDo ( int  nrtimes = 1,
bool  userinteraction = true 
)

◆ unDoDesc()

BufferString Undo::unDoDesc ( ) const

Member Data Documentation

◆ addlock_

Threads::Lock Undo::addlock_
protected

◆ changenotifier

Notifier<Undo> Undo::changenotifier

◆ currenteventid_

int Undo::currenteventid_
protected

◆ events_

ObjectSet<UndoEvent> Undo::events_
protected

◆ firsteventid_

int Undo::firsteventid_
protected

◆ maxsize_

int Undo::maxsize_
protected

◆ undoredochange

Notifier<Undo> Undo::undoredochange

◆ userendscount_

int Undo::userendscount_
protected

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