Medical Imaging Interaction Toolkit  2018.4.99-93926fb8
Medical Imaging Interaction Toolkit
mitkToolManager.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkToolManager_h_Included
14 #define mitkToolManager_h_Included
15 
16 #include "mitkDataNode.h"
17 #include "mitkDataStorage.h"
18 #include "mitkTool.h"
19 #include "mitkWeakPointer.h"
21 
22 #pragma GCC visibility push(default)
23 #include <itkEventObject.h>
24 #pragma GCC visibility pop
25 
26 #include <vector>
27 
28 namespace mitk
29 {
30  class Image;
31  class PlaneGeometry;
32 
80  class MITKSEGMENTATION_EXPORT ToolManager : public itk::Object
81  {
82  public:
83  typedef std::vector<Tool::Pointer> ToolVectorType;
84  typedef std::vector<Tool::ConstPointer> ToolVectorTypeConst;
85  typedef std::vector<DataNode *> DataVectorType; // has to be observed for delete events!
86  typedef std::map<DataNode *, unsigned long> NodeTagMapType;
87 
91 
97 
100 
101  mitkClassMacroItkParent(ToolManager, itk::Object);
103 
108  const ToolVectorTypeConst GetTools();
109 
110  int GetToolID(const Tool *tool);
111 
116  Tool *GetToolById(int id);
117 
123  bool ActivateTool(int id);
124 
125  template <class T>
127  {
128  int id = 0;
129  for (auto iter = m_Tools.begin(); iter != m_Tools.end(); ++iter, ++id)
130  {
131  if (dynamic_cast<T *>(iter->GetPointer()))
132  {
133  return id;
134  }
135  }
136  return -1;
137  }
138 
142  int GetActiveToolID();
143 
147  Tool *GetActiveTool();
148 
152  void SetReferenceData(DataVectorType);
153 
157  void SetReferenceData(DataNode *);
158 
162  void SetWorkingData(DataVectorType);
163 
167  void SetWorkingData(DataNode *);
168 
172  void SetRoiData(DataVectorType);
173 
177  void SetRoiData(DataNode *);
178 
182  DataVectorType GetReferenceData();
183 
188  DataNode *GetReferenceData(int);
189 
193  DataVectorType GetWorkingData();
194 
199  DataNode *GetWorkingData(unsigned int);
200 
204  DataVectorType GetRoiData();
205 
209  DataNode *GetRoiData(int idx);
210 
211  DataStorage *GetDataStorage();
212  void SetDataStorage(DataStorage &storage);
213 
216  TimePointType GetCurrentTimePoint() const;
217 
222  void RegisterClient();
223 
228  void UnregisterClient();
229 
231  void InitializeTools();
232 
233  void OnOneOfTheReferenceDataDeletedConst(const itk::Object *caller, const itk::EventObject &e);
234  void OnOneOfTheReferenceDataDeleted(itk::Object *caller, const itk::EventObject &e);
235 
236  void OnOneOfTheWorkingDataDeletedConst(const itk::Object *caller, const itk::EventObject &e);
237  void OnOneOfTheWorkingDataDeleted(itk::Object *caller, const itk::EventObject &e);
238 
239  void OnOneOfTheRoiDataDeletedConst(const itk::Object *caller, const itk::EventObject &e);
240  void OnOneOfTheRoiDataDeleted(itk::Object *caller, const itk::EventObject &e);
241 
248  void OnToolErrorMessage(std::string s);
249  void OnGeneralToolMessage(std::string s);
250 
251  protected:
259  ToolManager(DataStorage *storage); // purposely hidden
260  ~ToolManager() override;
261 
262  ToolVectorType m_Tools;
263 
267 
268  DataVectorType m_ReferenceData;
270 
271  DataVectorType m_WorkingData;
273 
274  DataVectorType m_RoiData;
275  NodeTagMapType m_RoiDataObserverTags;
276 
278 
280 
282  void OnNodeRemoved(const mitk::DataNode *node);
283 
285  void OnTimeChangedConst(const itk::Object* caller, const itk::EventObject& e);
286  void OnTimeChanged(itk::Object* caller, const itk::EventObject& e);
287 
288  void EnsureTimeObservation();
289  void StopTimeObservation();
290 
291  private:
293  TimePointType m_LastTimePoint = 0;
295  unsigned long m_TimePointObserverTag = 0;
297  WeakPointer<SliceNavigationController> m_CurrentTimeNavigationController;
298  };
299 
300 } // namespace
301 
302 #endif
std::vector< Tool::ConstPointer > ToolVectorTypeConst
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:86
Data management class that handles &#39;was created by&#39; relations.
DataVectorType m_WorkingData
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:72
Message WorkingDataChanged
std::vector< DataNode * > DataVectorType
WeakPointer< DataStorage > m_DataStorage
NodeTagMapType m_RoiDataObserverTags
std::vector< Tool::Pointer > ToolVectorType
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
Message1< std::string > ToolErrorMessage
DataVectorType m_ReferenceData
std::map< DataNode *, unsigned long > NodeTagMapType
Message ReferenceDataChanged
NodeTagMapType m_ReferenceDataObserverTags
Message NodePropertiesChanged
class ITK_EXPORT Image
Message1< std::string > GeneralToolMessage
Message1< DataVectorType * > NewNodeObjectsGenerated
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
us::ServiceRegistration< InteractionEventObserver > m_ActiveToolRegistration
Event/message/notification class.
Definition: mitkMessage.h:568
mitk::ScalarType TimePointType
NodeTagMapType m_WorkingDataObserverTags
ToolVectorType m_Tools
Message SelectedTimePointChanged
DataVectorType m_RoiData
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
Manages and coordinates instances of mitk::Tool.