Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLMarkupsDisplayableManager3D.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 __vtkMRMLMarkupsDisplayableManager3D_h
19 #define __vtkMRMLMarkupsDisplayableManager3D_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 vtkMRMLMarkupsDisplayableManager3D :
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);
60  bool GetDisplayCoordinatesChanged(double * displayCoordinates1, double * displayCoordinates2);
61 
63  bool GetWorldCoordinatesChanged(double * worldCoordinates1, double * worldCoordinates2);
64 
66  void GetDisplayToWorldCoordinates(double x, double y, double * worldCoordinates);
67  void GetDisplayToWorldCoordinates(double * displayCoordinates, double * worldCoordinates);
68 
70  virtual void GetWorldToLocalCoordinates(vtkMRMLMarkupsNode *node,
71  double *worldCoordinates, double *localCoordinates);
72 
74  virtual void SetParentTransformToWidget(vtkMRMLMarkupsNode *vtkNotUsed(node), vtkAbstractWidget *vtkNotUsed(widget)){};
75 
78  vtkAbstractWidget *AddWidget(vtkMRMLMarkupsNode *markupsNode);
79 
80 // vtkMRMLMarkupsDisplayableManagerHelper * GetHelper() { return this->Helper; };
81  vtkGetObjectMacro(Helper, vtkMRMLMarkupsDisplayableManagerHelper);
82 
83 protected:
84 
87 
88  virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) VTK_OVERRIDE;
89 
90 // virtual void Create();
91 
93  virtual void RequestRender();
94 
96  virtual void RemoveMRMLObservers() VTK_OVERRIDE;
97 
100  virtual void UpdateFromMRML() VTK_OVERRIDE;
101 
102  virtual void SetMRMLSceneInternal(vtkMRMLScene* newScene) VTK_OVERRIDE;
103 
106  virtual void UpdateFromMRMLScene() VTK_OVERRIDE;
107  virtual void OnMRMLSceneEndClose() VTK_OVERRIDE;
108  virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node) VTK_OVERRIDE;
109  virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) VTK_OVERRIDE;
110 
112  virtual void OnMRMLDisplayableNodeModifiedEvent(vtkObject* caller) VTK_OVERRIDE;
113 
115  void SetAndObserveNode(vtkMRMLMarkupsNode *markupsNode);
117  void SetAndObserveNodes();
118 
120  void AddObserversToInteractionNode();
121  void RemoveObserversFromInteractionNode();
122 
124  void OnMRMLMarkupsNodeModifiedEvent(vtkMRMLNode* node);
125  void OnMRMLMarkupsNodeTransformModifiedEvent(vtkMRMLNode* node);
126  void OnMRMLMarkupsNodeLockModifiedEvent(vtkMRMLNode* node);
127  void OnMRMLMarkupsDisplayNodeModifiedEvent(vtkMRMLNode *node);
128  void OnMRMLMarkupsPointModifiedEvent(vtkMRMLNode *node, int n);
131  virtual void OnMRMLMarkupsNodeMarkupAddedEvent(vtkMRMLMarkupsNode * vtkNotUsed(markupsNode), int vtkNotUsed(n)) {};
132  virtual void OnMRMLMarkupsNodeMarkupRemovedEvent(vtkMRMLMarkupsNode * vtkNotUsed(markupsNode), int vtkNotUsed(n)) {};
133  virtual void OnMRMLMarkupsNodeNthMarkupModifiedEvent(vtkMRMLMarkupsNode* vtkNotUsed(node), int vtkNotUsed(n)) {};
134 
135  //
136  // Handling of interaction within the RenderWindow
137  //
138 
139  // Get the coordinates of a click in the RenderWindow
140  void OnClickInRenderWindowGetCoordinates();
142  virtual void OnClickInRenderWindow(double x, double y, const char *associatedNodeID = NULL);
145 
148  virtual bool UpdateNthSeedPositionFromMRML(int vtkNotUsed(n),
149  vtkAbstractWidget *vtkNotUsed(widget),
150  vtkMRMLMarkupsNode *vtkNotUsed(markupsNode))
151  { return false; }
153  virtual void UpdatePosition(vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLNode *vtkNotUsed(node)) {}
154 
155  //
156  // Seeds for widget placement
157  //
158 
160  virtual void PlaceSeed(double x, double y);
162  vtkHandleWidget * GetSeed(int index);
163 
164  //
165  // Coordinate Conversions
166  //
167 
169  void GetWorldToDisplayCoordinates(double r, double a, double s, double * displayCoordinates);
170  void GetWorldToDisplayCoordinates(double * worldCoordinates, double * displayCoordinates);
171 
173  void GetDisplayToViewportCoordinates(double x, double y, double * viewportCoordinates);
174  void GetDisplayToViewportCoordinates(double *displayCoordinates, double * viewportCoordinates);
175 
176  //
177  // Widget functionality
178  //
179 
181  virtual vtkAbstractWidget * CreateWidget(vtkMRMLMarkupsNode* node);
183  virtual void OnWidgetCreated(vtkAbstractWidget * widget, vtkMRMLMarkupsNode * node);
185  vtkAbstractWidget * GetWidget(vtkMRMLMarkupsNode * node);
186 
188  virtual bool IsCorrectDisplayableManager();
189 
194  virtual bool IsManageable(vtkMRMLNode* node);
199  virtual bool IsManageable(const char* nodeClassName);
200 
202  const char* Focus;
203 
205  int Updating;
206 
208  virtual void OnInteractorStyleEvent(int eventid) VTK_OVERRIDE;
209 
211  vtkGetMacro(DisableInteractorStyleEventsProcessing, int);
212 
214 
215  double LastClickWorldCoordinates[4];
216 
217 private:
218 
220  void operator=(const vtkMRMLMarkupsDisplayableManager3D&);
221 
222 
223  int DisableInteractorStyleEventsProcessing;
224 
225 };
226 
227 #endif
virtual void UpdatePosition(vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLNode *vtkNotUsed(node))
Update just the position for the widget, implemented by subclasses.
virtual void RemoveMRMLObservers()
Remove MRML observers.
virtual void SetParentTransformToWidget(vtkMRMLMarkupsNode *vtkNotUsed(node), vtkAbstractWidget *vtkNotUsed(widget))
Set mrml parent transform to widgets.
int Updating
Disable processing when updating is in progress.
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...
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
static vtkMRMLAbstractThreeDViewDisplayableManager * New()
virtual void OnMRMLMarkupsNodeMarkupRemovedEvent(vtkMRMLMarkupsNode *vtkNotUsed(markupsNode), int vtkNotUsed(n))
vtkMRMLMarkupsDisplayableManagerHelper * Helper
const char * Focus
Focus of this displayableManager is set to a specific markups type when inherited.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
vtkMRMLMarkupsClickCounter * ClickCounter
Counter for clicks in Render Window.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
virtual void OnMRMLMarkupsNodeNthMarkupModifiedEvent(vtkMRMLMarkupsNode *vtkNotUsed(node), int vtkNotUsed(n))
virtual void OnInteractorStyleEvent(int eventid)
virtual bool UpdateNthSeedPositionFromMRML(int vtkNotUsed(n), vtkAbstractWidget *vtkNotUsed(widget), vtkMRMLMarkupsNode *vtkNotUsed(markupsNode))