Medical Imaging Interaction Toolkit  2018.4.99-b585543d
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 (unsigned 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)
 
 ~ToolManager () override
 
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
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 nullptr 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 80 of file mitkToolManager.h.

Member Typedef Documentation

◆ DataVectorType

Definition at line 85 of file mitkToolManager.h.

◆ NodeTagMapType

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

Definition at line 86 of file mitkToolManager.h.

◆ ToolVectorType

Definition at line 83 of file mitkToolManager.h.

◆ ToolVectorTypeConst

Definition at line 84 of file mitkToolManager.h.

Constructor & Destructor Documentation

◆ ToolManager()

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 28 of file mitkToolManager.cpp.

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

◆ ~ToolManager()

Member Function Documentation

◆ ActivateTool()

◆ GetActiveTool()

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

Definition at line 469 of file mitkToolManager.cpp.

References m_ActiveTool.

◆ GetActiveToolID()

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

Definition at line 464 of file mitkToolManager.cpp.

References m_ActiveToolID.

◆ GetDataStorage()

◆ GetReferenceData() [1/2]

◆ GetReferenceData() [2/2]

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

Definition at line 402 of file mitkToolManager.cpp.

References m_ReferenceData.

◆ GetRoiData() [1/2]

◆ GetRoiData() [2/2]

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

Definition at line 424 of file mitkToolManager.cpp.

References m_RoiData.

◆ GetToolById()

mitk::Tool * mitk::ToolManager::GetToolById ( int  id)

◆ GetToolID()

int mitk::ToolManager::GetToolID ( const Tool tool)

Definition at line 504 of file mitkToolManager.cpp.

References m_Tools.

◆ GetToolIdByToolType()

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

Definition at line 125 of file mitkToolManager.h.

◆ GetTools()

const mitk::ToolManager::ToolVectorTypeConst mitk::ToolManager::GetTools ( )

◆ GetWorkingData() [1/2]

mitk::ToolManager::DataVectorType mitk::ToolManager::GetWorkingData ( )

Definition at line 414 of file mitkToolManager.cpp.

References m_WorkingData.

Referenced by mitk::FastMarchingTool3D::Activated(), mitk::SegTool2D::AddContourmarker(), mitk::SegmentationInteractor::ChangeActiveLabel(), mitk::PaintbrushTool::CheckIfCurrentSliceHasChanged(), mitk::LiveWireTool2D::ClearSegmentation(), mitk::LiveWireTool2D::ConfirmSegmentation(), mitk::FastMarchingTool::ConfirmSegmentation(), mitk::BinaryThresholdTool::CreateNewSegmentationFromThreshold(), mitk::BinaryThresholdULTool::CreateNewSegmentationFromThreshold(), mitk::SegTool2D::GetAffectedWorkingSlice(), mitk::AutoSegmentationTool::GetCurrentSegmentationName(), mitk::AutoSegmentationTool::GetTargetSegmentationNode(), mitk::PickingTool::GetWorkingData(), mitk::PaintbrushTool::MouseMoved(), mitk::SetRegionTool::OnMousePressed(), mitk::SetRegionTool::OnMouseReleased(), mitk::ContourTool::OnMouseReleased(), mitk::CorrectorTool2D::OnMouseReleased(), mitk::RegionGrowingTool::OnMouseReleased(), mitk::PickingTool::OnPointAdded(), QmitkSurfaceStampWidget::OnStamp(), QmitkMaskStampWidget::OnStamp(), QmitkSurfaceBasedInterpolatorWidget::OnToggleWidgetActivation(), QmitkSliceBasedInterpolatorWidget::OnToggleWidgetActivation(), QmitkSurfaceBasedInterpolatorWidget::OnToolManagerWorkingDataModified(), QmitkSliceBasedInterpolatorWidget::OnToolManagerWorkingDataModified(), mitk::SegmentationsProcessingTool::ProcessAllObjects(), QmitkLabelSetWidget::SetDataStorage(), mitk::FeedbackContourTool::SetFeedbackContourVisible(), mitk::BinaryThresholdTool::SetupPreviewNode(), mitk::BinaryThresholdULTool::SetupPreviewNode(), QmitkLabelSetWidget::UpdateControls(), mitk::SegTool2D::WriteBackSegmentationResult(), and mitk::SegTool2D::WriteSliceToVolume().

◆ GetWorkingData() [2/2]

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

Definition at line 453 of file mitkToolManager.cpp.

References m_WorkingData.

◆ InitializeTools()

void mitk::ToolManager::InitializeTools ( )

◆ mitkClassMacroItkParent()

mitk::ToolManager::mitkClassMacroItkParent ( ToolManager  ,
itk::Object   
)

◆ mitkNewMacro1Param()

mitk::ToolManager::mitkNewMacro1Param ( ToolManager  ,
DataStorage  
)

◆ OnGeneralToolMessage()

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

Definition at line 102 of file mitkToolManager.cpp.

References GeneralToolMessage.

Referenced by InitializeTools().

◆ OnNodeRemoved()

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

Callback for NodeRemove events.

