Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit

Manages and coordinates instances of mitk::Tool. More...

#include <mitkToolManager.h>

Inheritance diagram for mitk::ToolManager:
Collaboration diagram for mitk::ToolManager:

Public Types

typedef std::vector< Tool::PointerToolVectorType
 
typedef std::vector< Tool::ConstPointerToolVectorTypeConst
 
typedef std::vector< DataNode * > DataVectorType
 
typedef std::map< DataNode *, unsigned long > NodeTagMapType
 

Public Member Functions

 mitkClassMacroItkParent (ToolManager, itk::Object)
 
 mitkNewMacro1Param (ToolManager, DataStorage *)
 
const ToolVectorTypeConst GetTools ()
 Gives you a list of all tools. This is const on purpose. More...
 
int GetToolID (const Tool *tool)
 
ToolGetToolById (int id)
 
bool ActivateTool (int id)
 
template<class T >
int GetToolIdByToolType ()
 
int GetActiveToolID ()
 
ToolGetActiveTool ()
 
void SetReferenceData (DataVectorType)
 
void SetReferenceData (DataNode *)
 
void SetWorkingData (DataVectorType)
 
void SetWorkingData (DataNode *)
 
void SetRoiData (DataVectorType)
 
void SetRoiData (DataNode *)
 
DataVectorType GetReferenceData ()
 
DataNodeGetReferenceData (int)
 
DataVectorType GetWorkingData ()
 
DataNodeGetWorkingData (int)
 
DataVectorType GetRoiData ()
 
DataNodeGetRoiData (int idx)
 
DataStorageGetDataStorage ()
 
void SetDataStorage (DataStorage &storage)
 
void RegisterClient ()
 
void UnregisterClient ()
 
void InitializeTools ()
 Initialize all classes derived from mitk::Tool by itkObjectFactoy. More...
 
void OnOneOfTheReferenceDataDeletedConst (const itk::Object *caller, const itk::EventObject &e)
 
void OnOneOfTheReferenceDataDeleted (itk::Object *caller, const itk::EventObject &e)
 
void OnOneOfTheWorkingDataDeletedConst (const itk::Object *caller, const itk::EventObject &e)
 
void OnOneOfTheWorkingDataDeleted (itk::Object *caller, const itk::EventObject &e)
 
void OnOneOfTheRoiDataDeletedConst (const itk::Object *caller, const itk::EventObject &e)
 
void OnOneOfTheRoiDataDeleted (itk::Object *caller, const itk::EventObject &e)
 
void OnToolErrorMessage (std::string s)
 
void OnGeneralToolMessage (std::string s)
 

Public Attributes

Message NodePropertiesChanged
 
Message NewNodesGenerated
 
Message1< DataVectorType * > NewNodeObjectsGenerated
 
Message ActiveToolChanged
 
Message ReferenceDataChanged
 
Message WorkingDataChanged
 
Message RoiDataChanged
 
Message1< std::string > ToolErrorMessage
 
Message1< std::string > GeneralToolMessage
 

Protected Member Functions

 ToolManager (DataStorage *storage)
 
virtual ~ToolManager ()
 
void OnNodeRemoved (const mitk::DataNode *node)
 Callback for NodeRemove events. More...
 

Protected Attributes

ToolVectorType m_Tools
 
Toolm_ActiveTool
 
int m_ActiveToolID
 
us::ServiceRegistration< InteractionEventObserverm_ActiveToolRegistration
 
DataVectorType m_ReferenceData
 
NodeTagMapType m_ReferenceDataObserverTags
 
DataVectorType m_WorkingData
 
NodeTagMapType m_WorkingDataObserverTags
 
DataVectorType m_RoiData
 
NodeTagMapType m_RoiDataObserverTags
 
int m_RegisteredClients
 
WeakPointer< DataStoragem_DataStorage
 

Detailed Description

Manages and coordinates instances of mitk::Tool.

See also
QmitkToolSelectionBox
QmitkToolReferenceDataSelectionBox
QmitkToolWorkingDataSelectionBox
Tool
QmitkSegmentationView

There is a separate page describing the general design of QmitkSegmentationView: Technical design of QmitkSegmentation

This class creates and manages several instances of mitk::Tool.

  • ToolManager creates instances of mitk::Tool by asking the itk::ObjectFactory to list all known implementations of mitk::Tool. As a result, one has to implement both a subclass of mitk::Tool and a matching subclass of itk::ObjectFactoryBase that is registered to the top-level itk::ObjectFactory. For an example, see mitkContourToolFactory.h. (this limitiation of one-class-one-factory is due to the implementation of itk::ObjectFactory). In MITK, the right place to register the factories to itk::ObjectFactory is the mitk::QMCoreObjectFactory or mitk::SBCoreObjectFactory.
  • ToolManager knows a set of "reference" DataNodes and a set of "working" DataNodes. The first application are segmentation tools, where the reference is the original image and the working data the (kind of) binary segmentation. However, ToolManager is implemented more generally, so that there could be other tools that work, e.g., with surfaces.
  • There is a set of events that are sent by ToolManager. At the moment these are TODO update documentation:
    • mitk::ToolReferenceDataChangedEvent whenever somebody calls SetReferenceData. Most of the time this actually means that the data has changed, but there might be cases where the same data is passed to SetReferenceData a second time, so don't rely on the assumption that something actually changed.
    • mitk::ToolSelectedEvent is sent when a (truly) different tool was activated. In reaction to this event you can ask for the active Tool using GetActiveTool or GetActiveToolID (where NULL or -1 indicate that NO tool is active at the moment).

