Medical Imaging Interaction Toolkit  2024.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 "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 
202  virtual bool ConfirmBeforeDeactivation();
203 
204  protected:
205  friend class ToolManager;
206 
207  virtual void SetToolManager(ToolManager *);
209  ToolManager* GetToolManager() const;
210 
213  mitk::DataStorage* GetDataStorage() const;
214 
215  void ConnectActionsAndFunctions() override;
216 
222  virtual void Activated();
223 
229  virtual void Deactivated();
230 
234  std::string m_EventConfig;
235 
236  Tool(const char *, const us::Module *interactorModule = nullptr); // purposely hidden
237  ~Tool() override;
238 
239  void Notify(InteractionEvent *interactionEvent, bool isHandled) override;
240 
241  bool FilterEvents(InteractionEvent *, DataNode *) override;
242 
243  private:
244  ToolManager* m_ToolManager;
245 
246  // for reference data
247  NodePredicateDataType::Pointer m_PredicateImages;
248  NodePredicateDimension::Pointer m_PredicateDim3;
249  NodePredicateDimension::Pointer m_PredicateDim4;
250  NodePredicateOr::Pointer m_PredicateDimension;
251  NodePredicateAnd::Pointer m_PredicateImage3D;
252 
253  NodePredicateProperty::Pointer m_PredicateBinary;
254  NodePredicateNot::Pointer m_PredicateNotBinary;
255 
256  NodePredicateProperty::Pointer m_PredicateSegmentation;
257  NodePredicateNot::Pointer m_PredicateNotSegmentation;
258 
259  NodePredicateProperty::Pointer m_PredicateHelper;
260  NodePredicateNot::Pointer m_PredicateNotHelper;
261 
262  NodePredicateAnd::Pointer m_PredicateImageColorful;
263 
264  NodePredicateAnd::Pointer m_PredicateImageColorfulNotHelper;
265 
266  NodePredicateAnd::Pointer m_PredicateReference;
267 
268  // for working data
269  NodePredicateAnd::Pointer m_IsSegmentationPredicate;
270 
271  std::string m_InteractorType;
272 
273  std::map<us::ServiceReferenceU, EventConfig> m_DisplayInteractionConfigs;
274 
275  const us::Module *m_InteractorModule;
276  };
277 
278 } // namespace
279 
280 #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:38
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:34
mitk::Tool
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:83
mitkInteractionEventObserver.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:96
mitk::ToolManager
Manages and coordinates instances of mitk::Tool.
Definition: mitkToolManager.h:78
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:234
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