Medical Imaging Interaction Toolkit  2018.4.99-fa2b431b
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);
190  DataNode::Pointer CreateSegmentationNode(Image *image, const std::string &organName, const mitk::Color &color);
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 *);
203 
204  void ConnectActionsAndFunctions() override;
205 
211  virtual void Activated();
212 
218  virtual void Deactivated();
219 
223  std::string m_EventConfig;
224 
225  Tool(); // purposely hidden
226  Tool(const char *, const us::Module *interactorModule = nullptr); // purposely hidden
227  ~Tool() override;
228 
229  void Notify(InteractionEvent *interactionEvent, bool isHandled) override;
230 
231  bool FilterEvents(InteractionEvent *, DataNode *) override;
232 
234 
235  private:
236  // for reference data
237  NodePredicateDataType::Pointer m_PredicateImages;
238  NodePredicateDimension::Pointer m_PredicateDim3;
239  NodePredicateDimension::Pointer m_PredicateDim4;
240  NodePredicateOr::Pointer m_PredicateDimension;
241  NodePredicateAnd::Pointer m_PredicateImage3D;
242 
243  NodePredicateProperty::Pointer m_PredicateBinary;
244  NodePredicateNot::Pointer m_PredicateNotBinary;
245 
246  NodePredicateProperty::Pointer m_PredicateSegmentation;
247  NodePredicateNot::Pointer m_PredicateNotSegmentation;
248 
249  NodePredicateProperty::Pointer m_PredicateHelper;
250  NodePredicateNot::Pointer m_PredicateNotHelper;
251 
252  NodePredicateAnd::Pointer m_PredicateImageColorful;
253 
254  NodePredicateAnd::Pointer m_PredicateImageColorfulNotHelper;
255 
256  NodePredicateAnd::Pointer m_PredicateReference;
257 
258  // for working data
259  NodePredicateAnd::Pointer m_IsSegmentationPredicate;
260 
261  std::string m_InteractorType;
262 
263  std::map<us::ServiceReferenceU, EventConfig> m_DisplayInteractorConfigs;
264 
265  const us::Module *m_InteractorModule;
266  };
267 
268 } // namespace
269 
270 #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
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:223
virtual std::string GetIconPath() const
Returns the path of an icon.
Definition: mitkTool.h:130
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
Image class for storing images.
Definition: mitkImage.h:73
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
ToolManager * m_ToolManager
Definition: mitkTool.h:233
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. ...