VTK  9.3.0
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
34VTK_ABI_NAMESPACE_BEGIN
35class vtkActor;
36class vtkBox;
37class vtkCamera;
39class vtkCameraActor;
40class vtkCellPicker;
41class vtkLineSource;
42class vtkProperty;
43class vtkSphereSource;
44class vtkTransform;
45
46class VTKINTERACTIONWIDGETS_EXPORT vtkCamera3DRepresentation : public vtkWidgetRepresentation
47{
48public:
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
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
177
178 // Used to manage the state of the widget
179 enum
180 {
181 Outside = 0,
187 Scaling
188 };
189
190protected:
193
195 virtual void UpdateGeometry();
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
246private:
248 void operator=(const vtkCamera3DRepresentation&) = delete;
249};
250
251VTK_ABI_NAMESPACE_END
252#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
implicit function for a bounding box
Definition vtkBox.h:31
a class defining the representation for the vtkCamera3DWidget
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void SetTranslationAxisToZAxis()
Set/Get the constraint axis for translations.
void GetActors(vtkPropCollection *) override
These methods are necessary to make this representation behave as a vtkProp (i.e.,...
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void TranslatePosition(const double p1[4], const double p2[4])
std::array< vtkNew< vtkActor >, 3 > HandleSphereActor
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
static vtkCamera3DRepresentation * New()
Instantiate the class.
virtual void Scale(const double p1[4], const double p2[4], int X, int Y)
vtkNew< vtkTransform > FrontTransform
std::array< vtkNew< vtkLineSource >, 2 > HandleLineGeometry
void SetFrustumVisibility(bool visible)
Set/Get whether to show camera frustum.
virtual void TranslateNearTarget(const double p1[4], const double p2[4])
std::array< vtkNew< vtkActor >, 2 > HandleLineActor
void GetTranslation(const double p1[4], const double p2[4], double v[3])
vtkNew< vtkCameraActor > CameraFrustumActor
vtkSmartPointer< vtkCamera > Camera
virtual void TranslateAll(const double p1[4], const double p2[4])
void SetInteractionState(int state)
The interaction state may be set from a widget (e.g., vtkCamera3DWidget) or other object.
void SetSecondaryHandlesVisibility(bool visible)
Set/Get whether to show secondary handles (spheres and lines).
vtkNew< vtkCellPicker > HandlePicker
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
std::array< vtkNew< vtkSphereSource >, 3 > HandleSphereGeometry
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
virtual void TranslateUp(const double p1[4], const double p2[4])
void SetTranslationAxisToNone()
Set/Get the constraint axis for translations.
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void CreateDefaultProperties()
virtual void UpdateGeometry()
vtkNew< vtkProperty > SelectedHandleProperty
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetTranslationAxisToYAxis()
Set/Get the constraint axis for translations.
vtkNew< vtkTransform > CameraTransform
virtual void TranslateTarget(const double p1[4], const double p2[4])
void HighlightHandle(vtkProp *prop)
~vtkCamera3DRepresentation() override
3D Widget for manipulating a vtkCamera
a frustum to represent a camera.
a virtual camera for 3D rendering
Definition vtkCamera.h:41
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:29
create a line defined by two end points
Allocate and hold a VTK object.
Definition vtkNew.h:51
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
represent surface properties of a geometric object
Definition vtkProperty.h:57
Hold a reference to a vtkObjectBase instance.
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
abstract specification for Viewports
Definition vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DOUBLE_MAX
Definition vtkType.h:154
#define VTK_SIZEHINT(...)