Medical Imaging Interaction Toolkit  2026.06.00
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 
80  {
81  public:
83 
88 
93 
98 
103 
105 
106  // no New(), there should only be subclasses
107 
114 
121 
131  virtual const char *GetName() const = 0;
132 
143 
150  virtual const char *GetGroup() const;
151 
158  virtual bool IsEligibleForAutoInit() const;
159 
161  virtual void InitializeStateMachine();
162 
184  virtual itk::Object::Pointer GetGUI(const std::string &toolkitPrefix, const std::string &toolkitPostfix);
185 
187  virtual NodePredicateBase::ConstPointer GetReferenceDataPreference() const;
188 
190  virtual NodePredicateBase::ConstPointer GetWorkingDataPreference() const;
191 
201  virtual bool CanHandle(const BaseData *referenceData, const BaseData *workingData) const;
202 
212 
213  protected:
214  friend class ToolManager;
215 
216  virtual void SetToolManager(ToolManager *);
219 
223 
224  void ConnectActionsAndFunctions() override;
225 
231  virtual void Activated();
232 
238  virtual void Deactivated();
239 
243  std::string m_EventConfig;
244 
245  Tool(const char *, const us::Module *interactorModule = nullptr); // purposely hidden
246  ~Tool() override;
247 
248  void Notify(InteractionEvent *interactionEvent, bool isHandled) override;
249 
251 
252  private:
253  ToolManager* m_ToolManager;
254 
255  std::string m_InteractorType;
256 
257  std::map<us::ServiceReferenceU, EventConfig> m_DisplayInteractionConfigs;
258 
259  const us::Module *m_InteractorModule;
260  };
261 
262 } // namespace
263 
264 #endif
#define MITKSEGMENTATION_EXPORT
Base class of all data objects.
Definition: mitkBaseData.h:60
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
Provides state machine functionality for DataInteractors.
Base class for all interaction events in MITK.
unsigned short PixelType
Pixel type used for label values (unsigned short).
Definition: mitkLabel.h:106
AlgorithmType
Enumeration describing how a label was created or refined.
Definition: mitkLabel.h:283
Event/message/notification class.
Definition: mitkMessage.h:521
Manages and coordinates instances of mitk::Tool.
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:80
mitkClassMacro(Tool, EventStateMachine)
virtual mitk::Label::AlgorithmType GetAlgorithmType() const
Returns the intrinsic algorithm type of this tool, used to stamp label provenance.
virtual us::ModuleResource GetIconResource() const
Returns the tool button icon of the tool wrapped by a usModuleResource.
virtual bool IsEligibleForAutoInit() const
Returns whether this tool is eligible for auto-initialization by ToolManager.
Message1< std::string > ErrorMessage
To send error messages (to be shown by some GUI)
Definition: mitkTool.h:92
virtual NodePredicateBase::ConstPointer GetWorkingDataPreference() const
Returns a predicate describing valid working data for this tool.
virtual bool CanHandle(const BaseData *referenceData, const BaseData *workingData) const
Checks if a tool can handle the given reference data and optional working data.
Message1< bool > CurrentlyBusy
To send whether the tool is busy (to be shown by some GUI)
Definition: mitkTool.h:97
virtual void SetToolManager(ToolManager *)
virtual itk::Object::Pointer GetGUI(const std::string &toolkitPrefix, const std::string &toolkitPostfix)
Interface for GUI creation.
Message GUIProcessEventsMessage
To let GUI process new events (e.g. qApp->processEvents() )
Definition: mitkTool.h:87
virtual const char * GetGroup() const
Name of a group.
Message1< std::string > GeneralMessage
To send general messages (to be shown by some GUI)
Definition: mitkTool.h:102
Tool(const char *, const us::Module *interactorModule=nullptr)
std::string m_EventConfig
Let subclasses change their event configuration.
Definition: mitkTool.h:243
ToolManager * GetToolManager() const
virtual void Activated()
Called when the tool gets activated.
void ConnectActionsAndFunctions() override
void Notify(InteractionEvent *interactionEvent, bool isHandled) override
Called by the Dispatcher to notify this observer about an InteractionEvent.
virtual NodePredicateBase::ConstPointer GetReferenceDataPreference() const
Returns a predicate describing valid reference data for this tool.
~Tool() override
bool FilterEvents(InteractionEvent *, DataNode *) override
virtual const char * GetName() const =0
Returns the name of this tool. Make it short!
virtual void InitializeStateMachine()
Initializes the state machine for this tool based on the interaction type.
mitk::DataStorage * GetDataStorage() const
virtual bool ConfirmBeforeDeactivation()
Method call to invoke a dialog box just before exiting.
virtual void Deactivated()
Called when the tool gets deactivated.
mitk::Label::PixelType DefaultSegmentationDataType
Definition: mitkTool.h:82
virtual us::ModuleResource GetCursorIconResource() const
Returns the cursor icon of the tool wrapped by a usModuleResource.
Represents a resource (text file, image, etc.) embedded in a CppMicroServices module.
Represents a CppMicroServices module.
Definition: usModule.h:70
Macros for registering MITK segmentation tools and tool GUIs via ITK object factories.
Find image slices visible on a given plane.
Interface for observing all InteractionEvents dispatched through the system.