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=========================================================================*/
37#ifndef vtkCameraOrientationRepresentation_h
38#define vtkCameraOrientationRepresentation_h
39
40#include "vtkInteractionWidgetsModule.h" // needed for export macro
42
43class vtkActor;
44class vtkDiskSource;
45class vtkDoubleArray;
47class vtkImageData;
48class vtkPoints;
49class vtkPolyData;
51class vtkProperty;
52class vtkPropPicker;
53class vtkTextProperty;
54class vtkTexture;
55class vtkTubeFilter;
56
57class VTKINTERACTIONWIDGETS_EXPORT vtkCameraOrientationRepresentation
59{
60public:
63 void PrintSelf(ostream& os, vtkIndent indent) override;
64
65 enum class InteractionStateType : int
66 {
67 Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
68 Hovering, // corresponds to vtkCameraOrientationWidget::Hot
69 Rotating // corresponds to vtkCameraOrientationWidget::Active
70 };
71
77 void ApplyInteractionState(const int& state);
78
85 {
86 // clamp to 0-2
87 this->InteractionState =
88 this->InteractionState < 0 ? 0 : (this->InteractionState > 2 ? 2 : this->InteractionState);
89 // convert
90 return static_cast<InteractionStateType>(this->InteractionState);
91 }
92
94
97 vtkSetVector2Macro(Size, int);
98 vtkGetVector2Macro(Size, int);
100
102
105 vtkSetVector2Macro(Padding, int);
106 vtkGetVector2Macro(Padding, int);
108
109 enum class AnchorType : int
110 {
111 LowerLeft = 0,
112 UpperLeft,
113 LowerRight,
114 UpperRight
115 };
116
118
121 AnchorType GetAnchorPosition() { return this->AnchorPosition; }
123 {
124 this->AnchorPosition = AnchorType::LowerLeft;
125 this->Modified();
126 }
128 {
129 this->AnchorPosition = AnchorType::UpperLeft;
130 this->Modified();
131 }
133 {
134 this->AnchorPosition = AnchorType::LowerRight;
135 this->Modified();
136 }
138 {
139 this->AnchorPosition = AnchorType::UpperRight;
140 this->Modified();
141 }
143
145
149 vtkSetMacro(TotalLength, double);
150 vtkGetMacro(TotalLength, double);
152
154
158 vtkSetMacro(NormalizedHandleDia, double);
159 vtkGetMacro(NormalizedHandleDia, double);
161
163
166 vtkGetMacro(Azimuth, double);
167 vtkGetVector3Macro(Back, double);
168 vtkGetMacro(Elevation, double);
169 vtkGetVector3Macro(Up, double);
171
173
176 vtkSetClampMacro(ShaftResolution, int, 3, 256);
177 vtkGetMacro(ShaftResolution, int);
179
181
184 vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
185 vtkGetMacro(HandleCircumferentialResolution, int);
187
189
192 vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
193 vtkGetMacro(ContainerCircumferentialResolution, int);
195
197
200 vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
201 vtkGetMacro(ContainerRadialResolution, int);
203
205
208 vtkGetMacro(PickedAxis, int);
209 vtkGetMacro(PickedDir, int);
211
213
220
222
229
234
236
239 void SetContainerVisibility(bool state);
240 vtkBooleanMacro(ContainerVisibility, bool);
243
250
255
257
260 void PlaceWidget(double*) override{}; // this representation is an overlay. Doesn't need this.
261 void BuildRepresentation() override;
262 void StartWidgetInteraction(double eventPos[2]) override;
263 void WidgetInteraction(double newEventPos[2]) override;
264 void EndWidgetInteraction(double newEventPos[2]) override;
265 int ComputeInteractionState(int X, int Y, int modify = 0) override;
266 double* GetBounds() VTK_SIZEHINT(6) override;
268
270
273 void ReleaseGraphicsResources(vtkWindow*) override;
274 int RenderOpaqueGeometry(vtkViewport*) override;
275 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
276 vtkTypeBool HasTranslucentPolygonalGeometry() override;
278
282 void ShallowCopy(vtkProp* prop) override;
283
284protected:
287
288 virtual void CreateDefaultGeometry();
289 virtual void CreateDefaultProperties();
290 virtual void PositionHandles();
291 virtual void HighlightHandle();
292 virtual void Rotate(double newEventPos[2]);
293 void RegisterPickers() override;
294 void FinalizeHandlePicks();
295
296 // description of source shapes.
297 vtkNew<vtkDiskSource> ContainerSource;
298 vtkNew<vtkEllipticalButtonSource> HandleSources[3][2];
299 vtkNew<vtkTubeFilter> ShaftGlyphs;
300
301 // geometries of handles and shafts. (position, color info)
303 vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
304
305 // defaults are slight variations of r, y, g
307
308 // props
309 vtkNew<vtkActor> Container;
310 vtkNew<vtkActor> Handles[3][2];
312
313 // font-sz, font-type, frame color of the labels.
314 vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
315 vtkNew<vtkImageData> LabelImages[3][2];
316 vtkNew<vtkTexture> LabelTextures[3][2];
317
318 vtkNew<vtkPropPicker> HandlePicker;
319
320 // Store rotation of gizmo.
322
323 // Positioning of the representation within a parent renderer.
324 AnchorType AnchorPosition = AnchorType::UpperRight;
325 int Padding[2] = { 10, 10 }; // In display coords.
326 int Size[2] = { 120, 120 }; // In display coords.
327
328 // Geometrical, textual, interaction description of the representation.
329 const char* AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
330 double Azimuth = 0.;
331 double Back[3] = { 0., 0., -1. };
332 double Bounds[6] = {};
333 double Elevation = 0.;
334 double MotionFactor = 1.;
335 double NormalizedHandleDia = 0.4;
336 double TotalLength = 1.;
337 double Up[3] = { 0., 1., 0. };
338 int ContainerCircumferentialResolution = 32;
339 int ContainerRadialResolution = 1;
340 int HandleCircumferentialResolution = 32;
341 int ShaftResolution = 10;
342
343 // Picking information.
344 int PickedAxis = -1;
345 int LastPickedAx = -1;
346 int PickedDir = -1;
347 int LastPickedDir = -1;
348
349 // Event tracking
350 double LastEventPosition[3] = {};
351
352private:
354 void operator=(const vtkCameraOrientationRepresentation&) = delete;
355};
356
357#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:55
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:43
dynamic, self-adjusting array of double
create a ellipsoidal-shaped button
topologically and geometrically regular array of data
Definition: vtkImageData.h:57
a simple class to control print indentation
Definition: vtkIndent.h:43
Allocate and hold a VTK object.
Definition: vtkNew.h:65
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:43
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:95
an ordered list of Props
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:49
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:71
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:75
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:64
filter that generates tubes around lines
Definition: vtkTubeFilter.h:89
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:45
@ Transform
Definition: vtkX3D.h:47
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)