NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkBaseSegmentorController.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkBaseSegmentorController_h
16 #define niftkBaseSegmentorController_h
17 
18 #include <niftkMIDASGuiExports.h>
19 
20 #include <QColor>
21 #include <QList>
22 
23 #include <mitkDataNode.h>
24 #include <mitkToolManager.h>
25 
26 #include <niftkBaseController.h>
29 
30 class QWidget;
31 
32 namespace niftk
33 {
34 
35 class BaseSegmentorGUI;
36 
37 
39 class NIFTKMIDASGUI_EXPORT BaseSegmentorController : public BaseController, public StateMachineEventFilter
40 {
41 
42  Q_OBJECT
43 
44 public:
45 
47 
48  virtual ~BaseSegmentorController();
49 
52  virtual void SetupGUI(QWidget* parent) override;
53 
55  mitk::ToolManager* GetToolManager() const;
56 
57  template <class ToolType>
58  ToolType* GetToolByType();
59 
62  virtual bool EventFilter(const mitk::StateEvent* stateEvent) const override;
63 
66  virtual bool EventFilter(mitk::InteractionEvent* event) const override;
67 
69  const QColor& GetDefaultSegmentationColour() const;
70 
72  void SetDefaultSegmentationColour(const QColor& defaultSegmentationColour);
73 
75  virtual void OnViewGetsActivated() override;
76 
77 protected:
78 
80  virtual void OnActiveToolChanged();
81 
85  std::vector<mitk::DataNode*> GetWorkingData();
86 
89  mitk::Image* GetWorkingImage(int index);
90 
92  mitk::DataNode* GetReferenceNode();
93 
96  mitk::Image* GetReferenceImage();
97 
101  mitk::DataNode* FindReferenceNodeFromSegmentationNode(const mitk::DataNode::Pointer segmentationNode);
102 
104  void SetReferenceImageSelected();
105 
107  virtual bool IsAReferenceImage(const mitk::DataNode::Pointer node);
108 
110  virtual bool IsASegmentationImage(const mitk::DataNode::Pointer node);
111 
113  virtual bool IsAWorkingImage(const mitk::DataNode::Pointer node);
114 
116  virtual std::vector<mitk::DataNode*> GetWorkingDataFromSegmentationNode(const mitk::DataNode::Pointer node);
117 
119  virtual mitk::DataNode* GetSegmentationNodeFromWorkingData(const mitk::DataNode::Pointer node);
120 
122  virtual bool CanStartSegmentationForBinaryNode(const mitk::DataNode::Pointer node) = 0;
123 
125  virtual void ApplyDisplayOptions(mitk::DataNode* node);
126 
130  int GetReferenceImageSliceAxis();
131 
135  int GetReferenceImageSliceAxis(ImageOrientation orientation);
136 
139  int GetReferenceImageSliceIndex();
140 
142  int GetReferenceImageSliceUpDirection();
143 
148  virtual mitk::DataNode* CreateNewSegmentation();
149 
151  BaseSegmentorGUI* GetSegmentorGUI() const;
152 
154  bool HasInitialisedWorkingData();
155 
158  virtual void OnDataManagerSelectionChanged(const QList<mitk::DataNode::Pointer>& nodes);
159 
160 protected slots:
161 
163  virtual void OnNewSegmentationButtonClicked() = 0;
164 
165 private:
166 
168  virtual void SetToolManagerSelection(const mitk::DataNode* referenceData, const std::vector<mitk::DataNode*>& workingDataNodes);
169 
170  mitk::ToolManager::Pointer m_ToolManager;
171 
172  BaseSegmentorGUI* m_SegmentorGUI;
173 
175  QColor m_DefaultSegmentationColour;
176 
178  int m_ActiveToolID;
179 
181  bool m_CursorIsVisibleWhenToolsAreOff;
182 
183 friend class BaseSegmentorView;
184 
185 };
186 
187 
188 //-----------------------------------------------------------------------------
189 template <class ToolType>
191 {
192  int toolId = m_ToolManager->GetToolIdByToolType<ToolType>();
193  return dynamic_cast<ToolType*>(m_ToolManager->GetToolById(toolId));
194 }
195 
196 }
197 
198 #endif
ImageOrientation
Describes the different types of orientation, axial, sagittal, coronal, that can be achieved in the D...
Definition: niftkImageOrientation.h:26
Public interface to QmitkBaseView.
Definition: niftkIBaseView.h:39
Base view component for MIDAS Segmentation widgets.
Definition: niftkBaseSegmentorView.h:46
StateMachineEventFilter represents a condition that has to be fulfilled so that an event is processed...
Definition: niftkStateMachineEventFilter.h:41
Definition: niftkBaseController.h:43
Base class for GUI controls on MIDAS segmentor views.
Definition: niftkBaseSegmentorGUI.h:36
Definition: niftkBaseSegmentorController.h:39
GLuint index
Definition: glew.h:1798
Some utilities to help with MIDAS conventions on orientation.
cl_event event
Definition: glew.h:3231
Definition: niftkExceptionObject.h:21
ToolType * GetToolByType()
Definition: niftkBaseSegmentorController.h:190