VTK  9.3.1
vtkCameraOrientationRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
19 #ifndef vtkCameraOrientationRepresentation_h
20 #define vtkCameraOrientationRepresentation_h
21 
22 #include "vtkInteractionWidgetsModule.h" // needed for export macro
24 
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkActor;
27 class vtkDiskSource;
28 class vtkDoubleArray;
30 class vtkImageData;
31 class vtkPoints;
32 class vtkPolyData;
33 class vtkPropCollection;
34 class vtkProperty;
35 class vtkPropPicker;
36 class vtkTextProperty;
37 class vtkTexture;
38 class vtkTubeFilter;
39 
40 class VTKINTERACTIONWIDGETS_EXPORT vtkCameraOrientationRepresentation
42 {
43 public:
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
48  enum class InteractionStateType : int
49  {
50  Outside = 0, // corresponds to vtkCameraOrientationWidget::Inactive
51  Hovering, // corresponds to vtkCameraOrientationWidget::Hot
52  Rotating // corresponds to vtkCameraOrientationWidget::Active
53  };
54 
59  void ApplyInteractionState(const InteractionStateType& state);
60  void ApplyInteractionState(const int& state);
61 
68  {
69  // clamp to 0-2
70  this->InteractionState =
71  this->InteractionState < 0 ? 0 : (this->InteractionState > 2 ? 2 : this->InteractionState);
72  // convert
73  return static_cast<InteractionStateType>(this->InteractionState);
74  }
75 
77 
80  vtkSetVector2Macro(Size, int);
81  vtkGetVector2Macro(Size, int);
83 
85 
88  vtkSetVector2Macro(Padding, int);
89  vtkGetVector2Macro(Padding, int);
91 
92  enum class AnchorType : int
93  {
94  LowerLeft = 0,
95  UpperLeft,
96  LowerRight,
97  UpperRight
98  };
99 
101 
104  AnchorType GetAnchorPosition() { return this->AnchorPosition; }
106  {
107  this->AnchorPosition = AnchorType::LowerLeft;
108  this->Modified();
109  }
111  {
112  this->AnchorPosition = AnchorType::UpperLeft;
113  this->Modified();
114  }
116  {
117  this->AnchorPosition = AnchorType::LowerRight;
118  this->Modified();
119  }
121  {
122  this->AnchorPosition = AnchorType::UpperRight;
123  this->Modified();
124  }
126 
128 
132  vtkSetMacro(TotalLength, double);
133  vtkGetMacro(TotalLength, double);
135 
137 
141  vtkSetMacro(NormalizedHandleDia, double);
142  vtkGetMacro(NormalizedHandleDia, double);
144 
146 
149  vtkGetMacro(Azimuth, double);
150  vtkGetVector3Macro(Back, double);
151  vtkGetMacro(Elevation, double);
152  vtkGetVector3Macro(Up, double);
154 
156 
159  vtkSetClampMacro(ShaftResolution, int, 3, 256);
160  vtkGetMacro(ShaftResolution, int);
162 
164 
167  vtkSetClampMacro(HandleCircumferentialResolution, int, 3, 256);
168  vtkGetMacro(HandleCircumferentialResolution, int);
170 
172 
175  vtkSetClampMacro(ContainerCircumferentialResolution, int, 3, 256);
176  vtkGetMacro(ContainerCircumferentialResolution, int);
178 
180 
183  vtkSetClampMacro(ContainerRadialResolution, int, 3, 256);
184  vtkGetMacro(ContainerRadialResolution, int);
186 
188 
191  vtkGetMacro(PickedAxis, int);
192  vtkGetMacro(PickedDir, int);
194 
196 
199  vtkTextProperty* GetXPlusLabelProperty();
200  vtkTextProperty* GetYPlusLabelProperty();
201  vtkTextProperty* GetZPlusLabelProperty();
203 
205 
208  vtkTextProperty* GetXMinusLabelProperty();
209  vtkTextProperty* GetYMinusLabelProperty();
210  vtkTextProperty* GetZMinusLabelProperty();
212 
216  vtkProperty* GetContainerProperty();
217 
219 
222  void SetContainerVisibility(bool state);
223  vtkBooleanMacro(ContainerVisibility, bool);
224  bool GetContainerVisibility();
226 
232  void GetActors(vtkPropCollection*) override;
233 
237  vtkTransform* GetTransform();
238 
240 
243  void PlaceWidget(double*) override{}; // this representation is an overlay. Doesn't need this.
244  void BuildRepresentation() override;
245  void StartWidgetInteraction(double eventPos[2]) override;
246  void WidgetInteraction(double newEventPos[2]) override;
247  void EndWidgetInteraction(double newEventPos[2]) override;
248  int ComputeInteractionState(int X, int Y, int modify = 0) override;
249  double* GetBounds() VTK_SIZEHINT(6) override;
251 
253 
256  void ReleaseGraphicsResources(vtkWindow*) override;
257  int RenderOpaqueGeometry(vtkViewport*) override;
258  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
259  vtkTypeBool HasTranslucentPolygonalGeometry() override;
261 
265  void ShallowCopy(vtkProp* prop) override;
266 
270  bool IsAnyHandleSelected() { return (this->PickedAxis != -1) && (this->PickedDir != -1); }
271 
272 protected:
275 
276  virtual void CreateDefaultGeometry();
277  virtual void CreateDefaultProperties();
278  virtual void PositionHandles();
279  virtual void HighlightHandle();
280  virtual void Rotate(double newEventPos[2]);
281  void RegisterPickers() override;
282  void FinalizeHandlePicks();
283 
284  // description of source shapes.
288 
289  // geometries of handles and shafts. (position, color info)
291  vtkNew<vtkPoints> Points; // used to store handle positions, also used by shafts
292 
293  // defaults are slight variations of r, y, g
295 
296  // props
298  vtkNew<vtkActor> Handles[3][2];
300 
301  // font-sz, font-type, frame color of the labels.
302  vtkNew<vtkTextProperty> AxisVectorTextProperties[3][2];
303  vtkNew<vtkImageData> LabelImages[3][2];
304  vtkNew<vtkTexture> LabelTextures[3][2];
305 
307 
308  // Store rotation of gizmo.
310 
311  // Positioning of the representation within a parent renderer.
312  AnchorType AnchorPosition = AnchorType::UpperRight;
313  int Padding[2] = { 10, 10 }; // In display coords.
314  int Size[2] = { 120, 120 }; // In display coords.
315 
316  // Geometrical, textual, interaction description of the representation.
317  const char* AxisLabelsText[3][2] = { { "X", "-X" }, { "Y", "-Y" }, { "Z", "-Z" } };
318  double Azimuth = 0.;
319  double Back[3] = { 0., 0., -1. };
320  double Bounds[6] = {};
321  double Elevation = 0.;
322  double MotionFactor = 1.;
323  double NormalizedHandleDia = 0.4;
324  double TotalLength = 1.;
325  double Up[3] = { 0., 1., 0. };
326  int ContainerCircumferentialResolution = 32;
327  int ContainerRadialResolution = 1;
328  int HandleCircumferentialResolution = 32;
329  int ShaftResolution = 10;
330 
331  // Picking information.
332  int PickedAxis = -1;
333  int LastPickedAx = -1;
334  int PickedDir = -1;
335  int LastPickedDir = -1;
336 
337  // Event tracking
338  double LastEventPosition[3] = {};
339 
340 private:
342  void operator=(const vtkCameraOrientationRepresentation&) = delete;
343 };
344 
345 VTK_ABI_NAMESPACE_END
346 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
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:40
virtual int ComputeInteractionState(int X, int Y, int modify=0)
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:34
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:56
virtual void StartWidgetInteraction(double eventPos[2])
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
filter that generates tubes around lines
Definition: vtkTubeFilter.h:74
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
handles properties associated with a texture map
Definition: vtkTexture.h:57
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:30
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:28
void AnchorToLowerRight()
Get/Set the widget anchor type.
void AnchorToUpperLeft()
Get/Set the widget anchor type.