VTK  9.3.1
vtkCamera3DRepresentation.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
24 #ifndef vtkCamera3DRepresentation_h
25 #define vtkCamera3DRepresentation_h
26 
27 #include "vtkInteractionWidgetsModule.h" // For export macro
28 #include "vtkNew.h" // For vtkNew
29 #include "vtkSmartPointer.h" // For vtkSmartPointer
31 
32 #include <array>
33 
34 VTK_ABI_NAMESPACE_BEGIN
35 class vtkActor;
36 class vtkBox;
37 class vtkCamera;
38 class vtkCamera3DWidget;
39 class vtkCameraActor;
40 class vtkCellPicker;
41 class vtkLineSource;
42 class vtkProperty;
43 class vtkSphereSource;
44 class vtkTransform;
45 
46 class VTKINTERACTIONWIDGETS_EXPORT vtkCamera3DRepresentation : public vtkWidgetRepresentation
47 {
48 public:
53 
55 
59  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
63 
66  void PlaceWidget(double bounds[6]) override;
67  void BuildRepresentation() override;
68  int ComputeInteractionState(int X, int Y, int modify = 0) override;
69  void StartWidgetInteraction(double e[2]) override;
70  void WidgetInteraction(double e[2]) override;
71  double* GetBounds() VTK_SIZEHINT(6) override;
73 
75 
78  void ReleaseGraphicsResources(vtkWindow*) override;
79  int RenderOpaqueGeometry(vtkViewport*) override;
80  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
81  vtkTypeBool HasTranslucentPolygonalGeometry() override;
83 
85 
88  virtual void SetCamera(vtkCamera* camera);
89  vtkCamera* GetCamera();
91 
93 
98  vtkSetClampMacro(FrontHandleDistance, double, 1.5, VTK_DOUBLE_MAX);
99  vtkGetMacro(FrontHandleDistance, double);
101 
103 
108  vtkSetClampMacro(UpHandleDistance, double, 0.5, VTK_DOUBLE_MAX);
109  vtkGetMacro(UpHandleDistance, double);
111 
113 
117  void SetTranslationAxisToXAxis() { this->SetTranslationAxis(Axis::XAxis); }
118  void SetTranslationAxisToYAxis() { this->SetTranslationAxis(Axis::YAxis); }
119  void SetTranslationAxisToZAxis() { this->SetTranslationAxis(Axis::ZAxis); }
120  void SetTranslationAxisToNone() { this->SetTranslationAxis(Axis::NONE); }
121  vtkSetClampMacro(TranslationAxis, int, Axis::NONE, Axis::ZAxis);
122  vtkGetMacro(TranslationAxis, int);
124 
126 
130  vtkSetMacro(TranslatingAll, bool);
131  vtkGetMacro(TranslatingAll, bool);
132  vtkBooleanMacro(TranslatingAll, bool);
134 
136 
140  void SetFrustumVisibility(bool visible);
141  vtkGetMacro(FrustumVisibility, bool);
142  vtkBooleanMacro(FrustumVisibility, bool);
144 
146 
150  void SetSecondaryHandlesVisibility(bool visible);
151  vtkGetMacro(SecondaryHandlesVisibility, bool);
152  vtkBooleanMacro(SecondaryHandlesVisibility, bool);
154 
164  void SetInteractionState(int state);
165 
166  /*
167  * Register internal Pickers within PickingManager
168  */
169  void RegisterPickers() override;
170 
176  void GetActors(vtkPropCollection*) override;
177 
178  // Used to manage the state of the widget
179  enum
180  {
181  Outside = 0,
187  Scaling
188  };
189 
190 protected:
192  ~vtkCamera3DRepresentation() override;
193 
194  virtual void CreateDefaultProperties();
195  virtual void UpdateGeometry();
196  void HighlightHandle(vtkProp* prop);
197 
198  // Helper methods
199  virtual void TranslateAll(const double p1[4], const double p2[4]);
200  virtual void TranslatePosition(const double p1[4], const double p2[4]);
201  virtual void TranslateTarget(const double p1[4], const double p2[4]);
202  virtual void TranslateNearTarget(const double p1[4], const double p2[4]);
203  virtual void TranslateUp(const double p1[4], const double p2[4]);
204  virtual void Scale(const double p1[4], const double p2[4], int X, int Y);
205  void GetTranslation(const double p1[4], const double p2[4], double v[3]);
206 
207  // Manage how the representation appears
208  double LastEventPosition[3] = { 0.0 };
209  double LastEventOrientation[4] = { 0.0 };
210  double StartEventOrientation[4] = { 0.0 };
211 
212  // the camera object
220 
221  // secondary handles
222  double FrontHandleDistance = 2.5;
223  double UpHandleDistance = 1.5;
224  std::array<vtkNew<vtkActor>, 3> HandleSphereActor;
225  std::array<vtkNew<vtkSphereSource>, 3> HandleSphereGeometry;
226  std::array<vtkNew<vtkActor>, 2> HandleLineActor;
227  std::array<vtkNew<vtkLineSource>, 2> HandleLineGeometry;
228 
229  // Properties used to control the appearance of selected objects and
230  // the manipulator in general.
233 
234  // Do the picking
236  vtkProp* CurrentHandle = nullptr;
237 
238  // Support GetBounds() method
240 
241  int TranslationAxis = Axis::NONE;
242  bool TranslatingAll = false;
243  bool FrustumVisibility = true;
244  bool SecondaryHandlesVisibility = true;
245 
246 private:
248  void operator=(const vtkCamera3DRepresentation&) = delete;
249 };
250 
251 VTK_ABI_NAMESPACE_END
252 #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.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
virtual void PlaceWidget(double vtkNotUsed(bounds)[6])
The following is a suggested API for widget representations.
vtkNew< vtkProperty > SelectedHandleProperty
virtual int ComputeInteractionState(int X, int Y, int modify=0)
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154
void SetTranslationAxisToYAxis()
Set/Get the constraint axis for translations.
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])
std::array< vtkNew< vtkSphereSource >, 3 > HandleSphereGeometry
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
vtkNew< vtkProperty > HandleProperty
a frustum to represent a camera.
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
create a polygonal sphere centered at the origin
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkNew< vtkCellPicker > HandlePicker
a virtual camera for 3D rendering
Definition: vtkCamera.h:40
void SetTranslationAxisToNone()
Set/Get the constraint axis for translations.
virtual void WidgetInteraction(double newEventPos[2])
void SetTranslationAxisToZAxis()
Set/Get the constraint axis for translations.
#define VTK_SIZEHINT(...)
vtkNew< vtkCameraActor > CameraFrustumActor
create a line defined by two end points
Definition: vtkLineSource.h:52
vtkNew< vtkTransform > FrontTransform
std::array< vtkNew< vtkLineSource >, 2 > HandleLineGeometry
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:61
std::array< vtkNew< vtkActor >, 3 > HandleSphereActor
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...
implicit function for a bounding box
Definition: vtkBox.h:30
vtkNew< vtkTransform > CameraTransform
3D Widget for manipulating a vtkCamera
a class defining the representation for the vtkCamera3DWidget
std::array< vtkNew< vtkActor >, 2 > HandleLineActor
vtkNew< vtkTransform > UpTransform
vtkSmartPointer< vtkCamera > Camera