Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
Base class of all tools used by mitk::ToolManager. More...
#include <mitkTool.h>
Public Types | |
typedef mitk::Label::PixelType | DefaultSegmentationDataType |
Public Types inherited from mitk::EventStateMachine | |
typedef EventStateMachine | Self |
typedef InteractionEventHandler | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer< const Self > | ConstPointer |
typedef std::map< std::string, TActionFunctor * > | ActionFunctionsMapType |
typedef itk::SmartPointer< StateMachineState > | StateMachineStateType |
Public Types inherited from mitk::InteractionEventHandler | |
typedef InteractionEventHandler | Self |
typedef itk::Object | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer< const Self > | ConstPointer |
Public Member Functions | |
mitkClassMacro (Tool, EventStateMachine) | |
virtual const char ** | GetXPM () const =0 |
Returns an icon in the XPM format. More... | |
virtual std::string | GetIconPath () const |
Returns the path of an icon. More... | |
virtual us::ModuleResource | GetCursorIconResource () const |
Returns the path of a cursor icon. More... | |
virtual us::ModuleResource | GetIconResource () const |
Returns the tool button icon of the tool wrapped by a usModuleResource. More... | |
virtual const char * | GetName () const =0 |
Returns the name of this tool. Make it short! More... | |
virtual const char * | GetGroup () const |
Name of a group. More... | |
virtual void | InitializeStateMachine () |
virtual itk::Object::Pointer | GetGUI (const std::string &toolkitPrefix, const std::string &toolkitPostfix) |
Interface for GUI creation. More... | |
virtual NodePredicateBase::ConstPointer | GetReferenceDataPreference () const |
virtual NodePredicateBase::ConstPointer | GetWorkingDataPreference () const |
DataNode::Pointer | CreateEmptySegmentationNode (Image *original, const std::string &organName, const mitk::Color &color) |
DataNode::Pointer | CreateSegmentationNode (Image *image, const std::string &organName, const mitk::Color &color) |
virtual bool | CanHandle (BaseData *referenceData) const |
Public Member Functions inherited from mitk::EventStateMachine | |
virtual std::vector< std::string > | GetClassHierarchy () const override |
virtual const char * | GetClassName () const |
bool | LoadStateMachine (const std::string &filename, const us::Module *module=nullptr) |
Loads XML resource. More... | |
bool | HandleEvent (InteractionEvent *event, DataNode *dataNode) |
void | EnableUndo (bool enable) |
Enables or disabled Undo. More... | |
void | EnableInteraction (bool enable) |
Enables/disables the state machine. In un-enabled state it won't react to any events. More... | |
Public Member Functions inherited from mitk::InteractionEventHandler | |
bool | SetEventConfig (const std::string &filename, const us::Module *module=nullptr) |
Loads a configuration from an XML resource. More... | |
bool | SetEventConfig (const EventConfig &config) |
Loads a configuration from an EventConfig object. More... | |
EventConfig | GetEventConfig () const |
Returns the current configuration. More... | |
bool | AddEventConfig (const std::string &filename, const us::Module *module=nullptr) |
This method extends the configuration. More... | |
bool | AddEventConfig (const EventConfig &config) |
This method extends the configuration. The configuration from the EventConfig object is loaded and only the ones conflicting are replaced by the new one. This way several configurations can be combined. More... | |
Public Member Functions inherited from mitk::InteractionEventObserver | |
InteractionEventObserver () | |
virtual | ~InteractionEventObserver () |
void | Disable () |
void | Enable () |
bool | IsEnabled () const |
Public Attributes | |
Message | GUIProcessEventsMessage |
To let GUI process new events (e.g. qApp->processEvents() ) More... | |
Message1< std::string > | ErrorMessage |
To send error messages (to be shown by some GUI) More... | |
Message1< bool > | CurrentlyBusy |
To send whether the tool is busy (to be shown by some GUI) More... | |
Message1< std::string > | GeneralMessage |
To send general messages (to be shown by some GUI) More... | |
Protected Member Functions | |
virtual void | SetToolManager (ToolManager *) |
void | ConnectActionsAndFunctions () override |
virtual void | Activated () |
Called when the tool gets activated. More... | |
virtual void | Deactivated () |
Called when the tool gets deactivated. More... | |
Tool () | |
Tool (const char *) | |
virtual | ~Tool () |
virtual void | Notify (InteractionEvent *interactionEvent, bool isHandled) override |
bool | FilterEvents (InteractionEvent *, DataNode *) override |
Protected Member Functions inherited from mitk::EventStateMachine | |
EventStateMachine () | |
virtual | ~EventStateMachine () |
void | AddActionFunction (const std::string &action, TActionFunctor *functor) |
void | AddActionFunction (const std::string &action, const ActionFunctionDelegate &delegate) |
void | AddConditionFunction (const std::string &condition, const ConditionFunctionDelegate &delegate) |
StateMachineState * | GetCurrentState () const |
void | ResetToStartState () |
ResetToStartState Reset state machine to it initial starting state. More... | |
virtual bool | CheckCondition (const StateMachineCondition &condition, const InteractionEvent *interactionEvent) |
virtual void | ExecuteAction (StateMachineAction *action, InteractionEvent *interactionEvent) |
void | SetMouseCursor (const char *xpm[], int hotspotX, int hotspotY) |
Sets the specified mouse cursor. More... | |
void | ResetMouseCursor () |
Resets the mouse cursor (if modified by the SlicesCoordinator) to its original state. More... | |
StateMachineTransition * | GetExecutableTransition (InteractionEvent *event) |
Returns the executable transition for the given event. More... | |
Protected Member Functions inherited from mitk::InteractionEventHandler | |
InteractionEventHandler () | |
virtual | ~InteractionEventHandler () |
PropertyList::Pointer | GetAttributes () const |
std::string | MapToEventVariant (InteractionEvent *interactionEvent) |
virtual void | ConfigurationChanged () |
Protected Attributes | |
std::string | m_EventConfig |
Let subclasses change their event configuration. More... | |
ToolManager * | m_ToolManager |
Protected Attributes inherited from mitk::EventStateMachine | |
bool | m_IsActive |
UndoController * | m_UndoController |
bool | m_UndoEnabled |
Additional Inherited Members | |
Static Public Member Functions inherited from mitk::EventStateMachine | |
static const char * | GetStaticNameOfClass () |
Static Public Member Functions inherited from mitk::InteractionEventHandler | |
static const char * | GetStaticNameOfClass () |
Protected Types inherited from mitk::EventStateMachine | |
typedef MessageAbstractDelegate2< StateMachineAction *, InteractionEvent *, void > | ActionFunctionDelegate |
typedef MessageAbstractDelegate1< const InteractionEvent *, bool > | ConditionFunctionDelegate |
Base class of all tools used by mitk::ToolManager.
There is a separate page describing the QmitkInteractiveSegmentationTechnicalPage.
Every tool is a mitk::StateMachine, which can follow any transition pattern that it likes. One important thing to know is, that every derived tool should always call SuperClass::Deactivated() at the end of its own implementation of Deactivated, because mitk::Tool resets the StateMachine in this method. Only if you are very sure that you covered all possible things that might happen to your own tool, you should consider not to reset the StateMachine from time to time.
To learn about the MITK implementation of state machines in general, have a look at Interaction and Undo/Redo Concepts.
To derive a non-abstract tool, you inherit from mitk::Tool (or some other base class further down the inheritance tree), and in your own parameterless constructor (that is called from the itkFactorylessNewMacro that you use) you pass a StateMachine pattern name to the superclass. Names for valid patterns can be found in StateMachine.xml (which might be enhanced by you).
You have to implement at least GetXPM() and GetName() to provide some identification.
Each Tool knows its ToolManager, which can provide the data that the tool should work on.
$Author$
Definition at line 92 of file mitkTool.h.
Definition at line 95 of file mitkTool.h.
|
protected |
|
protected |
Definition at line 36 of file mitkTool.cpp.
|
protectedvirtual |
Definition at line 60 of file mitkTool.cpp.
|
protectedvirtual |
Called when the tool gets activated.
Derived tools should call their parents implementation at the beginning of the overriding function.
Reimplemented in mitk::FastMarchingTool, mitk::FastMarchingTool3D, mitk::WatershedTool, mitk::AdaptiveRegionGrowingTool, mitk::RegionGrowingTool, mitk::CorrectorTool2D, mitk::FeedbackContourTool, mitk::LiveWireTool2D, mitk::PaintbrushTool, mitk::ContourTool, mitk::BinaryThresholdULTool, mitk::PickingTool, mitk::SetRegionTool, mitk::BinaryThresholdTool, mitk::SegmentationsProcessingTool, mitk::PixelManipulationTool, and mitk::OtsuTool3D.
Definition at line 116 of file mitkTool.cpp.
References mitk::InteractionEventHandler::GetEventConfig(), us::GetModuleContext(), ModuleContext::GetService(), ModuleContext::GetServiceReferences(), and mitk::InteractionEventHandler::SetEventConfig().
|
virtual |
Reimplemented in mitk::FastMarchingTool3D, and mitk::AdaptiveRegionGrowingTool.
Definition at line 64 of file mitkTool.cpp.
Referenced by QmitkToolSelectionBox::RecreateButtons().
|
overrideprotectedvirtual |
Is called after loading a statemachine. Overwrite this function in specific interactor implementations. Connect actions and functions using the CONNECT_FUNCTION macro within this function.
Reimplemented from mitk::EventStateMachine.
Definition at line 97 of file mitkTool.cpp.
mitk::DataNode::Pointer mitk::Tool::CreateEmptySegmentationNode | ( | Image * | original, |
const std::string & | organName, | ||
const mitk::Color & | color | ||
) |
Definition at line 198 of file mitkTool.cpp.
References mitk::TimeGeometry::Clone(), ErrorMessage, mitk::Image::GetDimension(), mitk::BaseData::GetTimeGeometry(), mitk::Label::New(), and mitk::Image::New().
mitk::DataNode::Pointer mitk::Tool::CreateSegmentationNode | ( | Image * | image, |
const std::string & | organName, | ||
const mitk::Color & | color | ||
) |
Definition at line 271 of file mitkTool.cpp.
References mitk::LookupTable::MULTILABEL, mitk::BoolProperty::New(), mitk::IntProperty::New(), mitk::FloatProperty::New(), mitk::VtkResliceInterpolationProperty::New(), mitk::StringProperty::New(), mitk::LevelWindowProperty::New(), mitk::LookupTable::New(), mitk::LookupTableProperty::New(), mitk::ColorProperty::New(), and mitk::DataNode::New().
|
protectedvirtual |
Called when the tool gets deactivated.
Derived tools should call their parents implementation at the end of the overriding function.
Reimplemented in mitk::FastMarchingTool, mitk::FastMarchingTool3D, mitk::AdaptiveRegionGrowingTool, mitk::WatershedTool, mitk::RegionGrowingTool, mitk::CorrectorTool2D, mitk::LiveWireTool2D, mitk::FeedbackContourTool, mitk::PaintbrushTool, mitk::ContourTool, mitk::BinaryThresholdULTool, mitk::PickingTool, mitk::SetRegionTool, mitk::BinaryThresholdTool, mitk::SegmentationsProcessingTool, mitk::PixelManipulationTool, and mitk::OtsuTool3D.
Definition at line 141 of file mitkTool.cpp.
References us::GetModuleContext(), ModuleContext::GetService(), and mitk::InteractionEventHandler::SetEventConfig().
|
overrideprotectedvirtual |
Implements filter scheme for events. Standard implementation accepts events from 2d and 3d windows, and rejects events if DataNode is not visible.
Overwrite this function to adapt for your own needs, for example to filter out events from 3d windows like this:
or to enforce that the interactor only reacts when the corresponding DataNode is selected in the DataManager view..
Reimplemented from mitk::EventStateMachine.
Definition at line 101 of file mitkTool.cpp.
|
virtual |
Returns the path of a cursor icon.
Reimplemented in mitk::FastMarchingTool, mitk::RegionGrowingTool, mitk::CorrectorTool2D, mitk::SubtractContourTool, mitk::AddContourTool, mitk::LiveWireTool2D, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::EraseRegionTool, and mitk::FillRegionTool.
Definition at line 314 of file mitkTool.cpp.
|
virtual |
Name of a group.
You can group several tools by assigning a group name. Graphical tool selectors might use this information to group tools. (What other reason could there be?)
Reimplemented in mitk::AutoSegmentationTool, and mitk::SegmentationsProcessingTool.
Definition at line 106 of file mitkTool.cpp.
Referenced by QmitkToolWorkingDataSelectionBox::GetAllNodes(), QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImagesPredicate(), QmitkToolSelectionBox::RecreateButtons(), and QmitkToolSelectionBox::SetOrUnsetButtonForActiveTool().
|
virtual |
Interface for GUI creation.
This is the basic interface for creation of a GUI object belonging to one tool.
Tools that support a GUI (e.g. for display/editing of parameters) should follow some rules:
Definition at line 163 of file mitkTool.cpp.
References MITK_ERROR.
Referenced by QmitkToolSelectionBox::SetOrUnsetButtonForActiveTool().
|
inlinevirtual |
Returns the path of an icon.
This icon is preferred to the XPM icon.
Definition at line 136 of file mitkTool.h.
|
virtual |
Returns the tool button icon of the tool wrapped by a usModuleResource.
Reimplemented in mitk::FastMarchingTool, mitk::FastMarchingTool3D, mitk::WatershedTool, mitk::AdaptiveRegionGrowingTool, mitk::RegionGrowingTool, mitk::CorrectorTool2D, mitk::SubtractContourTool, mitk::AddContourTool, mitk::LiveWireTool2D, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::PickingTool, mitk::BinaryThresholdULTool, mitk::BinaryThresholdTool, mitk::EraseRegionTool, mitk::FillRegionTool, and mitk::OtsuTool3D.
Definition at line 308 of file mitkTool.cpp.
Referenced by QmitkToolSelectionBox::RecreateButtons().
|
pure virtual |
Returns the name of this tool. Make it short!
This name has to fit into some kind of button in most applications, so take some time to think of a good name!
Implemented in mitk::FastMarchingTool, mitk::FastMarchingTool3D, mitk::WatershedTool, mitk::RegionGrowingTool, mitk::CorrectorTool2D, mitk::AdaptiveRegionGrowingTool, mitk::SubtractContourTool, mitk::AddContourTool, mitk::LiveWireTool2D, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::BinaryThresholdULTool, mitk::EraseRegionTool, mitk::BinaryThresholdTool, mitk::FillRegionTool, mitk::PickingTool, mitk::CalculateGrayValueStatisticsTool, mitk::AutoCropTool, mitk::CalculateVolumetryTool, mitk::CreateSurfaceTool, mitk::PixelManipulationTool, and mitk::OtsuTool3D.
Referenced by QmitkToolWorkingDataSelectionBox::GetAllNodes(), QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImagesPredicate(), and QmitkToolSelectionBox::RecreateButtons().
|
virtual |
Definition at line 188 of file mitkTool.cpp.
Referenced by QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImagesPredicate().
|
virtual |
Definition at line 193 of file mitkTool.cpp.
Referenced by QmitkToolWorkingDataSelectionBox::GetAllNodes().
|
pure virtual |
Returns an icon in the XPM format.
This icon has to fit into some kind of button in most applications, so make it smaller than 25x25 pixels.
XPM is e.g. supported by The Gimp. But if you open any XPM file in your text editor, you will see that you could also "draw" it with an editor.
Implemented in mitk::FastMarchingTool, mitk::FastMarchingTool3D, mitk::WatershedTool, mitk::RegionGrowingTool, mitk::CorrectorTool2D, mitk::AdaptiveRegionGrowingTool, mitk::SubtractContourTool, mitk::AddContourTool, mitk::LiveWireTool2D, mitk::BinaryThresholdULTool, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::PickingTool, mitk::BinaryThresholdTool, mitk::EraseRegionTool, mitk::CalculateGrayValueStatisticsTool, mitk::FillRegionTool, mitk::AutoCropTool, mitk::CalculateVolumetryTool, mitk::PixelManipulationTool, mitk::CreateSurfaceTool, and mitk::OtsuTool3D.
Referenced by QmitkToolSelectionBox::RecreateButtons().
|
virtual |
Definition at line 69 of file mitkTool.cpp.
References us::GetModuleContext(), and MITK_ERROR.
mitk::Tool::mitkClassMacro | ( | Tool | , |
EventStateMachine | |||
) |
|
overrideprotectedvirtual |
By this method all registered EventObersers are notified about every InteractionEvent, the isHandled flag indicates if a DataInteractor has already handled that event. InteractionEventObserver that trigger an action when observing an event may consider this in order to not confuse the user by, triggering several independent action with one single user event (such as a mouse click)
If you want to use the InteractionEventObserver as a state machine give the event to the state machine by implementing, e.g.
This overwrites the FilterEvents function of the EventStateMachine to ignore the DataNode, since InteractionEventObservers are not associated with one. virtual bool FilterEvents(InteractionEvent* interactionEvent, DataNode* dataNode);
Implements mitk::InteractionEventObserver.
Definition at line 87 of file mitkTool.cpp.
|
protectedvirtual |
Definition at line 111 of file mitkTool.cpp.
Message1<bool> mitk::Tool::CurrentlyBusy |
To send whether the tool is busy (to be shown by some GUI)
Definition at line 110 of file mitkTool.h.
Message1<std::string> mitk::Tool::ErrorMessage |
To send error messages (to be shown by some GUI)
Definition at line 105 of file mitkTool.h.
Referenced by CreateEmptySegmentationNode(), mitk::BinaryThresholdTool::CreateNewSegmentationFromThreshold(), mitk::BinaryThresholdULTool::CreateNewSegmentationFromThreshold(), mitk::CalculateVolumetryTool::ProcessOneWorkingData(), QmitkToolSelectionBox::RecreateButtons(), and mitk::SegmentationsProcessingTool::SendErrorMessageIfAny().
Message1<std::string> mitk::Tool::GeneralMessage |
To send general messages (to be shown by some GUI)
Definition at line 115 of file mitkTool.h.
Referenced by QmitkToolSelectionBox::RecreateButtons().
Message mitk::Tool::GUIProcessEventsMessage |
To let GUI process new events (e.g. qApp->processEvents() )
Definition at line 100 of file mitkTool.h.
Referenced by QmitkToolSelectionBox::RecreateButtons().
|
protected |
Let subclasses change their event configuration.
Definition at line 224 of file mitkTool.h.
Referenced by mitk::SegTool2D::SegTool2D().
|
protected |
Definition at line 234 of file mitkTool.h.