ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vtkUndoElement.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include "qPCL.h" // needed for export macro
11 #include "vtkObject.h"
12 class vtkCollection;
13 
14 class QPCL_ENGINE_LIB_API vtkUndoElement : public vtkObject {
15 public:
17  void PrintSelf(ostream& os, vtkIndent indent) override;
18 
23  virtual int Undo() = 0;
24 
29  virtual int Redo() = 0;
30 
32 
40  vtkGetMacro(Mergeable, bool);
42 
49  virtual bool Merge(vtkUndoElement* vtkNotUsed(new_element)) {
50  return false;
51  }
52 
53  // Set the working context if run inside a UndoSet context, so object
54  // that are cross referenced can leave long enough to be associated
55  // to another object. Otherwise the undo of a Delete will create the object
56  // again but as no-one is holding a reference to that newly created object
57  // it will be automatically deleted. Therefore, we provide a collection
58  // that will hold a reference during an undoset so the object has a chance
59  // to be attached to the ProxyManager or any other object.
60  virtual void SetUndoSetWorkingContext(vtkCollection* workCTX) {
61  this->UndoSetWorkingContext = workCTX;
62  }
63 
64 protected:
66  ~vtkUndoElement() override;
67 
69 
73  bool Mergeable;
74  vtkSetMacro(Mergeable, bool);
75  vtkCollection* UndoSetWorkingContext;
77 
78 private:
79  vtkUndoElement(const vtkUndoElement&) = delete;
80  void operator=(const vtkUndoElement&) = delete;
81 };
vtkGetMacro(Mergeable, bool)
vtkTypeMacro(vtkUndoElement, vtkObject)
vtkCollection * UndoSetWorkingContext
vtkSetMacro(Mergeable, bool)
virtual int Redo()=0
virtual int Undo()=0
virtual void SetUndoSetWorkingContext(vtkCollection *workCTX)
virtual bool Merge(vtkUndoElement *vtkNotUsed(new_element))
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15