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=========================================================================*/
35#ifndef vtkCoordinateFrameRepresentation_h
36#define vtkCoordinateFrameRepresentation_h
37
38#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
39#include "vtkInteractionWidgetsModule.h" // For export macro
40#include "vtkNew.h" // For vtkNew command
42
43class vtkActor;
44class vtkBox;
45class vtkCellPicker;
46class vtkConeSource;
47class vtkFeatureEdges;
48class vtkGenericCell;
50class vtkLineSource;
51class vtkPlane;
52class vtkPolyData;
54class vtkProperty;
55class vtkSphereSource;
56class vtkTransform;
57
58class VTKINTERACTIONWIDGETS_EXPORT vtkCoordinateFrameRepresentation : public vtkWidgetRepresentation
59{
60public:
65
67
71 void PrintSelf(ostream& os, vtkIndent indent) override;
73
75
78 void SetOrigin(double x, double y, double z);
79 void SetOrigin(double x[3]);
80 vtkGetVector3Macro(Origin, double);
82
84
95 void SetNormal(double x, double y, double z);
96 void SetNormal(double n[3]);
98 vtkGetVector3Macro(XVectorNormal, double);
99 vtkGetVector3Macro(YVectorNormal, double);
100 vtkGetVector3Macro(ZVectorNormal, double);
102
104
108 void SetDirection(double x, double y, double z);
109 void SetDirection(double d[3]);
111
113
119 void SetXAxisVector(const double v[3]);
120 void SetXAxisVector(double x, double y, double z);
121 void SetYAxisVector(const double v[3]);
122 void SetYAxisVector(double x, double y, double z);
123 void SetZAxisVector(const double v[3]);
124 void SetZAxisVector(double x, double y, double z);
126
128
134 vtkGetMacro(LockNormalToCamera, vtkTypeBool);
135 vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
137
139
142 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
143 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
144 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
145 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
147
149
152 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
154
160
165 void Reset();
166
170 void ResetAxes();
171
173
177 vtkGetObjectMacro(OriginProperty, vtkProperty);
178 vtkGetObjectMacro(SelectedOriginProperty, vtkProperty);
180
182
186 vtkGetObjectMacro(XVectorProperty, vtkProperty);
187 vtkGetObjectMacro(SelectedXVectorProperty, vtkProperty);
189
191
195 vtkGetObjectMacro(LockedXVectorProperty, vtkProperty);
196 vtkGetObjectMacro(SelectedLockedXVectorProperty, vtkProperty);
198
200
204 vtkGetObjectMacro(UnlockedXVectorProperty, vtkProperty);
205 vtkGetObjectMacro(SelectedUnlockedXVectorProperty, vtkProperty);
207
209
213 vtkGetObjectMacro(YVectorProperty, vtkProperty);
214 vtkGetObjectMacro(SelectedYVectorProperty, vtkProperty);
216
218
222 vtkGetObjectMacro(LockedYVectorProperty, vtkProperty);
223 vtkGetObjectMacro(SelectedLockedYVectorProperty, vtkProperty);
225
227
231 vtkGetObjectMacro(UnlockedYVectorProperty, vtkProperty);
232 vtkGetObjectMacro(SelectedUnlockedYVectorProperty, vtkProperty);
234
236
240 vtkGetObjectMacro(ZVectorProperty, vtkProperty);
241 vtkGetObjectMacro(SelectedZVectorProperty, vtkProperty);
243
245
249 vtkGetObjectMacro(LockedZVectorProperty, vtkProperty);
250 vtkGetObjectMacro(SelectedLockedZVectorProperty, vtkProperty);
252
254
258 vtkGetObjectMacro(UnlockedZVectorProperty, vtkProperty);
259 vtkGetObjectMacro(SelectedUnlockedZVectorProperty, vtkProperty);
261
263
267 vtkGetMacro(PickCameraFocalInfo, bool);
268 vtkSetMacro(PickCameraFocalInfo, bool);
269 vtkBooleanMacro(PickCameraFocalInfo, bool);
271
279 bool PickOrigin(int X, int Y, bool snapToMeshPoint = false);
280
288 bool PickNormal(int X, int Y, bool snapToMeshPoint = false);
289
297 bool PickDirectionPoint(int X, int Y, bool snapToMeshPoint = false);
298
316 int GetLockedAxis() const;
317 void SetLockedAxis(int axis);
318
320
323 int ComputeInteractionState(int X, int Y, int modify = 0) override;
324 void PlaceWidget(double bounds[6]) override;
325 void BuildRepresentation() override;
326 void StartWidgetInteraction(double eventPos[2]) override;
327 void WidgetInteraction(double newEventPos[2]) override;
328 void EndWidgetInteraction(double newEventPos[2]) override;
330
332
335 double* GetBounds() VTK_SIZEHINT(6) override;
336 void GetActors(vtkPropCollection* pc) override;
337 void ReleaseGraphicsResources(vtkWindow*) override;
338 int RenderOpaqueGeometry(vtkViewport*) override;
339 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
340 vtkTypeBool HasTranslucentPolygonalGeometry() override;
342
343 // Manage the state of the widget
345 {
346 Outside = 0,
354 ModifyingLockerZVector
355 };
356#if !defined(VTK_LEGACY_REMOVE)
357 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
359#endif
360
362
371 vtkSetClampMacro(InteractionState, int, Outside, ModifyingLockerZVector);
373
375
379 virtual void SetRepresentationState(int);
380 vtkGetMacro(RepresentationState, int);
382
384
388 vtkSetClampMacro(LengthFactor, double, 0, 1);
389 vtkGetMacro(LengthFactor, double);
391
392protected:
395
396 int RepresentationState = Outside;
397
398 // Keep track of event positions
399 double LastEventPosition[3];
400
401 bool PickCameraFocalInfo = false;
402
403 // Locking normal to camera
404 vtkTypeBool LockNormalToCamera = false;
405
406 int TranslationAxis = Axis::NONE;
407
408 double Origin[3] = { 0, 0, 0 };
409 double XVectorNormal[3] = { 1, 0, 0 };
410 double YVectorNormal[3] = { 0, 1, 0 };
411 double ZVectorNormal[3] = { 0, 0, 1 };
412 vtkSetVector3Macro(XVectorNormal, double);
413 vtkSetVector3Macro(YVectorNormal, double);
414 vtkSetVector3Macro(ZVectorNormal, double);
415
416 // The origin positioning handle
420 void HighlightOrigin(int highlight);
421
422 // The XVector line source
426 // The XVector cone source
430 void HighlightXVector(int highlight);
431 // The lock XVector cone source
432 bool XVectorIsLocked = false;
436 void HighlightLockerXVector(int highlight);
437
438 // The YVector line source
442 // The YVector cone source
446 void HighlightYVector(int highlight);
447 // The lock YVector cone source
448 bool YVectorIsLocked = false;
452 void HighlightLockerYVector(int highlight);
453
454 // The Vector Z line source
458 // The Vector Z cone source
462 void HighlightZVector(int highlight);
463 // The lock Vector Z cone source
464 bool ZVectorIsLocked = false;
468 void HighlightLockerZVector(int highlight);
469
470 // Do the picking
471 vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props
472 vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props
473 // Compute Picker tolerance
475
476 // Register internal Pickers within PickingManager
477 void RegisterPickers() override;
478
479 // Transform the normal (used for rotation)
481
482 // Methods to manipulate the plane
483 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
484 void ModifyingLocker(int axis);
485 void TranslateOrigin(double* p1, double* p2);
487
488 // Properties used to control the appearance of selected objects and
489 // the manipulator in general.
511
512 // Support GetBounds() method
515
516 double LengthFactor = 0.04;
517
518private:
520 void operator=(const vtkCoordinateFrameRepresentation&) = delete;
521};
522
523#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
implicit function for a bounding box
Definition: vtkBox.h:42
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:73
generate polygonal cone
Definition: vtkConeSource.h:45
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:40
create a line defined by two end points
Definition: vtkLineSource.h:64
Allocate and hold a VTK object.
Definition: vtkNew.h:62
perform various plane computations
Definition: vtkPlane.h:37
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:91
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:68
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
abstract specification for Viewports
Definition: vtkViewport.h:56
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(...)