VTK  9.7.1
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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
30 
31 VTK_ABI_NAMESPACE_BEGIN
32 class vtkActor;
33 class vtkBox;
34 class vtkCellPicker;
35 class vtkConeSource;
36 class vtkFeatureEdges;
37 class vtkGenericCell;
38 class vtkHardwarePicker;
39 class vtkLineSource;
40 class vtkPlane;
41 class vtkPolyData;
42 class vtkPolyDataMapper;
43 class vtkProperty;
44 class vtkSphereSource;
45 class vtkTransform;
46 
47 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCoordinateFrameRepresentation
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]);
87  void SetNormalToCamera();
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 
123  virtual void SetLockNormalToCamera(vtkTypeBool);
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 
149  void UpdatePlacement();
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 
348 
357  vtkSetClampMacro(InteractionState, int, Outside, ModifyingLockerZVector);
359 
361 
365  virtual void SetRepresentationState(int);
366  vtkGetMacro(RepresentationState, int);
368 
370 
374  vtkSetClampMacro(LengthFactor, double, 0, 1);
375  vtkGetMacro(LengthFactor, double);
377 
378 protected:
381 
382  int RepresentationState = Outside;
383 
384  // Keep track of event positions
385  double LastEventPosition[3];
386 
387  bool PickCameraFocalInfo = false;
388 
389  // Locking normal to camera
390  vtkTypeBool LockNormalToCamera = false;
391 
392  int TranslationAxis = Axis::NONE;
393 
394  double Origin[3] = { 0, 0, 0 };
395  double XVectorNormal[3] = { 1, 0, 0 };
396  double YVectorNormal[3] = { 0, 1, 0 };
397  double ZVectorNormal[3] = { 0, 0, 1 };
398  vtkSetVector3Macro(XVectorNormal, double);
399  vtkSetVector3Macro(YVectorNormal, double);
400  vtkSetVector3Macro(ZVectorNormal, double);
401 
402  // The origin positioning handle
406  void HighlightOrigin(int highlight);
407 
408  // The XVector line source
412  // The XVector cone source
416  void HighlightXVector(int highlight);
417  // The lock XVector cone source
418  bool XVectorIsLocked = false;
422  void HighlightLockerXVector(int highlight);
423 
424  // The YVector line source
428  // The YVector cone source
432  void HighlightYVector(int highlight);
433  // The lock YVector cone source
434  bool YVectorIsLocked = false;
438  void HighlightLockerYVector(int highlight);
439 
440  // The Vector Z line source
444  // The Vector Z cone source
448  void HighlightZVector(int highlight);
449  // The lock Vector Z cone source
450  bool ZVectorIsLocked = false;
454  void HighlightLockerZVector(int highlight);
455 
456  // Do the picking
457  vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props
458  vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props
459  // Compute Picker tolerance
460  void ComputeAdaptivePickerTolerance();
461 
462  // Register internal Pickers within PickingManager
463  void RegisterPickers() override;
464 
465  // Transform the normal (used for rotation)
467 
468  // Methods to manipulate the plane
469  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
470  void ModifyingLocker(int axis);
471  void TranslateOrigin(double* p1, double* p2);
472  void SizeHandles();
473 
474  // Properties used to control the appearance of selected objects and
475  // the manipulator in general.
496  virtual void CreateDefaultProperties();
497 
498  // Support GetBounds() method
501 
502  double LengthFactor = 0.04;
503 
504 private:
506  void operator=(const vtkCoordinateFrameRepresentation&) = delete;
507 };
508 
509 VTK_ABI_NAMESPACE_END
510 #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:41
virtual void PlaceWidget(double 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:46
represent surface properties of a geometric object
Definition: vtkProperty.h:59
virtual void StartWidgetInteraction(double eventPos[2])
generate polygonal cone
Definition: vtkConeSource.h:34
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
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:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
create a polygonal sphere centered at the origin
a simple class to control print indentation
Definition: vtkIndent.h:28
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:31
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:53
map vtkPolyData to graphics primitives
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
#define VTK_MARSHALAUTO
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:30
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.