Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkSlicerAnnotationModuleLogic.h
Go to the documentation of this file.
1 #ifndef __vtkSlicerAnnotationModuleLogic_h
2 #define __vtkSlicerAnnotationModuleLogic_h
3 
4 // Slicer Logic includes
5 #include "vtkSlicerAnnotationsModuleLogicExport.h"
6 #include "vtkSlicerModuleLogic.h"
7 
8 // MRML includes
14 
15 // VTK includes
16 #include <vtkStdString.h>
17 
18 // STD includes
19 #include <string>
20 
22 class VTK_SLICER_ANNOTATIONS_MODULE_LOGIC_EXPORT vtkSlicerAnnotationModuleLogic
23  :public vtkSlicerModuleLogic
24 {
25 public:
26  enum Events{
27  RefreshRequestEvent = vtkCommand::UserEvent,
28  HierarchyNodeAddedEvent
29  };
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33 
36  void StartPlaceMode(bool persistent=false, vtkMRMLInteractionNode* interactionNode = nullptr);
37 
40  void StopPlaceMode(bool persistent=false, vtkMRMLInteractionNode* interactionNode = nullptr);
41 
42  // Start adding a new annotation Node
43  void AddAnnotationNode(const char * nodeDescriptor, bool persistent=false);
44 
45  // After a node was added, propagate to widget
46  void AddNodeCompleted(vtkMRMLAnnotationNode* annotationNode);
47 
50  void CancelCurrentOrRemoveLastAddedAnnotationNode(vtkMRMLInteractionNode* interactionNode = nullptr);
51 
53  void RemoveAnnotationNode(vtkMRMLAnnotationNode* annotationNode);
54 
55  //
56  // Annotation Properties (interface to MRML)
57  //
59  void RegisterNodes() override;
60 
62  bool IsAnnotationNode(const char* id);
63 
64  bool IsAnnotationHierarchyNode(const char* id);
65 
69  vtkMRMLAnnotationTextDisplayNode *GetTextDisplayNode(const char *id);
73  vtkMRMLAnnotationPointDisplayNode *GetPointDisplayNode(const char *id);
77  vtkMRMLAnnotationLineDisplayNode *GetLineDisplayNode(const char *id);
78 
80  const char * GetAnnotationName(const char * id);
81 
83  vtkStdString GetAnnotationText(const char* id);
85  void SetAnnotationText(const char* id, const char * newtext);
86 
88  double GetAnnotationTextScale(const char* id);
90  void SetAnnotationTextScale(const char* id, double textScale);
91 
93  double * GetAnnotationTextSelectedColor(const char* id);
95  void SetAnnotationTextSelectedColor(const char* id, double * color);
96 
98  double * GetAnnotationTextUnselectedColor(const char* id);
100  void SetAnnotationTextUnselectedColor(const char* id, double * color);
101 
103  double * GetAnnotationColor(const char *id);
105  void SetAnnotationColor(const char *id, double *color);
106 
108  double * GetAnnotationUnselectedColor(const char *id);
110  void SetAnnotationUnselectedColor(const char *id, double *color);
111 
113  double * GetAnnotationPointColor(const char *id);
115  void SetAnnotationPointColor(const char *id, double *color);
116 
118  double * GetAnnotationPointUnselectedColor(const char *id);
120  void SetAnnotationPointUnselectedColor(const char *id, double *color);
121 
124  const char * GetAnnotationPointGlyphTypeAsString(const char *id);
126  int GetAnnotationPointGlyphType(const char *id);
128  void SetAnnotationPointGlyphTypeFromString(const char *id, const char *glyphType);
130  void SetAnnotationPointGlyphType(const char *id, int glyphType);
131 
133  double * GetAnnotationLineColor(const char *id);
135  void SetAnnotationLineColor(const char *id, double *color);
136 
138  double * GetAnnotationLineUnselectedColor(const char *id);
140  void SetAnnotationLineUnselectedColor(const char *id, double *color);
141 
142 
144  const char * GetAnnotationMeasurement(const char * id, bool showUnits);
145 
147  const char * GetAnnotationIcon(const char * id);
148  const char * GetAnnotationIcon(vtkMRMLNode* mrmlNode);
149 
151  int GetAnnotationLockedUnlocked(const char * id);
153  void SetAnnotationLockedUnlocked(const char * id);
154 
156  int GetAnnotationVisibility(const char * id);
158  void SetAnnotationVisibility(const char * id);
159 
161  void SetAnnotationSelected(const char * id, bool selected);
163  void SetAllAnnotationsSelected(bool selected);
164 
166  void BackupAnnotationNode(const char * id);
168  void RestoreAnnotationNode(const char * id);
170  void DeleteBackupNodes(const char * id);
171 
173  void JumpSlicesToAnnotationCoordinate(const char* id);
174 
175  const char * MoveAnnotationUp(const char* id);
176  const char * MoveAnnotationDown(const char* id);
177 
178  //
179  // SnapShot functionality
180  //
182  void CreateSnapShot(const char* name, const char* description, int screenshotType, double scaleFactor, vtkImageData* screenshot);
183 
185  void ModifySnapShot(vtkStdString id, const char* name, const char* description, int screenshotType, double scaleFactor, vtkImageData* screenshot);
186 
188  vtkStdString GetSnapShotName(const char* id);
189 
191  vtkStdString GetSnapShotDescription(const char* id);
192 
194  int GetSnapShotScreenshotType(const char* id);
195 
197  double GetSnapShotScaleFactor(const char* id);
198 
200  vtkImageData* GetSnapShotScreenshot(const char* id);
201 
203  bool IsSnapshotNode(const char* id);
204 
205  //
206  // Hierarchy functionality
207  //
214  bool AddHierarchy();
215 
219  char * GetTopLevelHierarchyNodeID(vtkMRMLNode* node=nullptr);
220 
222  char * GetTopLevelHierarchyNodeIDForNodeClass(vtkMRMLAnnotationNode *annotationNode);
223 
225  vtkMRMLAnnotationHierarchyNode *GetActiveHierarchyNode();
226 
228  vtkGetStringMacro(ActiveHierarchyNodeID);
229  vtkSetStringMacro(ActiveHierarchyNodeID);
230 
232  void SetHierarchyAnnotationsVisibleFlag(vtkMRMLAnnotationHierarchyNode* hierarchyNode, bool flag);
234  void SetHierarchyAnnotationsLockFlag(vtkMRMLAnnotationHierarchyNode* hierarchyNode, bool flag);
235 
236  //
237  // Place Annotations programmatically
238  //
239 
240  //
241  // Report functionality
242  //
244  const char* GetHTMLRepresentation(vtkMRMLAnnotationNode* annotationNode, int level);
246  const char* GetHTMLRepresentation(vtkMRMLAnnotationHierarchyNode* hierarchyNode, int level);
247 
248 
251  const char* AddDisplayNodeForHierarchyNode(vtkMRMLAnnotationHierarchyNode *hnode);
252 
256  char *LoadAnnotation(const char *filename, const char *name, int fileType);
258  enum
259  {
260  None = 0,
264  };
265 
270  char *AddFiducial(double r=0.0, double a=0.0, double s=0.0, const char *label=nullptr);
271 
272 protected:
273 
275 
276  ~vtkSlicerAnnotationModuleLogic() override;
277 
278  // Initialize listening to MRML events
279  void SetMRMLSceneInternal(vtkMRMLScene * newScene) override;
280  void ObserveMRMLScene() override;
281 
282  // MRML events
283  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
284  void OnMRMLSceneEndClose() override;
285  void ProcessMRMLNodesEvents(vtkObject *caller,
286  unsigned long event,
287  void *callData ) override;
288  virtual void OnMRMLAnnotationNodeModifiedEvent(vtkMRMLNode* node);
289 
290 private:
291 
292  vtkMRMLAnnotationNode* m_LastAddedAnnotationNode;
293 
294  std::string m_StringHolder;
295 
296  char* m_MeasurementFormat;
297  char* m_CoordinateFormat;
298 
299  // id of the currently active hierarchy node
300  char *ActiveHierarchyNodeID;
301 
302  //
303  // Private hierarchy functionality.
304  //
311  bool AddHierarchyNodeForAnnotation(vtkMRMLAnnotationNode* annotationNode=nullptr);
312 
313 private:
315  void operator=(const vtkSlicerAnnotationModuleLogic&) = delete;
316 };
317 
318 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
static vtkSlicerModuleLogic * New()
The Usual vtk class functions.
virtual void OnMRMLSceneEndClose()
virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData)
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode *)
virtual void ObserveMRMLScene()
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167