VTK  9.4.20250102
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 vtkSetEnumMacro(AnchorPosition, AnchorType);
106 vtkGetEnumMacro(AnchorPosition, AnchorType);
108 {
109 this->AnchorPosition = AnchorType::LowerLeft;
110 this->Modified();
111 }
113 {
114 this->AnchorPosition = AnchorType::UpperLeft;
115 this->Modified();
116 }
118 {
119 this->AnchorPosition = AnchorType::LowerRight;
120 this->Modified();
121 }
123 {
124 this->AnchorPosition = AnchorType::UpperRight;
125 this->Modified();
126 }
128
130
134 vtkSetMacro(TotalLength, double);
135 vtkGetMacro(TotalLength, double);
137
139
143 vtkSetMacro(NormalizedHandleDia, double);
144 vtkGetMacro(NormalizedHandleDia, double);
146
148
151 vtkGetMacro(Azimuth, double);
152 vtkGetVector3Macro(Back, double);
153 vtkGetMacro(Elevation, double);
154 vtkGetVector3Macro(Up, double);
156
158
161 vtkSetClampMacro(ShaftResolution, int, 3, 256);
162 vtkGetMacro(ShaftResolution, int);
164
166
169 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
170 vtkGetMacro(HandleCircumferentialResolution, int);
172
174
177 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
178 vtkGetMacro(ContainerCircumferentialResolution, int);
180
182
185 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
186 vtkGetMacro(ContainerRadialResolution, int);
188
190
193 vtkGetMacro(PickedAxis, int);
194 vtkGetMacro(PickedDir, int);
196
198
201 void SetXPlusLabelText(const std::string& label)
202 {
203 this->AxisLabelsText[0][0] = label;
204 this->Modified();
205 }
206 std::string GetXPlusLabelText() { return this->AxisLabelsText[0][0]; }
207 void SetYPlusLabelText(const std::string& label)
208 {
209 this->AxisLabelsText[1][0] = label;
210 this->Modified();
211 }
212 std::string GetYPlusLabelText() { return this->AxisLabelsText[1][0]; }
213 void SetZPlusLabelText(const std::string& label)
214 {
215 this->AxisLabelsText[2][0] = label;
216 this->Modified();
217 }
218 std::string GetZPlusLabelText() { return this->AxisLabelsText[2][0]; }
220
222
225 void SetXMinusLabelText(const std::string& label)
226 {
227 this->AxisLabelsText[0][1] = label;
228 this->Modified();
229 }
230 std::string GetXMinusLabelText() { return this->AxisLabelsText[0][1]; }
231 void SetYMinusLabelText(const std::string& label)
232 {
233 this->AxisLabelsText[1][1] = label;
234 this->Modified();
235 }
236 std::string GetYMinusLabelText() { return this->AxisLabelsText[1][1]; }
237 void SetZMinusLabelText(const std::string& label)
238 {
239 this->AxisLabelsText[2][1] = label;
240 this->Modified();
241 }
242 std::string GetZMinusLabelText() { return this->AxisLabelsText[2][1]; }
244
246
253
255
262
267
269
272 void SetContainerVisibility(bool state);
273 vtkBooleanMacro(ContainerVisibility, bool);
276
283
288
290
293 void PlaceWidget(double*) override {} // this representation is an overlay. Doesn't need this.
294 void BuildRepresentation() override;
295 void StartWidgetInteraction(double eventPos[2]) override;
296 void WidgetInteraction(double newEventPos[2]) override;
297 void EndWidgetInteraction(double newEventPos[2]) override;
298 int ComputeInteractionState(int X, int Y, int modify = 0) override;
299 double* GetBounds() VTK_SIZEHINT(6) override;
301
303
306 void ReleaseGraphicsResources(vtkWindow*) override;
307 int RenderOpaqueGeometry(vtkViewport*) override;
308 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
309 vtkTypeBool HasTranslucentPolygonalGeometry() override;
311
315 void ShallowCopy(vtkProp* prop) override;
316
320 bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
321
322protected:
325
326 virtual void CreateDefaultGeometry();
328 virtual void PositionHandles();
329 virtual void HighlightHandle();
330 virtual void Rotate(double newEventPos[2]);
331 void RegisterPickers() override;
333
334 // description of source shapes.
338
339 // geometries of handles and shafts. (position, color info)
341 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
342
343 // defaults are slight variations of r, y, g
345
346 // props
348 vtkNew<vtkActor> Handles[3][2];
350
351 // font-sz, font-type, frame color of the labels.
352 vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
353 vtkNew<vtkImageData> LabelImages[3][2];
354 vtkNew<vtkTexture> LabelTextures[3][2];
355
357
358 // Store rotation of gizmo.
360
361 // Positioning of the representation within a parent renderer.
362 AnchorType AnchorPosition = AnchorType::UpperRight;
363 int Padding[2] = { 10, 10 }; // In display coords.
364 int Size[2] = { 120, 120 }; // In display coords.
365
366 // Geometrical, textual, interaction description of the representation.
367 std::string AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
368 double Azimuth = 0.;
369 double Back[3] = { 0., 0., -1. };
370 double Bounds[6] = {};
371 double Elevation = 0.;
372 double MotionFactor = 1.;
373 double NormalizedHandleDia = 0.4;
374 double TotalLength = 1.;
375 double Up[3] = { 0., 1., 0. };
376 int ContainerCircumferentialResolution = 32;
377 int ContainerRadialResolution = 1;
378 int HandleCircumferentialResolution = 32;
379 int ShaftResolution = 10;
380
381 // Picking information.
382 int PickedAxis = -1;
383 int LastPickedAx = -1;
384 int PickedDir = -1;
385 int LastPickedDir = -1;
386
387 // Event tracking
388 double LastEventPosition[3] = {};
389
390private:
392 void operator=(const vtkCameraOrientationRepresentation&) = delete;
393};
394
395VTK_ABI_NAMESPACE_END
396#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: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