Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLMarkupsDisplayableManager.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 __vtkMRMLMarkupsDisplayableManager_h
19 #define __vtkMRMLMarkupsDisplayableManager_h
20 
21 // MarkupsModule includes
22 #include "vtkSlicerMarkupsModuleMRMLDisplayableManagerExport.h"
23 
24 // MarkupsModule/MRMLDisplayableManager includes
26 
27 // MRMLDisplayableManager includes
29 
30 // VTK includes
31 #include <vtkSlicerMarkupsWidget.h>
32 
33 // STD includes
34 #include <map>
35 
36 class vtkMRMLMarkupsNode;
37 class vtkSlicerViewerWidget;
39 class vtkAbstractWidget;
40 
42 class VTK_SLICER_MARKUPS_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT vtkMRMLMarkupsDisplayableManager :
44 {
45 public:
46 
47  // Allow the helper to call protected methods of displayable manager
49 
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
57  virtual bool Is2DDisplayableManager();
59  vtkMRMLSliceNode * GetMRMLSliceNode();
60 
61  vtkMRMLMarkupsDisplayableManagerHelper * GetHelper() { return this->Helper; };
62 
63  bool CanProcessInteractionEvent(vtkMRMLInteractionEventData* eventData, double &closestDistance2) override;
64  bool ProcessInteractionEvent(vtkMRMLInteractionEventData* eventData) override;
65 
66  void SetHasFocus(bool hasFocus, vtkMRMLInteractionEventData* eventData) override;
67  bool GetGrabFocus() override;
68  bool GetInteractive() override;
69  int GetMouseCursor() override;
70 
71  // Updates markup point preview position.
72  // Returns true if the event is processed.
73  vtkSlicerMarkupsWidget* GetWidgetForPlacement();
74 
75  vtkMRMLMarkupsNode* GetActiveMarkupsNodeForPlacement();
76 
77  int GetCurrentInteractionMode();
78 
79  // Methods from vtkMRMLAbstractSliceViewDisplayableManager
80 
84  void ConvertDeviceToXYZ(double x, double y, double xyz[3]);
85 
88 
89 protected:
90 
93 
94  vtkSlicerMarkupsWidget* FindClosestWidget(vtkMRMLInteractionEventData *callData, double &closestDistance2);
95 
96  void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) override;
97 
99  virtual void RequestRender();
100 
103  void UpdateFromMRML() override;
104 
105  void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
106 
109  void UpdateFromMRMLScene() override;
110  void OnMRMLSceneEndClose() override;
111  void OnMRMLSceneEndImport() override;
112  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
113  void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) override;
114 
117 
119  void OnMRMLDisplayableNodeModifiedEvent(vtkObject* caller) override;
120 
122  virtual void OnMRMLSliceNodeModifiedEvent();
123 
125  void AddObserversToInteractionNode();
126  void RemoveObserversFromInteractionNode();
127 
129  virtual bool IsCorrectDisplayableManager();
130 
135  virtual bool IsManageable(vtkMRMLNode* node);
140  virtual bool IsManageable(const char* nodeClassName);
141 
143  void OnInteractorStyleEvent(int eventid) override;
144 
146  vtkGetMacro(DisableInteractorStyleEventsProcessing, int);
147 
148  vtkSmartPointer<vtkMRMLMarkupsDisplayableManagerHelper> Helper;
149 
150  double LastClickWorldCoordinates[4];
151 
152  vtkWeakPointer<vtkSlicerMarkupsWidget> LastActiveWidget;
153 
154 private:
156  void operator=(const vtkMRMLMarkupsDisplayableManager&) = delete;
157 
158  int DisableInteractorStyleEventsProcessing;
159 
160  // by default, this displayableManager handles a 2d view, so the SliceNode
161  // must be set when it's assigned to a viewer
162  vtkWeakPointer<vtkMRMLSliceNode> SliceNode;
163 };
164 
165 #endif
virtual bool GetInteractive()
Displayable manager can indicate that the window is in interactive mode (faster updates).
Superclass for displayable manager classes.
virtual void OnMRMLSceneEndImport()
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void OnMRMLSceneEndClose()
vtkSmartPointer< vtkMRMLMarkupsDisplayableManagerHelper > Helper
static vtkMRMLAbstractDisplayableManager * New()
MRML node for storing a slice through RAS space.
virtual void OnMRMLDisplayableNodeModifiedEvent(vtkObject *caller)
vtkWeakPointer< vtkSlicerMarkupsWidget > LastActiveWidget
vtkMRMLMarkupsDisplayableManagerHelper * GetHelper()
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 OnMRMLSceneNodeRemoved(vtkMRMLNode *)
void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) override
void SetMRMLSceneInternal(vtkMRMLScene *newScene) override
Process interaction events to update state of markup widget nodes.
virtual bool CanProcessInteractionEvent(vtkMRMLInteractionEventData *eventData, double &distance2)
virtual int GetMouseCursor()
Displayable manager returns ID of the mouse cursor shape that should be displayed.
virtual bool GetGrabFocus()
Displayable manager can indicate that it would like to get all events (even when mouse pointer is out...
virtual void UpdateFromMRMLScene()
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
vtkSlicerMarkupsWidget * GetWidget(vtkMRMLMarkupsDisplayNode *markupsDisplayNode)
Set all widget status to manipulate.
virtual void SetHasFocus(bool hasFocus, vtkMRMLInteractionEventData *eventData)
Set if the widget gets/loses focus (interaction events are processed by this displayable manager)...
virtual void OnInteractorStyleEvent(int eventid)