VTK  9.3.0
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 "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
40#include "vtkInteractionWidgetsModule.h" // For export macro
41#include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
43
44VTK_ABI_NAMESPACE_BEGIN
45class vtkCoordinate;
46class vtkRenderer;
47class vtkPointPlacer;
48
49class VTKINTERACTIONWIDGETS_EXPORT vtkHandleRepresentation : public vtkWidgetRepresentation
50{
51public:
53
57 void PrintSelf(ostream& os, vtkIndent indent) override;
59
61
69 virtual void SetDisplayPosition(double pos[3]);
70 virtual void GetDisplayPosition(double pos[3]);
71 virtual double* GetDisplayPosition() VTK_SIZEHINT(3);
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#if !defined(VTK_LEGACY_REMOVE)
111 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
113#endif
114
116
125 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
127
129
134 vtkSetMacro(Constrained, vtkTypeBool);
135 vtkGetMacro(Constrained, vtkTypeBool);
136 vtkBooleanMacro(Constrained, vtkTypeBool);
138
146 virtual int CheckConstraint(vtkRenderer* renderer, double pos[2]);
147
149
152 void ShallowCopy(vtkProp* prop) override;
153 virtual void DeepCopy(vtkProp* prop);
154 void SetRenderer(vtkRenderer* ren) override;
156
162
164
173 vtkGetObjectMacro(PointPlacer, vtkPointPlacer);
175
177
180 virtual void GetTranslationVector(const double* p1, const double* p2, double* v) const;
181
183
186 virtual void Translate(const double* p1, const double* p2);
188
190
193 virtual void Translate(const double* v);
195
197
201 vtkGetMacro(TranslationAxis, int);
202 vtkSetClampMacro(TranslationAxis, int, -1, 2);
204
206
209 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
210 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
211 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
212 void SetCustomTranslationAxisOn() { this->TranslationAxis = Axis::Custom; }
213 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
215
217
223 vtkGetVector3Macro(CustomTranslationAxis, double);
224 vtkSetVector3Macro(CustomTranslationAxis, double);
226
228
231 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
233
234protected:
237
238 int Tolerance = 15;
239 vtkTypeBool ActiveRepresentation = false;
240 vtkTypeBool Constrained = false;
241
242 // Two vtkCoordinates are available to subclasses, one in display
243 // coordinates and the other in world coordinates. These facilitate
244 // the conversion between these two systems. Note that the WorldPosition
245 // is the ultimate maintainer of position.
248
249 // Keep track of when coordinates were changed
252
253 // Constraint the placement of handles.
255
256 // Constraint axis translation
257 int TranslationAxis = Axis::NONE;
258 double CustomTranslationAxis[3] = { 1.0, 0.0, 0.0 };
259
260private:
262 void operator=(const vtkHandleRepresentation&) = delete;
263};
264
265VTK_ABI_NAMESPACE_END
266#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.
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)...
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
virtual void DeepCopy(vtkProp *prop)
Methods to make this class properly act like a vtkWidgetRepresentation.
virtual void SetDisplayPosition(double pos[3])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
vtkNew< vtkCoordinate > WorldPosition
vtkMTimeType GetMTime() override
Overload the superclasses' GetMTime() because the internal vtkCoordinates are used to keep the state ...
virtual void GetDisplayPosition(double pos[3])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
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:29
Allocate and hold a VTK object.
Definition vtkNew.h:51
Abstract interface to translate 2D display positions to world coordinates.
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
abstract specification for renderers
Definition vtkRenderer.h:59
record modification and/or execution time
abstract class defines interface between the widget and widget representation classes
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_2_0(reason)
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270
#define VTK_SIZEHINT(...)