Slicer  4.13
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) override;
35 
36  //--------------------------------------------------------------------------
38  //--------------------------------------------------------------------------
39 
40  vtkMRMLNode* CreateNodeInstance() override;
41 
44  void ReadXMLAttributes( const char** atts) override;
45 
48  void WriteXML(ostream& of, int indent) override;
49 
50 
53  void Copy(vtkMRMLNode* node) override;
54 
58 
61  const char* GetNodeTagName() override {return "Camera";};
62 
67  const char* GetActiveTag();
68  virtual void SetActiveTag(const char *);
69 
78  void SetLayoutName(const char* layoutName);
79  char* GetLayoutName();
80 
83  vtkGetObjectMacro(Camera, vtkCamera);
84 
87  void SetParallelProjection(int parallelProjection);
88 
91  int GetParallelProjection();
92 
95  void SetParallelScale(double scale);
96 
99  double GetParallelScale();
100 
105  void SetViewAngle(double viewAngle);
106 
111  double GetViewAngle();
112 
118  void SetPosition(double position[3]);
119  inline void SetPosition(double x, double y, double z);
120 
124  double *GetPosition();
125  void GetPosition(double position[3]);
126 
131  void SetFocalPoint(double focalPoint[3]);
132  inline void SetFocalPoint(double x, double y, double z);
133 
137  double *GetFocalPoint();
138  void GetFocalPoint(double focalPoint[3]);
139 
143  void SetViewUp(double viewUp[3]);
144  inline void SetViewUp(double vx, double vy, double vz);
145 
149  double *GetViewUp();
150  void GetViewUp(double viewUp[3]);
151 
154  void ProcessMRMLEvents ( vtkObject * /*caller*/,
155  unsigned long /*event*/,
156  void * /*callData*/ ) override;
157 
162  vtkGetObjectMacro(AppliedTransform, vtkMatrix4x4);
163  virtual void SetAppliedTransform(vtkMatrix4x4* appliedTransform);
164 
167  enum
168  {
169  LayoutNameModifiedEvent = 30000,
170  ActiveTagModifiedEvent = LayoutNameModifiedEvent, // deprecated, kept for backward compatibility only
171  CameraInteractionEvent = 31000,
172  ResetCameraClippingEvent = 32000,
173  };
174 
176  void ResetClippingRange();
177 
178  enum Direction{
179  Right = 0,
180  Left = 1,
181  Anterior = 2,
182  Posterior = 3,
183  Superior = 4,
184  Inferior = 5
185  };
186 
187  enum RASAxis{
188  R = 0,
189  A = 1,
190  S = 2,
191  };
192 
194  X = 0, // left
195  Y = 1, // up
196  Z = 2 // forward
197  };
198 
201  void RotateTo(Direction position);
202 
205  void RotateAround(RASAxis axis, bool clockWise);
206 
208  void RotateAround(RASAxis axis, double angle = 15.);
209 
212  void TranslateAlong(ScreenAxis axis, bool positive);
213 
220  using vtkMRMLNode::Reset;
221  void Reset(bool resetRotation,
222  bool resetTranslation = true,
223  bool resetDistance = true,
224  vtkRenderer* renderer = nullptr);
225 
231  void SetInteracting(int);
232  vtkGetMacro(Interacting, int);
233  vtkBooleanMacro(Interacting, int);
234 
241  {
242  None = 0,
248  };
249 
255  void SetInteractionFlags(unsigned int);
256  vtkGetMacro(InteractionFlags, unsigned int);
257 
258 protected:
260  ~vtkMRMLCameraNode() override;
262  void operator=(const vtkMRMLCameraNode&);
263 
264 
265  void SetCamera(vtkCamera* camera);
266  void SetAndObserveCamera(vtkCamera* camera);
267  vtkCamera* Camera{nullptr};
268 
269  std::string InternalActiveTag; // variable to hold returned value of GetActiveTag
270 
271  vtkMatrix4x4* AppliedTransform;
272 
274  unsigned int InteractionFlags;
275 };
276 
277 //---------------------------------------------------------------------------
278 void vtkMRMLCameraNode::SetPosition(double x, double y, double z)
279 {
280  double pos[3] = {x, y, z};
281  this->SetPosition(pos);
282 }
283 
284 //---------------------------------------------------------------------------
285 void vtkMRMLCameraNode::SetFocalPoint(double x, double y, double z)
286 {
287  double pos[3] = {x, y, z};
288  this->SetFocalPoint(pos);
289 }
290 
291 //---------------------------------------------------------------------------
292 void vtkMRMLCameraNode::SetViewUp(double vx, double vy, double vz)
293 {
294  double viewUp[3] = {vx, vy, vz};
295  this->SetViewUp(viewUp);
296 }
297 
298 #endif
vtkMRMLNode * CreateNodeInstance() override=0
MRMLNode methods.
std::string InternalActiveTag
unsigned int InteractionFlags
void ProcessMRMLEvents(vtkObject *, unsigned long, void *) override
alternative method to propagate events generated in Transform nodes
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
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 Copy(vtkMRMLNode *node)
Copy node contents from another node of the same type. Does not copy node ID and Scene. Performs deep copy - an independent copy is created from all data, including bulk data.
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file
void operator=(const vtkMRMLTransformableNode &)
void PrintSelf(ostream &os, vtkIndent indent) override
MRML node to represent camera node.
vtkMRMLCopyContentMacro(vtkMRMLStorableNode)
void SetPosition(double position[3])
void SetViewUp(double viewUp[3])
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
MRML node for representing a node with a transform.