-
Notifications
You must be signed in to change notification settings - Fork 3
/
vtkMRMLCameraPathNode.h
152 lines (125 loc) · 4.42 KB
/
vtkMRMLCameraPathNode.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
152
#ifndef __vtkMRMLCameraPathNode_h
#define __vtkMRMLCameraPathNode_h
// MRML includes
#include "vtkSlicerCameraPathModuleMRMLExport.h"
#include "vtkMRMLPointSplineNode.h"
#include <vtkMRMLCameraNode.h>
#include <vtkMRMLStorableNode.h>
class vtkMRMLStorageNode;
// STD includes
#include <utility>
#include <vector>
struct KeyFrame
{
vtkSmartPointer<vtkMRMLCameraNode> Camera;
double Time;
//std::string ID;
//std::string Label;
//bool Locked;
//bool Visibility;
KeyFrame(vtkMRMLCameraNode* camera = NULL,
double time = 0.0):
Camera(camera),
Time(time)
{}
KeyFrame& operator = (const KeyFrame& a)
{
Camera = a.Camera;
Time = a.Time;
return *this;
}
bool operator < (const KeyFrame& a) const
{
return Time < a.Time;
}
bool operator == (const KeyFrame& a) const
{
return (Camera == a.Camera && Time == a.Time); //TODO : camera, check members not pointer ?
}
};
typedef std::vector<KeyFrame> KeyFrameVector;
struct timeEqual
{
timeEqual(double const& time) : Time(time) { }
double Time;
bool operator ()(const KeyFrame& a)
{
return Time == a.Time;
}
};
/// \brief MRML node to hold the information about a camera path.
///
class VTK_SLICER_CAMERAPATH_MODULE_MRML_EXPORT vtkMRMLCameraPathNode:
public vtkMRMLStorableNode
{
public:
typedef vtkMRMLCameraPathNode Self;
enum {PATH_NOT_CREATED=0,
PATH_NOT_UP_TO_DATE,
PATH_UP_TO_DATE};
static vtkMRMLCameraPathNode *New();
vtkTypeMacro(vtkMRMLCameraPathNode,vtkMRMLStorableNode)
virtual void PrintSelf(ostream& os, vtkIndent indent);
//--------------------------------------------------------------------------
/// MRMLNode methods
//--------------------------------------------------------------------------
virtual vtkMRMLNode* CreateNodeInstance();
/// Copy the node's attributes to this object
virtual void Copy(vtkMRMLNode *node);
/// Get node XML tag name (like Volume, Model)
virtual const char* GetNodeTagName() {return "CameraPath";}
/// Create default camera path storage node
/// \sa vtkMRMLCameraPathStorageNode
virtual vtkMRMLStorageNode* CreateDefaultStorageNode();
//--------------------------------------------------------------------------
/// CameraPath methods
//--------------------------------------------------------------------------
vtkIdType GetNumberOfKeyFrames();
double GetMinimumT();
double GetMaximumT();
KeyFrameVector GetKeyFrames();
KeyFrame GetKeyFrame(vtkIdType index);
double GetKeyFrameTime(vtkIdType index);
vtkMRMLCameraNode* GetKeyFrameCamera(vtkIdType index);
void GetKeyFramePosition(vtkIdType index, double position[3] = 0);
void GetKeyFrameFocalPoint(vtkIdType index, double focalPoint[3] = 0);
void GetKeyFrameViewUp(vtkIdType index, double viewUp[3] = 0);
void SetKeyFrames(KeyFrameVector keyFrames);
void SetKeyFrame(vtkIdType index, KeyFrame keyFrame);
void SetKeyFrameTime(vtkIdType index, double time);
void SetKeyFrameCamera(vtkIdType index, vtkMRMLCameraNode* camera);
void SetKeyFramePosition(vtkIdType index, double position[3]);
void SetKeyFrameFocalPoint(vtkIdType index, double focalPoint[3]);
void SetKeyFrameViewUp(vtkIdType index, double viewUp[3]);
void AddKeyFrame(KeyFrame keyFrame);
void AddKeyFrame(double t, vtkMRMLCameraNode* camera);
void AddKeyFrame(double t,
double position[3],
double focalPoint[3],
double viewUp[3]);
vtkIdType KeyFrameIndexAt(double t);
void RemoveKeyFrames();
void RemoveKeyFrame(vtkIdType index);
void RemoveCameraFromScene(vtkIdType index);
void SortKeyFrames();
void CreatePath();
vtkMRMLPointSplineNode* GetPositionSplines();
vtkMRMLPointSplineNode *GetFocalPointSplines();
vtkMRMLPointSplineNode* GetViewUpSplines();
void SetPointSplines(vtkMRMLPointSplineNode* positions,
vtkMRMLPointSplineNode* focalPoints,
vtkMRMLPointSplineNode* viewUps);
void GetCameraAt(double t, vtkMRMLCameraNode* camera);
void GetPositionAt(double t, double position[3] = 0);
void GetFocalPointAt(double t, double focalPoint[3] = 0);
void GetViewUpAt(double t, double viewUp[3] = 0);
double ClampTime(double t);
protected:
vtkMRMLCameraPathNode();
virtual ~vtkMRMLCameraPathNode();
vtkMRMLCameraPathNode(const vtkMRMLCameraPathNode&);
void operator=(const vtkMRMLCameraPathNode&);
class vtkInternal;
vtkInternal* Internal;
};
#endif