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 =========================================================================*/
40 #ifndef vtkCameraOrientationRepresentation_h
41 #define vtkCameraOrientationRepresentation_h
42 
43 #include "vtkInteractionWidgetsModule.h" // needed for export macro
45 
46 class vtkActor;
47 class vtkDiskSource;
48 class vtkDoubleArray;
50 class vtkImageData;
51 class vtkPoints;
52 class vtkPolyData;
53 class vtkPropCollection;
54 class vtkProperty;
55 class vtkPropPicker;
56 class vtkTextProperty;
57 class vtkTexture;
58 class vtkTubeFilter;
59 
60 class VTKINTERACTIONWIDGETS_EXPORT vtkCameraOrientationRepresentation
62 {
63 public:
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 
124  AnchorType GetAnchorPosition() { return this->AnchorPosition; }
126  {
127  this->AnchorPosition = AnchorType::LowerLeft;
128  this->Modified();
129  }
131  {
132  this->AnchorPosition = AnchorType::UpperLeft;
133  this->Modified();
134  }
136  {
137  this->AnchorPosition = AnchorType::LowerRight;
138  this->Modified();
139  }
141  {
142  this->AnchorPosition = AnchorType::UpperRight;
143  this->Modified();
144  }
146 
148 
152  vtkSetMacro(TotalLength, double);
153  vtkGetMacro(TotalLength, double);
155 
157 
161  vtkSetMacro(NormalizedHandleDia, double);
162  vtkGetMacro(NormalizedHandleDia, double);
164 
166 
169  vtkGetMacro(Azimuth, double);
170  vtkGetVector3Macro(Back, double);
171  vtkGetMacro(Elevation, double);
172  vtkGetVector3Macro(Up, double);
174 
176 
179  vtkSetClampMacro(ShaftResolution, int, 3, 256);
180  vtkGetMacro(ShaftResolution, int);
182 
184 
187  vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
188  vtkGetMacro(HandleCircumferentialResolution, int);
190 
192 
195  vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
196  vtkGetMacro(ContainerCircumferentialResolution, int);
198 
200 
203  vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
204  vtkGetMacro(ContainerRadialResolution, int);
206 
208 
211  vtkGetMacro(PickedAxis, int);
212  vtkGetMacro(PickedDir, int);
214 
216 
223 
225 
232 
237 
239 
242  void SetContainerVisibility(bool state);
243  vtkBooleanMacro(ContainerVisibility, bool);
246 
252  void GetActors(vtkPropCollection*) override;
253 
258 
260 
263  void PlaceWidget(double*) override{}; // this representation is an overlay. Doesn't need this.
264  void BuildRepresentation() override;
265  void StartWidgetInteraction(double eventPos[2]) override;
266  void WidgetInteraction(double newEventPos[2]) override;
267  void EndWidgetInteraction(double newEventPos[2]) override;
268  int ComputeInteractionState(int X, int Y, int modify = 0) override;
269  double* GetBounds() VTK_SIZEHINT(6) override;
271 
273 
276  void ReleaseGraphicsResources(vtkWindow*) override;
277  int RenderOpaqueGeometry(vtkViewport*) override;
278  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
279  vtkTypeBool HasTranslucentPolygonalGeometry() override;
281 
285  void ShallowCopy(vtkProp* prop) override;
286 
290  bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
291 
292 protected:
295 
296  virtual void CreateDefaultGeometry();
297  virtual void CreateDefaultProperties();
298  virtual void PositionHandles();
299  virtual void HighlightHandle();
300  virtual void Rotate(double newEventPos[2]);
301  void RegisterPickers() override;
303 
304  // description of source shapes.
308 
309  // geometries of handles and shafts. (position, color info)
311  vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
312 
313  // defaults are slight variations of r, y, g
315 
316  // props
318  vtkNew<vtkActor> Handles[3][2];
320 
321  // font-sz, font-type, frame color of the labels.
322  vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
323  vtkNew<vtkImageData> LabelImages[3][2];
324  vtkNew<vtkTexture> LabelTextures[3][2];
325 
327 
328  // Store rotation of gizmo.
330 
331  // Positioning of the representation within a parent renderer.
332  AnchorType AnchorPosition = AnchorType::UpperRight;
333  int Padding[2] = { 10, 10 }; // In display coords.
334  int Size[2] = { 120, 120 }; // In display coords.
335 
336  // Geometrical, textual, interaction description of the representation.
337  const char* AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
338  double Azimuth = 0.;
339  double Back[3] = { 0., 0., -1. };
340  double Bounds[6] = {};
341  double Elevation = 0.;
342  double MotionFactor = 1.;
343  double NormalizedHandleDia = 0.4;
344  double TotalLength = 1.;
345  double Up[3] = { 0., 1., 0. };
346  int ContainerCircumferentialResolution = 32;
347  int ContainerRadialResolution = 1;
348  int HandleCircumferentialResolution = 32;
349  int ShaftResolution = 10;
350 
351  // Picking information.
352  int PickedAxis = -1;
353  int LastPickedAx = -1;
354  int PickedDir = -1;
355  int LastPickedDir = -1;
356 
357  // Event tracking
358  double LastEventPosition[3] = {};
359 
360 private:
362  void operator=(const vtkCameraOrientationRepresentation&) = delete;
363 };
364 
365 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:61
A 3D representation for vtkCameraOrientationWidget.
void StartWidgetInteraction(double eventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkTextProperty * GetXMinusLabelProperty()
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.
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.
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
static vtkCameraOrientationRepresentation * New()
void AnchorToLowerRight()
Get/Set the widget anchor type.
vtkTransform * GetTransform()
Retrieve internal transform of this widget representation.
vtkProperty * GetContainerProperty()
Get the container property.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
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.
vtkTextProperty * GetYPlusLabelProperty()
Get the '+' axis label properties.
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.
vtkTextProperty * GetZPlusLabelProperty()
Get the '+' axis label properties.
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.
vtkTextProperty * GetXPlusLabelProperty()
Get the '+' axis label properties.
void EndWidgetInteraction(double newEventPos[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetContainerVisibility(bool state)
Show container to indicate mouse presence.
InteractionStateType GetInteractionStateAsEnum() noexcept
Convenient method to get InteractionState as enum.
vtkTextProperty * GetYMinusLabelProperty()
Get the '-' axis label properties.
void ApplyInteractionState(const int &state)
void AnchorToUpperLeft()
Get/Set the widget anchor type.
create a disk with hole in center
Definition: vtkDiskSource.h:51
dynamic, self-adjusting array of double
create a ellipsoidal-shaped button
topologically and geometrically regular array of data
Definition: vtkImageData.h:63
a simple class to control print indentation
Definition: vtkIndent.h:49
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:49
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:100
an ordered list of Props
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:55
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:66
represent surface properties of a geometric object
Definition: vtkProperty.h:77
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:78
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:70
filter that generates tubes around lines
Definition: vtkTubeFilter.h:95
abstract specification for Viewports
Definition: vtkViewport.h:65
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)