Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
12class VTK_SLICER_ANNOTATIONS_MODULE_MRML_EXPORT vtkMRMLAnnotationRulerNode : public vtkMRMLAnnotationLinesNode
13{
14public:
17 // Description:
18 // Just prints short summary
19 void PrintAnnotationInfo(ostream& os, vtkIndent indent, int titleFlag = 1) override;
20
21 //--------------------------------------------------------------------------
22 // MRMLNode methods
23 //--------------------------------------------------------------------------
24
26 // Description:
27 // Get node XML tag name (like Volume, Model)
28 const char* GetNodeTagName() override {return "AnnotationRuler";}
29
30 const char* GetIcon() override {return ":/Icons/AnnotationDistance.png";}
31
32 // Description:
33 // Read node attributes from XML file
34 void ReadXMLAttributes( const char** atts) override;
35
36 // Description:
37 // Write this node's information to a MRML file in XML format.
38 void WriteXML(ostream& of, int indent) override;
39
40
41 // Description:
42 // Copy the node's attributes to this object
43 void Copy(vtkMRMLNode *node) override;
44
45 void UpdateScene(vtkMRMLScene *scene) override;
46
47 // Description:
48 // alternative method to propagate events generated in Display nodes
49 void ProcessMRMLEvents ( vtkObject * /*caller*/,
50 unsigned long /*event*/,
51 void * /*callData*/ ) 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 parent transforms
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 parent transforms
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
135 void SetDistanceAnnotationScale(double init);
136
137 // Description:
138 // get/set the distance annotation visibility
141
142 int SetRuler(vtkIdType line1Id, int sel, int vis);
143
144 // Description:
145 // get/set the point representation color
146 double *GetPointColor();
147 void SetPointColor( double initColor[3]);
148
149 // Description:
150 // get/set the line representation color
151 double *GetLineColor();
152 void SetLineColor(double newColor[3]);
153
154 // Description:
155 // get/set the distance annotation text color
157 void SetDistanceAnnotationTextColor(double initColor[3]);
158
159 // Description:
160 // transform utility functions
161 void ApplyTransform(vtkAbstractTransform* transform) override;
162
163 // Description:
164 // Create default storage node or nullptr if does not have one
166
167// void Initialize(vtkMRMLScene* mrmlScene);
168
171
172
174 vtkGetStringMacro(ModelID1);
175 vtkSetStringMacro(ModelID1);
176 vtkGetStringMacro(ModelID2);
177 vtkSetStringMacro(ModelID2);
178
179 enum
180 {
181 RulerNodeAddedEvent = 20010,
183 };
184
185
186protected:
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
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.