VTK  9.5.20251104
vtkCameraOrientationRepresentation.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
38#ifndef vtkCameraOrientationRepresentation_h
39#define vtkCameraOrientationRepresentation_h
40
41#include "vtkInteractionWidgetsModule.h" // needed for export macro
43#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
44
45#include <algorithm> // std::min, std::max
46
47VTK_ABI_NAMESPACE_BEGIN
48class vtkActor;
49class vtkDiskSource;
50class vtkDoubleArray;
52class vtkImageData;
53class vtkPoints;
54class vtkPolyData;
56class vtkProperty;
57class vtkPropPicker;
58class vtkTextProperty;
59class vtkTexture;
60class vtkTubeFilter;
61
62class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCameraOrientationRepresentation
64{
65public:
68 void PrintSelf(ostream& os, vtkIndent indent) override;
69
70 enum class InteractionStateType : int
71 {
72 Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
73 Hovering, // corresponds to vtkCameraOrientationWidget::Hot
74 Rotating // corresponds to vtkCameraOrientationWidget::Active
75 };
76
82 void ApplyInteractionState(const int& state);
83
90 {
91 // clamp to 0-2
92 this->InteractionState = std::min(std::max(this->InteractionState, 0), 2);
93 // convert
94 return static_cast<InteractionStateType>(this->InteractionState);
95 }
96
98
101 vtkSetVector2Macro(Size, int);
102 vtkGetVector2Macro(Size, int);
104
106
109 vtkSetVector2Macro(Padding, int);
110 vtkGetVector2Macro(Padding, int);
112
113 enum class AnchorType : int
114 {
115 LowerLeft = 0,
116 UpperLeft,
117 LowerRight,
118 UpperRight
119 };
120
122
125 vtkSetEnumMacro(AnchorPosition, AnchorType);
126 vtkGetEnumMacro(AnchorPosition, AnchorType);
128 {
129 this->AnchorPosition = AnchorType::LowerLeft;
130 this->Modified();
131 }
133 {
134 this->AnchorPosition = AnchorType::UpperLeft;
135 this->Modified();
136 }
138 {
139 this->AnchorPosition = AnchorType::LowerRight;
140 this->Modified();
141 }
143 {
144 this->AnchorPosition = AnchorType::UpperRight;
145 this->Modified();
146 }
148
150
154 vtkSetMacro(TotalLength, double);
155 vtkGetMacro(TotalLength, double);
157
159
163 vtkSetMacro(NormalizedHandleDia, double);
164 vtkGetMacro(NormalizedHandleDia, double);
166
168
171 vtkGetMacro(Azimuth, double);
172 vtkGetVector3Macro(Back, double);
173 vtkGetMacro(Elevation, double);
174 vtkGetVector3Macro(Up, double);
176
178
181 vtkSetClampMacro(ShaftResolution, int, 3, 256);
182 vtkGetMacro(ShaftResolution, int);
184
186
189 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
190 vtkGetMacro(HandleCircumferentialResolution, int);
192
194
197 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
198 vtkGetMacro(ContainerCircumferentialResolution, int);
200
202
205 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
206 vtkGetMacro(ContainerRadialResolution, int);
208
210
213 vtkGetMacro(PickedAxis, int);
214 vtkGetMacro(PickedDir, int);
216
218
221 void SetXPlusLabelText(const std::string& label)
222 {
223 this->AxisLabelsText[0][0] = label;
224 this->Modified();
225 }
226 std::string GetXPlusLabelText() { return this->AxisLabelsText[0][0]; }
227 void SetYPlusLabelText(const std::string& label)
228 {
229 this->AxisLabelsText[1][0] = label;
230 this->Modified();
231 }
232 std::string GetYPlusLabelText() { return this->AxisLabelsText[1][0]; }
233 void SetZPlusLabelText(const std::string& label)
234 {
235 this->AxisLabelsText[2][0] = label;
236 this->Modified();
237 }
238 std::string GetZPlusLabelText() { return this->AxisLabelsText[2][0]; }
240
242
245 void SetXMinusLabelText(const std::string& label)
246 {
247 this->AxisLabelsText[0][1] = label;
248 this->Modified();
249 }
250 std::string GetXMinusLabelText() { return this->AxisLabelsText[0][1]; }
251 void SetYMinusLabelText(const std::string& label)
252 {
253 this->AxisLabelsText[1][1] = label;
254 this->Modified();
255 }
256 std::string GetYMinusLabelText() { return this->AxisLabelsText[1][1]; }
257 void SetZMinusLabelText(const std::string& label)
258 {
259 this->AxisLabelsText[2][1] = label;
260 this->Modified();
261 }
262 std::string GetZMinusLabelText() { return this->AxisLabelsText[2][1]; }
264
266
273
275
282
284
287 void SetXAxisColor(double color[3]);
288 void SetXAxisColor(double, double, double);
290
292
295 void SetYAxisColor(double color[3]);
296 void SetYAxisColor(double, double, double);
298
300
303 void SetZAxisColor(double color[3]);
304 void SetZAxisColor(double, double, double);
306
308
311 void SetAxisColor(int ax, double color[3]);
312 void SetAxisColor(int ax, double, double, double);
314
316
320 void GetXAxisColor(double color[3]);
322
324
327 double* GetYAxisColor() VTK_SIZEHINT(3);
328 void GetYAxisColor(double color[3]);
330
332
335 double* GetZAxisColor() VTK_SIZEHINT(3);
336 void GetZAxisColor(double color[3]);
338
340
343 double* GetAxisColor(int ax) VTK_SIZEHINT(3);
344 void GetAxisColor(int ax, double color[3]);
346
350 vtkProperty* GetContainerProperty();
351
353
356 void SetContainerVisibility(bool state);
357 vtkBooleanMacro(ContainerVisibility, bool);
358 bool GetContainerVisibility();
360
366 void GetActors(vtkPropCollection*) override;
367
371 vtkTransform* GetTransform();
372
374
377 void PlaceWidget(double*) override {} // this representation is an overlay. Doesn't need this.
378 void BuildRepresentation() override;
379 void StartWidgetInteraction(double eventPos[2]) override;
380 void WidgetInteraction(double newEventPos[2]) override;
381 void EndWidgetInteraction(double newEventPos[2]) override;
382 int ComputeInteractionState(int X, int Y, int modify = 0) override;
383 double* GetBounds() VTK_SIZEHINT(6) override;
385
387
390 void ReleaseGraphicsResources(vtkWindow*) override;
391 int RenderOpaqueGeometry(vtkViewport*) override;
392 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
393 vtkTypeBool HasTranslucentPolygonalGeometry() override;
395
399 void ShallowCopy(vtkProp* prop) override;
400
404 bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
405
406protected:
409
410 virtual void CreateDefaultGeometry();
412 virtual void PositionHandles();
413 virtual void HighlightHandle();
414 virtual void Rotate(double newEventPos[2]);
415 void RegisterPickers() override;
417
418 // description of source shapes.
422
423 // geometries of handles and shafts. (position, color info)
425 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
426
427 // defaults are slight variations of r, y, g
429
430 // props
432 vtkNew<vtkActor> Handles[3][2];
434
435 // font-sz, font-type, frame color of the labels.
436 vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
437 vtkNew<vtkImageData> LabelImages[3][2];
438 vtkNew<vtkTexture> LabelTextures[3][2];
439
441
442 // Store rotation of gizmo.
444
445 // Positioning of the representation within a parent renderer.
446 AnchorType AnchorPosition = AnchorType::UpperRight;
447 int Padding[2] = { 10, 10 }; // In display coords.
448 int Size[2] = { 120, 120 }; // In display coords.
449
450 // Geometrical, textual, interaction description of the representation.
451 std::string AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
452 double Azimuth = 0.;
453 double Back[3] = { 0., 0., -1. };
454 double Bounds[6] = {};
455 double Elevation = 0.;
456 double MotionFactor = 1.;
457 double NormalizedHandleDia = 0.4;
458 double TotalLength = 1.;
459 double Up[3] = { 0., 1., 0. };
460 int ContainerCircumferentialResolution = 32;
461 int ContainerRadialResolution = 1;
462 int HandleCircumferentialResolution = 32;
463 int ShaftResolution = 10;
464
465 // Picking information.
466 int PickedAxis = -1;
467 int LastPickedAx = -1;
468 int PickedDir = -1;
469 int LastPickedDir = -1;
470
471 // Event tracking
472 double LastEventPosition[3] = {};
473
474private:
476 void operator=(const vtkCameraOrientationRepresentation&) = delete;
477};
478
479VTK_ABI_NAMESPACE_END
480#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
A 3D representation for vtkCameraOrientationWidget.
void StartWidgetInteraction(double eventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkTextProperty * GetXPlusLabelProperty()
Get the '+' axis label properties.
void AnchorToUpperRight()
Get/Set the widget anchor type.
void SetZAxisColor(double, double, double)
Set the Z axis color.
void SetYAxisColor(double color[3])
Set the Y axis color.
vtkTextProperty * GetXMinusLabelProperty()
Get the '-' axis label properties.
std::string GetYPlusLabelText()
Set/Get the '+' axis label text.
void SetZPlusLabelText(const std::string &label)
Set/Get the '+' axis label text.
void SetYMinusLabelText(const std::string &label)
Set/Get the '-' axis label text.
void AnchorToLowerLeft()
Get/Set the widget anchor type.
std::string GetZMinusLabelText()
Set/Get the '-' axis label text.
std::string GetXMinusLabelText()
Set/Get the '-' axis label text.
vtkTextProperty * GetZMinusLabelProperty()
Get the '-' axis label properties.
void AnchorToLowerRight()
Get/Set the widget anchor type.
vtkTextProperty * GetYMinusLabelProperty()
Get the '-' axis label properties.
void SetAxisColor(int ax, double, double, double)
Set the axis color for the axis ax.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkTextProperty * GetZPlusLabelProperty()
Get the '+' axis label properties.
virtual void Rotate(double newEventPos[2])
std::string GetZPlusLabelText()
Set/Get the '+' axis label text.
double * GetXAxisColor()
Get the X axis color.
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
void WidgetInteraction(double newEventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
std::string GetXPlusLabelText()
Set/Get the '+' axis label text.
void SetAxisColor(int ax, double color[3])
Set the axis color for the axis ax.
vtkSetEnumMacro(AnchorPosition, AnchorType)
Get/Set the widget anchor type.
vtkGetEnumMacro(AnchorPosition, AnchorType)
Get/Set the widget anchor type.
void SetZMinusLabelText(const std::string &label)
Set/Get the '-' axis label text.
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetXPlusLabelText(const std::string &label)
Set/Get the '+' axis label text.
void ApplyInteractionState(const InteractionStateType &state)
The interaction state may be set from a widget (e.g., vtkCameraOrientationWidget) or other object.
void SetYPlusLabelText(const std::string &label)
Set/Get the '+' axis label text.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::string GetYMinusLabelText()
Set/Get the '-' axis label text.
static vtkCameraOrientationRepresentation * New()
void EndWidgetInteraction(double newEventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkTextProperty * GetYPlusLabelProperty()
Get the '+' axis label properties.
InteractionStateType GetInteractionStateAsEnum() noexcept
Convenient method to get InteractionState as enum.
void SetYAxisColor(double, double, double)
Set the Y axis color.
void SetXAxisColor(double color[3])
Set the X axis color.
void SetXAxisColor(double, double, double)
Set the X axis color.
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetZAxisColor(double color[3])
Set the Z axis color.
void ApplyInteractionState(const int &state)
void AnchorToUpperLeft()
Get/Set the widget anchor type.
void SetXMinusLabelText(const std::string &label)
Set/Get the '-' axis label text.
create a disk with hole in center
dynamic, self-adjusting array of double
create a ellipsoidal-shaped button
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition vtkPoints.h:139
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
pick an actor/prop using graphics hardware
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:69
represent surface properties of a geometric object
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:168
describes linear transformations via a 4x4 matrix
filter that generates tubes around lines
abstract specification for Viewports
Definition vtkViewport.h:66
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