Medical Imaging Interaction Toolkit  2025.08.99-f7084adb
Medical Imaging Interaction Toolkit
mitkTool.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 mitkTool_h
14 #define mitkTool_h
15 
16 #include "itkObjectFactoryBase.h"
17 #include "itkVersion.h"
18 #include "mitkCommon.h"
19 #include "mitkDataNode.h"
20 #include "mitkEventStateMachine.h"
22 #include "mitkLabelSetImage.h"
23 #include "mitkMessage.h"
24 #include "mitkNodePredicateBase.h"
25 #include "mitkToolEvents.h"
26 #include "mitkToolFactoryMacro.h"
28 #include <mitkLabel.h>
29 
30 #include <iostream>
31 #include <map>
32 #include <string>
33 
34 #include <itkObject.h>
35 
36 #include "usServiceRegistration.h"
37 
38 namespace us
39 {
40  class ModuleResource;
41 }
42 
43 namespace mitk
44 {
45  class ToolManager;
46 
79  {
80  public:
82 
87 
92 
97 
102 
104 
105  // no New(), there should only be subclasses
106 
115  //[[deprecated]]
116  DEPRECATED(virtual const char **GetXPM() const) = 0;
117 
123  virtual std::string GetIconPath() const { return ""; }
128  virtual us::ModuleResource GetCursorIconResource() const;
129 
135  virtual us::ModuleResource GetIconResource() const;
136 
142  virtual const char *GetName() const = 0;
143 
150  virtual const char *GetGroup() const;
151 
158  virtual bool IsEligibleForAutoInit() const;
159 
160  virtual void InitializeStateMachine();
161 
183  virtual itk::Object::Pointer GetGUI(const std::string &toolkitPrefix, const std::string &toolkitPostfix);
184 
185  virtual NodePredicateBase::ConstPointer GetReferenceDataPreference() const;
186  virtual NodePredicateBase::ConstPointer GetWorkingDataPreference() const;
187 
193  virtual bool CanHandle(const BaseData *referenceData, const BaseData *workingData) const;
194 
200  virtual bool ConfirmBeforeDeactivation();
201 
202  protected:
203  friend class ToolManager;
204 
205  virtual void SetToolManager(ToolManager *);
207  ToolManager* GetToolManager() const;
208 
211  mitk::DataStorage* GetDataStorage() const;
212 
213  void ConnectActionsAndFunctions() override;
214 
220  virtual void Activated();
221 
227  virtual void Deactivated();
228 
232  std::string m_EventConfig;
233 
234  Tool(const char *, const us::Module *interactorModule = nullptr); // purposely hidden
235  ~Tool() override;
236 
237  void Notify(InteractionEvent *interactionEvent, bool isHandled) override;
238 
239  bool FilterEvents(InteractionEvent *, DataNode *) override;
240 
241  private:
242  ToolManager* m_ToolManager;
243 
244  std::string m_InteractorType;
245 
246  std::map<us::ServiceReferenceU, EventConfig> m_DisplayInteractionConfigs;
247 
248  const us::Module *m_InteractorModule;
249  };
250 
251 } // namespace
252 
253 #endif
mitk::Tool::DefaultSegmentationDataType
mitk::Label::PixelType DefaultSegmentationDataType
Definition: mitkTool.h:81
mitk::Tool::CurrentlyBusy
Message1< bool > CurrentlyBusy
To send whether the tool is busy (to be shown by some GUI)
Definition: mitkTool.h:96
mitkLabel.h
mitk::InteractionEvent
Definition: mitkInteractionEvent.h:26
mitk::Message1< std::string >
mitk::InteractionEventObserver
Base class to implement InteractionEventObservers.
Definition: mitkInteractionEventObserver.h:33
us
Definition: mitkAbstractFileReader.h:29
DEPRECATED
#define DEPRECATED(func)
Definition: mitkCommon.h:175
itk::SmartPointer< const Self >
mitk::Label::PixelType
unsigned short PixelType
Definition: mitkLabel.h:34
mitk::Tool
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:78
mitkInteractionEventObserver.h
mitkNodePredicateBase.h
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::Tool::ErrorMessage
Message1< std::string > ErrorMessage
To send error messages (to be shown by some GUI)
Definition: mitkTool.h:91
mitk::ToolManager
Manages and coordinates instances of mitk::Tool.
Definition: mitkToolManager.h:78
mitk::EventStateMachine
‍**
Definition: mitkEventStateMachine.h:111
mitk::Tool::GetIconPath
virtual std::string GetIconPath() const
Returns the path of an icon.
Definition: mitkTool.h:123
mitkMessage.h
us::Module
Definition: usModule.h:78
mitkCommon.h
MITKSEGMENTATION_EXPORT
#define MITKSEGMENTATION_EXPORT
Definition: MitkSegmentationExports.h:15
usServiceRegistration.h
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitk::DataStorage
Data management class that handles 'was created by' relations.
Definition: mitkDataStorage.h:43
us::ModuleResource
Definition: usModuleResource.h:55
mitkDataNode.h
mitkEventStateMachine.h
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
MitkSegmentationExports.h
mitkToolFactoryMacro.h
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::Message
Event/message/notification class.
Definition: mitkMessage.h:452
mitk::Tool::m_EventConfig
std::string m_EventConfig
Let subclasses change their event configuration.
Definition: mitkTool.h:232
mitkToolEvents.h
mitk::Tool::GeneralMessage
Message1< std::string > GeneralMessage
To send general messages (to be shown by some GUI)
Definition: mitkTool.h:101
mitk::Tool::GUIProcessEventsMessage
Message GUIProcessEventsMessage
To let GUI process new events (e.g. qApp->processEvents() )
Definition: mitkTool.h:86
mitkLabelSetImage.h