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

#include <layerops.h>

Inheritance diagram for lc::operation::ReplaceLayer:
Collaboration diagram for lc::operation::ReplaceLayer:

Public Member Functions

 ReplaceLayer (std::shared_ptr< Document > document, const Layer_CSPtr oldLayer, const Layer_CSPtr newLayer)
 
virtual void undo () const
 Undo a given operation. More...
 
virtual void redo () const
 Redo a given operation. More...
 
- Public Member Functions inherited from lc::operation::DocumentOperation
 DocumentOperation (Document_SPtr document, const std::string &description)
 
Document_SPtr document () const
 
virtual void execute ()
 execute this operation More...
 
virtual ~DocumentOperation ()
 
- Public Member Functions inherited from lc::operation::Undoable
 Undoable (const std::string &text)
 Name of this operartion. More...
 
virtual ~Undoable ()
 
virtual std::string text ()
 Name of the operation. More...
 

Protected Member Functions

virtual void processInternal ()
 

Private Attributes

Layer_CSPtr _oldLayer
 
Layer_CSPtr _newLayer
 

Detailed Description

Remove layer from document

Definition at line 52 of file layerops.h.

Constructor & Destructor Documentation

ReplaceLayer::ReplaceLayer ( std::shared_ptr< Document document,
const Layer_CSPtr  oldLayer,
const Layer_CSPtr  newLayer 
)

ReplaceLayer

Definition at line 71 of file layerops.cpp.

71  :
72  DocumentOperation(document, "ReplaceLayer"),
73  _oldLayer(oldLayer),
74  _newLayer(newLayer) {
75 }
DocumentOperation(Document_SPtr document, const std::string &description)

Member Function Documentation

void ReplaceLayer::processInternal ( )
protectedvirtual

This function gets called when an operation starts and when the document is locked for you so you can do your work

Implements lc::operation::DocumentOperation.

Definition at line 77 of file layerops.cpp.

77  {
78  auto le = document()->entityContainer().entitiesByLayer(_oldLayer).asVector();
79 
80  for (auto i : le) {
81  document()->removeEntity(i);
82  document()->insertEntity(i->modify(_newLayer, i->metaInfo(), i->block()));
83  }
84 
85  document()->removeDocumentMetaType(_oldLayer);
86  document()->addDocumentMetaType(_newLayer);
87 }
void ReplaceLayer::redo ( ) const
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.

Implements lc::operation::Undoable.

Definition at line 92 of file layerops.cpp.

92  {
93 }
void ReplaceLayer::undo ( ) const
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

Implements lc::operation::Undoable.

Definition at line 89 of file layerops.cpp.

89  {
90 }

Member Data Documentation

Layer_CSPtr lc::operation::ReplaceLayer::_newLayer
private

Definition at line 66 of file layerops.h.

Layer_CSPtr lc::operation::ReplaceLayer::_oldLayer
private

Definition at line 65 of file layerops.h.


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