Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLAnnotationRulerNode.h
Go to the documentation of this file.
1 #ifndef __vtkMRMLAnnotationRulerNode_h
2 #define __vtkMRMLAnnotationRulerNode_h
3 
4 #include "vtkSlicerAnnotationsModuleMRMLExport.h"
6 
7 class vtkMatrix4x4;
8 class vtkAbstractTransform;
9 class vtkMRMLScene;
10 
12 class VTK_SLICER_ANNOTATIONS_MODULE_MRML_EXPORT vtkMRMLAnnotationRulerNode : public vtkMRMLAnnotationLinesNode
13 {
14 public:
17  // Description:
18  // Just prints short summary
19  void PrintAnnotationInfo(ostream& os, vtkIndent indent, int titleFlag = 1) VTK_OVERRIDE;
20 
21  //--------------------------------------------------------------------------
22  // MRMLNode methods
23  //--------------------------------------------------------------------------
24 
25  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
26  // Description:
27  // Get node XML tag name (like Volume, Model)
28  virtual const char* GetNodeTagName() VTK_OVERRIDE {return "AnnotationRuler";}
29 
30  virtual const char* GetIcon() VTK_OVERRIDE {return ":/Icons/AnnotationDistance.png";}
31 
32  // Description:
33  // Read node attributes from XML file
34  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
35 
36  // Description:
37  // Write this node's information to a MRML file in XML format.
38  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
39 
40 
41  // Description:
42  // Copy the node's attributes to this object
43  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
44 
45  void UpdateScene(vtkMRMLScene *scene) VTK_OVERRIDE;
46 
47  // Description:
48  // alternative method to propagate events generated in Display nodes
49  virtual void ProcessMRMLEvents ( vtkObject * /*caller*/,
50  unsigned long /*event*/,
51  void * /*callData*/ ) VTK_OVERRIDE;
52 
53 
54 
55  // Get position of the first point
56  void GetPosition1(double position[3]);
57 
58  // Get position of the first point in world coordinates, including parnts transfroms
59  void GetPositionWorldCoordinates1(double position[4])
60  {
61  double p[4]={0,0,0,1};
62  this->GetPosition1(p);
63  this->TransformPointToWorld(p,position);
64  }
65 
66  // Legacy code
67  // Description:
68  // get/set the first point position
69  double* GetPosition1()
70  {
71  return this->GetControlPointCoordinates(0);
72  }
73 
74  int SetPosition1(double newControl[3])
75  {
76  return this->SetControlPoint(0, newControl) ;
77  }
78 
79  int SetPositionWorldCoordinates1(double newControl[4])
80  {
81  double locPoint[4]={0,0,0,1};
82  this->TransformPointFromWorld(newControl, locPoint);
83  return this->SetPosition1(locPoint) ;
84  }
85 
86  int SetPosition1(double nC1, double nC2, double nC3)
87  {
88  double newControl[3] = {nC1,nC2,nC3};
89  return this->SetPosition1(newControl) ;
90  }
91 
92 
93  // Get position of the second point
94  void GetPosition2(double position[3]);
95 
96  // Get position of the second point in world coordinates, including parnts transfroms
97  void GetPositionWorldCoordinates2(double position[4])
98  {
99  double p[4]={0,0,0,1};
100  this->GetPosition2(p);
101  this->TransformPointToWorld(p,position);
102  }
103 
104  double* GetPosition2()
105  {
106  return this->GetControlPointCoordinates(1);
107  }
108 
109  int SetPosition2(double newControl[3])
110  {
111  return this->SetControlPoint(1, newControl);
112  }
113 
114  int SetPositionWorldCoordinates2(double newControl[4])
115  {
116  double locPoint[4]={0,0,0,1};
117  this->TransformPointFromWorld(newControl, locPoint);
118  return this->SetPosition2(locPoint) ;
119  }
120 
121  int SetPosition2(double nC1, double nC2, double nC3)
122  {
123  double newControl[3] = {nC1,nC2,nC3};
124  return this->SetPosition2(newControl) ;
125  }
126 
127  // Description:
128  // get/set the distance annotation format, it's in standard sprintf notation
129  vtkGetStringMacro(DistanceAnnotationFormat);
130  vtkSetStringMacro(DistanceAnnotationFormat);
131 
132  // Description:
133  // KP Define - should be part of AnnotationRulerDisplayNode
134  double GetDistanceAnnotationScale();
135  void SetDistanceAnnotationScale(double init);
136 
137  // Description:
138  // get/set the distance annotation visbility
139  int GetDistanceAnnotationVisibility();
140  void SetDistanceAnnotationVisibility(int flag);
141 
142  int SetRuler(vtkIdType line1Id, int sel, int vis);
143 
144  // Description:
145  // get/set the point representation colour
146  double *GetPointColour();
147  void SetPointColour( double initColor[3]);
148 
149  // Description:
150  // get/set the line representation colour
151  double *GetLineColour();
152  void SetLineColour(double newColor[3]);
153 
154  // Description:
155  // get/set the distance annotation text colour
156  double *GetDistanceAnnotationTextColour();
157  void SetDistanceAnnotationTextColour(double initColor[3]);
158 
159  // Description:
160  // transform utility functions
161  virtual void ApplyTransform(vtkAbstractTransform* transform) VTK_OVERRIDE;
162 
163  // Description:
164  // Create default storage node or NULL if does not have one
165  virtual vtkMRMLStorageNode* CreateDefaultStorageNode() VTK_OVERRIDE;
166 
167 // void Initialize(vtkMRMLScene* mrmlScene);
168 
170  double GetDistanceMeasurement();
171 
172 
174  vtkGetStringMacro(ModelID1);
175  vtkSetStringMacro(ModelID1);
176  vtkGetStringMacro(ModelID2);
177  vtkSetStringMacro(ModelID2);
178 
179  enum
180  {
181  RulerNodeAddedEvent = 20010,
183  };
184 
185 
186 protected:
191 
192  // Description:
193  // The format string that defines the text showing the distance
195 
196  int SetControlPoint(int id, double newControl[3]);
197 
198  int AddControlPoint(double newControl[3],int selectedFlag, int visibleFlag);
199 
202  char *ModelID1;
203  char *ModelID2;
204 };
205 
206 #endif
void GetPositionWorldCoordinates1(double position[4])
virtual void PrintAnnotationInfo(ostream &os, vtkIndent indent, int titleFlag=1) VTK_OVERRIDE
int AddControlPoint(double newControl[3], int selectedFlag, int visibleFlag)
void operator=(const vtkMRMLAnnotationLinesNode &)
virtual void ReadXMLAttributes(const char **atts) VTK_OVERRIDE
Read node attributes from XML file.
void GetPositionWorldCoordinates2(double position[4])
virtual const char * GetIcon() VTK_OVERRIDE
int SetPosition2(double newControl[3])
int SetControlPoint(int id, double newControl[3], int selectedFlag, int visibleFlag)
virtual void TransformPointToWorld(const double inLocal[3], double outWorld[3])
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE
Copy the node's attributes to this object.
virtual void WriteXML(ostream &of, int indent) VTK_OVERRIDE
Write this node's information to a MRML file in XML format.
int SetPosition2(double nC1, double nC2, double nC3)
int SetPosition1(double newControl[3])
A supercalss for other storage nodes.
double * GetControlPointCoordinates(vtkIdType id)
int SetPosition1(double nC1, double nC2, double nC3)
static vtkMRMLAnnotationLinesNode * New()
virtual void ApplyTransform(vtkAbstractTransform *transform) VTK_OVERRIDE
virtual vtkMRMLStorageNode * CreateDefaultStorageNode() VTK_OVERRIDE
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
virtual void ProcessMRMLEvents(vtkObject *, unsigned long, void *) VTK_OVERRIDE
alternative method to propagate events generated in Display nodes
void UpdateScene(vtkMRMLScene *scene) VTK_OVERRIDE
Finds the storage node and read the data.
int SetPositionWorldCoordinates2(double newControl[4])
virtual void TransformPointFromWorld(const double inWorld[3], double outLocal[3])
int SetPositionWorldCoordinates1(double newControl[4])