Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLMarkupsDisplayableManager2D.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 __vtkMRMLMarkupsDisplayableManager2D_h
19 #define __vtkMRMLMarkupsDisplayableManager2D_h
20 
21 // MarkupsModule includes
22 #include "vtkSlicerMarkupsModuleMRMLDisplayableManagerExport.h"
23 
24 // MarkupsModule/MRMLDisplayableManager includes
27 
28 // MRMLDisplayableManager includes
30 
31 // VTK includes
32 #include <vtkHandleWidget.h>
33 #include <vtkSeedWidget.h>
34 
35 class vtkMRMLMarkupsNode;
36 class vtkSlicerViewerWidget;
38 class vtkAbstractWidget;
39 
41 class VTK_SLICER_MARKUPS_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT vtkMRMLMarkupsDisplayableManager2D :
43 {
44 public:
45 
48  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
49 
52  void UpdateWidgetVisibility(vtkMRMLMarkupsNode* node);
53 
54  // the following functions must be public to be accessible by the callback
56  virtual void PropagateMRMLToWidget(vtkMRMLMarkupsNode* node, vtkAbstractWidget * widget);
58  virtual void PropagateWidgetToMRML(vtkAbstractWidget * widget, vtkMRMLMarkupsNode* node);
59 
65  bool RestrictDisplayCoordinatesToViewport(double* displayCoordinates);
66 
68  bool GetDisplayCoordinatesChanged(double * displayCoordinates1, double * displayCoordinates2);
69 
71  bool GetWorldCoordinatesChanged(double * worldCoordinates1, double * worldCoordinates2);
72 
74  void GetDisplayToWorldCoordinates(double x, double y, double * worldCoordinates);
75  void GetDisplayToWorldCoordinates(double * displayCoordinates, double * worldCoordinates);
76 
78  virtual void GetWorldToLocalCoordinates(vtkMRMLMarkupsNode *node,
79  double *worldCoordinates, double *localCoordinates);
80 
82  virtual void SetParentTransformToWidget(vtkMRMLMarkupsNode *vtkNotUsed(node), vtkAbstractWidget *vtkNotUsed(widget)){}
83 
85  vtkSetMacro(ScaleFactor2D, double);
86  vtkGetMacro(ScaleFactor2D, double);
87 
90  vtkAbstractWidget *AddWidget(vtkMRMLMarkupsNode *markupsNode);
91 
92  vtkMRMLMarkupsDisplayableManagerHelper * GetHelper() { return this->Helper; };
93 
97  bool IsInLightboxMode();
98 
102  int GetLightboxIndex(vtkMRMLMarkupsNode *node, int markupIndex, int pointIndex);
103 
106  virtual bool UpdateNthSeedPositionFromMRML(int vtkNotUsed(n),
107  vtkAbstractWidget *vtkNotUsed(widget),
108  vtkMRMLMarkupsNode *vtkNotUsed(markupsNode))
109  { return false; }
110 
113  virtual bool UpdateNthMarkupPositionFromWidget(int vtkNotUsed(n),
114  vtkMRMLMarkupsNode *vtkNotUsed(pointsNode),
115  vtkAbstractWidget *vtkNotUsed(widget))
116  { return false; }
117 
118 protected:
119 
122 
123  virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) VTK_OVERRIDE;
124 
126  virtual void RequestRender();
127 
129  virtual void RemoveMRMLObservers() VTK_OVERRIDE;
130 
133  virtual void UpdateFromMRML() VTK_OVERRIDE;
134 
135  virtual void SetMRMLSceneInternal(vtkMRMLScene* newScene) VTK_OVERRIDE;
136 
139  virtual void UpdateFromMRMLScene() VTK_OVERRIDE;
140  virtual void OnMRMLSceneEndClose() VTK_OVERRIDE;
141  virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node) VTK_OVERRIDE;
142  virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) VTK_OVERRIDE;
143 
145  virtual void OnMRMLDisplayableNodeModifiedEvent(vtkObject* caller) VTK_OVERRIDE;
146 
148  virtual void OnMRMLSliceNodeModifiedEvent() VTK_OVERRIDE;
149 
152  virtual bool IsWidgetDisplayableOnSlice(vtkMRMLMarkupsNode* node, int markupIndex = 0);
153 
155  void SetAndObserveNode(vtkMRMLMarkupsNode *markupsNode);
157  void SetAndObserveNodes();
158 
160  void AddObserversToInteractionNode();
161  void RemoveObserversFromInteractionNode();
162 
164  void OnMRMLMarkupsNodeModifiedEvent(vtkMRMLNode* node);
165  void OnMRMLMarkupsNodeTransformModifiedEvent(vtkMRMLNode* node);
166  void OnMRMLMarkupsNodeLockModifiedEvent(vtkMRMLNode* node);
167  void OnMRMLMarkupsDisplayNodeModifiedEvent(vtkMRMLNode *node);
168  void OnMRMLMarkupsPointModifiedEvent(vtkMRMLNode *node, int n);
170  virtual void OnMRMLMarkupsNodeMarkupAddedEvent(vtkMRMLMarkupsNode * vtkNotUsed(markupsNode), int vtkNotUsed(n)) {};
171  virtual void OnMRMLMarkupsNodeMarkupRemovedEvent(vtkMRMLMarkupsNode * vtkNotUsed(markupsNode), int vtkNotUsed(n)) {};
172  virtual void OnMRMLMarkupsNodeNthMarkupModifiedEvent(vtkMRMLMarkupsNode* vtkNotUsed(node), int vtkNotUsed(n)) {};
173 
174  //
175  // Handling of interaction within the RenderWindow
176  //
177 
178  // Get the coordinates of a click in the RenderWindow
179  void OnClickInRenderWindowGetCoordinates();
181  virtual void OnClickInRenderWindow(double x, double y, const char *associatedNodeID = NULL);
184 
186  virtual void UpdatePosition(vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLNode *vtkNotUsed(node)) {};
187 
188  //
189  // Seeds for widget placement
190  //
191 
193  virtual void PlaceSeed(double x, double y);
195  vtkHandleWidget * GetSeed(int index);
196 
197  //
198  // Coordinate Conversions
199  //
200 
202  void GetWorldToDisplayCoordinates(double r, double a, double s, double * displayCoordinates);
203  void GetWorldToDisplayCoordinates(double * worldCoordinates, double * displayCoordinates);
204 
206  void GetDisplayToViewportCoordinates(double x, double y, double * viewportCoordinates);
207  void GetDisplayToViewportCoordinates(double *displayCoordinates, double * viewportCoordinates);
208 
209  //
210  // Widget functionality
211  //
212 
214  virtual vtkAbstractWidget * CreateWidget(vtkMRMLMarkupsNode* node);
216  virtual void OnWidgetCreated(vtkAbstractWidget * widget, vtkMRMLMarkupsNode * node);
218  vtkAbstractWidget * GetWidget(vtkMRMLMarkupsNode * node);
219 
221  virtual bool IsCorrectDisplayableManager();
222 
227  virtual bool IsManageable(vtkMRMLNode* node);
232  virtual bool IsManageable(const char* nodeClassName);
233 
235  const char* Focus;
236 
238  int Updating;
239 
241  virtual void OnInteractorStyleEvent(int eventid) VTK_OVERRIDE;
242 
244  vtkGetMacro(DisableInteractorStyleEventsProcessing, int);
245 
247 
248  double LastClickWorldCoordinates[4];
249 
250 private:
251 
253  void operator=(const vtkMRMLMarkupsDisplayableManager2D&);
254 
255 
256  int DisableInteractorStyleEventsProcessing;
257 
258  vtkMRMLSliceNode * SliceNode;
259 
261  double ScaleFactor2D;
262 };
263 
264 #endif
virtual void RemoveMRMLObservers()
Remove MRML observers.
virtual bool UpdateNthSeedPositionFromMRML(int vtkNotUsed(n), vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLMarkupsNode *vtkNotUsed(markupsNode))
MRML node for storing a slice through RAS space.
vtkMRMLMarkupsClickCounter * ClickCounter
Counter for clicks in Render Window.
virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) VTK_OVERRIDE
MRML node to represent a list of markups Markups nodes contains a list of markups that each contain a...
virtual void UpdatePosition(vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLNode *vtkNotUsed(node))
Update just the position for the widget, implemented by subclasses.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
const char * Focus
Focus of this displayableManager is set to a specific markups type when inherited.
vtkMRMLMarkupsDisplayableManagerHelper * Helper
virtual void SetParentTransformToWidget(vtkMRMLMarkupsNode *vtkNotUsed(node), vtkAbstractWidget *vtkNotUsed(widget))
Set mrml parent transform to widgets.
virtual void OnMRMLMarkupsNodeNthMarkupModifiedEvent(vtkMRMLMarkupsNode *vtkNotUsed(node), int vtkNotUsed(n))
static vtkMRMLAbstractSliceViewDisplayableManager * New()
int Updating
Disable processing when updating is in progress.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual void OnMRMLMarkupsNodeMarkupRemovedEvent(vtkMRMLMarkupsNode *vtkNotUsed(markupsNode), int vtkNotUsed(n))
virtual bool UpdateNthMarkupPositionFromWidget(int vtkNotUsed(n), vtkMRMLMarkupsNode *vtkNotUsed(pointsNode), vtkAbstractWidget *vtkNotUsed(widget))
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
vtkMRMLMarkupsDisplayableManagerHelper * GetHelper()
virtual void OnInteractorStyleEvent(int eventid)