Design descisions:

  • Not a singleton, because there could be two functionalities using tools, each one with different reference/working data.

$Author$

Definition at line 86 of file mitkToolManager.h.

Member Typedef Documentation

Definition at line 91 of file mitkToolManager.h.

typedef std::map<DataNode *, unsigned long> mitk::ToolManager::NodeTagMapType

Definition at line 92 of file mitkToolManager.h.

Definition at line 89 of file mitkToolManager.h.

Definition at line 90 of file mitkToolManager.h.

Constructor & Destructor Documentation

mitk::ToolManager::ToolManager ( DataStorage storage)
protected

You may specify a list of tool "groups" that should be available for this ToolManager. Every Tool can report its group as a string. This constructor will try to find the tool's group inside the supplied string. If there is a match, the tool is accepted. Effectively, you can provide a human readable list like "default, lymphnodevolumetry, oldERISstuff".

Definition at line 31 of file mitkToolManager.cpp.

References mitk::CoreObjectFactory::GetInstance(), and InitializeTools().

mitk::ToolManager::~ToolManager ( )
protectedvirtual

Definition at line 39 of file mitkToolManager.cpp.

References GetDataStorage(), and OnNodeRemoved().

Member Function Documentation

bool mitk::ToolManager::ActivateTool ( int  id)
Parameters
idThe tool to activate. Provide -1 for disabling any tools. Counting starts with 0. Registeres a listner for NodeRemoved event at DataStorage (see mitk::ToolManager::OnNodeRemoved).

Definition at line 123 of file mitkToolManager.cpp.

References GetData(), GetDataStorage(), us::GetModuleContext(), OnNodeRemoved(), and ModuleContext::RegisterService().

Referenced by QmitkSurfaceStampWidget::OnStamp(), QmitkMaskStampWidget::QmitkMaskStampWidget(), and QmitkSurfaceStampWidget::QmitkSurfaceStampWidget().

mitk::Tool * mitk::ToolManager::GetActiveTool ( )
Returns
NULL for "No tool is active"

Definition at line 450 of file mitkToolManager.cpp.

int mitk::ToolManager::GetActiveToolID ( )
Returns
-1 for "No tool is active"

Definition at line 445 of file mitkToolManager.cpp.

mitk::DataStorage * mitk::ToolManager::GetDataStorage ( )

Definition at line 416 of file mitkToolManager.cpp.

References m_DataStorage.

mitk::ToolManager::DataVectorType mitk::ToolManager::GetReferenceData ( )

Definition at line 377 of file mitkToolManager.cpp.

mitk::DataNode * mitk::ToolManager::GetReferenceData ( int  idx)

Definition at line 382 of file mitkToolManager.cpp.

mitk::ToolManager::DataVectorType mitk::ToolManager::GetRoiData ( )

Definition at line 399 of file mitkToolManager.cpp.

mitk::DataNode * mitk::ToolManager::GetRoiData ( int  idx)

Definition at line 404 of file mitkToolManager.cpp.

mitk::Tool * mitk::ToolManager::GetToolById ( int  id)
int mitk::ToolManager::GetToolID ( const Tool tool)

Definition at line 485 of file mitkToolManager.cpp.

template<class T >
int mitk::ToolManager::GetToolIdByToolType ( )
inline

Definition at line 131 of file mitkToolManager.h.

mitk::DataNode * mitk::ToolManager::GetWorkingData ( int  idx)

Definition at line 433 of file mitkToolManager.cpp.

void mitk::ToolManager::InitializeTools ( )

Initialize all classes derived from mitk::Tool by itkObjectFactoy.

Definition at line 66 of file mitkToolManager.cpp.

References OnGeneralToolMessage(), and OnToolErrorMessage().

Referenced by ToolManager().

mitk::ToolManager::mitkClassMacroItkParent ( ToolManager  ,
itk::Object   
)
mitk::ToolManager::mitkNewMacro1Param ( ToolManager  ,
DataStorage  
)
void mitk::ToolManager::OnGeneralToolMessage ( std::string  s)

Definition at line 94 of file mitkToolManager.cpp.

Referenced by InitializeTools().

void mitk::ToolManager::OnNodeRemoved ( const mitk::DataNode node)
protected

Callback for NodeRemove events.

Definition at line 498 of file mitkToolManager.cpp.

Referenced by ActivateTool(), and ~ToolManager().

