VTK  9.3.20240301
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 "vtkInteractionWidgetsModule.h" // For export macro
27 #include "vtkNew.h" // For vtkNew command
29 
30 VTK_ABI_NAMESPACE_BEGIN
31 class vtkActor;
32 class vtkBox;
33 class vtkCellPicker;
34 class vtkConeSource;
35 class vtkFeatureEdges;
36 class vtkGenericCell;
37 class vtkHardwarePicker;
38 class vtkLineSource;
39 class vtkPlane;
40 class vtkPolyData;
41 class vtkPolyDataMapper;
42 class vtkProperty;
43 class vtkSphereSource;
44 class vtkTransform;
45 
46 class VTKINTERACTIONWIDGETS_EXPORT vtkCoordinateFrameRepresentation : public vtkWidgetRepresentation
47 {
48 public:
53 
55 
59  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
63 
66  void SetOrigin(double x, double y, double z);
67  void SetOrigin(double x[3]);
68  vtkGetVector3Macro(Origin, double);
70 
72 
83  void SetNormal(double x, double y, double z);
84  void SetNormal(double n[3]);
86  vtkGetVector3Macro(XVectorNormal, double);
87  vtkGetVector3Macro(YVectorNormal, double);
88  vtkGetVector3Macro(ZVectorNormal, double);
90 
92 
96  void SetDirection(double x, double y, double z);
97  void SetDirection(double d[3]);
99 
101 
107  void SetXAxisVector(const double v[3]);
108  void SetXAxisVector(double x, double y, double z);
109  void SetYAxisVector(const double v[3]);
110  void SetYAxisVector(double x, double y, double z);
111  void SetZAxisVector(const double v[3]);
112  void SetZAxisVector(double x, double y, double z);
114 
116 
122  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
123  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
125 
127 
130  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
131  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
132  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
133  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
135 
137 
140  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
142 
148 
153  void Reset();
154 
158  void ResetAxes();
159 
161 
165  vtkGetObjectMacro(OriginProperty, vtkProperty);
166  vtkGetObjectMacro(SelectedOriginProperty, vtkProperty);
168 
170 
174  vtkGetObjectMacro(XVectorProperty, vtkProperty);
175  vtkGetObjectMacro(SelectedXVectorProperty, vtkProperty);
177 
179 
183  vtkGetObjectMacro(LockedXVectorProperty, vtkProperty);
184  vtkGetObjectMacro(SelectedLockedXVectorProperty, vtkProperty);
186 
188 
192  vtkGetObjectMacro(UnlockedXVectorProperty, vtkProperty);
193  vtkGetObjectMacro(SelectedUnlockedXVectorProperty, vtkProperty);
195 
197 
201  vtkGetObjectMacro(YVectorProperty, vtkProperty);
202  vtkGetObjectMacro(SelectedYVectorProperty, vtkProperty);
204 
206 
210  vtkGetObjectMacro(LockedYVectorProperty, vtkProperty);
211  vtkGetObjectMacro(SelectedLockedYVectorProperty, vtkProperty);
213 
215 
219  vtkGetObjectMacro(UnlockedYVectorProperty, vtkProperty);
220  vtkGetObjectMacro(SelectedUnlockedYVectorProperty, vtkProperty);
222 
224 
228  vtkGetObjectMacro(ZVectorProperty, vtkProperty);
229  vtkGetObjectMacro(SelectedZVectorProperty, vtkProperty);
231 
233 
237  vtkGetObjectMacro(LockedZVectorProperty, vtkProperty);
238  vtkGetObjectMacro(SelectedLockedZVectorProperty, vtkProperty);
240 
242 
246  vtkGetObjectMacro(UnlockedZVectorProperty, vtkProperty);
247  vtkGetObjectMacro(SelectedUnlockedZVectorProperty, vtkProperty);
249 
251 
255  vtkGetMacro(PickCameraFocalInfo, bool);
256  vtkSetMacro(PickCameraFocalInfo, bool);
257  vtkBooleanMacro(PickCameraFocalInfo, bool);
259 
267  bool PickOrigin(int X, int Y, bool snapToMeshPoint = false);
268 
276  bool PickNormal(int X, int Y, bool snapToMeshPoint = false);
277 
285  bool PickDirectionPoint(int X, int Y, bool snapToMeshPoint = false);
286 
304  int GetLockedAxis() const;
305  void SetLockedAxis(int axis);
306 
308 
311  int ComputeInteractionState(int X, int Y, int modify = 0) override;
312  void PlaceWidget(double bounds[6]) override;
313  void BuildRepresentation() override;
314  void StartWidgetInteraction(double eventPos[2]) override;
315  void WidgetInteraction(double newEventPos[2]) override;
316  void EndWidgetInteraction(double newEventPos[2]) override;
318 
320 
323  double* GetBounds() VTK_SIZEHINT(6) override;
324  void GetActors(vtkPropCollection* pc) override;
325  void ReleaseGraphicsResources(vtkWindow*) override;
326  int RenderOpaqueGeometry(vtkViewport*) override;
327  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
328  vtkTypeBool HasTranslucentPolygonalGeometry() override;
330 
331  // Manage the state of the widget
333  {
334  Outside = 0,
342  ModifyingLockerZVector
343  };
344 
346 
355  vtkSetClampMacro(InteractionState, int, Outside, ModifyingLockerZVector);
357 
359 
363  virtual void SetRepresentationState(int);
364  vtkGetMacro(RepresentationState, int);
366 
368 
372  vtkSetClampMacro(LengthFactor, double, 0, 1);
373  vtkGetMacro(LengthFactor, double);
375 
376 protected:
379 
380  int RepresentationState = Outside;
381 
382  // Keep track of event positions
383  double LastEventPosition[3];
384 
385  bool PickCameraFocalInfo = false;
386 
387  // Locking normal to camera
388  vtkTypeBool LockNormalToCamera = false;
389 
390  int TranslationAxis = Axis::NONE;
391 
392  double Origin[3] = { 0, 0, 0 };
393  double XVectorNormal[3] = { 1, 0, 0 };
394  double YVectorNormal[3] = { 0, 1, 0 };
395  double ZVectorNormal[3] = { 0, 0, 1 };
396  vtkSetVector3Macro(XVectorNormal, double);
397  vtkSetVector3Macro(YVectorNormal, double);
398  vtkSetVector3Macro(ZVectorNormal, double);
399 
400  // The origin positioning handle
404  void HighlightOrigin(int highlight);
405 
406  // The XVector line source
410  // The XVector cone source
414  void HighlightXVector(int highlight);
415  // The lock XVector cone source
416  bool XVectorIsLocked = false;
420  void HighlightLockerXVector(int highlight);
421 
422  // The YVector line source
426  // The YVector cone source
430  void HighlightYVector(int highlight);
431  // The lock YVector cone source
432  bool YVectorIsLocked = false;
436  void HighlightLockerYVector(int highlight);
437 
438  // The Vector Z line source
442  // The Vector Z cone source
446  void HighlightZVector(int highlight);
447  // The lock Vector Z cone source
448  bool ZVectorIsLocked = false;
452  void HighlightLockerZVector(int highlight);
453 
454  // Do the picking
455  vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props
456  vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props
457  // Compute Picker tolerance
459 
460  // Register internal Pickers within PickingManager
461  void RegisterPickers() override;
462 
463  // Transform the normal (used for rotation)
465 
466  // Methods to manipulate the plane
467  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
468  void ModifyingLocker(int axis);
469  void TranslateOrigin(double* p1, double* p2);
470  void SizeHandles();
471 
472  // Properties used to control the appearance of selected objects and
473  // the manipulator in general.
494  virtual void CreateDefaultProperties();
495 
496  // Support GetBounds() method
499 
500  double LengthFactor = 0.04;
501 
502 private:
504  void operator=(const vtkCoordinateFrameRepresentation&) = delete;
505 };
506 
507 VTK_ABI_NAMESPACE_END
508 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:150
implicit function for a bounding box
Definition: vtkBox.h:110
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:91
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:108
create a line defined by two end points
perform various plane computations
Definition: vtkPlane.h:135
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:180
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:166
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:159
abstract specification for Viewports
Definition: vtkViewport.h:64
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:47
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_SIZEHINT(...)