Slicer 5.9
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
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 // Description:
40 // Copy the node's attributes to this object
41 void Copy(vtkMRMLNode* node) override;
42
43 void UpdateScene(vtkMRMLScene* scene) override;
44
45 // Description:
46 // alternative method to propagate events generated in Display nodes
47 void ProcessMRMLEvents(vtkObject* /*caller*/, unsigned long /*event*/, void* /*callData*/) override;
48
49 // Get position of the first point
50 void GetPosition1(double position[3]);
51
52 // Get position of the first point in world coordinates, including parent transforms
53 void GetPositionWorldCoordinates1(double position[4])
54 {
55 double p[4] = { 0, 0, 0, 1 };
56 this->GetPosition1(p);
57 this->TransformPointToWorld(p, position);
58 }
59
60 // Legacy code
61 // Description:
62 // get/set the first point position
63 double* GetPosition1() { return this->GetControlPointCoordinates(0); }
64
65 int SetPosition1(double newControl[3]) { return this->SetControlPoint(0, newControl); }
66
67 int SetPositionWorldCoordinates1(double newControl[4])
68 {
69 double locPoint[4] = { 0, 0, 0, 1 };
70 this->TransformPointFromWorld(newControl, locPoint);
71 return this->SetPosition1(locPoint);
72 }
73
74 int SetPosition1(double nC1, double nC2, double nC3)
75 {
76 double newControl[3] = { nC1, nC2, nC3 };
77 return this->SetPosition1(newControl);
78 }
79
80 // Get position of the second point
81 void GetPosition2(double position[3]);
82
83 // Get position of the second point in world coordinates, including parent transforms
84 void GetPositionWorldCoordinates2(double position[4])
85 {
86 double p[4] = { 0, 0, 0, 1 };
87 this->GetPosition2(p);
88 this->TransformPointToWorld(p, position);
89 }
90
91 double* GetPosition2() { return this->GetControlPointCoordinates(1); }
92
93 int SetPosition2(double newControl[3]) { return this->SetControlPoint(1, newControl); }
94
95 int SetPositionWorldCoordinates2(double newControl[4])
96 {
97 double locPoint[4] = { 0, 0, 0, 1 };
98 this->TransformPointFromWorld(newControl, locPoint);
99 return this->SetPosition2(locPoint);
100 }
101
102 int SetPosition2(double nC1, double nC2, double nC3)
103 {
104 double newControl[3] = { nC1, nC2, nC3 };
105 return this->SetPosition2(newControl);
106 }
107
108 // Description:
109 // get/set the distance annotation format, it's in standard sprintf notation
110 vtkGetStringMacro(DistanceAnnotationFormat);
111 vtkSetStringMacro(DistanceAnnotationFormat);
112
113 // Description:
114 // KP Define - should be part of AnnotationRulerDisplayNode
116 void SetDistanceAnnotationScale(double init);
117
118 // Description:
119 // get/set the distance annotation visibility
122
123 int SetRuler(vtkIdType line1Id, int sel, int vis);
124
125 // Description:
126 // get/set the point representation color
127 double* GetPointColor();
128 void SetPointColor(double initColor[3]);
129
130 // Description:
131 // get/set the line representation color
132 double* GetLineColor();
133 void SetLineColor(double newColor[3]);
134
135 // Description:
136 // get/set the distance annotation text color
138 void SetDistanceAnnotationTextColor(double initColor[3]);
139
140 // Description:
141 // transform utility functions
142 void ApplyTransform(vtkAbstractTransform* transform) override;
143
144 // Description:
145 // Create default storage node or nullptr if does not have one
147
148 // void Initialize(vtkMRMLScene* mrmlScene);
149
152
154 vtkGetStringMacro(ModelID1);
155 vtkSetStringMacro(ModelID1);
156 vtkGetStringMacro(ModelID2);
157 vtkSetStringMacro(ModelID2);
158
159 enum
160 {
163 };
164
165protected:
170
171 // Description:
172 // The format string that defines the text showing the distance
174
175 int SetControlPoint(int id, double newControl[3]);
176
177 int AddControlPoint(double newControl[3], int selectedFlag, int visibleFlag);
178
181 char* ModelID1;
182 char* ModelID2;
183};
184
185#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])