Base class of all tools used by mitk::ToolManager. More...
#include <mitkTool.h>
Public Types | |
typedef unsigned char | DefaultSegmentationDataType |
typedef Tool | Self |
typedef StateMachine | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual const char ** | GetXPM () const =0 |
Returns an icon in the XPM format. | |
virtual const char * | GetName () const =0 |
Returns the name of this tool. Make it short! | |
virtual const char * | GetGroup () const |
Name of a group. | |
virtual itk::Object::Pointer | GetGUI (const std::string &toolkitPrefix, const std::string &toolkitPostfix) |
Interface for GUI creation. | |
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 | GetSupportRoi () |
virtual void | SetSupportRoi (bool _arg) |
virtual void | SupportRoiOn () |
virtual void | SupportRoiOff () |
Public Attributes | |
Message | GUIProcessEventsMessage |
To let GUI process new events (e.g. qApp->processEvents() ) | |
Message1< std::string > | ErrorMessage |
To send error messages (to be shown by some GUI) | |
Message1< std::string > | GeneralMessage |
To send general messages (to be shown by some GUI) | |
Protected Member Functions | |
virtual void | SetToolManager (ToolManager *) |
virtual void | Activated () |
Called when the tool gets activated (registered to mitk::GlobalInteraction). | |
virtual void | Deactivated () |
Called when the tool gets deactivated (unregistered from mitk::GlobalInteraction). | |
Tool () | |
Tool (const char *) | |
virtual | ~Tool () |
Protected Attributes | |
ToolManager * | m_ToolManager |
bool | m_SupportRoi |
Friends | |
class | ToolManager |
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() in 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 itkNewMacro 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 76 of file mitkTool.h.
typedef itk::SmartPointer<const Self> mitk::Tool::ConstPointer |
Reimplemented from mitk::StateMachine.
Reimplemented in mitk::AddContourTool, mitk::AutoCropTool, mitk::AutoSegmentationTool, mitk::BinaryThresholdTool, mitk::BinaryThresholdULTool, mitk::CalculateGrayValueStatisticsTool, mitk::CalculateVolumetryTool, mitk::ClosingTool, mitk::ContourTool, mitk::CorrectorTool2D, mitk::CreateSurfaceTool, mitk::DilateTool, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::EraseRegionTool, mitk::ErodeTool, mitk::FeedbackContourTool, mitk::FillRegionTool, mitk::MorphologicTool, mitk::OpeningTool, mitk::PaintbrushTool, mitk::RegionGrowingTool, mitk::SegmentationsProcessingTool, mitk::SegTool2D, mitk::SetRegionTool, and mitk::SubtractContourTool.
Definition at line 97 of file mitkTool.h.
typedef unsigned char mitk::Tool::DefaultSegmentationDataType |
Definition at line 80 of file mitkTool.h.
typedef itk::SmartPointer<Self> mitk::Tool::Pointer |
Reimplemented from mitk::StateMachine.
Reimplemented in mitk::AddContourTool, mitk::AutoCropTool, mitk::AutoSegmentationTool, mitk::BinaryThresholdTool, mitk::BinaryThresholdULTool, mitk::CalculateGrayValueStatisticsTool, mitk::CalculateVolumetryTool, mitk::ClosingTool, mitk::ContourTool, mitk::CorrectorTool2D, mitk::CreateSurfaceTool, mitk::DilateTool, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::EraseRegionTool, mitk::ErodeTool, mitk::FeedbackContourTool, mitk::FillRegionTool, mitk::MorphologicTool, mitk::OpeningTool, mitk::PaintbrushTool, mitk::RegionGrowingTool, mitk::SegmentationsProcessingTool, mitk::SegTool2D, mitk::SetRegionTool, and mitk::SubtractContourTool.
Definition at line 97 of file mitkTool.h.
typedef Tool mitk::Tool::Self |
Reimplemented from mitk::StateMachine.
Reimplemented in mitk::AddContourTool, mitk::AutoCropTool, mitk::AutoSegmentationTool, mitk::BinaryThresholdTool, mitk::BinaryThresholdULTool, mitk::CalculateGrayValueStatisticsTool, mitk::CalculateVolumetryTool, mitk::ClosingTool, mitk::ContourTool, mitk::CorrectorTool2D, mitk::CreateSurfaceTool, mitk::DilateTool, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::EraseRegionTool, mitk::ErodeTool, mitk::FeedbackContourTool, mitk::FillRegionTool, mitk::MorphologicTool, mitk::OpeningTool, mitk::PaintbrushTool, mitk::RegionGrowingTool, mitk::SegmentationsProcessingTool, mitk::SegTool2D, mitk::SetRegionTool, and mitk::SubtractContourTool.
Definition at line 97 of file mitkTool.h.
typedef StateMachine mitk::Tool::Superclass |
Reimplemented from mitk::StateMachine.
Reimplemented in mitk::AddContourTool, mitk::AutoCropTool, mitk::AutoSegmentationTool, mitk::BinaryThresholdTool, mitk::BinaryThresholdULTool, mitk::CalculateGrayValueStatisticsTool, mitk::CalculateVolumetryTool, mitk::ClosingTool, mitk::ContourTool, mitk::CorrectorTool2D, mitk::CreateSurfaceTool, mitk::DilateTool, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::EraseRegionTool, mitk::ErodeTool, mitk::FeedbackContourTool, mitk::FillRegionTool, mitk::MorphologicTool, mitk::OpeningTool, mitk::PaintbrushTool, mitk::RegionGrowingTool, mitk::SegmentationsProcessingTool, mitk::SegTool2D, mitk::SetRegionTool, and mitk::SubtractContourTool.
Definition at line 97 of file mitkTool.h.
mitk::Tool::Tool | ( | ) | [protected] |
mitk::Tool::Tool | ( | const char * | type ) | [protected] |
Definition at line 26 of file mitkTool.cpp.
: StateMachine(type), m_SupportRoi(false), // for reference images m_PredicateImages(NodePredicateDataType::New("Image")), m_PredicateDim3(NodePredicateDimension::New(3, 1)), m_PredicateDim4(NodePredicateDimension::New(4, 1)), m_PredicateDimension( mitk::NodePredicateOr::New(m_PredicateDim3, m_PredicateDim4) ), m_PredicateImage3D( NodePredicateAnd::New(m_PredicateImages, m_PredicateDimension) ), m_PredicateBinary(NodePredicateProperty::New("binary", BoolProperty::New(true))), m_PredicateNotBinary( NodePredicateNot::New(m_PredicateBinary) ), m_PredicateSegmentation(NodePredicateProperty::New("segmentation", BoolProperty::New(true))), m_PredicateNotSegmentation( NodePredicateNot::New(m_PredicateSegmentation) ), m_PredicateHelper(NodePredicateProperty::New("helper object", BoolProperty::New(true))), m_PredicateNotHelper( NodePredicateNot::New(m_PredicateHelper) ), m_PredicateImageColorful( NodePredicateAnd::New(m_PredicateNotBinary, m_PredicateNotSegmentation) ), m_PredicateImageColorfulNotHelper( NodePredicateAnd::New(m_PredicateImageColorful, m_PredicateNotHelper) ), m_PredicateReference( NodePredicateAnd::New(m_PredicateImage3D, m_PredicateImageColorfulNotHelper) ), // for working image m_IsSegmentationPredicate(NodePredicateAnd::New(NodePredicateOr::New(m_PredicateBinary, m_PredicateSegmentation), m_PredicateNotHelper)) { }
mitk::Tool::~Tool | ( | ) | [protected, virtual] |
Definition at line 56 of file mitkTool.cpp.
{ }
void mitk::Tool::Activated | ( | ) | [protected, virtual] |
Called when the tool gets activated (registered to mitk::GlobalInteraction).
Derived tools should call their parents implementation.
Reimplemented in mitk::BinaryThresholdTool, mitk::BinaryThresholdULTool, mitk::ContourTool, mitk::CorrectorTool2D, mitk::MorphologicTool, mitk::PaintbrushTool, mitk::RegionGrowingTool, mitk::SegmentationsProcessingTool, and mitk::SetRegionTool.
Definition at line 70 of file mitkTool.cpp.
{ }
mitk::DataNode::Pointer mitk::Tool::CreateEmptySegmentationNode | ( | Image * | original, |
const std::string & | organName, | ||
const mitk::Color & | color | ||
) |
Definition at line 116 of file mitkTool.cpp.
References mitk::TimeSlicedGeometry::Clone(), ErrorMessage, mitk::Image::GetDimension(), mitk::Image::GetDimensions(), mitk::BaseData::GetTimeSlicedGeometry(), and mitk::Image::New().
Referenced by QmitkSegmentationView::CreateNewSegmentation(), mitk::BinaryThresholdULTool::CreateNewSegmentationFromThreshold(), and mitk::BinaryThresholdTool::CreateNewSegmentationFromThreshold().
{ // we NEED a reference image for size etc. if (!original) return NULL; // actually create a new empty segmentation PixelType pixelType( typeid(DefaultSegmentationDataType) ); Image::Pointer segmentation = Image::New(); segmentation->Initialize( pixelType, original->GetDimension(), original->GetDimensions() ); unsigned int byteSize = sizeof(DefaultSegmentationDataType); for (unsigned int dim = 0; dim < segmentation->GetDimension(); ++dim) { byteSize *= segmentation->GetDimension(dim); } memset( segmentation->GetData(), 0, byteSize ); if (original->GetTimeSlicedGeometry() ) { AffineGeometryFrame3D::Pointer originalGeometryAGF = original->GetTimeSlicedGeometry()->Clone(); TimeSlicedGeometry::Pointer originalGeometry = dynamic_cast<TimeSlicedGeometry*>( originalGeometryAGF.GetPointer() ); segmentation->SetGeometry( originalGeometry ); } else { Tool::ErrorMessage("Original image does not have a 'Time sliced geometry'! Cannot create a segmentation."); return NULL; } return CreateSegmentationNode( segmentation, organName, color ); }
mitk::DataNode::Pointer mitk::Tool::CreateSegmentationNode | ( | Image * | image, |
const std::string & | organName, | ||
const mitk::Color & | color | ||
) |
Definition at line 149 of file mitkTool.cpp.
References mitk::VtkResliceInterpolationProperty::New(), mitk::FloatProperty::New(), mitk::LevelWindowProperty::New(), mitk::IntProperty::New(), mitk::ColorProperty::New(), mitk::BoolProperty::New(), mitk::StringProperty::New(), and mitk::DataNode::New().
{ if (!image) return NULL; // decorate the datatreenode with some properties DataNode::Pointer segmentationNode = DataNode::New(); segmentationNode->SetData( image ); // name segmentationNode->SetProperty( "name", StringProperty::New( organName ) ); // visualization properties segmentationNode->SetProperty( "binary", BoolProperty::New(true) ); segmentationNode->SetProperty( "color", ColorProperty::New(color) ); segmentationNode->SetProperty( "texture interpolation", BoolProperty::New(false) ); segmentationNode->SetProperty( "layer", IntProperty::New(10) ); segmentationNode->SetProperty( "levelwindow", LevelWindowProperty::New( LevelWindow(0.5, 1) ) ); segmentationNode->SetProperty( "opacity", FloatProperty::New(0.3) ); segmentationNode->SetProperty( "segmentation", BoolProperty::New(true) ); segmentationNode->SetProperty( "reslice interpolation", VtkResliceInterpolationProperty::New() ); // otherwise -> segmentation appears in 2 slices sometimes (only visual effect, not different data) // For MITK-3M3 release, the volume of all segmentations should be shown segmentationNode->SetProperty( "showVolume", BoolProperty::New( true ) ); return segmentationNode; }
void mitk::Tool::Deactivated | ( | ) | [protected, virtual] |
Called when the tool gets deactivated (unregistered from mitk::GlobalInteraction).
Derived tools should call their parents implementation.
Reimplemented in mitk::BinaryThresholdTool, mitk::BinaryThresholdULTool, mitk::ContourTool, mitk::CorrectorTool2D, mitk::MorphologicTool, mitk::PaintbrushTool, mitk::RegionGrowingTool, mitk::SegmentationsProcessingTool, and mitk::SetRegionTool.
Definition at line 74 of file mitkTool.cpp.
References mitk::StateMachine::ResetStatemachineToStartState().
{ StateMachine::ResetStatemachineToStartState(); // forget about the past }
virtual const char* mitk::Tool::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::StateMachine.
Reimplemented in mitk::AddContourTool, mitk::AutoCropTool, mitk::AutoSegmentationTool, mitk::BinaryThresholdTool, mitk::BinaryThresholdULTool, mitk::CalculateGrayValueStatisticsTool, mitk::CalculateVolumetryTool, mitk::ClosingTool, mitk::ContourTool, mitk::CorrectorTool2D, mitk::CreateSurfaceTool, mitk::DilateTool, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::EraseRegionTool, mitk::ErodeTool, mitk::FeedbackContourTool, mitk::FillRegionTool, mitk::MorphologicTool, mitk::OpeningTool, mitk::PaintbrushTool, mitk::RegionGrowingTool, mitk::SegmentationsProcessingTool, mitk::SegTool2D, mitk::SetRegionTool, and mitk::SubtractContourTool.
const char * mitk::Tool::GetGroup | ( | ) | const [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, mitk::MorphologicTool, and mitk::SegmentationsProcessingTool.
Definition at line 60 of file mitkTool.cpp.
Referenced by QmitkToolWorkingDataSelectionBox::GetAllNodes(), QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImagesPredicate(), QmitkToolSelectionBox::RecreateButtons(), and QmitkToolSelectionBox::SetOrUnsetButtonForActiveTool().
{ return "default"; }
itk::Object::Pointer mitk::Tool::GetGUI | ( | const std::string & | toolkitPrefix, |
const std::string & | toolkitPostfix | ||
) | [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 79 of file mitkTool.cpp.
References MITK_ERROR.
Referenced by QmitkToolSelectionBox::SetOrUnsetButtonForActiveTool(), and QmitkSegmentationPostProcessing::ThresholdImage().
{ itk::Object::Pointer object; std::string classname = this->GetNameOfClass(); std::string guiClassname = toolkitPrefix + classname + toolkitPostfix; std::list<itk::LightObject::Pointer> allGUIs = itk::ObjectFactoryBase::CreateAllInstance(guiClassname.c_str()); for( std::list<itk::LightObject::Pointer>::iterator iter = allGUIs.begin(); iter != allGUIs.end(); ++iter ) { if (object.IsNull()) { object = dynamic_cast<itk::Object*>( iter->GetPointer() ); } else { MITK_ERROR << "There is more than one GUI for " << classname << " (several factories claim ability to produce a " << guiClassname << " ) " << std::endl; return NULL; // people should see and fix this error } } return object; }
virtual const char* mitk::Tool::GetName | ( | ) | const [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::AddContourTool, mitk::AutoCropTool, mitk::BinaryThresholdTool, mitk::BinaryThresholdULTool, mitk::CalculateGrayValueStatisticsTool, mitk::CalculateVolumetryTool, mitk::ClosingTool, mitk::CorrectorTool2D, mitk::CreateSurfaceTool, mitk::DilateTool, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::EraseRegionTool, mitk::ErodeTool, mitk::FillRegionTool, mitk::OpeningTool, mitk::RegionGrowingTool, and mitk::SubtractContourTool.
Referenced by QmitkToolWorkingDataSelectionBox::GetAllNodes(), QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImagesPredicate(), and QmitkToolSelectionBox::RecreateButtons().
mitk::NodePredicateBase::ConstPointer mitk::Tool::GetReferenceDataPreference | ( | ) | const [virtual] |
Definition at line 105 of file mitkTool.cpp.
Referenced by QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImagesPredicate().
{
return m_PredicateReference.GetPointer();
}
virtual bool mitk::Tool::GetSupportRoi | ( | ) | [virtual] |
mitk::NodePredicateBase::ConstPointer mitk::Tool::GetWorkingDataPreference | ( | ) | const [virtual] |
Definition at line 111 of file mitkTool.cpp.
Referenced by QmitkToolWorkingDataSelectionBox::GetAllNodes().
{
return m_IsSegmentationPredicate.GetPointer();
}
virtual const char** mitk::Tool::GetXPM | ( | ) | const [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::AddContourTool, mitk::AutoCropTool, mitk::BinaryThresholdTool, mitk::BinaryThresholdULTool, mitk::CalculateGrayValueStatisticsTool, mitk::CalculateVolumetryTool, mitk::ClosingTool, mitk::CorrectorTool2D, mitk::CreateSurfaceTool, mitk::DilateTool, mitk::DrawPaintbrushTool, mitk::ErasePaintbrushTool, mitk::EraseRegionTool, mitk::ErodeTool, mitk::FillRegionTool, mitk::OpeningTool, mitk::RegionGrowingTool, and mitk::SubtractContourTool.
Referenced by QmitkToolSelectionBox::RecreateButtons().
virtual void mitk::Tool::SetSupportRoi | ( | bool | _arg ) | [virtual] |
void mitk::Tool::SetToolManager | ( | ToolManager * | manager ) | [protected, virtual] |
Definition at line 65 of file mitkTool.cpp.
{ m_ToolManager = manager; }
virtual void mitk::Tool::SupportRoiOff | ( | ) | [virtual] |
virtual void mitk::Tool::SupportRoiOn | ( | ) | [virtual] |
friend class ToolManager [friend] |
Definition at line 153 of file mitkTool.h.
Message1<std::string> mitk::Tool::ErrorMessage |
To send error messages (to be shown by some GUI)
Definition at line 90 of file mitkTool.h.
Referenced by CreateEmptySegmentationNode(), mitk::BinaryThresholdULTool::CreateNewSegmentationFromThreshold(), mitk::BinaryThresholdTool::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 95 of file mitkTool.h.
Referenced by QmitkToolSelectionBox::RecreateButtons().
To let GUI process new events (e.g. qApp->processEvents() )
Definition at line 85 of file mitkTool.h.
Referenced by QmitkToolSelectionBox::RecreateButtons().
bool mitk::Tool::m_SupportRoi [protected] |
Definition at line 182 of file mitkTool.h.
ToolManager* mitk::Tool::m_ToolManager [protected] |
Definition at line 180 of file mitkTool.h.