vtkUndoElement.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
18 #ifndef vtkUndoElement_h
19 #define vtkUndoElement_h
20 
21 #include "vtkObject.h"
22 #include "vtkPVVTKExtensionsCoreModule.h" // needed for export macro
23 class vtkCollection;
24 
25 class VTKPVVTKEXTENSIONSCORE_EXPORT vtkUndoElement : public vtkObject
26 {
27 public:
28  vtkTypeMacro(vtkUndoElement, vtkObject);
29  void PrintSelf(ostream& os, vtkIndent indent) override;
30 
35  virtual int Undo() = 0;
36 
41  virtual int Redo() = 0;
42 
44 
52  vtkGetMacro(Mergeable, bool);
54 
61  virtual bool Merge(vtkUndoElement* vtkNotUsed(new_element)) { return false; }
62 
63  // Set the working context if run inside a UndoSet context, so object
64  // that are cross referenced can leave long enough to be associated
65  // to another object. Otherwise the undo of a Delete will create the object
66  // again but as no-one is holding a reference to that newly created object
67  // it will be automatically deleted. Therefore, we provide a collection
68  // that will hold a reference during an undoset so the object has a chance
69  // to be attached to the ProxyManager or any other object.
70  virtual void SetUndoSetWorkingContext(vtkCollection* workCTX)
71  {
72  this->UndoSetWorkingContext = workCTX;
73  }
74 
75 protected:
77  ~vtkUndoElement() override;
78 
80 
84  bool Mergeable;
85  vtkSetMacro(Mergeable, bool);
88 
89 private:
90  vtkUndoElement(const vtkUndoElement&) = delete;
91  void operator=(const vtkUndoElement&) = delete;
92 };
93 
94 #endif
vtkObjectBase::operator=
void operator=(const vtkObjectBase &)
vtkUndoElement::SetUndoSetWorkingContext
virtual void SetUndoSetWorkingContext(vtkCollection *workCTX)
Definition: vtkUndoElement.h:70
vtkUndoElement::Mergeable
bool Mergeable
Subclasses must set this flag to enable merging of consecutive elements in an UndoSet.
Definition: vtkUndoElement.h:84
vtkObject
vtkCollection
vtkUndoElement
unit undo-redo-able operation.
Definition: vtkUndoElement.h:25
vtkUndoElement::UndoSetWorkingContext
vtkCollection * UndoSetWorkingContext
Subclasses must set this flag to enable merging of consecutive elements in an UndoSet.
Definition: vtkUndoElement.h:85
vtkIndent
vtkObject.h
vtkUndoElement::Merge
virtual bool Merge(vtkUndoElement *vtkNotUsed(new_element))
Called on the older element in the UndoSet to merge with the element being added if both the elements...
Definition: vtkUndoElement.h:61
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE