Medical Imaging Interaction Toolkit  2024.06.00
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
14 #define mitkToolManager_h
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 
78  class MITKSEGMENTATION_EXPORT ToolManager : public itk::Object
79  {
80  public:
81  typedef std::vector<Tool::Pointer> ToolVectorType;
82  typedef std::vector<Tool::ConstPointer> ToolVectorTypeConst;
83  typedef std::vector<DataNode *> DataVectorType; // has to be observed for delete events!
84  typedef std::map<DataNode *, unsigned long> NodeTagMapType;
85 
89 
95 
98 
101 
106  const ToolVectorTypeConst GetTools();
107 
108  int GetToolID(const Tool *tool);
109 
114  Tool *GetToolById(int id);
115 
121  bool ActivateTool(int id);
122 
123  template <class T>
125  {
126  int id = 0;
127  for (auto iter = m_Tools.begin(); iter != m_Tools.end(); ++iter, ++id)
128  {
129  if (dynamic_cast<T *>(iter->GetPointer()))
130  {
131  return id;
132  }
133  }
134  return -1;
135  }
136 
140  int GetActiveToolID();
141 
145  Tool *GetActiveTool();
146 
150  void SetReferenceData(DataVectorType);
151 
155  void SetReferenceData(DataNode *);
156 
160  void SetWorkingData(DataVectorType);
161 
165  void SetWorkingData(DataNode *);
166 
170  void SetRoiData(DataVectorType);
171 
175  void SetRoiData(DataNode *);
176 
180  DataVectorType GetReferenceData();
181 
186  DataNode *GetReferenceData(int);
187 
191  DataVectorType GetWorkingData();
192 
197  DataNode *GetWorkingData(unsigned int);
198 
202  DataVectorType GetRoiData();
203 
207  DataNode *GetRoiData(int idx);
208 
209  DataStorage::Pointer GetDataStorage() const;
210  void SetDataStorage(DataStorage &storage);
211 
214  TimePointType GetCurrentTimePoint() const;
215 
220  void RegisterClient();
221 
226  void UnregisterClient();
227 
229  void InitializeTools();
230 
231  void OnOneOfTheReferenceDataDeletedConst(const itk::Object *caller, const itk::EventObject &e);
232  void OnOneOfTheReferenceDataDeleted(itk::Object *caller, const itk::EventObject &e);
233 
234  void OnOneOfTheWorkingDataDeletedConst(const itk::Object *caller, const itk::EventObject &e);
235  void OnOneOfTheWorkingDataDeleted(itk::Object *caller, const itk::EventObject &e);
236 
237  void OnOneOfTheRoiDataDeletedConst(const itk::Object *caller, const itk::EventObject &e);
238  void OnOneOfTheRoiDataDeleted(itk::Object *caller, const itk::EventObject &e);
239 
246  void OnToolErrorMessage(std::string s);
247  void OnGeneralToolMessage(std::string s);
248 
249  protected:
257  ToolManager(DataStorage *storage); // purposely hidden
258  ~ToolManager() override;
259 
261 
265 
268 
271 
274 
276 
278 
280  void OnNodeRemoved(const mitk::DataNode *node);
281 
283  void OnTimeChangedConst(const itk::Object* caller, const itk::EventObject& e);
284  void OnTimeChanged(itk::Object* caller, const itk::EventObject& e);
285 
286  void EnsureTimeObservation();
287  void StopTimeObservation();
288 
289  private:
291  TimePointType m_LastTimePoint = 0;
293  unsigned long m_TimePointObserverTag = 0;
295  WeakPointer<TimeNavigationController> m_CurrentTimeNavigationController;
296  };
297 
298 } // namespace
299 
300 #endif
mitk::ToolManager::m_RoiDataObserverTags
NodeTagMapType m_RoiDataObserverTags
Definition: mitkToolManager.h:273
mitkTool.h
mitk::ToolManager::NodeTagMapType
std::map< DataNode *, unsigned long > NodeTagMapType
Definition: mitkToolManager.h:84
mitk::ToolManager::WorkingDataChanged
Message WorkingDataChanged
Definition: mitkToolManager.h:92
mitk::ToolManager::m_WorkingDataObserverTags
NodeTagMapType m_WorkingDataObserverTags
Definition: mitkToolManager.h:270
mitk::Message1< DataVectorType * >
mitk::ToolManager::GeneralToolMessage
Message1< std::string > GeneralToolMessage
Definition: mitkToolManager.h:97
mitk::ToolManager::m_ActiveTool
Tool * m_ActiveTool
Definition: mitkToolManager.h:262
mitkDataStorage.h
mitk::ToolManager::m_ActiveToolRegistration
us::ServiceRegistration< InteractionEventObserver > m_ActiveToolRegistration
Definition: mitkToolManager.h:264
mitkNewMacro1Param
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
mitk::ToolManager::ToolErrorMessage
Message1< std::string > ToolErrorMessage
Definition: mitkToolManager.h:96
itk::SmartPointer< Self >
mitk::ToolManager::RoiDataChanged
Message RoiDataChanged
Definition: mitkToolManager.h:93
mitk::Tool
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:83
mitk::ToolManager::m_RegisteredClients
int m_RegisteredClients
Definition: mitkToolManager.h:275
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::ToolManager::m_ReferenceDataObserverTags
NodeTagMapType m_ReferenceDataObserverTags
Definition: mitkToolManager.h:267
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::ToolManager
Manages and coordinates instances of mitk::Tool.
Definition: mitkToolManager.h:78
mitk::ToolManager::m_ReferenceData
DataVectorType m_ReferenceData
Definition: mitkToolManager.h:266
mitk::ToolManager::NewNodesGenerated
Message NewNodesGenerated
Definition: mitkToolManager.h:87
mitk::ToolManager::NewNodeObjectsGenerated
Message1< DataVectorType * > NewNodeObjectsGenerated
Definition: mitkToolManager.h:88
mitk::ToolManager::SelectedTimePointChanged
Message SelectedTimePointChanged
Definition: mitkToolManager.h:94
mitk::ToolManager::m_WorkingData
DataVectorType m_WorkingData
Definition: mitkToolManager.h:269
mitk::ToolManager::m_DataStorage
WeakPointer< DataStorage > m_DataStorage
Definition: mitkToolManager.h:277
MITKSEGMENTATION_EXPORT
#define MITKSEGMENTATION_EXPORT
Definition: MitkSegmentationExports.h:15
mitk::ToolManager::NodePropertiesChanged
Message NodePropertiesChanged
Definition: mitkToolManager.h:86
mitk::ToolManager::m_ActiveToolID
int m_ActiveToolID
Definition: mitkToolManager.h:263
mitk::ToolManager::DataVectorType
std::vector< DataNode * > DataVectorType
Definition: mitkToolManager.h:83
mitk::DataStorage
Data management class that handles 'was created by' relations.
Definition: mitkDataStorage.h:43
mitkDataNode.h
mitkWeakPointer.h
mitk::ToolManager::ToolVectorType
std::vector< Tool::Pointer > ToolVectorType
Definition: mitkToolManager.h:81
mitk::ToolManager::ToolVectorTypeConst
std::vector< Tool::ConstPointer > ToolVectorTypeConst
Definition: mitkToolManager.h:82
mitk::ToolManager::m_RoiData
DataVectorType m_RoiData
Definition: mitkToolManager.h:272
itk::Image
class ITK_EXPORT Image
Definition: mitkGeometryClipImageFilter.h:25
mitk::TimePointType
mitk::ScalarType TimePointType
Definition: mitkTimeGeometry.h:26
mitk::ToolManager::ReferenceDataChanged
Message ReferenceDataChanged
Definition: mitkToolManager.h:91
MitkSegmentationExports.h
mitk::ToolManager::GetToolIdByToolType
int GetToolIdByToolType()
Definition: mitkToolManager.h:124
us::ServiceRegistration
Definition: usServiceRegistration.h:48
mitk::ToolManager::ActiveToolChanged
Message ActiveToolChanged
Definition: mitkToolManager.h:90
mitk::WeakPointer
Definition: mitkWeakPointer.h:22
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::Message
Event/message/notification class.
Definition: mitkMessage.h:452
mitk::ToolManager::m_Tools
ToolVectorType m_Tools
Definition: mitkToolManager.h:260