Definition at line 517 of file mitkToolManager.cpp.

References OnOneOfTheReferenceDataDeleted(), OnOneOfTheRoiDataDeleted(), and OnOneOfTheWorkingDataDeleted().

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

◆ OnOneOfTheReferenceDataDeleted()

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

◆ OnOneOfTheReferenceDataDeletedConst()

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

Definition at line 227 of file mitkToolManager.cpp.

References OnOneOfTheReferenceDataDeleted().

Referenced by SetReferenceData().

◆ OnOneOfTheRoiDataDeleted()

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

◆ OnOneOfTheRoiDataDeletedConst()

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

Definition at line 374 of file mitkToolManager.cpp.

References OnOneOfTheRoiDataDeleted().

Referenced by SetRoiData().

◆ OnOneOfTheWorkingDataDeleted()

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

◆ OnOneOfTheWorkingDataDeletedConst()

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

Definition at line 297 of file mitkToolManager.cpp.

References OnOneOfTheWorkingDataDeleted().

Referenced by SetWorkingData().

◆ OnToolErrorMessage()

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

Definition at line 97 of file mitkToolManager.cpp.

References ToolErrorMessage.

Referenced by InitializeTools().

◆ RegisterClient()

◆ SetDataStorage()

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

Definition at line 448 of file mitkToolManager.cpp.

References m_DataStorage.

◆ SetReferenceData() [1/2]

◆ SetReferenceData() [2/2]

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

Definition at line 250 of file mitkToolManager.cpp.

References SetReferenceData().

◆ SetRoiData() [1/2]

◆ SetRoiData() [2/2]

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

Definition at line 363 of file mitkToolManager.cpp.

References SetRoiData().

◆ SetWorkingData() [1/2]

◆ SetWorkingData() [2/2]

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

Definition at line 320 of file mitkToolManager.cpp.

References SetWorkingData().

◆ UnregisterClient()

void mitk::ToolManager::UnregisterClient ( )

Member Data Documentation

◆ ActiveToolChanged

Message mitk::ToolManager::ActiveToolChanged

Definition at line 92 of file mitkToolManager.h.

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

◆ GeneralToolMessage

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

Definition at line 98 of file mitkToolManager.h.

Referenced by OnGeneralToolMessage().

◆ m_ActiveTool

Tool* mitk::ToolManager::m_ActiveTool
protected

◆ m_ActiveToolID

int mitk::ToolManager::m_ActiveToolID
protected

Definition at line 260 of file mitkToolManager.h.

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

◆ m_ActiveToolRegistration

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

◆ m_DataStorage

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

Definition at line 274 of file mitkToolManager.h.

Referenced by GetDataStorage(), and SetDataStorage().

◆ m_ReferenceData

DataVectorType mitk::ToolManager::m_ReferenceData
protected

◆ m_ReferenceDataObserverTags

NodeTagMapType mitk::ToolManager::m_ReferenceDataObserverTags
protected

◆ m_RegisteredClients

int mitk::ToolManager::m_RegisteredClients
protected

Definition at line 272 of file mitkToolManager.h.

Referenced by ActivateTool(), RegisterClient(), and UnregisterClient().

◆ m_RoiData

DataVectorType mitk::ToolManager::m_RoiData
protected

Definition at line 269 of file mitkToolManager.h.

Referenced by GetRoiData(), OnOneOfTheRoiDataDeleted(), and SetRoiData().

◆ m_RoiDataObserverTags

NodeTagMapType mitk::ToolManager::m_RoiDataObserverTags
protected

Definition at line 270 of file mitkToolManager.h.

Referenced by OnOneOfTheRoiDataDeleted(), and SetRoiData().

◆ m_Tools

ToolVectorType mitk::ToolManager::m_Tools
protected

Definition at line 257 of file mitkToolManager.h.

Referenced by GetToolById(), GetToolID(), GetTools(), and InitializeTools().

◆ m_WorkingData

DataVectorType mitk::ToolManager::m_WorkingData
protected

◆ m_WorkingDataObserverTags

NodeTagMapType mitk::ToolManager::m_WorkingDataObserverTags
protected

Definition at line 267 of file mitkToolManager.h.

Referenced by OnOneOfTheWorkingDataDeleted(), SetWorkingData(), and ~ToolManager().

◆ NewNodeObjectsGenerated

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

Definition at line 90 of file mitkToolManager.h.

◆ NewNodesGenerated

Message mitk::ToolManager::NewNodesGenerated

Definition at line 89 of file mitkToolManager.h.

◆ NodePropertiesChanged

Message mitk::ToolManager::NodePropertiesChanged

Definition at line 88 of file mitkToolManager.h.

◆ ReferenceDataChanged

Message mitk::ToolManager::ReferenceDataChanged

Definition at line 93 of file mitkToolManager.h.

Referenced by SetReferenceData().

◆ RoiDataChanged

◆ ToolErrorMessage

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

Definition at line 97 of file mitkToolManager.h.

Referenced by OnToolErrorMessage().

◆ WorkingDataChanged


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