Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLCameraNode.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8  Program: 3D Slicer
9  Module: $RCSfile: vtkMRMLCameraNode.h,v $
10  Date: $Date: 2006/03/19 17:12:28 $
11  Version: $Revision: 1.6 $
12 
13 =========================================================================auto=*/
14 
15 #ifndef __vtkMRMLCameraNode_h
16 #define __vtkMRMLCameraNode_h
17 
18 // MRML includes
20 
21 // VTK includes
22 class vtkCamera;
23 class vtkMatrix4x4;
24 class vtkRenderer;
25 
29 class VTK_MRML_EXPORT vtkMRMLCameraNode : public vtkMRMLTransformableNode
30 {
31 public:
32  static vtkMRMLCameraNode *New();
34  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
35 
36  //--------------------------------------------------------------------------
38  //--------------------------------------------------------------------------
39 
40  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
41 
44  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
45 
48  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
49 
50 
53  virtual void Copy(vtkMRMLNode* node) VTK_OVERRIDE;
54 
57  virtual const char* GetNodeTagName() VTK_OVERRIDE {return "Camera";};
58 
62  const char* GetActiveTag();
63  virtual void SetActiveTag(const char *);
64 
67  vtkGetObjectMacro(Camera, vtkCamera);
68 
71  void SetParallelProjection(int parallelProjection);
72 
75  int GetParallelProjection();
76 
79  void SetParallelScale(double scale);
80 
83  double GetParallelScale();
84 
89  void SetViewAngle(double viewAngle);
90 
95  double GetViewAngle();
96 
100  void SetPosition(double position[3]);
101  inline void SetPosition(double x, double y, double z);
102 
106  double *GetPosition();
107  void GetPosition(double position[3]);
108 
113  void SetFocalPoint(double focalPoint[3]);
114  inline void SetFocalPoint(double x, double y, double z);
115 
119  double *GetFocalPoint();
120  void GetFocalPoint(double focalPoint[3]);
121 
125  void SetViewUp(double viewUp[3]);
126  inline void SetViewUp(double vx, double vy, double vz);
127 
131  double *GetViewUp();
132  void GetViewUp(double viewUp[3]);
133 
136  virtual void ProcessMRMLEvents ( vtkObject * /*caller*/,
137  unsigned long /*event*/,
138  void * /*callData*/ ) VTK_OVERRIDE;
139 
144  vtkGetObjectMacro(AppliedTransform, vtkMatrix4x4);
145  virtual void SetAppliedTransform(vtkMatrix4x4* appliedTransform);
146 
149  enum
150  {
151  ActiveTagModifiedEvent = 30000,
152  CameraInteractionEvent = 31000,
153  ResetCameraClippingEvent = 32000,
154  };
155 
157  virtual void SetSceneReferences() VTK_OVERRIDE;
158 
162  virtual void UpdateReferences() VTK_OVERRIDE;
163 
166  virtual void UpdateReferenceID(const char* oldID, const char* newID) VTK_OVERRIDE;
167 
169  void ResetClippingRange();
170 
171  enum Direction{
172  Right = 0,
173  Left = 1,
174  Anterior = 2,
175  Posterior = 3,
176  Superior = 4,
177  Inferior = 5
178  };
179 
180  enum RASAxis{
181  R = 0,
182  A = 1,
183  S = 2,
184  };
185 
187  X = 0,
188  Y = 1,
189  Z = 2
190  };
191 
194  void RotateTo(Direction position);
195 
198  void RotateAround(RASAxis axis, bool clockWise);
199 
201  void RotateAround(RASAxis axis, double angle = 15.);
202 
205  void TranslateAlong(ScreenAxis axis, bool positive);
206 
213  using vtkMRMLNode::Reset;
214  void Reset(bool resetRotation,
215  bool resetTranslation = true,
216  bool resetDistance = true,
217  vtkRenderer* renderer = 0);
218 
224  void SetInteracting(int);
225  vtkGetMacro(Interacting, int);
226  vtkBooleanMacro(Interacting, int);
227 
234  {
235  None = 0,
241  };
242 
248  void SetInteractionFlags(unsigned int);
249  vtkGetMacro(InteractionFlags, unsigned int);
250 
251 protected:
255  void operator=(const vtkMRMLCameraNode&);
256 
257 
258  void SetCamera(vtkCamera* camera);
259  void SetAndObserveCamera(vtkCamera* camera);
260  vtkCamera* Camera;
261 
262  vtkMRMLCameraNode* FindActiveTagInScene(const char* tag);
263 
264  void SetInternalActiveTag(const char* id);
266 
267  vtkMatrix4x4* AppliedTransform;
268 
270  unsigned int InteractionFlags;
271 };
272 
273 //---------------------------------------------------------------------------
274 void vtkMRMLCameraNode::SetPosition(double x, double y, double z)
275 {
276  double pos[3] = {x, y, z};
277  this->SetPosition(pos);
278 }
279 
280 //---------------------------------------------------------------------------
281 void vtkMRMLCameraNode::SetFocalPoint(double x, double y, double z)
282 {
283  double pos[3] = {x, y, z};
284  this->SetFocalPoint(pos);
285 }
286 
287 //---------------------------------------------------------------------------
288 void vtkMRMLCameraNode::SetViewUp(double vx, double vy, double vz)
289 {
290  double viewUp[3] = {vx, vy, vz};
291  this->SetViewUp(viewUp);
292 }
293 
294 #endif
unsigned int InteractionFlags
virtual void Reset(vtkMRMLNode *defaultNode)
Reset node attributes to the initial state as defined in the constructor or the passed default node...
vtkMatrix4x4 * AppliedTransform
void SetFocalPoint(double focalPoint[3])
virtual void ProcessMRMLEvents(vtkObject *, unsigned long, void *) VTK_OVERRIDE
alternative method to propagate events generated in Transform nodes
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual void SetSceneReferences()
Update the references of the node to the scene.
void operator=(const vtkMRMLTransformableNode &)
virtual vtkMRMLNode * CreateNodeInstance() VTK_OVERRIDE=0
MRMLNode methods.
MRML node to represent camera node.
void SetPosition(double position[3])
void SetViewUp(double viewUp[3])
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
MRML node for representing a node with a transform.