VTK  9.4.20241103
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
35VTK_ABI_NAMESPACE_BEGIN
36class vtkActor;
37class vtkBox;
38class vtkCamera;
40class vtkCameraActor;
41class vtkCellPicker;
42class vtkLineSource;
43class vtkProperty;
44class vtkSphereSource;
45class vtkTransform;
46
47class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkCamera3DRepresentation
49{
50public:
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
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
179
180 // Used to manage the state of the widget
181 enum
182 {
183 Outside = 0,
189 Scaling
190 };
191
192protected:
195
197 virtual void UpdateGeometry();
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
248private:
250 void operator=(const vtkCamera3DRepresentation&) = delete;
251};
252
253VTK_ABI_NAMESPACE_END
254#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
implicit function for a bounding box
Definition vtkBox.h:110
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:151
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:108
create a line defined by two end points
Allocate and hold a VTK object.
Definition vtkNew.h:167
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
represent surface properties of a geometric object
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:65
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DOUBLE_MAX
Definition vtkType.h:154
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO