Medical Imaging Interaction Toolkit  2021.10.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_Included
14 #define mitkTool_h_Included
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 
87  {
88  public:
90 
95 
100 
105 
110 
112 
113  // no New(), there should only be subclasses
114 
123  virtual const char **GetXPM() const = 0;
124 
130  virtual std::string GetIconPath() const { return ""; }
135  virtual us::ModuleResource GetCursorIconResource() const;
136 
142  virtual us::ModuleResource GetIconResource() const;
143 
149  virtual const char *GetName() const = 0;
150 
157  virtual const char *GetGroup() const;
158 
159  virtual void InitializeStateMachine();
160 
182  virtual itk::Object::Pointer GetGUI(const std::string &toolkitPrefix, const std::string &toolkitPostfix);
183 
184  virtual NodePredicateBase::ConstPointer GetReferenceDataPreference() const;
185  virtual NodePredicateBase::ConstPointer GetWorkingDataPreference() const;
186 
187  DataNode::Pointer CreateEmptySegmentationNode(const Image *original,
188  const std::string &organName,
189  const mitk::Color &color) const;
190  DataNode::Pointer CreateSegmentationNode(Image *image, const std::string &organName, const mitk::Color &color) const;
191 
197  virtual bool CanHandle(const BaseData *referenceData, const BaseData *workingData) const;
198 
199  protected:
200  friend class ToolManager;
201 
202  virtual void SetToolManager(ToolManager *);
204  ToolManager* GetToolManager() const;
205 
208  mitk::DataStorage* GetDataStorage() const;
209 
210  void ConnectActionsAndFunctions() override;
211 
217  virtual void Activated();
218 
224  virtual void Deactivated();
225 
229  std::string m_EventConfig;
230 
231  Tool(const char *, const us::Module *interactorModule = nullptr); // purposely hidden
232  ~Tool() override;
233 
234  void Notify(InteractionEvent *interactionEvent, bool isHandled) override;
235 
236  bool FilterEvents(InteractionEvent *, DataNode *) override;
237 
238  private:
239  ToolManager* m_ToolManager;
240 
241  // for reference data
242  NodePredicateDataType::Pointer m_PredicateImages;
243  NodePredicateDimension::Pointer m_PredicateDim3;
244  NodePredicateDimension::Pointer m_PredicateDim4;
245  NodePredicateOr::Pointer m_PredicateDimension;
246  NodePredicateAnd::Pointer m_PredicateImage3D;
247 
248  NodePredicateProperty::Pointer m_PredicateBinary;
249  NodePredicateNot::Pointer m_PredicateNotBinary;
250 
251  NodePredicateProperty::Pointer m_PredicateSegmentation;
252  NodePredicateNot::Pointer m_PredicateNotSegmentation;
253 
254  NodePredicateProperty::Pointer m_PredicateHelper;
255  NodePredicateNot::Pointer m_PredicateNotHelper;
256 
257  NodePredicateAnd::Pointer m_PredicateImageColorful;
258 
259  NodePredicateAnd::Pointer m_PredicateImageColorfulNotHelper;
260 
261  NodePredicateAnd::Pointer m_PredicateReference;
262 
263  // for working data
264  NodePredicateAnd::Pointer m_IsSegmentationPredicate;
265 
266  std::string m_InteractorType;
267 
268  std::map<us::ServiceReferenceU, EventConfig> m_DisplayInteractorConfigs;
269 
270  const us::Module *m_InteractorModule;
271  };
272 
273 } // namespace
274 
275 #endif
Message GUIProcessEventsMessage
To let GUI process new events (e.g. qApp->processEvents() )
Definition: mitkTool.h:94
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:86
Data management class that handles &#39;was created by&#39; relations.
Base class to implement InteractionEventObservers.
Base of all data objects.
Definition: mitkBaseData.h:42
Message1< bool > CurrentlyBusy
To send whether the tool is busy (to be shown by some GUI)
Definition: mitkTool.h:104
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
Message1< std::string > ErrorMessage
To send error messages (to be shown by some GUI)
Definition: mitkTool.h:99
std::string m_EventConfig
Let subclasses change their event configuration.
Definition: mitkTool.h:229
virtual std::string GetIconPath() const
Returns the path of an icon.
Definition: mitkTool.h:130
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
Image class for storing images.
Definition: mitkImage.h:69
Message1< std::string > GeneralMessage
To send general messages (to be shown by some GUI)
Definition: mitkTool.h:109
Event/message/notification class.
Definition: mitkMessage.h:452
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
mitk::Label::PixelType DefaultSegmentationDataType
Definition: mitkTool.h:89
unsigned short PixelType
Definition: mitkLabel.h:33
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
Manages and coordinates instances of mitk::Tool.
Super-class that provides the functionality of a StateMachine to DataInteractors. ...