VTK  9.6.1
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
18
19#ifndef vtkCameraOrientationRepresentation_h
20#define vtkCameraOrientationRepresentation_h
21
22#include "vtkInteractionWidgetsModule.h" // needed for export macro
24#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
25
26#include <algorithm> // std::min, std::max
27
28VTK_ABI_NAMESPACE_BEGIN
29class vtkActor;
30class vtkDiskSource;
31class vtkDoubleArray;
33class vtkImageData;
34class vtkPoints;
35class vtkPolyData;
37class vtkProperty;
38class vtkPropPicker;
39class vtkTextProperty;
40class vtkTexture;
41class vtkTubeFilter;
42
43class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCameraOrientationRepresentation
45{
46public:
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
51 enum class InteractionStateType : int
52 {
53 Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
54 Hovering, // corresponds to vtkCameraOrientationWidget::Hot
55 Rotating // corresponds to vtkCameraOrientationWidget::Active
56 };
57
63 void ApplyInteractionState(const int& state);
64
71 {
72 // clamp to 0-2
73 this->InteractionState = std::min(std::max(this->InteractionState, 0), 2);
74 // convert
75 return static_cast<InteractionStateType>(this->InteractionState);
76 }
77
79
82 vtkSetVector2Macro(Size, int);
83 vtkGetVector2Macro(Size, int);
85
87
90 vtkSetVector2Macro(Padding, int);
91 vtkGetVector2Macro(Padding, int);
93
94 enum class AnchorType : int
95 {
96 LowerLeft = 0,
97 UpperLeft,
98 LowerRight,
99 UpperRight
100 };
101
103
109 {
111 this->Modified();
112 }
114 {
116 this->Modified();
117 }
119 {
121 this->Modified();
122 }
124 {
126 this->Modified();
127 }
128
129
131
135 vtkSetMacro(TotalLength, double);
136 vtkGetMacro(TotalLength, double);
138
140
144 vtkSetMacro(NormalizedHandleDia, double);
145 vtkGetMacro(NormalizedHandleDia, double);
147
149
152 vtkGetMacro(Azimuth, double);
153 vtkGetVector3Macro(Back, double);
154 vtkGetMacro(Elevation, double);
155 vtkGetVector3Macro(Up, double);
157
159
162 vtkSetClampMacro(ShaftResolution, int, 3, 256);
163 vtkGetMacro(ShaftResolution, int);
165
167
170 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
173
175
178 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
181
183
186 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
187 vtkGetMacro(ContainerRadialResolution, int);
189
191
194 vtkGetMacro(PickedAxis, int);
195 vtkGetMacro(PickedDir, int);
197
199
202 void SetXPlusLabelText(const std::string& label)
203 {
204 this->AxisLabelsText[0][0] = label;
205 this->Modified();
206 }
207 std::string GetXPlusLabelText() { return this->AxisLabelsText[0][0]; }
208 void SetYPlusLabelText(const std::string& label)
209 {
210 this->AxisLabelsText[1][0] = label;
211 this->Modified();
212 }
213 std::string GetYPlusLabelText() { return this->AxisLabelsText[1][0]; }
214 void SetZPlusLabelText(const std::string& label)
215 {
216 this->AxisLabelsText[2][0] = label;
217 this->Modified();
218 }
219 std::string GetZPlusLabelText() { return this->AxisLabelsText[2][0]; }
221
223
226 void SetXMinusLabelText(const std::string& label)
227 {
228 this->AxisLabelsText[0][1] = label;
229 this->Modified();
230 }
231 std::string GetXMinusLabelText() { return this->AxisLabelsText[0][1]; }
232 void SetYMinusLabelText(const std::string& label)
233 {
234 this->AxisLabelsText[1][1] = label;
235 this->Modified();
236 }
237 std::string GetYMinusLabelText() { return this->AxisLabelsText[1][1]; }
238 void SetZMinusLabelText(const std::string& label)
239 {
240 this->AxisLabelsText[2][1] = label;
241 this->Modified();
242 }
243 std::string GetZMinusLabelText() { return this->AxisLabelsText[2][1]; }
245
247
254
256
263
265
268 void SetXAxisColor(double color[3]);
269 void SetXAxisColor(double, double, double);
271
273
276 void SetYAxisColor(double color[3]);
277 void SetYAxisColor(double, double, double);
279
281
284 void SetZAxisColor(double color[3]);
285 void SetZAxisColor(double, double, double);
287
289
292 void SetAxisColor(int ax, double color[3]);
293 void SetAxisColor(int ax, double, double, double);
295
297
301 void GetXAxisColor(double color[3]);
303
305
309 void GetYAxisColor(double color[3]);
311
313
317 void GetZAxisColor(double color[3]);
319
321
324 double* GetAxisColor(int ax) VTK_SIZEHINT(3);
325 void GetAxisColor(int ax, double color[3]);
327
332
334
337 void SetContainerVisibility(bool state);
338 vtkBooleanMacro(ContainerVisibility, bool);
341
348
353
355
358 void PlaceWidget(double*) override {} // this representation is an overlay. Doesn't need this.
359 void BuildRepresentation() override;
360 void StartWidgetInteraction(double eventPos[2]) override;
361 void WidgetInteraction(double newEventPos[2]) override;
362 void EndWidgetInteraction(double newEventPos[2]) override;
363 int ComputeInteractionState(int X, int Y, int modify = 0) override;
364 double* GetBounds() VTK_SIZEHINT(6) override;
366
368
376
380 void ShallowCopy(vtkProp* prop) override;
381
385 bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
386
387protected:
390
391 virtual void CreateDefaultGeometry();
393 virtual void PositionHandles();
394 virtual void HighlightHandle();
395 virtual void Rotate(double newEventPos[2]);
396 void RegisterPickers() override;
398
399 // description of source shapes.
403
404 // geometries of handles and shafts. (position, color info)
406 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
407
408 // defaults are slight variations of r, y, g
410
411 // props
415
416 // font-sz, font-type, frame color of the labels.
420
422
423 // Store rotation of gizmo.
425
426 // Positioning of the representation within a parent renderer.
428 int Padding[2] = { 10, 10 }; // In display coords.
429 int Size[2] = { 120, 120 }; // In display coords.
430
431 // Geometrical, textual, interaction description of the representation.
432 std::string AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
433 double Azimuth = 0.;
434 double Back[3] = { 0., 0., -1. };
435 double Bounds[6] = {};
436 double Elevation = 0.;
437 double MotionFactor = 1.;
439 double TotalLength = 1.;
440 double Up[3] = { 0., 1., 0. };
445
446 // Picking information.
447 int PickedAxis = -1;
448 int LastPickedAx = -1;
449 int PickedDir = -1;
451
452 // Event tracking
453 double LastEventPosition[3] = {};
454
455private:
457 void operator=(const vtkCameraOrientationRepresentation&) = delete;
458};
459
460VTK_ABI_NAMESPACE_END
461#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:42
A 3D representation for vtkCameraOrientationWidget.
void StartWidgetInteraction(double eventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkNew< vtkEllipticalButtonSource > HandleSources[3][2]
vtkTextProperty * GetXPlusLabelProperty()
Get the '+' axis label properties.
void AnchorToUpperRight()
Get/Set the widget anchor type.
void PlaceWidget(double *) override
These are methods that satisfy vtkWidgetRepresentation's API.
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.
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes.
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.
vtkNew< vtkTextProperty > AxisVectorTextProperties[3][2]
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.
bool IsAnyHandleSelected()
Is a grabber button picked.
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.
double * GetYAxisColor()
Get the Y axis color.
vtkGetEnumMacro(AnchorPosition, AnchorType)
Get/Set the widget anchor type.
void SetZMinusLabelText(const std::string &label)
Set/Get the '-' axis label text.
bool GetContainerVisibility()
Show container to indicate mouse presence.
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.
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
vtkTransform * GetTransform()
Retrieve internal transform of this widget representation.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting, and required by, the rendering process.
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.
void ShallowCopy(vtkProp *prop) override
Shallow copy of an axes actor.
static vtkCameraOrientationRepresentation * New()
void EndWidgetInteraction(double newEventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetContainerVisibility(bool state)
Show container to indicate mouse presence.
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 ReleaseGraphicsResources(vtkWindow *) override
Methods supporting, and required by, the rendering process.
void SetXAxisColor(double color[3])
Set the X axis color.
double * GetZAxisColor()
Get the Z axis color.
void SetXAxisColor(double, double, double)
Set the X axis color.
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void SetZAxisColor(double color[3])
Set the Z axis color.
void ApplyInteractionState(const int &state)
vtkProperty * GetContainerProperty()
Get the container property.
void AnchorToUpperLeft()
Get/Set the widget anchor type.
double * GetAxisColor(int ax)
Get the axis color for the axis ax.
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:29
Allocate and hold a VTK object.
Definition vtkNew.h:58
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition vtkPoints.h:30
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
an ordered list of Props
pick an actor/prop using graphics hardware
represent surface properties of a geometric object
Definition vtkProperty.h:60
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:59
describes linear transformations via a 4x4 matrix
filter that generates tubes around lines
abstract specification for Viewports
Definition vtkViewport.h:47
window superclass for vtkRenderWindow
Definition vtkWindow.h:29
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO