VTK  9.5.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
37
38#ifndef vtkCameraOrientationRepresentation_h
39#define vtkCameraOrientationRepresentation_h
40
41#include "vtkInteractionWidgetsModule.h" // needed for export macro
43#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
44
45VTK_ABI_NAMESPACE_BEGIN
46class vtkActor;
47class vtkDiskSource;
48class vtkDoubleArray;
50class vtkImageData;
51class vtkPoints;
52class vtkPolyData;
54class vtkProperty;
55class vtkPropPicker;
56class vtkTextProperty;
57class vtkTexture;
58class vtkTubeFilter;
59
60class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCameraOrientationRepresentation
62{
63public:
66 void PrintSelf(ostream& os, vtkIndent indent) override;
67
68 enum class InteractionStateType : int
69 {
70 Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
71 Hovering, // corresponds to vtkCameraOrientationWidget::Hot
72 Rotating // corresponds to vtkCameraOrientationWidget::Active
73 };
74
80 void ApplyInteractionState(const int& state);
81
88 {
89 // clamp to 0-2
90 this->InteractionState =
91 this->InteractionState < 0 ? 0 : (this->InteractionState > 2 ? 2 : this->InteractionState);
92 // convert
93 return static_cast<InteractionStateType>(this->InteractionState);
94 }
95
97
100 vtkSetVector2Macro(Size, int);
101 vtkGetVector2Macro(Size, int);
103
105
108 vtkSetVector2Macro(Padding, int);
109 vtkGetVector2Macro(Padding, int);
111
112 enum class AnchorType : int
113 {
114 LowerLeft = 0,
115 UpperLeft,
116 LowerRight,
117 UpperRight
118 };
119
121
127 {
129 this->Modified();
130 }
132 {
134 this->Modified();
135 }
137 {
139 this->Modified();
140 }
142 {
144 this->Modified();
145 }
146
147
149
153 vtkSetMacro(TotalLength, double);
154 vtkGetMacro(TotalLength, double);
156
158
162 vtkSetMacro(NormalizedHandleDia, double);
163 vtkGetMacro(NormalizedHandleDia, double);
165
167
170 vtkGetMacro(Azimuth, double);
171 vtkGetVector3Macro(Back, double);
172 vtkGetMacro(Elevation, double);
173 vtkGetVector3Macro(Up, double);
175
177
180 vtkSetClampMacro(ShaftResolution, int, 3, 256);
181 vtkGetMacro(ShaftResolution, int);
183
185
188 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
191
193
196 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
199
201
204 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
205 vtkGetMacro(ContainerRadialResolution, int);
207
209
212 vtkGetMacro(PickedAxis, int);
213 vtkGetMacro(PickedDir, int);
215
217
220 void SetXPlusLabelText(const std::string& label)
221 {
222 this->AxisLabelsText[0][0] = label;
223 this->Modified();
224 }
225 std::string GetXPlusLabelText() { return this->AxisLabelsText[0][0]; }
226 void SetYPlusLabelText(const std::string& label)
227 {
228 this->AxisLabelsText[1][0] = label;
229 this->Modified();
230 }
231 std::string GetYPlusLabelText() { return this->AxisLabelsText[1][0]; }
232 void SetZPlusLabelText(const std::string& label)
233 {
234 this->AxisLabelsText[2][0] = label;
235 this->Modified();
236 }
237 std::string GetZPlusLabelText() { return this->AxisLabelsText[2][0]; }
239
241
244 void SetXMinusLabelText(const std::string& label)
245 {
246 this->AxisLabelsText[0][1] = label;
247 this->Modified();
248 }
249 std::string GetXMinusLabelText() { return this->AxisLabelsText[0][1]; }
250 void SetYMinusLabelText(const std::string& label)
251 {
252 this->AxisLabelsText[1][1] = label;
253 this->Modified();
254 }
255 std::string GetYMinusLabelText() { return this->AxisLabelsText[1][1]; }
256 void SetZMinusLabelText(const std::string& label)
257 {
258 this->AxisLabelsText[2][1] = label;
259 this->Modified();
260 }
261 std::string GetZMinusLabelText() { return this->AxisLabelsText[2][1]; }
263
265
272
274
281
286
288
291 void SetContainerVisibility(bool state);
292 vtkBooleanMacro(ContainerVisibility, bool);
295
302
307
309
312 void PlaceWidget(double*) override {} // this representation is an overlay. Doesn't need this.
313 void BuildRepresentation() override;
314 void StartWidgetInteraction(double eventPos[2]) override;
315 void WidgetInteraction(double newEventPos[2]) override;
316 void EndWidgetInteraction(double newEventPos[2]) override;
317 int ComputeInteractionState(int X, int Y, int modify = 0) override;
318 double* GetBounds() VTK_SIZEHINT(6) override;
320
322
330
334 void ShallowCopy(vtkProp* prop) override;
335
339 bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
340
341protected:
344
345 virtual void CreateDefaultGeometry();
347 virtual void PositionHandles();
348 virtual void HighlightHandle();
349 virtual void Rotate(double newEventPos[2]);
350 void RegisterPickers() override;
352
353 // description of source shapes.
357
358 // geometries of handles and shafts. (position, color info)
360 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
361
362 // defaults are slight variations of r, y, g
364
365 // props
369
370 // font-sz, font-type, frame color of the labels.
374
376
377 // Store rotation of gizmo.
379
380 // Positioning of the representation within a parent renderer.
382 int Padding[2] = { 10, 10 }; // In display coords.
383 int Size[2] = { 120, 120 }; // In display coords.
384
385 // Geometrical, textual, interaction description of the representation.
386 std::string AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
387 double Azimuth = 0.;
388 double Back[3] = { 0., 0., -1. };
389 double Bounds[6] = {};
390 double Elevation = 0.;
391 double MotionFactor = 1.;
393 double TotalLength = 1.;
394 double Up[3] = { 0., 1., 0. };
399
400 // Picking information.
401 int PickedAxis = -1;
402 int LastPickedAx = -1;
403 int PickedDir = -1;
405
406 // Event tracking
407 double LastEventPosition[3] = {};
408
409private:
411 void operator=(const vtkCameraOrientationRepresentation&) = delete;
412};
413
414VTK_ABI_NAMESPACE_END
415#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.
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.
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 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.
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.
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.
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 ReleaseGraphicsResources(vtkWindow *) override
Methods supporting, and required by, the rendering process.
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
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
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
window superclass for vtkRenderWindow
Definition vtkWindow.h:45
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO