VTK  9.5.20250920
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
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
106 vtkSetEnumMacro(AnchorPosition, AnchorType);
107 vtkGetEnumMacro(AnchorPosition, AnchorType);
109 {
110 this->AnchorPosition = AnchorType::LowerLeft;
111 this->Modified();
112 }
114 {
115 this->AnchorPosition = AnchorType::UpperLeft;
116 this->Modified();
117 }
119 {
120 this->AnchorPosition = AnchorType::LowerRight;
121 this->Modified();
122 }
124 {
125 this->AnchorPosition = AnchorType::UpperRight;
126 this->Modified();
127 }
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);
171 vtkGetMacro(HandleCircumferentialResolution, int);
173
175
178 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
179 vtkGetMacro(ContainerCircumferentialResolution, int);
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
268
270
273 void SetContainerVisibility(bool state);
274 vtkBooleanMacro(ContainerVisibility, bool);
277
284
289
291
294 void PlaceWidget(double*) override {} // this representation is an overlay. Doesn't need this.
295 void BuildRepresentation() override;
296 void StartWidgetInteraction(double eventPos[2]) override;
297 void WidgetInteraction(double newEventPos[2]) override;
298 void EndWidgetInteraction(double newEventPos[2]) override;
299 int ComputeInteractionState(int X, int Y, int modify = 0) override;
300 double* GetBounds() VTK_SIZEHINT(6) override;
302
304
307 void ReleaseGraphicsResources(vtkWindow*) override;
308 int RenderOpaqueGeometry(vtkViewport*) override;
309 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
310 vtkTypeBool HasTranslucentPolygonalGeometry() override;
312
316 void ShallowCopy(vtkProp* prop) override;
317
321 bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
322
323protected:
326
327 virtual void CreateDefaultGeometry();
329 virtual void PositionHandles();
330 virtual void HighlightHandle();
331 virtual void Rotate(double newEventPos[2]);
332 void RegisterPickers() override;
334
335 // description of source shapes.
339
340 // geometries of handles and shafts. (position, color info)
342 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
343
344 // defaults are slight variations of r, y, g
346
347 // props
349 vtkNew<vtkActor> Handles[3][2];
351
352 // font-sz, font-type, frame color of the labels.
353 vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
354 vtkNew<vtkImageData> LabelImages[3][2];
355 vtkNew<vtkTexture> LabelTextures[3][2];
356
358
359 // Store rotation of gizmo.
361
362 // Positioning of the representation within a parent renderer.
363 AnchorType AnchorPosition = AnchorType::UpperRight;
364 int Padding[2] = { 10, 10 }; // In display coords.
365 int Size[2] = { 120, 120 }; // In display coords.
366
367 // Geometrical, textual, interaction description of the representation.
368 std::string AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
369 double Azimuth = 0.;
370 double Back[3] = { 0., 0., -1. };
371 double Bounds[6] = {};
372 double Elevation = 0.;
373 double MotionFactor = 1.;
374 double NormalizedHandleDia = 0.4;
375 double TotalLength = 1.;
376 double Up[3] = { 0., 1., 0. };
377 int ContainerCircumferentialResolution = 32;
378 int ContainerRadialResolution = 1;
379 int HandleCircumferentialResolution = 32;
380 int ShaftResolution = 10;
381
382 // Picking information.
383 int PickedAxis = -1;
384 int LastPickedAx = -1;
385 int PickedDir = -1;
386 int LastPickedDir = -1;
387
388 // Event tracking
389 double LastEventPosition[3] = {};
390
391private:
393 void operator=(const vtkCameraOrientationRepresentation&) = delete;
394};
395
396VTK_ABI_NAMESPACE_END
397#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.
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 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.
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.
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.
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.
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 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.
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.
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