VTK  9.4.2
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
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
26VTK_ABI_NAMESPACE_BEGIN
27class vtkActor;
28class vtkDiskSource;
29class vtkDoubleArray;
31class vtkImageData;
32class vtkPoints;
33class vtkPolyData;
35class vtkProperty;
36class vtkPropPicker;
37class vtkTextProperty;
38class vtkTexture;
39class vtkTubeFilter;
40
41class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCameraOrientationRepresentation
43{
44public:
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
49 enum class InteractionStateType : int
50 {
51 Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
52 Hovering, // corresponds to vtkCameraOrientationWidget::Hot
53 Rotating // corresponds to vtkCameraOrientationWidget::Active
54 };
55
61 void ApplyInteractionState(const int& state);
62
69 {
70 // clamp to 0-2
71 this->InteractionState =
72 this->InteractionState < 0 ? 0 : (this->InteractionState > 2 ? 2 : this->InteractionState);
73 // convert
74 return static_cast<InteractionStateType>(this->InteractionState);
75 }
76
78
81 vtkSetVector2Macro(Size, int);
82 vtkGetVector2Macro(Size, int);
84
86
89 vtkSetVector2Macro(Padding, int);
90 vtkGetVector2Macro(Padding, int);
92
93 enum class AnchorType : int
94 {
95 LowerLeft = 0,
96 UpperLeft,
97 LowerRight,
98 UpperRight
99 };
100
102
105 AnchorType GetAnchorPosition() { return this->AnchorPosition; }
107 {
108 this->AnchorPosition = AnchorType::LowerLeft;
109 this->Modified();
110 }
112 {
113 this->AnchorPosition = AnchorType::UpperLeft;
114 this->Modified();
115 }
117 {
118 this->AnchorPosition = AnchorType::LowerRight;
119 this->Modified();
120 }
122 {
123 this->AnchorPosition = AnchorType::UpperRight;
124 this->Modified();
125 }
127
129
133 vtkSetMacro(TotalLength, double);
134 vtkGetMacro(TotalLength, double);
136
138
142 vtkSetMacro(NormalizedHandleDia, double);
143 vtkGetMacro(NormalizedHandleDia, double);
145
147
150 vtkGetMacro(Azimuth, double);
151 vtkGetVector3Macro(Back, double);
152 vtkGetMacro(Elevation, double);
153 vtkGetVector3Macro(Up, double);
155
157
160 vtkSetClampMacro(ShaftResolution, int, 3, 256);
161 vtkGetMacro(ShaftResolution, int);
163
165
168 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
169 vtkGetMacro(HandleCircumferentialResolution, int);
171
173
176 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
177 vtkGetMacro(ContainerCircumferentialResolution, int);
179
181
184 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
185 vtkGetMacro(ContainerRadialResolution, int);
187
189
192 vtkGetMacro(PickedAxis, int);
193 vtkGetMacro(PickedDir, int);
195
197
204
206
213
218
220
223 void SetContainerVisibility(bool state);
224 vtkBooleanMacro(ContainerVisibility, bool);
227
234
239
241
244 void PlaceWidget(double*) override {} // this representation is an overlay. Doesn't need this.
245 void BuildRepresentation() override;
246 void StartWidgetInteraction(double eventPos[2]) override;
247 void WidgetInteraction(double newEventPos[2]) override;
248 void EndWidgetInteraction(double newEventPos[2]) override;
249 int ComputeInteractionState(int X, int Y, int modify = 0) override;
250 double* GetBounds() VTK_SIZEHINT(6) override;
252
254
257 void ReleaseGraphicsResources(vtkWindow*) override;
258 int RenderOpaqueGeometry(vtkViewport*) override;
259 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
260 vtkTypeBool HasTranslucentPolygonalGeometry() override;
262
266 void ShallowCopy(vtkProp* prop) override;
267
271 bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
272
273protected:
276
277 virtual void CreateDefaultGeometry();
279 virtual void PositionHandles();
280 virtual void HighlightHandle();
281 virtual void Rotate(double newEventPos[2]);
282 void RegisterPickers() override;
284
285 // description of source shapes.
289
290 // geometries of handles and shafts. (position, color info)
292 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
293
294 // defaults are slight variations of r, y, g
296
297 // props
299 vtkNew<vtkActor> Handles[3][2];
301
302 // font-sz, font-type, frame color of the labels.
303 vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
304 vtkNew<vtkImageData> LabelImages[3][2];
305 vtkNew<vtkTexture> LabelTextures[3][2];
306
308
309 // Store rotation of gizmo.
311
312 // Positioning of the representation within a parent renderer.
313 AnchorType AnchorPosition = AnchorType::UpperRight;
314 int Padding[2] = { 10, 10 }; // In display coords.
315 int Size[2] = { 120, 120 }; // In display coords.
316
317 // Geometrical, textual, interaction description of the representation.
318 const char* AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
319 double Azimuth = 0.;
320 double Back[3] = { 0., 0., -1. };
321 double Bounds[6] = {};
322 double Elevation = 0.;
323 double MotionFactor = 1.;
324 double NormalizedHandleDia = 0.4;
325 double TotalLength = 1.;
326 double Up[3] = { 0., 1., 0. };
327 int ContainerCircumferentialResolution = 32;
328 int ContainerRadialResolution = 1;
329 int HandleCircumferentialResolution = 32;
330 int ShaftResolution = 10;
331
332 // Picking information.
333 int PickedAxis = -1;
334 int LastPickedAx = -1;
335 int PickedDir = -1;
336 int LastPickedDir = -1;
337
338 // Event tracking
339 double LastEventPosition[3] = {};
340
341private:
343 void operator=(const vtkCameraOrientationRepresentation&) = delete;
344};
345
346VTK_ABI_NAMESPACE_END
347#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 PlaceWidget(double *) override
These are methods that satisfy vtkWidgetRepresentation's API.
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.
void AnchorToLowerLeft()
Get/Set the widget anchor type.
vtkTextProperty * GetZMinusLabelProperty()
Get the '-' axis label properties.
void AnchorToLowerRight()
Get/Set the widget anchor type.
vtkTextProperty * GetYMinusLabelProperty()
Get the '-' axis label properties.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkTextProperty * GetZPlusLabelProperty()
Get the '+' axis label properties.
virtual void Rotate(double newEventPos[2])
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.
AnchorType GetAnchorPosition()
Get/Set the widget anchor type.
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.
vtkTransform * GetTransform()
Retrieve internal transform of this widget representation.
void ApplyInteractionState(const InteractionStateType &state)
The interaction state may be set from a widget (e.g., vtkCameraOrientationWidget) or other object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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.
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
void ApplyInteractionState(const int &state)
vtkProperty * GetContainerProperty()
Get the container property.
void AnchorToUpperLeft()
Get/Set the widget anchor type.
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:66
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: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