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 
37 class vtkActor;
38 class vtkDiskSource;
39 class vtkDoubleArray;
41 class vtkImageData;
42 class vtkPoints;
43 class vtkPolyData;
44 class vtkPropCollection;
45 class vtkProperty;
46 class vtkPropPicker;
47 class vtkTextProperty;
48 class vtkTexture;
49 class vtkTubeFilter;
50 
51 class VTKINTERACTIONWIDGETS_EXPORT vtkCameraOrientationRepresentation
53 {
54 public:
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 
70  void ApplyInteractionState(const InteractionStateType& state);
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 
210  vtkTextProperty* GetXPlusLabelProperty();
211  vtkTextProperty* GetYPlusLabelProperty();
212  vtkTextProperty* GetZPlusLabelProperty();
214 
216 
219  vtkTextProperty* GetXMinusLabelProperty();
220  vtkTextProperty* GetYMinusLabelProperty();
221  vtkTextProperty* GetZMinusLabelProperty();
223 
227  vtkProperty* GetContainerProperty();
228 
230 
233  void SetContainerVisibility(bool state);
234  vtkBooleanMacro(ContainerVisibility, bool);
235  bool GetContainerVisibility();
237 
243  void GetActors(vtkPropCollection*) override;
244 
248  vtkTransform* GetTransform();
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 
283 protected:
286 
287  virtual void CreateDefaultGeometry();
288  virtual void CreateDefaultProperties();
289  virtual void PositionHandles();
290  virtual void HighlightHandle();
291  virtual void Rotate(double newEventPos[2]);
292  void RegisterPickers() override;
293  void FinalizeHandlePicks();
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 
351 private:
353  void operator=(const vtkCameraOrientationRepresentation&) = delete;
354 };
355 
356 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
virtual int ComputeInteractionState(int X, int Y, int modify=0)
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:45
abstract specification for Viewports
Definition: vtkViewport.h:55
represent surface properties of a geometric object
Definition: vtkProperty.h:67
virtual void StartWidgetInteraction(double eventPos[2])
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
void PlaceWidget(double *) override
These are methods that satisfy vtkWidgetRepresentation's API.
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
void AnchorToLowerLeft()
Get/Set the widget anchor type.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
dynamic, self-adjusting array of double
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
filter that generates tubes around lines
Definition: vtkTubeFilter.h:85
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
handles properties associated with a texture map
Definition: vtkTexture.h:68
create a ellipsoidal-shaped button
virtual void WidgetInteraction(double newEventPos[2])
virtual void Modified()
Update the modification time for this object.
#define VTK_SIZEHINT(...)
represent text properties.
AnchorType GetAnchorPosition()
Get/Set the widget anchor type.
void AnchorToUpperRight()
Get/Set the widget anchor type.
InteractionStateType GetInteractionStateAsEnum() noexcept
Convenient method to get InteractionState as enum.
create a disk with hole in center
Definition: vtkDiskSource.h:41
A 3D representation for vtkCameraOrientationWidget.
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
represent and manipulate 3D points
Definition: vtkPoints.h:39
void AnchorToLowerRight()
Get/Set the widget anchor type.
void AnchorToUpperLeft()
Get/Set the widget anchor type.