Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLAnnotationDisplayableManager.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8  Program: 3D Slicer
9 
10  Module: $RCSfile: vtkMRMLAnnotationDisplayableManager.h,v $
11  Date: $Date: 2010/07/26 04:48:05 $
12  Version: $Revision: 1.2 $
13 
14  =========================================================================auto=*/
15 
16 #ifndef __vtkMRMLAnnotationDisplayableManager_h
17 #define __vtkMRMLAnnotationDisplayableManager_h
18 
19 // Annotations includes
20 #include "vtkSlicerAnnotationsModuleMRMLDisplayableManagerExport.h"
27 class vtkSlicerViewerWidget;
28 
29 // MRMLDisplayableManager includes
31 
32 // MRML includes
33 class vtkMRMLSliceNode;
34 
35 // VTK includes
36 class vtkAbstractWidget;
37 class vtkHandleWidget;
38 class vtkSeedWidget;
39 
41 class VTK_SLICER_ANNOTATIONS_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT
44 {
45 public:
46 
49  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
50 
51  // the following functions must be public to be accessible by the callback
53  virtual void PropagateMRMLToWidget(vtkMRMLAnnotationNode* node, vtkAbstractWidget * widget);
55  virtual void PropagateWidgetToMRML(vtkAbstractWidget * widget, vtkMRMLAnnotationNode* node);
59  virtual bool Is2DDisplayableManager();
61  vtkMRMLSliceNode * GetSliceNode();
62 
64  void RestrictDisplayCoordinatesToViewport(double* displayCoordinates);
65 
67  bool GetDisplayCoordinatesChanged(double * displayCoordinates1, double * displayCoordinates2);
68 
70  bool GetWorldCoordinatesChanged(double * worldCoordinates1, double * worldCoordinates2);
71 
73  void GetDisplayToWorldCoordinates(double x, double y, double * worldCoordinates);
74  void GetDisplayToWorldCoordinates(double * displayCoordinates, double * worldCoordinates);
75 
77  virtual void GetWorldToLocalCoordinates(vtkMRMLAnnotationNode *node,
78  double *worldCoordinates, double *localCoordinates);
79 
81  virtual void SetParentTransformToWidget(vtkMRMLAnnotationNode *vtkNotUsed(node), vtkAbstractWidget *vtkNotUsed(widget)){}
82 
84  vtkSetMacro(ScaleFactor2D, double);
85  vtkGetMacro(ScaleFactor2D, double);
86 
89  bool IsInLightboxMode();
90 
95  int GetLightboxIndex(vtkMRMLAnnotationNode *node, int controlPointIndex = 0);
96 
101  bool AddAnnotation(vtkMRMLAnnotationNode *node);
102 
103 protected:
104 
107 
108  virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) VTK_OVERRIDE;
109 
110  virtual void Create() VTK_OVERRIDE;
111 
113  virtual void RequestRender();
114 
116  virtual void RemoveMRMLObservers() VTK_OVERRIDE;
117 
120  virtual void UpdateFromMRML() VTK_OVERRIDE;
121 
122  virtual void SetMRMLSceneInternal(vtkMRMLScene* newScene) VTK_OVERRIDE;
123 
126  virtual void UpdateFromMRMLScene() VTK_OVERRIDE;
127  virtual void OnMRMLSceneEndClose() VTK_OVERRIDE;
128  virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node) VTK_OVERRIDE;
129  virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) VTK_OVERRIDE;
130 
132  virtual void OnMRMLDisplayableNodeModifiedEvent(vtkObject* caller) VTK_OVERRIDE;
133 
135  virtual void OnMRMLSliceNodeModifiedEvent(vtkMRMLSliceNode * sliceNode);
136 
138  virtual bool IsWidgetDisplayable(vtkMRMLSliceNode * sliceNode, vtkMRMLAnnotationNode* node);
139 
141  void SetAndObserveNode(vtkMRMLAnnotationNode *annotationNode);
143  void SetAndObserveNodes();
144 
146  void AddObserversToInteractionNode();
147  void RemoveObserversFromInteractionNode();
148 
154  void AddObserversToSelectionNode();
155  void RemoveObserversFromSelectionNode();
156 
158  virtual void OnMRMLAnnotationNodeModifiedEvent(vtkMRMLNode* node);
159  virtual void OnMRMLAnnotationNodeTransformModifiedEvent(vtkMRMLNode* node);
160  virtual void OnMRMLAnnotationNodeLockModifiedEvent(vtkMRMLNode* node);
161  virtual void OnMRMLAnnotationDisplayNodeModifiedEvent(vtkMRMLNode *node);
162  virtual void OnMRMLAnnotationControlPointModifiedEvent(vtkMRMLNode *node);
163  virtual void OnMRMLSelectionNodeUnitModifiedEvent(vtkMRMLSelectionNode*) {}
164 
165  //
166  // Handling of interaction within the RenderWindow
167  //
168 
169  // Get the coordinates of a click in the RenderWindow
170  void OnClickInRenderWindowGetCoordinates();
172  virtual void OnClickInRenderWindow(double x, double y, const char *associatedNodeID = NULL);
175 
177  virtual void UpdatePosition(vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLNode *vtkNotUsed(node)) {}
178  //
179  // Seeds for widget placement
180  //
181 
183  virtual void PlaceSeed(double x, double y);
185  vtkHandleWidget * GetSeed(int index);
186 
187  //
188  // Coordinate Conversions
189  //
190 
192 // void GetDisplayToWorldCoordinates(double x, double y, double * worldCoordinates);
193 // void GetDisplayToWorldCoordinates(double * displayCoordinates, double * worldCoordinates);
194 
196  void GetWorldToDisplayCoordinates(double r, double a, double s, double * displayCoordinates);
197  void GetWorldToDisplayCoordinates(double * worldCoordinates, double * displayCoordinates);
198 
200  void GetDisplayToViewportCoordinates(double x, double y, double * viewportCoordinates);
201  void GetDisplayToViewportCoordinates(double *displayCoordinates, double * viewportCoordinates);
202 
203  //
204  // Widget functionality
205  //
206 
208  virtual vtkAbstractWidget * CreateWidget(vtkMRMLAnnotationNode* node);
210  virtual void OnWidgetCreated(vtkAbstractWidget * widget, vtkMRMLAnnotationNode * node);
212  vtkAbstractWidget * GetWidget(vtkMRMLAnnotationNode * node);
213 
215  bool IsCorrectDisplayableManager();
216 
221  virtual bool IsManageable(vtkMRMLNode* node);
226  virtual bool IsManageable(const char* nodeClassName);
227 
229  const char* m_Focus;
230 
233 
235  virtual void OnInteractorStyleEvent(int eventid) VTK_OVERRIDE;
236 
238  vtkGetMacro(DisableInteractorStyleEventsProcessing, int);
239 
241 
242  double LastClickWorldCoordinates[4];
243 
244 private:
245 
247  void operator=(const vtkMRMLAnnotationDisplayableManager&);
248 
249 
250  int DisableInteractorStyleEventsProcessing;
251 
253  double ScaleFactor2D;
254 };
255 
256 #endif
Superclass for displayable manager classes.
virtual void SetParentTransformToWidget(vtkMRMLAnnotationNode *vtkNotUsed(node), vtkAbstractWidget *vtkNotUsed(widget))
Set mrml parent transform to widgets.
static vtkMRMLAbstractDisplayableManager * New()
vtkMRMLAnnotationClickCounter * m_ClickCounter
Counter for clicks in Render Window.
MRML node for storing a slice through RAS space.
virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) VTK_OVERRIDE
int m_Updating
Disable processing when updating is in progress.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
vtkMRMLAnnotationDisplayableManagerHelper * Helper
const char * m_Focus
Focus of this displayableManager is set to a specific annotation type when inherited.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
MRML node for storing information about the active nodes in the scene.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual void UpdatePosition(vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLNode *vtkNotUsed(node))
Update just the position for the widget, implemented by subclasses.
virtual void OnInteractorStyleEvent(int eventid)