void mitk::ToolManager::OnOneOfTheReferenceDataDeleted ( itk::Object *  caller,
const itk::EventObject &  e 
)

Definition at line 212 of file mitkToolManager.cpp.

Referenced by SetReferenceData().

void mitk::ToolManager::OnOneOfTheReferenceDataDeletedConst ( const itk::Object *  caller,
const itk::EventObject &  e 
)

Definition at line 207 of file mitkToolManager.cpp.

Referenced by SetReferenceData().

void mitk::ToolManager::OnOneOfTheRoiDataDeleted ( itk::Object *  caller,
const itk::EventObject &  e 
)

Definition at line 359 of file mitkToolManager.cpp.

Referenced by SetRoiData().

void mitk::ToolManager::OnOneOfTheRoiDataDeletedConst ( const itk::Object *  caller,
const itk::EventObject &  e 
)

Definition at line 354 of file mitkToolManager.cpp.

Referenced by SetRoiData().

void mitk::ToolManager::OnOneOfTheWorkingDataDeleted ( itk::Object *  caller,
const itk::EventObject &  e 
)

Definition at line 282 of file mitkToolManager.cpp.

Referenced by SetWorkingData().

void mitk::ToolManager::OnOneOfTheWorkingDataDeletedConst ( const itk::Object *  caller,
const itk::EventObject &  e 
)

Definition at line 277 of file mitkToolManager.cpp.

Referenced by SetWorkingData().

void mitk::ToolManager::OnToolErrorMessage ( std::string  s)

Definition at line 89 of file mitkToolManager.cpp.

Referenced by InitializeTools().

void mitk::ToolManager::RegisterClient ( )
void mitk::ToolManager::SetDataStorage ( DataStorage storage)

Definition at line 428 of file mitkToolManager.cpp.

References m_DataStorage.

void mitk::ToolManager::SetReferenceData ( DataVectorType  data)
void mitk::ToolManager::SetReferenceData ( DataNode data)

Definition at line 230 of file mitkToolManager.cpp.

void mitk::ToolManager::SetRoiData ( DataVectorType  data)
void mitk::ToolManager::SetRoiData ( DataNode data)

Definition at line 343 of file mitkToolManager.cpp.

void mitk::ToolManager::SetWorkingData ( DataVectorType  data)
void mitk::ToolManager::SetWorkingData ( DataNode data)

Definition at line 300 of file mitkToolManager.cpp.

void mitk::ToolManager::UnregisterClient ( )

Definition at line 469 of file mitkToolManager.cpp.

Member Data Documentation

Message mitk::ToolManager::ActiveToolChanged

Definition at line 98 of file mitkToolManager.h.

Message1<std::string> mitk::ToolManager::GeneralToolMessage

Definition at line 104 of file mitkToolManager.h.

Tool* mitk::ToolManager::m_ActiveTool
protected

Definition at line 265 of file mitkToolManager.h.

int mitk::ToolManager::m_ActiveToolID
protected

Definition at line 266 of file mitkToolManager.h.

us::ServiceRegistration<InteractionEventObserver> mitk::ToolManager::m_ActiveToolRegistration
protected

Definition at line 267 of file mitkToolManager.h.

WeakPointer<DataStorage> mitk::ToolManager::m_DataStorage
protected

Definition at line 280 of file mitkToolManager.h.

DataVectorType mitk::ToolManager::m_ReferenceData
protected

Definition at line 269 of file mitkToolManager.h.

NodeTagMapType mitk::ToolManager::m_ReferenceDataObserverTags
protected

Definition at line 270 of file mitkToolManager.h.

int mitk::ToolManager::m_RegisteredClients
protected

Definition at line 278 of file mitkToolManager.h.

DataVectorType mitk::ToolManager::m_RoiData
protected

Definition at line 275 of file mitkToolManager.h.

NodeTagMapType mitk::ToolManager::m_RoiDataObserverTags
protected

Definition at line 276 of file mitkToolManager.h.

ToolVectorType mitk::ToolManager::m_Tools
protected

Definition at line 263 of file mitkToolManager.h.

DataVectorType mitk::ToolManager::m_WorkingData
protected

Definition at line 272 of file mitkToolManager.h.

NodeTagMapType mitk::ToolManager::m_WorkingDataObserverTags
protected

Definition at line 273 of file mitkToolManager.h.

Message1<DataVectorType *> mitk::ToolManager::NewNodeObjectsGenerated

Definition at line 96 of file mitkToolManager.h.

Message mitk::ToolManager::NewNodesGenerated

Definition at line 95 of file mitkToolManager.h.

Message mitk::ToolManager::NodePropertiesChanged

Definition at line 94 of file mitkToolManager.h.

Message mitk::ToolManager::ReferenceDataChanged

Definition at line 99 of file mitkToolManager.h.

Message mitk::ToolManager::RoiDataChanged

Definition at line 101 of file mitkToolManager.h.

Message1<std::string> mitk::ToolManager::ToolErrorMessage

Definition at line 103 of file mitkToolManager.h.


The documentation for this class was generated from the following files: