VTK  9.2.6
vtkCoordinateFrameRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCoordinateFrameRepresentation.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 =========================================================================*/
35 #ifndef vtkCoordinateFrameRepresentation_h
36 #define vtkCoordinateFrameRepresentation_h
37 
38 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
39 #include "vtkInteractionWidgetsModule.h" // For export macro
40 #include "vtkNew.h" // For vtkNew command
42 
43 class vtkActor;
44 class vtkBox;
45 class vtkCellPicker;
46 class vtkConeSource;
47 class vtkFeatureEdges;
48 class vtkGenericCell;
49 class vtkHardwarePicker;
50 class vtkLineSource;
51 class vtkPlane;
52 class vtkPolyData;
53 class vtkPolyDataMapper;
54 class vtkProperty;
55 class vtkSphereSource;
56 class vtkTransform;
57 
58 class VTKINTERACTIONWIDGETS_EXPORT vtkCoordinateFrameRepresentation : public vtkWidgetRepresentation
59 {
60 public:
65 
67 
71  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
75 
78  void SetOrigin(double x, double y, double z);
79  void SetOrigin(double x[3]);
80  vtkGetVector3Macro(Origin, double);
82 
84 
95  void SetNormal(double x, double y, double z);
96  void SetNormal(double n[3]);
97  void SetNormalToCamera();
98  vtkGetVector3Macro(XVectorNormal, double);
99  vtkGetVector3Macro(YVectorNormal, double);
100  vtkGetVector3Macro(ZVectorNormal, double);
102 
104 
108  void SetDirection(double x, double y, double z);
109  void SetDirection(double d[3]);
111 
113 
119  void SetXAxisVector(const double v[3]);
120  void SetXAxisVector(double x, double y, double z);
121  void SetYAxisVector(const double v[3]);
122  void SetYAxisVector(double x, double y, double z);
123  void SetZAxisVector(const double v[3]);
124  void SetZAxisVector(double x, double y, double z);
126 
128 
133  virtual void SetLockNormalToCamera(vtkTypeBool);
134  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
135  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
137 
139 
142  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
143  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
144  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
145  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
147 
149 
152  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
154 
159  void UpdatePlacement();
160 
165  void Reset();
166 
170  void ResetAxes();
171 
173 
177  vtkGetObjectMacro(OriginProperty, vtkProperty);
178  vtkGetObjectMacro(SelectedOriginProperty, vtkProperty);
180 
182 
186  vtkGetObjectMacro(XVectorProperty, vtkProperty);
187  vtkGetObjectMacro(SelectedXVectorProperty, vtkProperty);
189 
191 
195  vtkGetObjectMacro(LockedXVectorProperty, vtkProperty);
196  vtkGetObjectMacro(SelectedLockedXVectorProperty, vtkProperty);
198 
200 
204  vtkGetObjectMacro(UnlockedXVectorProperty, vtkProperty);
205  vtkGetObjectMacro(SelectedUnlockedXVectorProperty, vtkProperty);
207 
209 
213  vtkGetObjectMacro(YVectorProperty, vtkProperty);
214  vtkGetObjectMacro(SelectedYVectorProperty, vtkProperty);
216 
218 
222  vtkGetObjectMacro(LockedYVectorProperty, vtkProperty);
223  vtkGetObjectMacro(SelectedLockedYVectorProperty, vtkProperty);
225 
227 
231  vtkGetObjectMacro(UnlockedYVectorProperty, vtkProperty);
232  vtkGetObjectMacro(SelectedUnlockedYVectorProperty, vtkProperty);
234 
236 
240  vtkGetObjectMacro(ZVectorProperty, vtkProperty);
241  vtkGetObjectMacro(SelectedZVectorProperty, vtkProperty);
243 
245 
249  vtkGetObjectMacro(LockedZVectorProperty, vtkProperty);
250  vtkGetObjectMacro(SelectedLockedZVectorProperty, vtkProperty);
252 
254 
258  vtkGetObjectMacro(UnlockedZVectorProperty, vtkProperty);
259  vtkGetObjectMacro(SelectedUnlockedZVectorProperty, vtkProperty);
261 
263 
267  vtkGetMacro(PickCameraFocalInfo, bool);
268  vtkSetMacro(PickCameraFocalInfo, bool);
269  vtkBooleanMacro(PickCameraFocalInfo, bool);
271 
279  bool PickOrigin(int X, int Y, bool snapToMeshPoint = false);
280 
288  bool PickNormal(int X, int Y, bool snapToMeshPoint = false);
289 
297  bool PickDirectionPoint(int X, int Y, bool snapToMeshPoint = false);
298 
316  int GetLockedAxis() const;
317  void SetLockedAxis(int axis);
318 
320 
323  int ComputeInteractionState(int X, int Y, int modify = 0) override;
324  void PlaceWidget(double bounds[6]) override;
325  void BuildRepresentation() override;
326  void StartWidgetInteraction(double eventPos[2]) override;
327  void WidgetInteraction(double newEventPos[2]) override;
328  void EndWidgetInteraction(double newEventPos[2]) override;
330 
332 
335  double* GetBounds() VTK_SIZEHINT(6) override;
336  void GetActors(vtkPropCollection* pc) override;
337  void ReleaseGraphicsResources(vtkWindow*) override;
338  int RenderOpaqueGeometry(vtkViewport*) override;
339  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
340  vtkTypeBool HasTranslucentPolygonalGeometry() override;
342 
343  // Manage the state of the widget
345  {
346  Outside = 0,
354  ModifyingLockerZVector
355  };
356 #if !defined(VTK_LEGACY_REMOVE)
357  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
359 #endif
360 
362 
371  vtkSetClampMacro(InteractionState, int, Outside, ModifyingLockerZVector);
373 
375 
379  virtual void SetRepresentationState(int);
380  vtkGetMacro(RepresentationState, int);
382 
384 
388  vtkSetClampMacro(LengthFactor, double, 0, 1);
389  vtkGetMacro(LengthFactor, double);
391 
392 protected:
395 
396  int RepresentationState = Outside;
397 
398  // Keep track of event positions
399  double LastEventPosition[3];
400 
401  bool PickCameraFocalInfo = false;
402 
403  // Locking normal to camera
404  vtkTypeBool LockNormalToCamera = false;
405 
406  int TranslationAxis = Axis::NONE;
407 
408  double Origin[3] = { 0, 0, 0 };
409  double XVectorNormal[3] = { 1, 0, 0 };
410  double YVectorNormal[3] = { 0, 1, 0 };
411  double ZVectorNormal[3] = { 0, 0, 1 };
412  vtkSetVector3Macro(XVectorNormal, double);
413  vtkSetVector3Macro(YVectorNormal, double);
414  vtkSetVector3Macro(ZVectorNormal, double);
415 
416  // The origin positioning handle
420  void HighlightOrigin(int highlight);
421 
422  // The XVector line source
426  // The XVector cone source
430  void HighlightXVector(int highlight);
431  // The lock XVector cone source
432  bool XVectorIsLocked = false;
436  void HighlightLockerXVector(int highlight);
437 
438  // The YVector line source
442  // The YVector cone source
446  void HighlightYVector(int highlight);
447  // The lock YVector cone source
448  bool YVectorIsLocked = false;
452  void HighlightLockerYVector(int highlight);
453 
454  // The Vector Z line source
458  // The Vector Z cone source
462  void HighlightZVector(int highlight);
463  // The lock Vector Z cone source
464  bool ZVectorIsLocked = false;
468  void HighlightLockerZVector(int highlight);
469 
470  // Do the picking
471  vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props
472  vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props
473  // Compute Picker tolerance
474  void ComputeAdaptivePickerTolerance();
475 
476  // Register internal Pickers within PickingManager
477  void RegisterPickers() override;
478 
479  // Transform the normal (used for rotation)
481 
482  // Methods to manipulate the plane
483  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
484  void ModifyingLocker(int axis);
485  void TranslateOrigin(double* p1, double* p2);
486  void SizeHandles();
487 
488  // Properties used to control the appearance of selected objects and
489  // the manipulator in general.
510  virtual void CreateDefaultProperties();
511 
512  // Support GetBounds() method
515 
516  double LengthFactor = 0.04;
517 
518 private:
520  void operator=(const vtkCoordinateFrameRepresentation&) = delete;
521 };
522 
523 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
virtual void PlaceWidget(double vtkNotUsed(bounds)[6])
The following is a suggested API for widget representations.
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:55
represent surface properties of a geometric object
Definition: vtkProperty.h:67
virtual void StartWidgetInteraction(double eventPos[2])
#define VTK_DEPRECATED_IN_9_2_0(reason)
generate polygonal cone
Definition: vtkConeSource.h:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
provides thread-safe access to cells
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
create a polygonal sphere centered at the origin
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
perform various plane computations
Definition: vtkPlane.h:36
virtual void WidgetInteraction(double newEventPos[2])
a class defining the representation for a vtkCoordinateFrameWidget
pick a point or snap to point of an actor/prop using graphics hardware
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
#define VTK_SIZEHINT(...)
create a line defined by two end points
Definition: vtkLineSource.h:63
map vtkPolyData to graphics primitives
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:72
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
implicit function for a bounding box
Definition: vtkBox.h:41
bool IsTranslationConstrained()
Returns true if ContrainedAxis.