VTK  9.7.1
vtkCameraOrientationWidget.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
49 #ifndef vtkCameraOrientationWidget_h
50 #define vtkCameraOrientationWidget_h
51 
52 #include "vtkAbstractWidget.h"
53 #include "vtkInteractionWidgetsModule.h" // needed for export macro
54 #include "vtkWeakPointer.h" // for weak pointer ivar
55 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
56 
57 VTK_ABI_NAMESPACE_BEGIN
60 class vtkRenderer;
61 
62 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCameraOrientationWidget
63  : public vtkAbstractWidget
64 {
65 public:
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
71 
75  vtkSetMacro(Animate, bool);
76  vtkGetMacro(Animate, bool);
77  vtkBooleanMacro(Animate, bool);
79 
81 
84  vtkSetClampMacro(AnimatorTotalFrames, int, 2, VTK_INT_MAX);
85  vtkGetMacro(AnimatorTotalFrames, int);
87 
93  void SetRepresentation(vtkCameraOrientationRepresentation* r);
94 
98  void CreateDefaultRepresentation() override;
99 
103  void SquareResize();
104 
110  void SetDefaultRenderer(vtkRenderer* renderer) override;
111 
113 
120  void SetParentRenderer(vtkRenderer* renderer);
121  vtkRenderer* GetParentRenderer();
123 
125 
129  vtkSetMacro(ShouldResetCamera, bool);
130  vtkGetMacro(ShouldResetCamera, bool);
131  vtkBooleanMacro(ShouldResetCamera, bool);
133 
135 
141  vtkSetMacro(UseCenterOfRotation, bool);
142  vtkGetMacro(UseCenterOfRotation, bool);
143  vtkBooleanMacro(UseCenterOfRotation, bool);
145 
146 protected:
148  ~vtkCameraOrientationWidget() override;
149 
150  // These methods handle events
151  void ComputeWidgetState(int X, int Y, int modify = 0);
152  static void SelectAction(vtkAbstractWidget*);
153  static void EndSelectAction(vtkAbstractWidget*);
154  static void MoveAction(vtkAbstractWidget*);
155 
156  // These control the representation and parent renderer's camera.
157  void OrientParentCamera(double back[3], double up[3]);
158  void OrientWidgetRepresentation();
159  void InterpolateCamera(int t);
160 
161  void StartAnimation();
162  void PlayAnimationSingleFrame(vtkObject* caller, unsigned long event, void* callData);
163  void StopAnimation();
164 
165  // Manage the state of the widget
166  enum class WidgetStateType : int
167  {
168  Inactive, // mouse is not over the widget, none of the handles are selected.
169  Hot, // mouse is over the widget but none of the handles are selected
170  Active // any one handle is selected, representation could be rotating.
171  };
172  WidgetStateType WidgetState = WidgetStateType::Inactive;
173 
175 
176  // Store camera interpolations.
178 
179  bool Animate = true;
180  bool ShouldResetCamera = true;
181  bool UseCenterOfRotation = false;
182  int AnimatorTotalFrames = 20;
183  int AnimatorCurrentFrame = 0;
184  int AnimationTimerId = -1;
185 
186  int ResizeObserverTag = -1;
187  int ReorientObserverTag = -1;
188  int AnimationTimerObserverTag = -1;
189 
190 private:
192  void operator=(const vtkCameraOrientationWidget&) = delete;
193 };
194 
195 VTK_ABI_NAMESPACE_END
196 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:52
interpolate a series of cameras to update a new camera
vtkWeakPointer< vtkRenderer > ParentRenderer
void PrintSelf(ostream &os, vtkIndent indent) override
Standard macros implementing standard VTK methods.
#define VTK_INT_MAX
Definition: vtkType.h:192
abstract specification for renderers
Definition: vtkRenderer.h:63
virtual void CreateDefaultRepresentation()=0
Create the default widget representation if one is not set.
vtkNew< vtkCameraInterpolator > CameraInterpolator
virtual void SetDefaultRenderer(vtkRenderer *)
Set/Get the default renderer to use when activating the interactor observer.
a simple class to control print indentation
Definition: vtkIndent.h:28
A widget to manipulate vtkCameraOrientationWidget.
define the API for widget / widget representation
#define VTK_MARSHALAUTO
A 3D representation for vtkCameraOrientationWidget.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...