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 
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
unit undo-redo-able operation.
virtual void SetUndoSetWorkingContext(vtkCollection *workCTX)
#define VTKPVVTKEXTENSIONSCORE_EXPORT
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
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...
vtkCollection * UndoSetWorkingContext
Subclasses must set this flag to enable merging of consecutive elements in an UndoSet.
bool Mergeable
Subclasses must set this flag to enable merging of consecutive elements in an UndoSet.
void operator=(const vtkObjectBase &)