VTK  9.1.0
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=========================================================================*/
28#ifndef vtkCameraOrientationRepresentation_h
29#define vtkCameraOrientationRepresentation_h
30
31#include "vtkInteractionWidgetsModule.h" // needed for export macro
33
34class vtkActor;
35class vtkDiskSource;
36class vtkDoubleArray;
38class vtkImageData;
39class vtkPoints;
40class vtkPolyData;
42class vtkProperty;
43class vtkPropPicker;
44class vtkTextProperty;
45class vtkTexture;
46class vtkTubeFilter;
47
48class VTKINTERACTIONWIDGETS_EXPORT vtkCameraOrientationRepresentation
50{
51public:
54 void PrintSelf(ostream& os, vtkIndent indent) override;
55
56 enum class InteractionStateType : int
57 {
58 Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
59 Hovering, // corresponds to vtkCameraOrientationWidget::Hot
60 Rotating // corresponds to vtkCameraOrientationWidget::Active
61 };
62
68 void ApplyInteractionState(const int& state);
69
76 {
77 // clamp to 0-2
78 this->InteractionState =
79 this->InteractionState < 0 ? 0 : (this->InteractionState > 2 ? 2 : this->InteractionState);
80 // convert
81 return static_cast<InteractionStateType>(this->InteractionState);
82 }
83
85
88 vtkSetVector2Macro(Size, int);
89 vtkGetVector2Macro(Size, int);
91
93
96 vtkSetVector2Macro(Padding, int);
97 vtkGetVector2Macro(Padding, int);
99
100 enum class AnchorType : int
101 {
102 LowerLeft = 0,
103 UpperLeft,
104 LowerRight,
105 UpperRight
106 };
107
109
112 AnchorType GetAnchorPosition() { return this->AnchorPosition; }
114 {
115 this->AnchorPosition = AnchorType::LowerLeft;
116 this->Modified();
117 }
119 {
120 this->AnchorPosition = AnchorType::UpperLeft;
121 this->Modified();
122 }
124 {
125 this->AnchorPosition = AnchorType::LowerRight;
126 this->Modified();
127 }
129 {
130 this->AnchorPosition = AnchorType::UpperRight;
131 this->Modified();
132 }
134
136
140 vtkSetMacro(TotalLength, double);
141 vtkGetMacro(TotalLength, double);
143
145
149 vtkSetMacro(NormalizedHandleDia, double);
150 vtkGetMacro(NormalizedHandleDia, double);
152
154
157 vtkGetMacro(Azimuth, double);
158 vtkGetVector3Macro(Back, double);
159 vtkGetMacro(Elevation, double);
160 vtkGetVector3Macro(Up, double);
162
164
167 vtkSetClampMacro(ShaftResolution, int, 3, 256);
168 vtkGetMacro(ShaftResolution, int);
170
172
175 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
176 vtkGetMacro(HandleCircumferentialResolution, int);
178
180
183 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
184 vtkGetMacro(ContainerCircumferentialResolution, int);
186
188
191 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
192 vtkGetMacro(ContainerRadialResolution, int);
194
196
199 vtkGetMacro(PickedAxis, int);
200 vtkGetMacro(PickedDir, int);
202
204
211
213
220
225
227
230 void SetContainerVisibility(bool state);
231 vtkBooleanMacro(ContainerVisibility, bool);
234
241
246
248
251 void PlaceWidget(double*) override{}; // this representation is an overlay. Doesn't need this.
252 void BuildRepresentation() override;
253 void StartWidgetInteraction(double eventPos[2]) override;
254 void WidgetInteraction(double newEventPos[2]) override;
255 void EndWidgetInteraction(double newEventPos[2]) override;
256 int ComputeInteractionState(int X, int Y, int modify = 0) override;
257 double* GetBounds() VTK_SIZEHINT(6) override;
259
261
264 void ReleaseGraphicsResources(vtkWindow*) override;
265 int RenderOpaqueGeometry(vtkViewport*) override;
266 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
267 vtkTypeBool HasTranslucentPolygonalGeometry() override;
269
273 void ShallowCopy(vtkProp* prop) override;
274
275protected:
278
279 virtual void CreateDefaultGeometry();
280 virtual void CreateDefaultProperties();
281 virtual void PositionHandles();
282 virtual void HighlightHandle();
283 virtual void Rotate(double newEventPos[2]);
284 void RegisterPickers() override;
285 void FinalizeHandlePicks();
286
287 // description of source shapes.
288 vtkNew<vtkDiskSource> ContainerSource;
289 vtkNew<vtkEllipticalButtonSource> HandleSources[3][2];
290 vtkNew<vtkTubeFilter> ShaftGlyphs;
291
292 // geometries of handles and shafts. (position, color info)
294 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
295
296 // defaults are slight variations of r, y, g
298
299 // props
300 vtkNew<vtkActor> Container;
301 vtkNew<vtkActor> Handles[3][2];
303
304 // font-sz, font-type, frame color of the labels.
305 vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
306 vtkNew<vtkImageData> LabelImages[3][2];
307 vtkNew<vtkTexture> LabelTextures[3][2];
308
309 vtkNew<vtkPropPicker> HandlePicker;
310
311 // Store rotation of gizmo.
313
314 // Positioning of the representation within a parent renderer.
315 AnchorType AnchorPosition = AnchorType::UpperRight;
316 int Padding[2] = { 10, 10 }; // In display coords.
317 int Size[2] = { 120, 120 }; // In display coords.
318
319 // Geometrical, textual, interaction description of the representation.
320 const char* AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
321 double Azimuth = 0.;
322 double Back[3] = { 0., 0., -1. };
323 double Bounds[6] = {};
324 double Elevation = 0.;
325 double MotionFactor = 1.;
326 double NormalizedHandleDia = 0.4;
327 double TotalLength = 1.;
328 double Up[3] = { 0., 1., 0. };
329 int ContainerCircumferentialResolution = 32;
330 int ContainerRadialResolution = 1;
331 int HandleCircumferentialResolution = 32;
332 int ShaftResolution = 10;
333
334 // Picking information.
335 int PickedAxis = -1;
336 int LastPickedAx = -1;
337 int PickedDir = -1;
338 int LastPickedDir = -1;
339
340 // Event tracking
341 double LastEventPosition[3] = {};
342
343private:
345 void operator=(const vtkCameraOrientationRepresentation&) = delete;
346};
347
348#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
a 3D axes representation for interactive widgets
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.
vtkTextProperty * GetZPlusLabelProperty()
Get the '+' axis label properties.
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:93
dynamic, self-adjusting array of double
create a ellipsoidal-shaped button
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
a simple class to control print indentation
Definition: vtkIndent.h:113
Allocate and hold a VTK object.
Definition: vtkNew.h:165
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:143
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
an ordered list of Props
pick an actor/prop using graphics hardware
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
represent surface properties of a geometric object
Definition: vtkProperty.h:171
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:175
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
filter that generates tubes around lines
abstract specification for Viewports
Definition: vtkViewport.h:47
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(...)