VTK  9.2.20230606
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 "vtkLegacy.h" // for VTK_LEGACY_REMOVE
41 #include "vtkNew.h" // For vtkNew command
43 
44 VTK_ABI_NAMESPACE_BEGIN
45 class vtkActor;
46 class vtkBox;
47 class vtkCellPicker;
48 class vtkConeSource;
49 class vtkFeatureEdges;
50 class vtkGenericCell;
51 class vtkHardwarePicker;
52 class vtkLineSource;
53 class vtkPlane;
54 class vtkPolyData;
55 class vtkPolyDataMapper;
56 class vtkProperty;
57 class vtkSphereSource;
58 class vtkTransform;
59 
60 class VTKINTERACTIONWIDGETS_EXPORT vtkCoordinateFrameRepresentation : public vtkWidgetRepresentation
61 {
62 public:
67 
69 
73  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
77 
80  void SetOrigin(double x, double y, double z);
81  void SetOrigin(double x[3]);
82  vtkGetVector3Macro(Origin, double);
84 
86 
97  void SetNormal(double x, double y, double z);
98  void SetNormal(double n[3]);
100  vtkGetVector3Macro(XVectorNormal, double);
101  vtkGetVector3Macro(YVectorNormal, double);
102  vtkGetVector3Macro(ZVectorNormal, double);
104 
106 
110  void SetDirection(double x, double y, double z);
111  void SetDirection(double d[3]);
113 
115 
121  void SetXAxisVector(const double v[3]);
122  void SetXAxisVector(double x, double y, double z);
123  void SetYAxisVector(const double v[3]);
124  void SetYAxisVector(double x, double y, double z);
125  void SetZAxisVector(const double v[3]);
126  void SetZAxisVector(double x, double y, double z);
128 
130 
136  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
137  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
139 
141 
144  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
145  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
146  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
147  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
149 
151 
154  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
156 
162 
167  void Reset();
168 
172  void ResetAxes();
173 
175 
179  vtkGetObjectMacro(OriginProperty, vtkProperty);
180  vtkGetObjectMacro(SelectedOriginProperty, vtkProperty);
182 
184 
188  vtkGetObjectMacro(XVectorProperty, vtkProperty);
189  vtkGetObjectMacro(SelectedXVectorProperty, vtkProperty);
191 
193 
197  vtkGetObjectMacro(LockedXVectorProperty, vtkProperty);
198  vtkGetObjectMacro(SelectedLockedXVectorProperty, vtkProperty);
200 
202 
206  vtkGetObjectMacro(UnlockedXVectorProperty, vtkProperty);
207  vtkGetObjectMacro(SelectedUnlockedXVectorProperty, vtkProperty);
209 
211 
215  vtkGetObjectMacro(YVectorProperty, vtkProperty);
216  vtkGetObjectMacro(SelectedYVectorProperty, vtkProperty);
218 
220 
224  vtkGetObjectMacro(LockedYVectorProperty, vtkProperty);
225  vtkGetObjectMacro(SelectedLockedYVectorProperty, vtkProperty);
227 
229 
233  vtkGetObjectMacro(UnlockedYVectorProperty, vtkProperty);
234  vtkGetObjectMacro(SelectedUnlockedYVectorProperty, vtkProperty);
236 
238 
242  vtkGetObjectMacro(ZVectorProperty, vtkProperty);
243  vtkGetObjectMacro(SelectedZVectorProperty, vtkProperty);
245 
247 
251  vtkGetObjectMacro(LockedZVectorProperty, vtkProperty);
252  vtkGetObjectMacro(SelectedLockedZVectorProperty, vtkProperty);
254 
256 
260  vtkGetObjectMacro(UnlockedZVectorProperty, vtkProperty);
261  vtkGetObjectMacro(SelectedUnlockedZVectorProperty, vtkProperty);
263 
265 
269  vtkGetMacro(PickCameraFocalInfo, bool);
270  vtkSetMacro(PickCameraFocalInfo, bool);
271  vtkBooleanMacro(PickCameraFocalInfo, bool);
273 
281  bool PickOrigin(int X, int Y, bool snapToMeshPoint = false);
282 
290  bool PickNormal(int X, int Y, bool snapToMeshPoint = false);
291 
299  bool PickDirectionPoint(int X, int Y, bool snapToMeshPoint = false);
300 
318  int GetLockedAxis() const;
319  void SetLockedAxis(int axis);
320 
322 
325  int ComputeInteractionState(int X, int Y, int modify = 0) override;
326  void PlaceWidget(double bounds[6]) override;
327  void BuildRepresentation() override;
328  void StartWidgetInteraction(double eventPos[2]) override;
329  void WidgetInteraction(double newEventPos[2]) override;
330  void EndWidgetInteraction(double newEventPos[2]) override;
332 
334 
337  double* GetBounds() VTK_SIZEHINT(6) override;
338  void GetActors(vtkPropCollection* pc) override;
339  void ReleaseGraphicsResources(vtkWindow*) override;
340  int RenderOpaqueGeometry(vtkViewport*) override;
341  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
342  vtkTypeBool HasTranslucentPolygonalGeometry() override;
344 
345  // Manage the state of the widget
347  {
348  Outside = 0,
356  ModifyingLockerZVector
357  };
358 #if !defined(VTK_LEGACY_REMOVE)
359  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
361 #endif
362 
364 
373  vtkSetClampMacro(InteractionState, int, Outside, ModifyingLockerZVector);
375 
377 
381  virtual void SetRepresentationState(int);
382  vtkGetMacro(RepresentationState, int);
384 
386 
390  vtkSetClampMacro(LengthFactor, double, 0, 1);
391  vtkGetMacro(LengthFactor, double);
393 
394 protected:
397 
398  int RepresentationState = Outside;
399 
400  // Keep track of event positions
401  double LastEventPosition[3];
402 
403  bool PickCameraFocalInfo = false;
404 
405  // Locking normal to camera
406  vtkTypeBool LockNormalToCamera = false;
407 
408  int TranslationAxis = Axis::NONE;
409 
410  double Origin[3] = { 0, 0, 0 };
411  double XVectorNormal[3] = { 1, 0, 0 };
412  double YVectorNormal[3] = { 0, 1, 0 };
413  double ZVectorNormal[3] = { 0, 0, 1 };
414  vtkSetVector3Macro(XVectorNormal, double);
415  vtkSetVector3Macro(YVectorNormal, double);
416  vtkSetVector3Macro(ZVectorNormal, double);
417 
418  // The origin positioning handle
422  void HighlightOrigin(int highlight);
423 
424  // The XVector line source
428  // The XVector cone source
432  void HighlightXVector(int highlight);
433  // The lock XVector cone source
434  bool XVectorIsLocked = false;
438  void HighlightLockerXVector(int highlight);
439 
440  // The YVector line source
444  // The YVector cone source
448  void HighlightYVector(int highlight);
449  // The lock YVector cone source
450  bool YVectorIsLocked = false;
454  void HighlightLockerYVector(int highlight);
455 
456  // The Vector Z line source
460  // The Vector Z cone source
464  void HighlightZVector(int highlight);
465  // The lock Vector Z cone source
466  bool ZVectorIsLocked = false;
470  void HighlightLockerZVector(int highlight);
471 
472  // Do the picking
473  vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props
474  vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props
475  // Compute Picker tolerance
477 
478  // Register internal Pickers within PickingManager
479  void RegisterPickers() override;
480 
481  // Transform the normal (used for rotation)
483 
484  // Methods to manipulate the plane
485  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
486  void ModifyingLocker(int axis);
487  void TranslateOrigin(double* p1, double* p2);
488  void SizeHandles();
489 
490  // Properties used to control the appearance of selected objects and
491  // the manipulator in general.
512  virtual void CreateDefaultProperties();
513 
514  // Support GetBounds() method
517 
518  double LengthFactor = 0.04;
519 
520 private:
522  void operator=(const vtkCoordinateFrameRepresentation&) = delete;
523 };
524 
525 VTK_ABI_NAMESPACE_END
526 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:162
implicit function for a bounding box
Definition: vtkBox.h:142
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
a class defining the representation for a vtkCoordinateFrameWidget
int ComputeInteractionState(int X, int Y, int modify=0) override
Methods to interface with the vtkCoordinateFrameWidget.
virtual void SetLockNormalToCamera(vtkTypeBool)
If enabled, and a vtkCamera is available through the renderer, then LockNormalToCamera will cause the...
bool PickNormal(int X, int Y, bool snapToMeshPoint=false)
Given the X, Y display coordinates, pick a new normal for the coordinate frame from a point that is o...
void SetXAxisVector(double x, double y, double z)
Force an axis to be aligned with the vector v, regardless of whether any axis is locked.
void EndWidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkCoordinateFrameWidget.
void SetNormalToCamera()
Set/Get the normal of one of the axes of the coordinate frame.
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
void HighlightXVector(int highlight)
double * GetBounds() override
Methods supporting the rendering process.
void BuildRepresentation() override
Methods to interface with the vtkCoordinateFrameWidget.
void Reset()
Reset the origin (by calling update placement) and the axes (to be aligned with the world coordinate ...
void TranslateOrigin(double *p1, double *p2)
void ResetAxes()
Reset only the axis orientations (not the origin).
void SetOrigin(double x[3])
Set/Get the origin of the coordinate frame.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void SetOrigin(double x, double y, double z)
Set/Get the origin of the coordinate frame.
void HighlightLockerXVector(int highlight)
virtual void CreateDefaultProperties()
int GetLockedAxis() const
Get/set which axis (if any) is locked.
void PlaceWidget(double bounds[6]) override
Methods to interface with the vtkCoordinateFrameWidget.
void SetZAxisVector(double x, double y, double z)
Force an axis to be aligned with the vector v, regardless of whether any axis is locked.
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
void HighlightZVector(int highlight)
void HighlightOrigin(int highlight)
void UpdatePlacement()
Satisfies the superclass API.
void SetDirection(double x, double y, double z)
Set the direction of the locked (or absent a locked axis, the nearest axis) to point from the frame's...
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void SetYAxisVector(const double v[3])
Force an axis to be aligned with the vector v, regardless of whether any axis is locked.
void SetXAxisVector(const double v[3])
Force an axis to be aligned with the vector v, regardless of whether any axis is locked.
void Rotate(double X, double Y, double *p1, double *p2, double *vpn)
bool PickDirectionPoint(int X, int Y, bool snapToMeshPoint=false)
Given the X, Y display coordinates, pick a point and using the origin define normal for the coordinat...
static vtkCoordinateFrameRepresentation * New()
Instantiate the class.
void SetDirection(double d[3])
Set the direction of the locked (or absent a locked axis, the nearest axis) to point from the frame's...
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void SetNormal(double n[3])
Set/Get the normal of one of the axes of the coordinate frame.
void HighlightLockerZVector(int highlight)
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
void SetYAxisVector(double x, double y, double z)
Force an axis to be aligned with the vector v, regardless of whether any axis is locked.
void SetNormal(double x, double y, double z)
Set/Get the normal of one of the axes of the coordinate frame.
void WidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkCoordinateFrameWidget.
bool PickOrigin(int X, int Y, bool snapToMeshPoint=false)
Given the X, Y display coordinates, pick a new origin for the coordinate frame from a point that is o...
void HighlightYVector(int highlight)
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetZAxisVector(const double v[3])
Force an axis to be aligned with the vector v, regardless of whether any axis is locked.
void HighlightLockerYVector(int highlight)
void StartWidgetInteraction(double eventPos[2]) override
Methods to interface with the vtkCoordinateFrameWidget.
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
provides thread-safe access to cells
pick a point or snap to point of an actor/prop using graphics hardware
a simple class to control print indentation
Definition: vtkIndent.h:120
create a line defined by two end points
perform various plane computations
Definition: vtkPlane.h:147
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:201
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:178
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:171
abstract specification for Viewports
Definition: vtkViewport.h:57
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:40
int vtkTypeBool
Definition: vtkABI.h:71
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_SIZEHINT(...)