VTK  9.7.1
vtkHandleRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
36 #ifndef vtkHandleRepresentation_h
37 #define vtkHandleRepresentation_h
38 
39 #include "vtkInteractionWidgetsModule.h" // For export macro
41 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
42 
43 VTK_ABI_NAMESPACE_BEGIN
44 class vtkCoordinate;
45 class vtkRenderer;
46 class vtkPointPlacer;
47 
48 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkHandleRepresentation
50 {
51 public:
53 
57  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
61 
70  virtual void SetDisplayPosition(double pos[2]);
72  virtual void GetDisplayPosition(double pos[2]);
74  virtual double* GetDisplayPosition() VTK_SIZEHINT(2);
75  virtual void SetWorldPosition(double pos[3]);
76  virtual void GetWorldPosition(double pos[3]) VTK_FUTURE_CONST;
77  virtual double* GetWorldPosition() VTK_SIZEHINT(3);
79 
81 
86  vtkSetClampMacro(Tolerance, int, 1, 100);
87  vtkGetMacro(Tolerance, int);
89 
91 
96  vtkSetMacro(ActiveRepresentation, vtkTypeBool);
97  vtkGetMacro(ActiveRepresentation, vtkTypeBool);
98  vtkBooleanMacro(ActiveRepresentation, vtkTypeBool);
100 
101  // Enums define the state of the representation relative to the mouse pointer
102  // position. Used by ComputeInteractionState() to communicate with the
103  // widget. Note that ComputeInteractionState() and several other methods
104  // must be implemented by subclasses.
106  {
107  Outside = 0,
111  Scaling
112  };
113 
115 
124  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
126 
128 
133  vtkSetMacro(Constrained, vtkTypeBool);
134  vtkGetMacro(Constrained, vtkTypeBool);
135  vtkBooleanMacro(Constrained, vtkTypeBool);
137 
145  virtual int CheckConstraint(vtkRenderer* renderer, double pos[2]);
146 
148 
151  void ShallowCopy(vtkProp* prop) override;
152  virtual void DeepCopy(vtkProp* prop);
153  void SetRenderer(vtkRenderer* ren) override;
155 
160  vtkMTimeType GetMTime() override;
161 
163 
171  virtual void SetPointPlacer(vtkPointPlacer*);
172  vtkGetObjectMacro(PointPlacer, vtkPointPlacer);
174 
176 
179  virtual void GetTranslationVector(const double* p1, const double* p2, double* v) const;
180 
182 
185  virtual void Translate(const double* p1, const double* p2);
187 
189 
192  virtual void Translate(const double* v);
194 
196 
200  vtkGetMacro(TranslationAxis, int);
201  vtkSetClampMacro(TranslationAxis, int, -1, 2);
203 
205 
208  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
209  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
210  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
211  void SetCustomTranslationAxisOn() { this->TranslationAxis = Axis::Custom; }
212  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
214 
216 
222  vtkGetVector3Macro(CustomTranslationAxis, double);
223  vtkSetVector3Macro(CustomTranslationAxis, double);
225 
227 
230  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
232 
233 protected:
235  ~vtkHandleRepresentation() override;
236 
237  int Tolerance = 15;
238  vtkTypeBool ActiveRepresentation = false;
239  vtkTypeBool Constrained = false;
240 
241  // Two vtkCoordinates are available to subclasses, one in display
242  // coordinates and the other in world coordinates. These facilitate
243  // the conversion between these two systems. Note that the WorldPosition
244  // is the ultimate maintainer of position.
247 
248  // Keep track of when coordinates were changed
251 
252  // Constraint the placement of handles.
254 
255  // Constraint axis translation
256  int TranslationAxis = Axis::NONE;
257  double CustomTranslationAxis[3] = { 1.0, 0.0, 0.0 };
258 
259 private:
261  void operator=(const vtkHandleRepresentation&) = delete;
262 };
263 
264 VTK_ABI_NAMESPACE_END
265 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
abstract class for representing widget handles
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkProp.
vtkNew< vtkCoordinate > WorldPosition
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
record modification and/or execution time
Definition: vtkTimeStamp.h:24
void SetCustomTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual void SetRenderer(vtkRenderer *ren)
Subclasses of vtkWidgetRepresentation must implement these methods.
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
abstract specification for renderers
Definition: vtkRenderer.h:63
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
abstract class defines interface between the widget and widget representation classes ...
int vtkTypeBool
Definition: vtkABI.h:64
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual vtkMTimeType GetMTime()
Return this object's modified time.
Abstract interface to translate 2D display positions to world coordinates.
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
#define VTK_SIZEHINT(...)
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems ...
Definition: vtkCoordinate.h:69
#define VTK_MARSHALEXCLUDE(reason)
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
#define VTK_MARSHALAUTO
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
vtkNew< vtkCoordinate > DisplayPosition