forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkCameraPathRepresentation.h
151 lines (122 loc) · 4.44 KB
/
vtkCameraPathRepresentation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCameraPathRepresentation.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkCameraPathRepresentation
* @brief representation for a camera path.
*
* vtkCameraPathRepresentation is a vtkWidgetRepresentation for a camera path.
* This 3D widget defines a camera path that can be interactively manipulated in a
* scene. The camera path has camera handles, that can be added and deleted, plus they
* can be picked on the path itself to be translated in the scene.
* This representation is used with vtkCameraPathWidget.
* @sa
* vtkCameraPathWidget
*/
#ifndef vtkCameraPathRepresentation_h
#define vtkCameraPathRepresentation_h
#include "vtkAbstractSplineRepresentation.h"
#include "vtkInteractionWidgetsModule.h" // For export macro
class vtkCameraHandleSource;
class vtkCamera;
class VTKINTERACTIONWIDGETS_EXPORT vtkCameraPathRepresentation
: public vtkAbstractSplineRepresentation
{
public:
static vtkCameraPathRepresentation* New();
vtkTypeMacro(vtkCameraPathRepresentation, vtkAbstractSplineRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* Sets the representation to be a curve interpolating multiple cameras pointing to their focal
* point. If set to false, the cameras are only represented as spheres.
*/
void SetDirectional(bool val) override;
/**
* Adjust the number of camera handles while keeping
the same path.
*/
void SetNumberOfHandles(int npts) override;
/**
* Set the parametric spline object.
*/
void SetParametricSpline(vtkParametricSpline* spline) override;
/**
* Convenience method to allocate and set the Camera handles from a vtkPoints
* instance (corresponding to the camera positions).
* If the first and last points are the same, the spline sets
* Closed to the on InteractionState and disregards the last point, otherwise Closed
* remains unchanged.
*/
void InitializeHandles(vtkPoints* points) override;
/**
* Method that satisfy vtkWidgetRepresentation API.
* Updates the spline in relation with the handles positions
* and updates vtkWidgetRepresentation::InitialLength
* (useful for the sizing methods).
*/
void BuildRepresentation() override;
/**
* Add a camera to the path.
*/
void AddCameraAt(vtkCamera* camera, int index);
/**
* Remove a camera from the path.
*/
void DeleteCameraAt(int index);
protected:
vtkCameraPathRepresentation();
~vtkCameraPathRepresentation() override = default;
/**
* Resize the camera handles on demand.
*/
void SizeHandles() override;
/**
* Delete all camera handles.
*/
void ClearCameraHandles();
/**
* Creates a new handle from a vtkcamera and
* insert it in the handles collection.
*/
void InsertCamera(vtkCamera* camera, int index);
/**
* Create/Recreate npts default camera handles.
*/
void CreateDefaultHandles(int npts);
/**
* Recreate the handles according to a
* number of points equal to newNPts.
* The old number of handles must be entered
* as oldNPts.
* It uses the current spline to recompute
* the positions of the new handles.
*/
void ReconfigureHandles(int newNPts, int oldNPts);
/**
* Specialized method to insert a camera handle on the camera path.
*/
int InsertHandleOnLine(double* pos) override;
/**
* Specialized method to erase a camera handle from the camera path.
*/
void EraseHandle(const int&) override;
// Specialized methods to access handles
vtkActor* GetHandleActor(int index) override;
vtkHandleSource* GetHandleSource(int index) override;
virtual int GetHandleIndex(vtkProp* prop) override;
private:
vtkCameraPathRepresentation(const vtkCameraPathRepresentation&) = delete;
void operator=(const vtkCameraPathRepresentation&) = delete;
void RebuildRepresentation();
void UpdateConfiguration(int npts);
std::vector<vtkSmartPointer<vtkCameraHandleSource>> CameraHandles;
std::vector<vtkSmartPointer<vtkActor>> HandleActors;
};
#endif