Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
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::Pointer GetDataStorage() const;
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 
263 
267 
270 
273 
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<TimeNavigationController> m_CurrentTimeNavigationController;
298  };
299 
300 } // namespace
301 
302 #endif
mitk::ToolManager::m_RoiDataObserverTags
NodeTagMapType m_RoiDataObserverTags
Definition: mitkToolManager.h:275
mitkTool.h
mitk::ToolManager::NodeTagMapType
std::map< DataNode *, unsigned long > NodeTagMapType
Definition: mitkToolManager.h:86
mitk::ToolManager::WorkingDataChanged
Message WorkingDataChanged
Definition: mitkToolManager.h:94
mitk::ToolManager::m_WorkingDataObserverTags
NodeTagMapType m_WorkingDataObserverTags
Definition: mitkToolManager.h:272
mitk::Message1< DataVectorType * >
mitk::ToolManager::GeneralToolMessage
Message1< std::string > GeneralToolMessage
Definition: mitkToolManager.h:99
mitk::ToolManager::m_ActiveTool
Tool * m_ActiveTool
Definition: mitkToolManager.h:264
mitkDataStorage.h
mitk::ToolManager::m_ActiveToolRegistration
us::ServiceRegistration< InteractionEventObserver > m_ActiveToolRegistration
Definition: mitkToolManager.h:266
mitkNewMacro1Param
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
mitk::ToolManager::ToolErrorMessage
Message1< std::string > ToolErrorMessage
Definition: mitkToolManager.h:98
itk::SmartPointer< Self >
mitk::ToolManager::RoiDataChanged
Message RoiDataChanged
Definition: mitkToolManager.h:95
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:277
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::ToolManager::m_ReferenceDataObserverTags
NodeTagMapType m_ReferenceDataObserverTags
Definition: mitkToolManager.h:269
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:80
mitk::ToolManager::m_ReferenceData
DataVectorType m_ReferenceData
Definition: mitkToolManager.h:268
mitk::ToolManager::NewNodesGenerated
Message NewNodesGenerated
Definition: mitkToolManager.h:89
mitk::ToolManager::NewNodeObjectsGenerated
Message1< DataVectorType * > NewNodeObjectsGenerated
Definition: mitkToolManager.h:90
mitk::ToolManager::SelectedTimePointChanged
Message SelectedTimePointChanged
Definition: mitkToolManager.h:96
mitk::ToolManager::m_WorkingData
DataVectorType m_WorkingData
Definition: mitkToolManager.h:271
mitk::ToolManager::m_DataStorage
WeakPointer< DataStorage > m_DataStorage
Definition: mitkToolManager.h:279
MITKSEGMENTATION_EXPORT
#define MITKSEGMENTATION_EXPORT
Definition: MitkSegmentationExports.h:15
mitk::ToolManager::NodePropertiesChanged
Message NodePropertiesChanged
Definition: mitkToolManager.h:88
mitk::ToolManager::m_ActiveToolID
int m_ActiveToolID
Definition: mitkToolManager.h:265
mitk::ToolManager::DataVectorType
std::vector< DataNode * > DataVectorType
Definition: mitkToolManager.h:85
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:83
mitk::ToolManager::ToolVectorTypeConst
std::vector< Tool::ConstPointer > ToolVectorTypeConst
Definition: mitkToolManager.h:84
mitk::ToolManager::m_RoiData
DataVectorType m_RoiData
Definition: mitkToolManager.h:274
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:93
MitkSegmentationExports.h
mitk::ToolManager::GetToolIdByToolType
int GetToolIdByToolType()
Definition: mitkToolManager.h:126
us::ServiceRegistration
Definition: usServiceRegistration.h:48
mitk::ToolManager::ActiveToolChanged
Message ActiveToolChanged
Definition: mitkToolManager.h:92
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:262