VTK  9.3.20240424
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
43VTK_ABI_NAMESPACE_BEGIN
44class vtkCoordinate;
45class vtkRenderer;
46class vtkPointPlacer;
47
48class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkHandleRepresentation
50{
51public:
53
57 void PrintSelf(ostream& os, vtkIndent indent) override;
59
61
69 virtual void SetDisplayPosition(double pos[2]);
70 virtual void GetDisplayPosition(double pos[2]);
71 virtual double* GetDisplayPosition() VTK_SIZEHINT(2);
72 virtual void SetWorldPosition(double pos[3]);
73 virtual void GetWorldPosition(double pos[3]);
74 virtual double* GetWorldPosition() VTK_SIZEHINT(3);
76
78
83 vtkSetClampMacro(Tolerance, int, 1, 100);
84 vtkGetMacro(Tolerance, int);
86
88
93 vtkSetMacro(ActiveRepresentation, vtkTypeBool);
94 vtkGetMacro(ActiveRepresentation, vtkTypeBool);
95 vtkBooleanMacro(ActiveRepresentation, vtkTypeBool);
97
98 // Enums define the state of the representation relative to the mouse pointer
99 // position. Used by ComputeInteractionState() to communicate with the
100 // widget. Note that ComputeInteractionState() and several other methods
101 // must be implemented by subclasses.
103 {
104 Outside = 0,
108 Scaling
109 };
110
112
121 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
123
125
130 vtkSetMacro(Constrained, vtkTypeBool);
131 vtkGetMacro(Constrained, vtkTypeBool);
132 vtkBooleanMacro(Constrained, vtkTypeBool);
134
142 virtual int CheckConstraint(vtkRenderer* renderer, double pos[2]);
143
145
148 void ShallowCopy(vtkProp* prop) override;
149 virtual void DeepCopy(vtkProp* prop);
150 void SetRenderer(vtkRenderer* ren) override;
152
158
160
169 vtkGetObjectMacro(PointPlacer, vtkPointPlacer);
171
173
176 virtual void GetTranslationVector(const double* p1, const double* p2, double* v) const;
177
179
182 virtual void Translate(const double* p1, const double* p2);
184
186
189 virtual void Translate(const double* v);
191
193
197 vtkGetMacro(TranslationAxis, int);
198 vtkSetClampMacro(TranslationAxis, int, -1, 2);
200
202
205 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
206 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
207 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
208 void SetCustomTranslationAxisOn() { this->TranslationAxis = Axis::Custom; }
209 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
211
213
219 vtkGetVector3Macro(CustomTranslationAxis, double);
220 vtkSetVector3Macro(CustomTranslationAxis, double);
222
224
227 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
229
230protected:
233
234 int Tolerance = 15;
235 vtkTypeBool ActiveRepresentation = false;
236 vtkTypeBool Constrained = false;
237
238 // Two vtkCoordinates are available to subclasses, one in display
239 // coordinates and the other in world coordinates. These facilitate
240 // the conversion between these two systems. Note that the WorldPosition
241 // is the ultimate maintainer of position.
244
245 // Keep track of when coordinates were changed
248
249 // Constraint the placement of handles.
251
252 // Constraint axis translation
253 int TranslationAxis = Axis::NONE;
254 double CustomTranslationAxis[3] = { 1.0, 0.0, 0.0 };
255
256private:
258 void operator=(const vtkHandleRepresentation&) = delete;
259};
260
261VTK_ABI_NAMESPACE_END
262#endif
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
abstract class for representing widget handles
void SetCustomTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual void SetPointPlacer(vtkPointPlacer *)
Set/Get the point placer.
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual void GetDisplayPosition(double pos[2])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
~vtkHandleRepresentation() override
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual double * GetDisplayPosition()
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
virtual void SetDisplayPosition(double pos[2])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
virtual void DeepCopy(vtkProp *prop)
Methods to make this class properly act like a vtkWidgetRepresentation.
vtkNew< vtkCoordinate > WorldPosition
vtkMTimeType GetMTime() override
Overload the superclasses' GetMTime() because the internal vtkCoordinates are used to keep the state ...
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
virtual void Translate(const double *v)
Translates world position by vector v projected on the constraint axis if any.
void ShallowCopy(vtkProp *prop) override
Methods to make this class properly act like a vtkWidgetRepresentation.
virtual int CheckConstraint(vtkRenderer *renderer, double pos[2])
Method has to be overridden in the subclasses which has constraints on placing the handle (Ex.
virtual void Translate(const double *p1, const double *p2)
Translates world position by vector p1p2 projected on the constraint axis if any.
virtual void GetTranslationVector(const double *p1, const double *p2, double *v) const
Gets the translation vector.
vtkNew< vtkCoordinate > DisplayPosition
void SetRenderer(vtkRenderer *ren) override
Methods to make this class properly act like a vtkWidgetRepresentation.
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:160
Abstract interface to translate 2D display positions to world coordinates.
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
abstract specification for renderers
record modification and/or execution time
abstract class defines interface between the widget and widget representation classes
int vtkTypeBool
Definition vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO