Medical Imaging Interaction Toolkit  2023.04.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 "mitkNodePredicateAnd.h"
27 #include "mitkNodePredicateNot.h"
28 #include "mitkNodePredicateOr.h"
30 #include "mitkToolEvents.h"
31 #include "mitkToolFactoryMacro.h"
33 #include <mitkLabel.h>
34 
35 #include <iostream>
36 #include <map>
37 #include <string>
38 
39 #include <itkObject.h>
40 
41 #include "usServiceRegistration.h"
42 
43 namespace us
44 {
45  class ModuleResource;
46 }
47 
48 namespace mitk
49 {
50  class ToolManager;
51 
84  {
85  public:
87 
92 
97 
102 
107 
109 
110  // no New(), there should only be subclasses
111 
120  //[[deprecated]]
121  DEPRECATED(virtual const char **GetXPM() const) = 0;
122 
128  virtual std::string GetIconPath() const { return ""; }
133  virtual us::ModuleResource GetCursorIconResource() const;
134 
140  virtual us::ModuleResource GetIconResource() const;
141 
147  virtual const char *GetName() const = 0;
148 
155  virtual const char *GetGroup() const;
156 
157  virtual void InitializeStateMachine();
158 
180  virtual itk::Object::Pointer GetGUI(const std::string &toolkitPrefix, const std::string &toolkitPostfix);
181 
182  virtual NodePredicateBase::ConstPointer GetReferenceDataPreference() const;
183  virtual NodePredicateBase::ConstPointer GetWorkingDataPreference() const;
184 
186  const std::string &organName,
187  const mitk::Color &color) const;
188  DataNode::Pointer CreateSegmentationNode(Image *image, const std::string &organName, const mitk::Color &color) const;
189 
195  virtual bool CanHandle(const BaseData *referenceData, const BaseData *workingData) const;
196 
197  protected:
198  friend class ToolManager;
199 
200  virtual void SetToolManager(ToolManager *);
202  ToolManager* GetToolManager() const;
203 
206  mitk::DataStorage* GetDataStorage() const;
207 
208  void ConnectActionsAndFunctions() override;
209 
215  virtual void Activated();
216 
222  virtual void Deactivated();
223 
227  std::string m_EventConfig;
228 
229  Tool(const char *, const us::Module *interactorModule = nullptr); // purposely hidden
230  ~Tool() override;
231 
232  void Notify(InteractionEvent *interactionEvent, bool isHandled) override;
233 
234  bool FilterEvents(InteractionEvent *, DataNode *) override;
235 
236  private:
237  ToolManager* m_ToolManager;
238 
239  // for reference data
240  NodePredicateDataType::Pointer m_PredicateImages;
241  NodePredicateDimension::Pointer m_PredicateDim3;
242  NodePredicateDimension::Pointer m_PredicateDim4;
243  NodePredicateOr::Pointer m_PredicateDimension;
244  NodePredicateAnd::Pointer m_PredicateImage3D;
245 
246  NodePredicateProperty::Pointer m_PredicateBinary;
247  NodePredicateNot::Pointer m_PredicateNotBinary;
248 
249  NodePredicateProperty::Pointer m_PredicateSegmentation;
250  NodePredicateNot::Pointer m_PredicateNotSegmentation;
251 
252  NodePredicateProperty::Pointer m_PredicateHelper;
253  NodePredicateNot::Pointer m_PredicateNotHelper;
254 
255  NodePredicateAnd::Pointer m_PredicateImageColorful;
256 
257  NodePredicateAnd::Pointer m_PredicateImageColorfulNotHelper;
258 
259  NodePredicateAnd::Pointer m_PredicateReference;
260 
261  // for working data
262  NodePredicateAnd::Pointer m_IsSegmentationPredicate;
263 
264  std::string m_InteractorType;
265 
266  std::map<us::ServiceReferenceU, EventConfig> m_DisplayInteractionConfigs;
267 
268  const us::Module *m_InteractorModule;
269  };
270 
271 } // namespace
272 
273 #endif
mitkNodePredicateNot.h
mitk::Tool::DefaultSegmentationDataType
mitk::Label::PixelType DefaultSegmentationDataType
Definition: mitkTool.h:86
mitk::Tool::CurrentlyBusy
Message1< bool > CurrentlyBusy
To send whether the tool is busy (to be shown by some GUI)
Definition: mitkTool.h:101
mitkLabel.h
mitkNodePredicateDataType.h
mitk::InteractionEvent
Definition: mitkInteractionEvent.h:26
mitk::Message1< std::string >
mitkNodePredicateAnd.h
mitk::InteractionEventObserver
Base class to implement InteractionEventObservers.
Definition: mitkInteractionEventObserver.h:33
us
Definition: mitkAbstractFileReader.h:29
mitk::Color
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
Definition: mitkColorProperty.h:35
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
DEPRECATED
#define DEPRECATED(func)
Definition: mitkCommon.h:175
itk::SmartPointer< const Self >
mitk::Label::PixelType
unsigned short PixelType
Definition: mitkLabel.h:33
mitk::Tool
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:83
mitkInteractionEventObserver.h
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::Tool::ErrorMessage
Message1< std::string > ErrorMessage
To send error messages (to be shown by some GUI)
Definition: mitkTool.h:96
mitk::ToolManager
Manages and coordinates instances of mitk::Tool.
Definition: mitkToolManager.h:80
mitk::EventStateMachine
‍**
Definition: mitkEventStateMachine.h:111
mitkNodePredicateProperty.h
mitk::Tool::GetIconPath
virtual std::string GetIconPath() const
Returns the path of an icon.
Definition: mitkTool.h:128
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
mitk::LabelSetImageHelper::CreateEmptySegmentationNode
MITKMULTILABEL_EXPORT mitk::DataNode::Pointer CreateEmptySegmentationNode(const std::string &segmentationName=std::string())
This function creates and returns a new empty segmentation data node.
us::ModuleResource
Definition: usModuleResource.h:55
mitkDataNode.h
mitkEventStateMachine.h
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitkNodePredicateDimension.h
MitkSegmentationExports.h
mitkToolFactoryMacro.h
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitkNodePredicateOr.h
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:227
mitkToolEvents.h
mitk::Tool::GeneralMessage
Message1< std::string > GeneralMessage
To send general messages (to be shown by some GUI)
Definition: mitkTool.h:106
mitk::Tool::GUIProcessEventsMessage
Message GUIProcessEventsMessage
To let GUI process new events (e.g. qApp->processEvents() )
Definition: mitkTool.h:91
mitkLabelSetImage.h