VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
32 
33 #include <array>
34 
35 VTK_ABI_NAMESPACE_BEGIN
36 class vtkActor;
37 class vtkBox;
38 class vtkCamera;
39 class vtkCamera3DWidget;
40 class vtkCameraActor;
41 class vtkCellPicker;
42 class vtkLineSource;
43 class vtkProperty;
44 class vtkSphereSource;
45 class vtkTransform;
46 
47 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCamera3DRepresentation
49 {
50 public:
55 
57 
61  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
65 
68  void PlaceWidget(double bounds[6]) override;
69  void BuildRepresentation() override;
70  int ComputeInteractionState(int X, int Y, int modify = 0) override;
71  void StartWidgetInteraction(double e[2]) override;
72  void WidgetInteraction(double e[2]) override;
73  double* GetBounds() VTK_SIZEHINT(6) override;
75 
77 
80  void ReleaseGraphicsResources(vtkWindow*) override;
81  int RenderOpaqueGeometry(vtkViewport*) override;
82  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
83  vtkTypeBool HasTranslucentPolygonalGeometry() override;
85 
87 
90  virtual void SetCamera(vtkCamera* camera);
91  vtkCamera* GetCamera();
93 
95 
100  vtkSetClampMacro(FrontHandleDistance, double, 1.5, VTK_DOUBLE_MAX);
101  vtkGetMacro(FrontHandleDistance, double);
103 
105 
110  vtkSetClampMacro(UpHandleDistance, double, 0.5, VTK_DOUBLE_MAX);
111  vtkGetMacro(UpHandleDistance, double);
113 
115 
119  void SetTranslationAxisToXAxis() { this->SetTranslationAxis(Axis::XAxis); }
120  void SetTranslationAxisToYAxis() { this->SetTranslationAxis(Axis::YAxis); }
121  void SetTranslationAxisToZAxis() { this->SetTranslationAxis(Axis::ZAxis); }
122  void SetTranslationAxisToNone() { this->SetTranslationAxis(Axis::NONE); }
123  vtkSetClampMacro(TranslationAxis, int, Axis::NONE, Axis::ZAxis);
124  vtkGetMacro(TranslationAxis, int);
126 
128 
132  vtkSetMacro(TranslatingAll, bool);
133  vtkGetMacro(TranslatingAll, bool);
134  vtkBooleanMacro(TranslatingAll, bool);
136 
138 
142  void SetFrustumVisibility(bool visible);
143  vtkGetMacro(FrustumVisibility, bool);
144  vtkBooleanMacro(FrustumVisibility, bool);
146 
148 
152  void SetSecondaryHandlesVisibility(bool visible);
153  vtkGetMacro(SecondaryHandlesVisibility, bool);
154  vtkBooleanMacro(SecondaryHandlesVisibility, bool);
156 
166  void SetInteractionState(int state);
167 
168  /*
169  * Register internal Pickers within PickingManager
170  */
171  void RegisterPickers() override;
172 
178  void GetActors(vtkPropCollection*) override;
179 
180  // Used to manage the state of the widget
181  enum
182  {
183  Outside = 0,
189  Scaling
190  };
191 
192 protected:
194  ~vtkCamera3DRepresentation() override;
195 
196  virtual void CreateDefaultProperties();
197  virtual void UpdateGeometry();
198  void HighlightHandle(vtkProp* prop);
199 
200  // Helper methods
201  virtual void TranslateAll(const double p1[4], const double p2[4]);
202  virtual void TranslatePosition(const double p1[4], const double p2[4]);
203  virtual void TranslateTarget(const double p1[4], const double p2[4]);
204  virtual void TranslateNearTarget(const double p1[4], const double p2[4]);
205  virtual void TranslateUp(const double p1[4], const double p2[4]);
206  virtual void Scale(const double p1[4], const double p2[4], int X, int Y);
207  void GetTranslation(const double p1[4], const double p2[4], double v[3]);
208 
209  // Manage how the representation appears
210  double LastEventPosition[3] = { 0.0 };
211  double LastEventOrientation[4] = { 0.0 };
212  double StartEventOrientation[4] = { 0.0 };
213 
214  // the camera object
222 
223  // secondary handles
224  double FrontHandleDistance = 2.5;
225  double UpHandleDistance = 1.5;
226  std::array<vtkNew<vtkActor>, 3> HandleSphereActor;
227  std::array<vtkNew<vtkSphereSource>, 3> HandleSphereGeometry;
228  std::array<vtkNew<vtkActor>, 2> HandleLineActor;
229  std::array<vtkNew<vtkLineSource>, 2> HandleLineGeometry;
230 
231  // Properties used to control the appearance of selected objects and
232  // the manipulator in general.
235 
236  // Do the picking
238  vtkProp* CurrentHandle = nullptr;
239 
240  // Support GetBounds() method
242 
243  int TranslationAxis = Axis::NONE;
244  bool TranslatingAll = false;
245  bool FrustumVisibility = true;
246  bool SecondaryHandlesVisibility = true;
247 
248 private:
250  void operator=(const vtkCamera3DRepresentation&) = delete;
251 };
252 
253 VTK_ABI_NAMESPACE_END
254 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
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:41
virtual void PlaceWidget(double 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:202
void SetTranslationAxisToYAxis()
Set/Get the constraint axis for translations.
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:59
virtual void StartWidgetInteraction(double eventPos[2])
std::array< vtkNew< vtkSphereSource >, 3 > HandleSphereGeometry
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
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:41
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:41
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:53
vtkNew< vtkTransform > FrontTransform
std::array< vtkNew< vtkLineSource >, 2 > HandleLineGeometry
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
#define VTK_MARSHALAUTO
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