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