Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLMarkupsNode.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Portions (c) Copyright Brigham and Women's Hospital (BWH) All Rights Reserved.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 ==============================================================================*/
17 
18 #ifndef __vtkMRMLMarkupsNode_h
19 #define __vtkMRMLMarkupsNode_h
20 
21 // MRML includes
22 #include "vtkMRMLDisplayableNode.h"
23 
24 // Markups includes
25 #include "vtkSlicerMarkupsModuleMRMLExport.h"
26 
27 // VTK includes
28 #include <vtkSmartPointer.h>
29 #include <vtkVector.h>
30 
31 class vtkStringArray;
32 class vtkMatrix4x4;
33 
35 typedef struct
36 {
37  std::string ID;
38  std::string Label;
39  std::string Description;
40  std::string AssociatedNodeID;
41  std::vector < vtkVector3d> points;
42  double OrientationWXYZ[4];
43  bool Selected;
44  bool Locked;
45  bool Visibility;
46 } Markup;
47 
65 class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsNode : public vtkMRMLDisplayableNode
66 {
71 
72 public:
73  static vtkMRMLMarkupsNode *New();
75 
76  void PrintMarkup(ostream& os, vtkIndent indent, Markup *markup);
77  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
78 
79  virtual const char* GetIcon() {return "";};
80 
81  //--------------------------------------------------------------------------
82  // MRMLNode methods
83  //--------------------------------------------------------------------------
84 
85  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
87  virtual const char* GetNodeTagName() VTK_OVERRIDE {return "Markups";};
88 
90  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
91 
93  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
94 
99  virtual void WriteCLI(std::vector<std::string>& commandLine,
100  std::string prefix, int coordinateSystem = 0,
101  int multipleFlag = 1) VTK_OVERRIDE;
102 
104  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
105 
107  void UpdateScene(vtkMRMLScene *scene) VTK_OVERRIDE;
108 
110  virtual void ProcessMRMLEvents ( vtkObject * /*caller*/,
111  unsigned long /*event*/,
112  void * /*callData*/ ) VTK_OVERRIDE;
113 
114 
116  virtual vtkMRMLStorageNode* CreateDefaultStorageNode() VTK_OVERRIDE;
117 
119  int AddText(const char *newText);
120  void SetText(int id, const char *newText);
121  vtkStdString GetText(int id);
122  int DeleteText(int id);
123  int GetNumberOfTexts();
124  void RemoveAllTexts();
125 
138  enum
139  {
140  LockModifiedEvent = 19000,
149  };
150 
152  virtual void RemoveAllMarkups();
153 
155  vtkGetMacro(Locked, int);
163  void SetLocked(int locked);
166  vtkBooleanMacro(Locked, int);
167 
169  bool MarkupExists(int n);
171  int GetNumberOfMarkups();
173  bool PointExistsInMarkup(int p, int n);
175  int GetNumberOfPointsInNthMarkup(int n);
177  Markup * GetNthMarkup(int n);
179  void InitMarkup(Markup *markup);
182  int AddMarkup(Markup markup);
187  int AddMarkupWithNPoints(int n, std::string label = std::string(), vtkVector3d* point = NULL);
190  int AddPointToNewMarkup(vtkVector3d point, std::string label = std::string());
193  int AddPointWorldToNewMarkup(vtkVector3d point, std::string label = std::string());
195  int AddPointToNthMarkup(vtkVector3d point, int n);
196 
199  vtkVector3d GetMarkupPointVector(int markupIndex, int pointIndex);
202  void GetMarkupPoint(int markupIndex, int pointIndex, double point[3]);
204  void GetMarkupPointLPS(int markupIndex, int pointIndex, double point[3]);
208  int GetMarkupPointWorld(int markupIndex, int pointIndex, double worldxyz[4]);
209 
211  void RemoveMarkup(int m);
212 
217  bool InsertMarkup(Markup m, int targetIndex);
218 
220  void CopyMarkup(Markup *source, Markup *target);
221 
223  void SwapMarkups(int m1, int m2);
224 
227  void SetMarkupPointFromPointer(const int markupIndex, const int pointIndex, const double * pos);
230  void SetMarkupPointFromArray(const int markupIndex, const int pointIndex, const double pos[3]);
233  void SetMarkupPoint(const int markupIndex, const int pointIndex, const double x, const double y, const double z);
236  void SetMarkupPointLPS(const int markupIndex, const int pointIndex, const double x, const double y, const double z);
241  void SetMarkupPointWorld(const int markupIndex, const int pointIndex, const double x, const double y, const double z);
242 
244  void SetNthMarkupOrientationFromPointer(int n, const double *orientation);
246  void SetNthMarkupOrientationFromArray(int n, const double orientation[4]);
248  void SetNthMarkupOrientation(int n, double w, double x, double y, double z);
250  void GetNthMarkupOrientation(int n, double orientation[4]);
251 
253  std::string GetNthMarkupAssociatedNodeID(int n = 0);
254  void SetNthMarkupAssociatedNodeID(int n, std::string id);
255 
257  std::string GetNthMarkupID(int n = 0);
259  int GetMarkupIndexByID(const char* markupID);
261  Markup* GetMarkupByID(const char* markupID);
262 
265  bool GetNthMarkupSelected(int n = 0);
268  void SetNthMarkupSelected(int n, bool flag);
271  bool GetNthMarkupLocked(int n = 0);
278  void SetNthMarkupLocked(int n, bool flag);
281  bool GetNthMarkupVisibility(int n = 0);
289  void SetNthMarkupVisibility(int n, bool flag);
292  std::string GetNthMarkupLabel(int n = 0);
294  void SetNthMarkupLabel(int n, std::string label);
297  std::string GetNthMarkupDescription(int n = 0);
299  void SetNthMarkupDescription(int n, std::string description);
300 
301  // Transform utility functions
302 
305  virtual bool CanApplyNonLinearTransforms()const VTK_OVERRIDE;
308  virtual void ApplyTransform(vtkAbstractTransform* transform) VTK_OVERRIDE;
309 
312  std::string GetMarkupLabelFormat();
322  void SetMarkupLabelFormat(std::string format);
323 
328  std::string ReplaceListNameInMarkupLabelFormat();
329 
337  virtual bool GetModifiedSinceRead() VTK_OVERRIDE;
338 
342  bool ResetNthMarkupID(int n);
343 
344 protected:
348  void operator=(const vtkMRMLMarkupsNode&);
349 
350  vtkStringArray *TextList;
351 
355  void SetNthMarkupID(int n, std::string id);
356 
360  std::string GenerateUniqueMarkupID();;
361 
362 private:
365  std::vector < Markup > Markups;
366 
367  int Locked;
368 
369  std::string MarkupLabelFormat;
370 
371  // Keep track of the number of markups that were added to the list, always
372  // incrementing, not decreasing when they're removed. Used to help create
373  // unique names and ids. Reset to 0 when \sa RemoveAllMarkups called
374  int MaximumNumberOfMarkups;
375 };
376 
377 #endif
virtual const char * GetNodeTagName() VTK_OVERRIDE
Get node XML tag name (like Storage, Model)
LRU Cache.
virtual void WriteCLI(std::vector< std::string > &vtkNotUsed(commandLine), std::string vtkNotUsed(prefix), int vtkNotUsed(coordinateSystemFlag)=0, int vtkNotUsed(multipleFlag)=1)
std::string Description
see doxygen enabled comment in class description
virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE
Copy the node&#39;s attributes to this object.
static vtkMRMLMarkupsFiducialStorageNode * New()
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
MRML node to represent a list of markups Markups nodes contains a list of markups that each contain a...
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
virtual const char * GetIcon()
virtual void ReadXMLAttributes(const char **atts) VTK_OVERRIDE
Read node attributes from XML file
A superclass for other storage nodes.
std::string ID
virtual void WriteXML(ostream &of, int indent) VTK_OVERRIDE
Write this node&#39;s information to a MRML file in XML format.
virtual void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) VTK_OVERRIDE
Propagate Progress Event generated in ReadData
std::string AssociatedNodeID
virtual bool CanApplyNonLinearTransforms() const
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
std::vector< vtkVector3d > points
virtual vtkMRMLNode * CreateNodeInstance() VTK_OVERRIDE=0
MRMLNode methods.
virtual void UpdateScene(vtkMRMLScene *)
Definition: vtkMRMLNode.h:174
std::string Label