VTK  9.3.20240425
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
31VTK_ABI_NAMESPACE_BEGIN
32class vtkActor;
33class vtkBox;
34class vtkCellPicker;
35class vtkConeSource;
36class vtkFeatureEdges;
37class vtkGenericCell;
39class vtkLineSource;
40class vtkPlane;
41class vtkPolyData;
43class vtkProperty;
44class vtkSphereSource;
45class vtkTransform;
46
47class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCoordinateFrameRepresentation
49{
50public:
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]);
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
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
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
378protected:
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
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);
473
474 // Properties used to control the appearance of selected objects and
475 // the manipulator in general.
497
498 // Support GetBounds() method
501
502 double LengthFactor = 0.04;
503
504private:
506 void operator=(const vtkCoordinateFrameRepresentation&) = delete;
507};
508
509VTK_ABI_NAMESPACE_END
510#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
implicit function for a bounding box
Definition vtkBox.h:110
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 ConstrainedAxis.
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:108
create a line defined by two end points
Allocate and hold a VTK object.
Definition vtkNew.h:160
perform various plane computations
Definition vtkPlane.h:135
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
represent surface properties of a geometric object
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
abstract specification for Viewports
Definition vtkViewport.h:65
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO