VTK  9.0.20201126
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 
174  virtual void SetPointPlacer(vtkPointPlacer*);
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:
226  ~vtkHandleRepresentation() override;
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
vtkWidgetRepresentation.h
vtkHandleRepresentation::Nearby
Definition: vtkHandleRepresentation.h:111
vtkHandleRepresentation::Constrained
vtkTypeBool Constrained
Definition: vtkHandleRepresentation.h:230
vtkHandleRepresentation::ActiveRepresentation
vtkTypeBool ActiveRepresentation
Definition: vtkHandleRepresentation.h:229
vtkWidgetRepresentation::ShallowCopy
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkProp.
vtkPointPlacer
Abstract interface to translate 2D display positions to world coordinates.
Definition: vtkPointPlacer.h:49
vtkHandleRepresentation::Tolerance
int Tolerance
Definition: vtkHandleRepresentation.h:228
vtkWidgetRepresentation::SetRenderer
virtual void SetRenderer(vtkRenderer *ren)
Subclasses of vtkWidgetRepresentation must implement these methods.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:59
vtkHandleRepresentation
abstract class for representing widget handles
Definition: vtkHandleRepresentation.h:55
vtkHandleRepresentation::WorldPositionTime
vtkTimeStamp WorldPositionTime
Definition: vtkHandleRepresentation.h:241
vtkHandleRepresentation::SetYTranslationAxisOn
void SetYTranslationAxisOn()
Definition: vtkHandleRepresentation.h:212
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkHandleRepresentation::DisplayPosition
vtkCoordinate * DisplayPosition
Definition: vtkHandleRepresentation.h:236
vtkObject::GetMTime
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkCoordinate
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
Definition: vtkCoordinate.h:76
vtkHandleRepresentation::SetZTranslationAxisOn
void SetZTranslationAxisOn()
Definition: vtkHandleRepresentation.h:213
vtkHandleRepresentation::_InteractionState
_InteractionState
Definition: vtkHandleRepresentation.h:108
vtkHandleRepresentation::IsTranslationConstrained
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
Definition: vtkHandleRepresentation.h:221
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkHandleRepresentation::SetXTranslationAxisOn
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkHandleRepresentation.h:211
vtkHandleRepresentation::TranslationAxis
int TranslationAxis
Definition: vtkHandleRepresentation.h:247
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkHandleRepresentation::WorldPosition
vtkCoordinate * WorldPosition
Definition: vtkHandleRepresentation.h:237
vtkHandleRepresentation::DisplayPositionTime
vtkTimeStamp DisplayPositionTime
Definition: vtkHandleRepresentation.h:240
vtkHandleRepresentation::PointPlacer
vtkPointPlacer * PointPlacer
Definition: vtkHandleRepresentation.h:244
vtkHandleRepresentation::Selecting
Definition: vtkHandleRepresentation.h:112
vtkHandleRepresentation::Translating
Definition: vtkHandleRepresentation.h:113
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkHandleRepresentation::SetTranslationAxisOff
void SetTranslationAxisOff()
Definition: vtkHandleRepresentation.h:214