VTK  9.1.20211115
vtkHandleRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkHandleRepresentation.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
45 #ifndef vtkHandleRepresentation_h
46 #define vtkHandleRepresentation_h
47 
48 #include "vtkInteractionWidgetsModule.h" // For export macro
50 
51 class vtkCoordinate;
52 class vtkRenderer;
53 class vtkPointPlacer;
54 
55 class VTKINTERACTIONWIDGETS_EXPORT vtkHandleRepresentation : public vtkWidgetRepresentation
56 {
57 public:
59 
63  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
67 
75  virtual void SetDisplayPosition(double pos[3]);
76  virtual void GetDisplayPosition(double pos[3]);
77  virtual double* GetDisplayPosition() VTK_SIZEHINT(3);
78  virtual void SetWorldPosition(double pos[3]);
79  virtual void GetWorldPosition(double pos[3]);
80  virtual double* GetWorldPosition() VTK_SIZEHINT(3);
82 
84 
89  vtkSetClampMacro(Tolerance, int, 1, 100);
90  vtkGetMacro(Tolerance, int);
92 
94 
99  vtkSetMacro(ActiveRepresentation, vtkTypeBool);
100  vtkGetMacro(ActiveRepresentation, vtkTypeBool);
101  vtkBooleanMacro(ActiveRepresentation, vtkTypeBool);
103 
104  // Enums define the state of the representation relative to the mouse pointer
105  // position. Used by ComputeInteractionState() to communicate with the
106  // widget. Note that ComputeInteractionState() and several other methods
107  // must be implemented by subclasses.
109  {
110  Outside = 0,
114  Scaling
115  };
116 
118 
127  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
129 
131 
136  vtkSetMacro(Constrained, vtkTypeBool);
137  vtkGetMacro(Constrained, vtkTypeBool);
138  vtkBooleanMacro(Constrained, vtkTypeBool);
140 
148  virtual int CheckConstraint(vtkRenderer* renderer, double pos[2]);
149 
151 
154  void ShallowCopy(vtkProp* prop) override;
155  virtual void DeepCopy(vtkProp* prop);
156  void SetRenderer(vtkRenderer* ren) override;
158 
163  vtkMTimeType GetMTime() override;
164 
166 
175  vtkGetObjectMacro(PointPlacer, vtkPointPlacer);
177 
179 
182  virtual void GetTranslationVector(const double* p1, const double* p2, double* v) const;
183 
185 
188  virtual void Translate(const double* p1, const double* p2);
190 
192 
195  virtual void Translate(const double* v);
197 
199 
203  vtkGetMacro(TranslationAxis, int);
204  vtkSetClampMacro(TranslationAxis, int, -1, 2);
206 
208 
211  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
212  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
213  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
214  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
216 
218 
221  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
223 
224 protected:
227 
231 
232  // Two vtkCoordinates are available to subclasses, one in display
233  // coordinates and the other in world coordinates. These facilitate
234  // the conversion between these two systems. Note that the WorldPosition
235  // is the ultimate maintainer of position.
238 
239  // Keep track of when coordinates were changed
242 
243  // Constraint the placement of handles.
245 
246  // Constraint axis translation
248 
249 private:
251  void operator=(const vtkHandleRepresentation&) = delete;
252 };
253 
254 #endif
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
abstract class for representing widget handles
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.
virtual void SetDisplayPosition(double pos[3])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
vtkMTimeType GetMTime() override
Overload the superclasses' GetMTime() because the internal vtkCoordinates are used to keep the state ...
virtual double * GetDisplayPosition()
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
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.
void SetRenderer(vtkRenderer *ren) override
Methods to make this class properly act like a vtkWidgetRepresentation.
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
a simple class to control print indentation
Definition: vtkIndent.h:113
Abstract interface to translate 2D display positions to world coordinates.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
abstract specification for renderers
Definition: vtkRenderer.h:182
record modification and/or execution time
Definition: vtkTimeStamp.h:52
abstract class defines interface between the widget and widget representation classes
int vtkTypeBool
Definition: vtkABI.h:69
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)