Slicer 4.2
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.
00001 #ifndef __vtkSlicerAnnotationModuleLogic_h
00002 #define __vtkSlicerAnnotationModuleLogic_h
00003 
00004 // Slicer Logic includes
00005 #include "vtkSlicerAnnotationsModuleLogicExport.h"
00006 #include "vtkSlicerModuleLogic.h"
00007 
00008 // MRML includes
00009 class vtkMRMLAnnotationHierarchyNode;
00010 class vtkMRMLAnnotationLineDisplayNode;
00011 class vtkMRMLAnnotationNode;
00012 class vtkMRMLAnnotationPointDisplayNode;
00013 class vtkMRMLAnnotationTextDisplayNode;
00014 
00015 // STD includes
00016 #include <string>
00017 
00019 class VTK_SLICER_ANNOTATIONS_MODULE_LOGIC_EXPORT vtkSlicerAnnotationModuleLogic
00020   :public vtkSlicerModuleLogic
00021 {
00022 public:
00023   enum Events{
00024     RefreshRequestEvent = vtkCommand::UserEvent,
00025     HierarchyNodeAddedEvent
00026   };
00027   static vtkSlicerAnnotationModuleLogic *New();
00028   vtkTypeRevisionMacro(vtkSlicerAnnotationModuleLogic,vtkSlicerModuleLogic);
00029   virtual void PrintSelf(ostream& os, vtkIndent indent);
00030 
00031   // Start the place mode for annotations
00032   void StartPlaceMode(bool persistent=false);
00033 
00034   // Exit the place mode for annotations
00035   void StopPlaceMode(bool persistent=false);
00036 
00037   // Start adding a new annotation Node
00038   void AddAnnotationNode(const char * nodeDescriptor, bool persistent=false);
00039 
00040   // After a node was added, propagate to widget
00041   void AddNodeCompleted(vtkMRMLAnnotationNode* annotationNode);
00042 
00043   // Cancel the current annotation placement or remove last annotation node
00044   void CancelCurrentOrRemoveLastAddedAnnotationNode();
00045 
00047   void RemoveAnnotationNode(vtkMRMLAnnotationNode* annotationNode);
00048 
00049   //
00050   // Annotation Properties (interface to MRML)
00051   //
00053   virtual void RegisterNodes();
00054 
00056   bool IsAnnotationNode(const char* id);
00057 
00058   bool IsAnnotationHierarchyNode(const char* id);
00059 
00063   vtkMRMLAnnotationTextDisplayNode *GetTextDisplayNode(const char *id);
00067   vtkMRMLAnnotationPointDisplayNode *GetPointDisplayNode(const char *id);
00071   vtkMRMLAnnotationLineDisplayNode *GetLineDisplayNode(const char *id);
00072   
00074   const char * GetAnnotationName(const char * id);
00075 
00077   vtkStdString GetAnnotationText(const char* id);
00079   void SetAnnotationText(const char* id, const char * newtext);
00080 
00082   double GetAnnotationTextScale(const char* id);
00084   void SetAnnotationTextScale(const char* id, double textScale);
00085 
00087   double * GetAnnotationTextSelectedColor(const char* id);
00089   void SetAnnotationTextSelectedColor(const char* id, double * color);
00090 
00092   double * GetAnnotationTextUnselectedColor(const char* id);
00094   void SetAnnotationTextUnselectedColor(const char* id, double * color);
00095 
00097   double * GetAnnotationColor(const char *id);
00099   void SetAnnotationColor(const char *id, double *color);
00100 
00102   double * GetAnnotationUnselectedColor(const char *id);
00104   void SetAnnotationUnselectedColor(const char *id, double *color);
00105 
00107   double * GetAnnotationPointColor(const char *id);
00109   void SetAnnotationPointColor(const char *id, double *color);
00110 
00112   double * GetAnnotationPointUnselectedColor(const char *id);
00114   void SetAnnotationPointUnselectedColor(const char *id, double *color);
00115 
00118   const char * GetAnnotationPointGlyphTypeAsString(const char *id);
00120   int GetAnnotationPointGlyphType(const char *id);
00122   void SetAnnotationPointGlyphTypeFromString(const char *id, const char *glyphType);
00124   void SetAnnotationPointGlyphType(const char *id, int glyphType);
00125   
00127   double * GetAnnotationLineColor(const char *id);
00129   void SetAnnotationLineColor(const char *id, double *color);
00130 
00132   double * GetAnnotationLineUnselectedColor(const char *id);
00134   void SetAnnotationLineUnselectedColor(const char *id, double *color);
00135 
00136   
00138   const char * GetAnnotationMeasurement(const char * id, bool showUnits);
00139 
00141   const char * GetAnnotationIcon(const char * id);
00142   const char * GetAnnotationIcon(vtkMRMLNode* mrmlNode);
00143 
00145   int GetAnnotationLockedUnlocked(const char * id);
00147   void SetAnnotationLockedUnlocked(const char * id);
00148 
00150   int GetAnnotationVisibility(const char * id);
00152   void SetAnnotationVisibility(const char * id);
00153 
00155   void SetAnnotationSelected(const char * id, bool selected);
00157   void SetAllAnnotationsSelected(bool selected);
00158   
00160   void BackupAnnotationNode(const char * id);
00162   void RestoreAnnotationNode(const char * id);
00164   void DeleteBackupNodes(const char * id);
00165 
00167   void JumpSlicesToAnnotationCoordinate(const char* id);
00168 
00169   const char * MoveAnnotationUp(const char* id);
00170   const char * MoveAnnotationDown(const char* id);
00171 
00172   //
00173   // SnapShot functionality
00174   //
00177   void CreateSnapShot(const char* name, const char* description, int screenshotType, double scaleFactor, vtkImageData* screenshot);
00178 
00180   void ModifySnapShot(vtkStdString id, const char* name, const char* description, int screenshotType, double scaleFactor, vtkImageData* screenshot);
00181 
00183   vtkStdString GetSnapShotName(const char* id);
00184 
00186   vtkStdString GetSnapShotDescription(const char* id);
00187 
00189   int GetSnapShotScreenshotType(const char* id);
00190 
00192   double GetSnapShotScaleFactor(const char* id);
00193 
00195   vtkImageData* GetSnapShotScreenshot(const char* id);
00196 
00198   bool IsSnapshotNode(const char* id);
00199 
00200   //
00201   // Hierarchy functionality
00202   //
00209   bool AddHierarchy();
00210 
00214   char * GetTopLevelHierarchyNodeID(vtkMRMLNode* node=0);
00215 
00217   char * GetTopLevelHierarchyNodeIDForNodeClass(vtkMRMLAnnotationNode *annotationNode);
00218 
00220   vtkMRMLAnnotationHierarchyNode *GetActiveHierarchyNode();
00221 
00223   vtkGetStringMacro(ActiveHierarchyNodeID);
00224   vtkSetStringMacro(ActiveHierarchyNodeID);
00225 
00227   void SetHierarchyAnnotationsVisibleFlag(vtkMRMLAnnotationHierarchyNode* hierarchyNode, bool flag);
00229   void SetHierarchyAnnotationsLockFlag(vtkMRMLAnnotationHierarchyNode* hierarchyNode, bool flag);
00230 
00231   //
00232   // Place Annotations programmatically
00233   //
00234 
00235   //
00236   // Report functionality
00237   //
00239   const char* GetHTMLRepresentation(vtkMRMLAnnotationNode* annotationNode, int level);
00241   const char* GetHTMLRepresentation(vtkMRMLAnnotationHierarchyNode* hierarchyNode, int level);
00242 
00243 
00246   const char* AddDisplayNodeForHierarchyNode(vtkMRMLAnnotationHierarchyNode *hnode);
00247 
00250   char *LoadFiducialList(const char *filename);
00251   
00255   char *LoadAnnotation(const char *filename, const char *name, int fileType);
00257   enum
00258   {
00259     None = 0,
00260     Fiducial,
00261     Ruler,
00262     ROI,
00263   };
00264 
00265   
00266 protected:
00267 
00268   vtkSlicerAnnotationModuleLogic();
00269 
00270   virtual ~vtkSlicerAnnotationModuleLogic();
00271 
00272   // Initialize listening to MRML events
00273   virtual void SetMRMLSceneInternal(vtkMRMLScene * newScene);
00274   virtual void ObserveMRMLScene();
00275 
00276   // MRML events
00277   virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node);
00278   virtual void OnMRMLSceneEndClose();
00279   virtual void ProcessMRMLNodesEvents(vtkObject *caller,
00280                                       unsigned long event,
00281                                       void *callData );
00282   virtual void OnMRMLAnnotationNodeModifiedEvent(vtkMRMLNode* node);
00283   virtual void OnInteractionModeChangedEvent(vtkMRMLInteractionNode *interactionNode);
00284   virtual void OnInteractionModePersistenceChangedEvent(vtkMRMLInteractionNode *interactionNode);
00285 
00286 private:
00287 
00288   vtkMRMLAnnotationNode* m_LastAddedAnnotationNode;
00289 
00290   std::string m_StringHolder;
00291 
00292   char* m_MeasurementFormat;
00293   char* m_CoordinateFormat;
00294 
00295   // id of the currently active hierarchy node
00296   char *ActiveHierarchyNodeID;
00297 
00298   //
00299   // Private hierarchy functionality.
00300   //
00307   bool AddHierarchyNodeForAnnotation(vtkMRMLAnnotationNode* annotationNode=0);
00308 
00309 
00310 };
00311 
00312 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines