VTK  9.2.6
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=========================================================================*/
32#ifndef vtkCoordinateFrameRepresentation_h
33#define vtkCoordinateFrameRepresentation_h
34
35#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
36#include "vtkInteractionWidgetsModule.h" // For export macro
37#include "vtkNew.h" // For vtkNew command
39
40class vtkActor;
41class vtkBox;
42class vtkCellPicker;
43class vtkConeSource;
44class vtkFeatureEdges;
45class vtkGenericCell;
47class vtkLineSource;
48class vtkPlane;
49class vtkPolyData;
51class vtkProperty;
52class vtkSphereSource;
53class vtkTransform;
54
55class VTKINTERACTIONWIDGETS_EXPORT vtkCoordinateFrameRepresentation : public vtkWidgetRepresentation
56{
57public:
62
64
68 void PrintSelf(ostream& os, vtkIndent indent) override;
70
72
75 void SetOrigin(double x, double y, double z);
76 void SetOrigin(double x[3]);
77 vtkGetVector3Macro(Origin, double);
79
81
92 void SetNormal(double x, double y, double z);
93 void SetNormal(double n[3]);
95 vtkGetVector3Macro(XVectorNormal, double);
96 vtkGetVector3Macro(YVectorNormal, double);
97 vtkGetVector3Macro(ZVectorNormal, double);
99
101
105 void SetDirection(double x, double y, double z);
106 void SetDirection(double d[3]);
108
110
116 void SetXAxisVector(const double v[3]);
117 void SetXAxisVector(double x, double y, double z);
118 void SetYAxisVector(const double v[3]);
119 void SetYAxisVector(double x, double y, double z);
120 void SetZAxisVector(const double v[3]);
121 void SetZAxisVector(double x, double y, double z);
123
125
131 vtkGetMacro(LockNormalToCamera, vtkTypeBool);
132 vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
134
136
139 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
140 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
141 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
142 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
144
146
149 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
151
157
162 void Reset();
163
167 void ResetAxes();
168
170
174 vtkGetObjectMacro(OriginProperty, vtkProperty);
175 vtkGetObjectMacro(SelectedOriginProperty, vtkProperty);
177
179
183 vtkGetObjectMacro(XVectorProperty, vtkProperty);
184 vtkGetObjectMacro(SelectedXVectorProperty, vtkProperty);
186
188
192 vtkGetObjectMacro(LockedXVectorProperty, vtkProperty);
193 vtkGetObjectMacro(SelectedLockedXVectorProperty, vtkProperty);
195
197
201 vtkGetObjectMacro(UnlockedXVectorProperty, vtkProperty);
202 vtkGetObjectMacro(SelectedUnlockedXVectorProperty, vtkProperty);
204
206
210 vtkGetObjectMacro(YVectorProperty, vtkProperty);
211 vtkGetObjectMacro(SelectedYVectorProperty, vtkProperty);
213
215
219 vtkGetObjectMacro(LockedYVectorProperty, vtkProperty);
220 vtkGetObjectMacro(SelectedLockedYVectorProperty, vtkProperty);
222
224
228 vtkGetObjectMacro(UnlockedYVectorProperty, vtkProperty);
229 vtkGetObjectMacro(SelectedUnlockedYVectorProperty, vtkProperty);
231
233
237 vtkGetObjectMacro(ZVectorProperty, vtkProperty);
238 vtkGetObjectMacro(SelectedZVectorProperty, vtkProperty);
240
242
246 vtkGetObjectMacro(LockedZVectorProperty, vtkProperty);
247 vtkGetObjectMacro(SelectedLockedZVectorProperty, vtkProperty);
249
251
255 vtkGetObjectMacro(UnlockedZVectorProperty, vtkProperty);
256 vtkGetObjectMacro(SelectedUnlockedZVectorProperty, vtkProperty);
258
260
264 vtkGetMacro(PickCameraFocalInfo, bool);
265 vtkSetMacro(PickCameraFocalInfo, bool);
266 vtkBooleanMacro(PickCameraFocalInfo, bool);
268
276 bool PickOrigin(int X, int Y, bool snapToMeshPoint = false);
277
285 bool PickNormal(int X, int Y, bool snapToMeshPoint = false);
286
294 bool PickDirectionPoint(int X, int Y, bool snapToMeshPoint = false);
295
313 int GetLockedAxis() const;
314 void SetLockedAxis(int axis);
315
317
320 int ComputeInteractionState(int X, int Y, int modify = 0) override;
321 void PlaceWidget(double bounds[6]) override;
322 void BuildRepresentation() override;
323 void StartWidgetInteraction(double eventPos[2]) override;
324 void WidgetInteraction(double newEventPos[2]) override;
325 void EndWidgetInteraction(double newEventPos[2]) override;
327
329
332 double* GetBounds() VTK_SIZEHINT(6) override;
333 void GetActors(vtkPropCollection* pc) override;
334 void ReleaseGraphicsResources(vtkWindow*) override;
335 int RenderOpaqueGeometry(vtkViewport*) override;
336 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
337 vtkTypeBool HasTranslucentPolygonalGeometry() override;
339
340 // Manage the state of the widget
342 {
343 Outside = 0,
351 ModifyingLockerZVector
352 };
353#if !defined(VTK_LEGACY_REMOVE)
354 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
356#endif
357
359
368 vtkSetClampMacro(InteractionState, int, Outside, ModifyingLockerZVector);
370
372
376 virtual void SetRepresentationState(int);
377 vtkGetMacro(RepresentationState, int);
379
381
385 vtkSetClampMacro(LengthFactor, double, 0, 1);
386 vtkGetMacro(LengthFactor, double);
388
389protected:
392
393 int RepresentationState = Outside;
394
395 // Keep track of event positions
396 double LastEventPosition[3];
397
398 bool PickCameraFocalInfo = false;
399
400 // Locking normal to camera
401 vtkTypeBool LockNormalToCamera = false;
402
403 int TranslationAxis = Axis::NONE;
404
405 double Origin[3] = { 0, 0, 0 };
406 double XVectorNormal[3] = { 1, 0, 0 };
407 double YVectorNormal[3] = { 0, 1, 0 };
408 double ZVectorNormal[3] = { 0, 0, 1 };
409 vtkSetVector3Macro(XVectorNormal, double);
410 vtkSetVector3Macro(YVectorNormal, double);
411 vtkSetVector3Macro(ZVectorNormal, double);
412
413 // The origin positioning handle
417 void HighlightOrigin(int highlight);
418
419 // The XVector line source
423 // The XVector cone source
427 void HighlightXVector(int highlight);
428 // The lock XVector cone source
429 bool XVectorIsLocked = false;
433 void HighlightLockerXVector(int highlight);
434
435 // The YVector line source
439 // The YVector cone source
443 void HighlightYVector(int highlight);
444 // The lock YVector cone source
445 bool YVectorIsLocked = false;
449 void HighlightLockerYVector(int highlight);
450
451 // The Vector Z line source
455 // The Vector Z cone source
459 void HighlightZVector(int highlight);
460 // The lock Vector Z cone source
461 bool ZVectorIsLocked = false;
465 void HighlightLockerZVector(int highlight);
466
467 // Do the picking
468 vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props
469 vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props
470 // Compute Picker tolerance
472
473 // Register internal Pickers within PickingManager
474 void RegisterPickers() override;
475
476 // Transform the normal (used for rotation)
478
479 // Methods to manipulate the plane
480 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
481 void ModifyingLocker(int axis);
482 void TranslateOrigin(double* p1, double* p2);
484
485 // Properties used to control the appearance of selected objects and
486 // the manipulator in general.
508
509 // Support GetBounds() method
512
513 double LengthFactor = 0.04;
514
515private:
517 void operator=(const vtkCoordinateFrameRepresentation&) = delete;
518};
519
520#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:46
implicit function for a bounding box
Definition vtkBox.h:39
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)
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.
double * GetBounds() override
Methods supporting the rendering process.
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 ContrainedAxis.
void HighlightZVector(int highlight)
static vtkCoordinateFrameRepresentation * New()
Instantiate the class.
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...
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:34
create a line defined by two end points
Allocate and hold a VTK object.
Definition vtkNew.h:56
perform various plane computations
Definition vtkPlane.h:34
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:85
an ordered list of Props
represent surface properties of a geometric object
Definition vtkProperty.h:62
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
abstract specification for Viewports
Definition vtkViewport.h:50
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:39
int vtkTypeBool
Definition vtkABI.h:69
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_SIZEHINT(...)