VTK  9.3.0
vtkCoordinateFrameRepresentation.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
23 #ifndef vtkCoordinateFrameRepresentation_h
24 #define vtkCoordinateFrameRepresentation_h
25 
26 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
27 #include "vtkInteractionWidgetsModule.h" // For export macro
28 #include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
29 #include "vtkNew.h" // For vtkNew command
31 
32 VTK_ABI_NAMESPACE_BEGIN
33 class vtkActor;
34 class vtkBox;
35 class vtkCellPicker;
36 class vtkConeSource;
37 class vtkFeatureEdges;
38 class vtkGenericCell;
39 class vtkHardwarePicker;
40 class vtkLineSource;
41 class vtkPlane;
42 class vtkPolyData;
43 class vtkPolyDataMapper;
44 class vtkProperty;
45 class vtkSphereSource;
46 class vtkTransform;
47 
48 class VTKINTERACTIONWIDGETS_EXPORT vtkCoordinateFrameRepresentation : public vtkWidgetRepresentation
49 {
50 public:
55 
57 
61  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
65 
68  void SetOrigin(double x, double y, double z);
69  void SetOrigin(double x[3]);
70  vtkGetVector3Macro(Origin, double);
72 
74 
85  void SetNormal(double x, double y, double z);
86  void SetNormal(double n[3]);
88  vtkGetVector3Macro(XVectorNormal, double);
89  vtkGetVector3Macro(YVectorNormal, double);
90  vtkGetVector3Macro(ZVectorNormal, double);
92 
94 
98  void SetDirection(double x, double y, double z);
99  void SetDirection(double d[3]);
101 
103 
109  void SetXAxisVector(const double v[3]);
110  void SetXAxisVector(double x, double y, double z);
111  void SetYAxisVector(const double v[3]);
112  void SetYAxisVector(double x, double y, double z);
113  void SetZAxisVector(const double v[3]);
114  void SetZAxisVector(double x, double y, double z);
116 
118 
124  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
125  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
127 
129 
132  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
133  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
134  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
135  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
137 
139 
142  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
144 
150 
155  void Reset();
156 
160  void ResetAxes();
161 
163 
167  vtkGetObjectMacro(OriginProperty, vtkProperty);
168  vtkGetObjectMacro(SelectedOriginProperty, vtkProperty);
170 
172 
176  vtkGetObjectMacro(XVectorProperty, vtkProperty);
177  vtkGetObjectMacro(SelectedXVectorProperty, vtkProperty);
179 
181 
185  vtkGetObjectMacro(LockedXVectorProperty, vtkProperty);
186  vtkGetObjectMacro(SelectedLockedXVectorProperty, vtkProperty);
188 
190 
194  vtkGetObjectMacro(UnlockedXVectorProperty, vtkProperty);
195  vtkGetObjectMacro(SelectedUnlockedXVectorProperty, vtkProperty);
197 
199 
203  vtkGetObjectMacro(YVectorProperty, vtkProperty);
204  vtkGetObjectMacro(SelectedYVectorProperty, vtkProperty);
206 
208 
212  vtkGetObjectMacro(LockedYVectorProperty, vtkProperty);
213  vtkGetObjectMacro(SelectedLockedYVectorProperty, vtkProperty);
215 
217 
221  vtkGetObjectMacro(UnlockedYVectorProperty, vtkProperty);
222  vtkGetObjectMacro(SelectedUnlockedYVectorProperty, vtkProperty);
224 
226 
230  vtkGetObjectMacro(ZVectorProperty, vtkProperty);
231  vtkGetObjectMacro(SelectedZVectorProperty, vtkProperty);
233 
235 
239  vtkGetObjectMacro(LockedZVectorProperty, vtkProperty);
240  vtkGetObjectMacro(SelectedLockedZVectorProperty, vtkProperty);
242 
244 
248  vtkGetObjectMacro(UnlockedZVectorProperty, vtkProperty);
249  vtkGetObjectMacro(SelectedUnlockedZVectorProperty, vtkProperty);
251 
253 
257  vtkGetMacro(PickCameraFocalInfo, bool);
258  vtkSetMacro(PickCameraFocalInfo, bool);
259  vtkBooleanMacro(PickCameraFocalInfo, bool);
261 
269  bool PickOrigin(int X, int Y, bool snapToMeshPoint = false);
270 
278  bool PickNormal(int X, int Y, bool snapToMeshPoint = false);
279 
287  bool PickDirectionPoint(int X, int Y, bool snapToMeshPoint = false);
288 
306  int GetLockedAxis() const;
307  void SetLockedAxis(int axis);
308 
310 
313  int ComputeInteractionState(int X, int Y, int modify = 0) override;
314  void PlaceWidget(double bounds[6]) override;
315  void BuildRepresentation() override;
316  void StartWidgetInteraction(double eventPos[2]) override;
317  void WidgetInteraction(double newEventPos[2]) override;
318  void EndWidgetInteraction(double newEventPos[2]) override;
320 
322 
325  double* GetBounds() VTK_SIZEHINT(6) override;
326  void GetActors(vtkPropCollection* pc) override;
327  void ReleaseGraphicsResources(vtkWindow*) override;
328  int RenderOpaqueGeometry(vtkViewport*) override;
329  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
330  vtkTypeBool HasTranslucentPolygonalGeometry() override;
332 
333  // Manage the state of the widget
335  {
336  Outside = 0,
344  ModifyingLockerZVector
345  };
346 #if !defined(VTK_LEGACY_REMOVE)
347  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
349 #endif
350 
352 
361  vtkSetClampMacro(InteractionState, int, Outside, ModifyingLockerZVector);
363 
365 
369  virtual void SetRepresentationState(int);
370  vtkGetMacro(RepresentationState, int);
372 
374 
378  vtkSetClampMacro(LengthFactor, double, 0, 1);
379  vtkGetMacro(LengthFactor, double);
381 
382 protected:
385 
386  int RepresentationState = Outside;
387 
388  // Keep track of event positions
389  double LastEventPosition[3];
390 
391  bool PickCameraFocalInfo = false;
392 
393  // Locking normal to camera
394  vtkTypeBool LockNormalToCamera = false;
395 
396  int TranslationAxis = Axis::NONE;
397 
398  double Origin[3] = { 0, 0, 0 };
399  double XVectorNormal[3] = { 1, 0, 0 };
400  double YVectorNormal[3] = { 0, 1, 0 };
401  double ZVectorNormal[3] = { 0, 0, 1 };
402  vtkSetVector3Macro(XVectorNormal, double);
403  vtkSetVector3Macro(YVectorNormal, double);
404  vtkSetVector3Macro(ZVectorNormal, double);
405 
406  // The origin positioning handle
410  void HighlightOrigin(int highlight);
411 
412  // The XVector line source
416  // The XVector cone source
420  void HighlightXVector(int highlight);
421  // The lock XVector cone source
422  bool XVectorIsLocked = false;
426  void HighlightLockerXVector(int highlight);
427 
428  // The YVector line source
432  // The YVector cone source
436  void HighlightYVector(int highlight);
437  // The lock YVector cone source
438  bool YVectorIsLocked = false;
442  void HighlightLockerYVector(int highlight);
443 
444  // The Vector Z line source
448  // The Vector Z cone source
452  void HighlightZVector(int highlight);
453  // The lock Vector Z cone source
454  bool ZVectorIsLocked = false;
458  void HighlightLockerZVector(int highlight);
459 
460  // Do the picking
461  vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props
462  vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props
463  // Compute Picker tolerance
465 
466  // Register internal Pickers within PickingManager
467  void RegisterPickers() override;
468 
469  // Transform the normal (used for rotation)
471 
472  // Methods to manipulate the plane
473  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
474  void ModifyingLocker(int axis);
475  void TranslateOrigin(double* p1, double* p2);
476  void SizeHandles();
477 
478  // Properties used to control the appearance of selected objects and
479  // the manipulator in general.
500  virtual void CreateDefaultProperties();
501 
502  // Support GetBounds() method
505 
506  double LengthFactor = 0.04;
507 
508 private:
510  void operator=(const vtkCoordinateFrameRepresentation&) = delete;
511 };
512 
513 VTK_ABI_NAMESPACE_END
514 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
implicit function for a bounding box
Definition: vtkBox.h:31
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
generate polygonal cone
Definition: vtkConeSource.h:34
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:29
create a line defined by two end points
Definition: vtkLineSource.h:53
perform various plane computations
Definition: vtkPlane.h:26
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:80
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:57
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
abstract specification for Viewports
Definition: vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_SIZEHINT(...)