Slicer  5.0
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) 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  bool CanProcessInteractionEvent(vtkMRMLInteractionEventData* eventData, double &closestDistance2) override;
104  bool ProcessInteractionEvent(vtkMRMLInteractionEventData* eventData) override;
105 
106 protected:
107 
110 
111  void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) override;
112 
113  void Create() override;
114 
116  virtual void RequestRender();
117 
119  void RemoveMRMLObservers() override;
120 
123  void UpdateFromMRML() override;
124 
125  void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
126 
129  void UpdateFromMRMLScene() override;
130  void OnMRMLSceneEndClose() override;
131  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
132  void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) override;
133 
135  void OnMRMLDisplayableNodeModifiedEvent(vtkObject* caller) override;
136 
138  virtual void OnMRMLSliceNodeModifiedEvent(vtkMRMLSliceNode * sliceNode);
139 
141  virtual bool IsWidgetDisplayable(vtkMRMLSliceNode * sliceNode, vtkMRMLAnnotationNode* node);
142 
144  void SetAndObserveNode(vtkMRMLAnnotationNode *annotationNode);
146  void SetAndObserveNodes();
147 
149  void AddObserversToInteractionNode();
150  void RemoveObserversFromInteractionNode();
151 
157  void AddObserversToSelectionNode();
158  void RemoveObserversFromSelectionNode();
159 
161  virtual void OnMRMLAnnotationNodeModifiedEvent(vtkMRMLNode* node);
162  virtual void OnMRMLAnnotationNodeTransformModifiedEvent(vtkMRMLNode* node);
163  virtual void OnMRMLAnnotationNodeLockModifiedEvent(vtkMRMLNode* node);
164  virtual void OnMRMLAnnotationDisplayNodeModifiedEvent(vtkMRMLNode *node);
165  virtual void OnMRMLAnnotationControlPointModifiedEvent(vtkMRMLNode *node);
167 
168  //
169  // Handling of interaction within the RenderWindow
170  //
171 
172  // Get the coordinates of a click in the RenderWindow
173  void OnClickInRenderWindowGetCoordinates();
175  virtual void OnClickInRenderWindow(double x, double y, const char *associatedNodeID = nullptr);
178 
180  virtual void UpdatePosition(vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLNode *vtkNotUsed(node)) {}
181  //
182  // Seeds for widget placement
183  //
184 
186  virtual void PlaceSeed(double x, double y);
188  vtkHandleWidget * GetSeed(int index);
189 
190  //
191  // Coordinate Conversions
192  //
193 
195 // void GetDisplayToWorldCoordinates(double x, double y, double * worldCoordinates);
196 // void GetDisplayToWorldCoordinates(double * displayCoordinates, double * worldCoordinates);
197 
199  void GetWorldToDisplayCoordinates(double r, double a, double s, double * displayCoordinates);
200  void GetWorldToDisplayCoordinates(double * worldCoordinates, double * displayCoordinates);
201 
203  void GetDisplayToViewportCoordinates(double x, double y, double * viewportCoordinates);
204  void GetDisplayToViewportCoordinates(double *displayCoordinates, double * viewportCoordinates);
205 
206  //
207  // Widget functionality
208  //
209 
211  virtual vtkAbstractWidget * CreateWidget(vtkMRMLAnnotationNode* node);
213  virtual void OnWidgetCreated(vtkAbstractWidget * widget, vtkMRMLAnnotationNode * node);
215  vtkAbstractWidget * GetWidget(vtkMRMLAnnotationNode * node);
216 
218  bool IsCorrectDisplayableManager();
219 
224  virtual bool IsManageable(vtkMRMLNode* node);
229  virtual bool IsManageable(const char* nodeClassName);
230 
232  const char* m_Focus;
233 
236 
238  void OnInteractorStyleEvent(int eventid) override;
239 
241  vtkGetMacro(DisableInteractorStyleEventsProcessing, int);
242 
244 
245  double LastClickWorldCoordinates[4];
246 
247 private:
248 
250  void operator=(const vtkMRMLAnnotationDisplayableManager&) = delete;
251 
252 
253  int DisableInteractorStyleEventsProcessing;
254 
256  double ScaleFactor2D;
257 };
258 
259 #endif
Superclass for displayable manager classes.
virtual void RemoveMRMLObservers()
Remove MRML observers.
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void OnMRMLSceneEndClose()
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 OnMRMLDisplayableNodeModifiedEvent(vtkObject *caller)
int m_Updating
Disable processing when updating is in progress.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
virtual bool ProcessInteractionEvent(vtkMRMLInteractionEventData *eventData)
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode *)
virtual void OnMRMLSelectionNodeUnitModifiedEvent(vtkMRMLSelectionNode *)
virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode *)
void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) override
void SetMRMLSceneInternal(vtkMRMLScene *newScene) override
vtkMRMLAnnotationDisplayableManagerHelper * Helper
virtual bool CanProcessInteractionEvent(vtkMRMLInteractionEventData *eventData, double &distance2)
const char * m_Focus
Focus of this displayableManager is set to a specific annotation type when inherited.
virtual void UpdateFromMRMLScene()
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
MRML node for storing information about the active nodes in the scene.
virtual void UpdatePosition(vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLNode *vtkNotUsed(node))
Update just the position for the widget, implemented by subclasses.
virtual void OnInteractorStyleEvent(int eventid)