VTK  9.3.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 "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]);
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 #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
464  void ComputeAdaptivePickerTolerance();
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
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:40
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:44
represent surface properties of a geometric object
Definition: vtkProperty.h:56
virtual void StartWidgetInteraction(double eventPos[2])
#define VTK_DEPRECATED_IN_9_2_0(reason)
generate polygonal cone
Definition: vtkConeSource.h:33
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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:27
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:25
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:52
map vtkPolyData to graphics primitives
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:61
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.