vtkUndoElement.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkUndoElement.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
30 #ifndef vtkUndoElement_h
31 #define vtkUndoElement_h
32 
33 #include "vtkObject.h"
34 #include "vtkPVVTKExtensionsCoreModule.h" // needed for export macro
35 class vtkCollection;
36 
38 {
39 public:
40  vtkTypeMacro(vtkUndoElement, vtkObject);
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
47  virtual int Undo() = 0;
48 
53  virtual int Redo() = 0;
54 
56 
64  vtkGetMacro(Mergeable, bool);
66 
73  virtual bool Merge(vtkUndoElement* vtkNotUsed(new_element)) { return false; }
74 
75  // Set the working context if run inside a UndoSet context, so object
76  // that are cross referenced can leave long enough to be associated
77  // to another object. Otherwise the undo of a Delete will create the object
78  // again but as no-one is holding a reference to that newly created object
79  // it will be automatically deleted. Therefore, we provide a collection
80  // that will hold a reference during an undoset so the object has a chance
81  // to be attached to the ProxyManager or any other object.
82  virtual void SetUndoSetWorkingContext(vtkCollection* workCTX)
83  {
84  this->UndoSetWorkingContext = workCTX;
85  }
86 
87 protected:
89  ~vtkUndoElement() override;
90 
92 
96  bool Mergeable;
97  vtkSetMacro(Mergeable, bool);
100 
101 private:
102  vtkUndoElement(const vtkUndoElement&) = delete;
103  void operator=(const vtkUndoElement&) = delete;
104 };
105 
106 #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 &)