VTK  9.3.0
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
25VTK_ABI_NAMESPACE_BEGIN
26class vtkActor;
27class vtkDiskSource;
28class vtkDoubleArray;
30class vtkImageData;
31class vtkPoints;
32class vtkPolyData;
34class vtkProperty;
35class vtkPropPicker;
36class vtkTextProperty;
37class vtkTexture;
38class vtkTubeFilter;
39
40class VTKINTERACTIONWIDGETS_EXPORT vtkCameraOrientationRepresentation
42{
43public:
46 void PrintSelf(ostream& os, vtkIndent indent) override;
47
48 enum class InteractionStateType : int
49 {
50 Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
51 Hovering, // corresponds to vtkCameraOrientationWidget::Hot
52 Rotating // corresponds to vtkCameraOrientationWidget::Active
53 };
54
60 void ApplyInteractionState(const int& state);
61
68 {
69 // clamp to 0-2
70 this->InteractionState =
71 this->InteractionState < 0 ? 0 : (this->InteractionState > 2 ? 2 : this->InteractionState);
72 // convert
73 return static_cast<InteractionStateType>(this->InteractionState);
74 }
75
77
80 vtkSetVector2Macro(Size, int);
81 vtkGetVector2Macro(Size, int);
83
85
88 vtkSetVector2Macro(Padding, int);
89 vtkGetVector2Macro(Padding, int);
91
92 enum class AnchorType : int
93 {
94 LowerLeft = 0,
95 UpperLeft,
96 LowerRight,
97 UpperRight
98 };
99
101
104 AnchorType GetAnchorPosition() { return this->AnchorPosition; }
106 {
107 this->AnchorPosition = AnchorType::LowerLeft;
108 this->Modified();
109 }
111 {
112 this->AnchorPosition = AnchorType::UpperLeft;
113 this->Modified();
114 }
116 {
117 this->AnchorPosition = AnchorType::LowerRight;
118 this->Modified();
119 }
121 {
122 this->AnchorPosition = AnchorType::UpperRight;
123 this->Modified();
124 }
126
128
132 vtkSetMacro(TotalLength, double);
133 vtkGetMacro(TotalLength, double);
135
137
141 vtkSetMacro(NormalizedHandleDia, double);
142 vtkGetMacro(NormalizedHandleDia, double);
144
146
149 vtkGetMacro(Azimuth, double);
150 vtkGetVector3Macro(Back, double);
151 vtkGetMacro(Elevation, double);
152 vtkGetVector3Macro(Up, double);
154
156
159 vtkSetClampMacro(ShaftResolution, int, 3, 256);
160 vtkGetMacro(ShaftResolution, int);
162
164
167 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
168 vtkGetMacro(HandleCircumferentialResolution, int);
170
172
175 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
176 vtkGetMacro(ContainerCircumferentialResolution, int);
178
180
183 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
184 vtkGetMacro(ContainerRadialResolution, int);
186
188
191 vtkGetMacro(PickedAxis, int);
192 vtkGetMacro(PickedDir, int);
194
196
203
205
212
217
219
222 void SetContainerVisibility(bool state);
223 vtkBooleanMacro(ContainerVisibility, bool);
226
233
238
240
243 void PlaceWidget(double*) override{}; // this representation is an overlay. Doesn't need this.
244 void BuildRepresentation() override;
245 void StartWidgetInteraction(double eventPos[2]) override;
246 void WidgetInteraction(double newEventPos[2]) override;
247 void EndWidgetInteraction(double newEventPos[2]) override;
248 int ComputeInteractionState(int X, int Y, int modify = 0) override;
249 double* GetBounds() VTK_SIZEHINT(6) override;
251
253
256 void ReleaseGraphicsResources(vtkWindow*) override;
257 int RenderOpaqueGeometry(vtkViewport*) override;
258 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
259 vtkTypeBool HasTranslucentPolygonalGeometry() override;
261
265 void ShallowCopy(vtkProp* prop) override;
266
270 bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
271
272protected:
275
276 virtual void CreateDefaultGeometry();
278 virtual void PositionHandles();
279 virtual void HighlightHandle();
280 virtual void Rotate(double newEventPos[2]);
281 void RegisterPickers() override;
283
284 // description of source shapes.
288
289 // geometries of handles and shafts. (position, color info)
291 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
292
293 // defaults are slight variations of r, y, g
295
296 // props
298 vtkNew<vtkActor> Handles[3][2];
300
301 // font-sz, font-type, frame color of the labels.
302 vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
303 vtkNew<vtkImageData> LabelImages[3][2];
304 vtkNew<vtkTexture> LabelTextures[3][2];
305
307
308 // Store rotation of gizmo.
310
311 // Positioning of the representation within a parent renderer.
312 AnchorType AnchorPosition = AnchorType::UpperRight;
313 int Padding[2] = { 10, 10 }; // In display coords.
314 int Size[2] = { 120, 120 }; // In display coords.
315
316 // Geometrical, textual, interaction description of the representation.
317 const char* AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
318 double Azimuth = 0.;
319 double Back[3] = { 0., 0., -1. };
320 double Bounds[6] = {};
321 double Elevation = 0.;
322 double MotionFactor = 1.;
323 double NormalizedHandleDia = 0.4;
324 double TotalLength = 1.;
325 double Up[3] = { 0., 1., 0. };
326 int ContainerCircumferentialResolution = 32;
327 int ContainerRadialResolution = 1;
328 int HandleCircumferentialResolution = 32;
329 int ShaftResolution = 10;
330
331 // Picking information.
332 int PickedAxis = -1;
333 int LastPickedAx = -1;
334 int PickedDir = -1;
335 int LastPickedDir = -1;
336
337 // Event tracking
338 double LastEventPosition[3] = {};
339
340private:
342 void operator=(const vtkCameraOrientationRepresentation&) = delete;
343};
344
345VTK_ABI_NAMESPACE_END
346#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
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:29
Allocate and hold a VTK object.
Definition vtkNew.h:51
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition vtkPoints.h:29
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:80
an ordered list of Props
pick an actor/prop using graphics hardware
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
represent surface properties of a geometric object
Definition vtkProperty.h:57
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:58
describes linear transformations via a 4x4 matrix
filter that generates tubes around lines
abstract specification for Viewports
Definition vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)