LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lc::operation::Undoable Class Referenceabstract

: Abstract class for a Undoable operations All operations you wnt to beable to get place in the undo stack should inherit from Undoable and implement undo and redo. A provided text can be used to show within the undo stack what operation will be re-done or un-done. More...

#include <undoable.h>

Inheritance diagram for lc::operation::Undoable:

Public Member Functions

 Undoable (const std::string &text)
 Name of this operartion. More...
 
virtual ~Undoable ()
 
virtual void undo () const =0
 Undo a given operation. More...
 
virtual void redo () const =0
 Redo a given operation. More...
 
virtual std::string text ()
 Name of the operation. More...
 

Private Attributes

std::string _text
 

Detailed Description

: Abstract class for a Undoable operations All operations you wnt to beable to get place in the undo stack should inherit from Undoable and implement undo and redo. A provided text can be used to show within the undo stack what operation will be re-done or un-done.

Parameters
text

Definition at line 18 of file undoable.h.

Constructor & Destructor Documentation

lc::operation::Undoable::Undoable ( const std::string &  text)
inline

Name of this operartion.

Keep it as short as possible since it will be used in the UI

Definition at line 24 of file undoable.h.

24  {
25  _text = text;
26  }
virtual std::string text()
Name of the operation.
Definition: undoable.h:57
std::string _text
Definition: undoable.h:62
virtual lc::operation::Undoable::~Undoable ( )
inlinevirtual

Definition at line 27 of file undoable.h.

27  {
28  // LOG4CXX_DEBUG(logger, "Undoable removed:");
29  }

Member Function Documentation

virtual void lc::operation::Undoable::redo ( ) const
pure virtual

Redo a given operation.

This can get called if we want to redo a operation. Redo is usually called after an undo operation. If in the undo operation entities where removed, it needs to get added again. it doesn't have to do any re.calculation but just remember what entities have been added or removed.

Implemented in lc::operation::ReplaceLinePattern, lc::operation::ReplaceLayer, lc::operation::ReplaceBlock, lc::operation::RemoveLinePattern, lc::operation::EntityBuilder, lc::operation::RemoveLayer, lc::operation::RemoveBlock, lc::operation::Builder, lc::operation::AddLinePattern, lc::operation::AddLayer, and lc::operation::AddBlock.

virtual std::string lc::operation::Undoable::text ( )
inlinevirtual

Name of the operation.

Return the name of the operation. For example when a operation started it can be given the name 'add lines' So in the UI you can say 'Undo add lines' or 'Redo add lines'

Returns

Definition at line 57 of file undoable.h.

57  {
58  return _text;
59  }
std::string _text
Definition: undoable.h:62
virtual void lc::operation::Undoable::undo ( ) const
pure virtual

Undo a given operation.

For any operation that means for example when it added entities to the document it now needs to remove all created entities on the document. When the operation added a layer or block, it will call functions to remove that block

Implemented in lc::operation::ReplaceLinePattern, lc::operation::ReplaceLayer, lc::operation::ReplaceBlock, lc::operation::RemoveLinePattern, lc::operation::EntityBuilder, lc::operation::RemoveLayer, lc::operation::RemoveBlock, lc::operation::Builder, lc::operation::AddLinePattern, lc::operation::AddLayer, and lc::operation::AddBlock.

Member Data Documentation

std::string lc::operation::Undoable::_text
private

Definition at line 62 of file undoable.h.


The documentation for this class was generated from the following file: