VTK  9.2.6
vtkCameraOrientationRepresentation.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkCameraOrientationRepresentation.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
31#ifndef vtkCameraOrientationRepresentation_h
32#define vtkCameraOrientationRepresentation_h
33
34#include "vtkInteractionWidgetsModule.h" // needed for export macro
36
37class vtkActor;
38class vtkDiskSource;
39class vtkDoubleArray;
41class vtkImageData;
42class vtkPoints;
43class vtkPolyData;
45class vtkProperty;
46class vtkPropPicker;
47class vtkTextProperty;
48class vtkTexture;
49class vtkTubeFilter;
50
51class VTKINTERACTIONWIDGETS_EXPORT vtkCameraOrientationRepresentation
53{
54public:
57 void PrintSelf(ostream& os, vtkIndent indent) override;
58
59 enum class InteractionStateType : int
60 {
61 Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
62 Hovering, // corresponds to vtkCameraOrientationWidget::Hot
63 Rotating // corresponds to vtkCameraOrientationWidget::Active
64 };
65
71 void ApplyInteractionState(const int& state);
72
79 {
80 // clamp to 0-2
81 this->InteractionState =
82 this->InteractionState < 0 ? 0 : (this->InteractionState > 2 ? 2 : this->InteractionState);
83 // convert
84 return static_cast<InteractionStateType>(this->InteractionState);
85 }
86
88
91 vtkSetVector2Macro(Size, int);
92 vtkGetVector2Macro(Size, int);
94
96
99 vtkSetVector2Macro(Padding, int);
100 vtkGetVector2Macro(Padding, int);
102
103 enum class AnchorType : int
104 {
105 LowerLeft = 0,
106 UpperLeft,
107 LowerRight,
108 UpperRight
109 };
110
112
115 AnchorType GetAnchorPosition() { return this->AnchorPosition; }
117 {
118 this->AnchorPosition = AnchorType::LowerLeft;
119 this->Modified();
120 }
122 {
123 this->AnchorPosition = AnchorType::UpperLeft;
124 this->Modified();
125 }
127 {
128 this->AnchorPosition = AnchorType::LowerRight;
129 this->Modified();
130 }
132 {
133 this->AnchorPosition = AnchorType::UpperRight;
134 this->Modified();
135 }
137
139
143 vtkSetMacro(TotalLength, double);
144 vtkGetMacro(TotalLength, double);
146
148
152 vtkSetMacro(NormalizedHandleDia, double);
153 vtkGetMacro(NormalizedHandleDia, double);
155
157
160 vtkGetMacro(Azimuth, double);
161 vtkGetVector3Macro(Back, double);
162 vtkGetMacro(Elevation, double);
163 vtkGetVector3Macro(Up, double);
165
167
170 vtkSetClampMacro(ShaftResolution, int, 3, 256);
171 vtkGetMacro(ShaftResolution, int);
173
175
178 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
179 vtkGetMacro(HandleCircumferentialResolution, int);
181
183
186 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
187 vtkGetMacro(ContainerCircumferentialResolution, int);
189
191
194 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
195 vtkGetMacro(ContainerRadialResolution, int);
197
199
202 vtkGetMacro(PickedAxis, int);
203 vtkGetMacro(PickedDir, int);
205
207
214
216
223
228
230
233 void SetContainerVisibility(bool state);
234 vtkBooleanMacro(ContainerVisibility, bool);
237
244
249
251
254 void PlaceWidget(double*) override{}; // this representation is an overlay. Doesn't need this.
255 void BuildRepresentation() override;
256 void StartWidgetInteraction(double eventPos[2]) override;
257 void WidgetInteraction(double newEventPos[2]) override;
258 void EndWidgetInteraction(double newEventPos[2]) override;
259 int ComputeInteractionState(int X, int Y, int modify = 0) override;
260 double* GetBounds() VTK_SIZEHINT(6) override;
262
264
267 void ReleaseGraphicsResources(vtkWindow*) override;
268 int RenderOpaqueGeometry(vtkViewport*) override;
269 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
270 vtkTypeBool HasTranslucentPolygonalGeometry() override;
272
276 void ShallowCopy(vtkProp* prop) override;
277
281 bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
282
283protected:
286
287 virtual void CreateDefaultGeometry();
289 virtual void PositionHandles();
290 virtual void HighlightHandle();
291 virtual void Rotate(double newEventPos[2]);
292 void RegisterPickers() override;
294
295 // description of source shapes.
299
300 // geometries of handles and shafts. (position, color info)
302 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
303
304 // defaults are slight variations of r, y, g
306
307 // props
309 vtkNew<vtkActor> Handles[3][2];
311
312 // font-sz, font-type, frame color of the labels.
313 vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
314 vtkNew<vtkImageData> LabelImages[3][2];
315 vtkNew<vtkTexture> LabelTextures[3][2];
316
318
319 // Store rotation of gizmo.
321
322 // Positioning of the representation within a parent renderer.
323 AnchorType AnchorPosition = AnchorType::UpperRight;
324 int Padding[2] = { 10, 10 }; // In display coords.
325 int Size[2] = { 120, 120 }; // In display coords.
326
327 // Geometrical, textual, interaction description of the representation.
328 const char* AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
329 double Azimuth = 0.;
330 double Back[3] = { 0., 0., -1. };
331 double Bounds[6] = {};
332 double Elevation = 0.;
333 double MotionFactor = 1.;
334 double NormalizedHandleDia = 0.4;
335 double TotalLength = 1.;
336 double Up[3] = { 0., 1., 0. };
337 int ContainerCircumferentialResolution = 32;
338 int ContainerRadialResolution = 1;
339 int HandleCircumferentialResolution = 32;
340 int ShaftResolution = 10;
341
342 // Picking information.
343 int PickedAxis = -1;
344 int LastPickedAx = -1;
345 int PickedDir = -1;
346 int LastPickedDir = -1;
347
348 // Event tracking
349 double LastEventPosition[3] = {};
350
351private:
353 void operator=(const vtkCameraOrientationRepresentation&) = delete;
354};
355
356#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
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
Definition: vtkDiskSource.h:42
dynamic, self-adjusting array of double
create a ellipsoidal-shaped button
topologically and geometrically regular array of data
Definition: vtkImageData.h:54
a simple class to control print indentation
Definition: vtkIndent.h:40
Allocate and hold a VTK object.
Definition: vtkNew.h:62
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:40
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:91
an ordered list of Props
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:46
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:68
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:69
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
filter that generates tubes around lines
Definition: vtkTubeFilter.h:86
abstract specification for Viewports
Definition: vtkViewport.h:56
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)