VTK  9.5.20250806
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
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
161
163
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
233protected:
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
259private:
261 void operator=(const vtkHandleRepresentation&) = delete;
262};
263
264VTK_ABI_NAMESPACE_END
265#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.
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:167
Abstract interface to translate 2D display positions to world coordinates.
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:69
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:287
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)