NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
niftk::DrawTool Class Reference

Tool to draw lines around voxel edges like MIDAS does rather than through them as most of the MITK tools do. More...

Inheritance diagram for niftk::DrawTool:
Inheritance graph
[legend]
Collaboration diagram for niftk::DrawTool:
Collaboration graph
[legend]

Public Member Functions

 mitkClassMacro (DrawTool, ContourTool) static Pointer New()
 
virtual void InitializeStateMachine ()
 
virtual void ExecuteOperation (mitk::Operation *operation)
 Method to enable this class to interact with the Undo/Redo framework. More...
 
virtual const char * GetName () const
 
virtual const char ** GetXPM () const
 
double GetCursorSize () const
 Gets the cursor size. Default size is 0.5. More...
 
void SetCursorSize (double cursorSize)
 Sets the cursor size. More...
 
virtual bool StartDrawing (mitk::StateMachineAction *action, mitk::InteractionEvent *event)
 Start drawing a line at the given mouse point. More...
 
virtual bool KeepDrawing (mitk::StateMachineAction *action, mitk::InteractionEvent *event)
 Continue drawing a line. More...
 
virtual bool StopDrawing (mitk::StateMachineAction *action, mitk::InteractionEvent *event)
 Finish drawing a line. More...
 
virtual bool StartErasing (mitk::StateMachineAction *action, mitk::InteractionEvent *event)
 Erase any contours within the distance given by the cursor size in this class, and denoted by the Erase slider in the GUI. More...
 
virtual bool KeepErasing (mitk::StateMachineAction *action, mitk::InteractionEvent *event)
 Erase any contours within the distance given by the cursor size in this class, and denoted by the Erase slider in the GUI. More...
 
virtual bool StopErasing (mitk::StateMachineAction *action, mitk::InteractionEvent *event)
 Finish editing. More...
 
virtual void ClearWorkingData ()
 Different to ContourTool::ClearData which clears the Feedback contour, this one finds the working data node, and erases all contours. More...
 
virtual void Clean (int sliceNumber, int axisNumber)
 Called by the main application to clean the contour, which means, to erase any bits of contour not currently touching the region growing image. More...
 
- Public Member Functions inherited from niftk::ContourTool
virtual void ClearData ()
 Clears the contour, meaning it re-initialised the feedback contour in mitk::FeedbackContourTool, and also the background contour herein. More...
 
virtual mitk::ContourModel * GetContour ()
 Get a pointer to the current feedback contour. More...
 
virtual void SetFeedbackContourVisible (bool)
 Turns the feedback contour on/off. More...
 
- Public Member Functions inherited from niftk::Tool
 mitkClassMacro (Tool, mitk::FeedbackContourTool) static void LoadBehaviourStrings()
 Loads the behaviour string to the global interaction. This function should be called before any niftk::Tool object is created. More...
 
const char * GetGroup () const override
 
virtual void Deactivated ()
 When called, we unregister the reference to the set of seeds, and deactivate the interactors(s). More...
 
bool GetBlockNumberOfSeedsSignal () const
 Gets the flag to block the signal that indicates that the number of seeds has changed. More...
 
void SetBlockNumberOfSeedsSignal (bool blockNumberOfSeedsSignal)
 Sets the flag to block the signal that indicates that the number of seeds has changed. More...
 
virtual void InstallEventFilter (StateMachineEventFilter *eventFilter)
 Adds an event filter that can reject a state machine event or let it pass through. Overrides niftk::FilteringStateMachine::InstallEventFilter() so that it adds every filter also to the internal point set interactor. More...
 
virtual void RemoveEventFilter (StateMachineEventFilter *eventFilter)
 Removes an event filter that can reject a state machine event or let it pass through. Overrides niftkFilteringStateMachine::InstallEventFilter() to that it removes every filter also from the internal point set interactor. More...
 
- Public Member Functions inherited from niftk::FilteringStateMachine
 FilteringStateMachine ()
 Constructs a FilteringStateMachine object. More...
 
virtual ~FilteringStateMachine ()
 Destructs the FilteringStateMachine object. More...
 
float CanHandleEvent (const mitk::StateEvent *event) const
 This function is to replace the original CanHandleEvent function to support event filtering. More...
 
bool CanHandleEvent (mitk::InteractionEvent *event)
 
std::vector
< StateMachineEventFilter * > 
GetEventFilters () const
 Gets the list of the installed event filters. More...
 
bool IsFiltered (const mitk::StateEvent *stateEvent) const
 Tells if the event is rejected by the installed event filters or they let it pass through. More...
 
bool IsFiltered (mitk::InteractionEvent *event)
 Tells if the event is rejected by the installed event filters or they let it pass through. More...
 

Public Attributes

mitk::Message1< double > CursorSizeChanged
 Used to send messages when the cursor size is changed or should be updated in a GUI. */. More...
 
- Public Attributes inherited from niftk::ContourTool
mitk::Message ContoursHaveChanged
 Used to signal that the contours have changed. More...
 
- Public Attributes inherited from niftk::Tool
mitk::Message1< intNumberOfSeedsHasChanged
 Used to signal that the number of seeds has changed. More...
 

Protected Member Functions

 DrawTool ()
 
virtual ~DrawTool ()
 
virtual void ConnectActionsAndFunctions ()
 Connects state machine actions to functions. More...
 
virtual void Activated ()
 Called when the tool gets activated (registered to mitk::GlobalInteraction). More...
 
- Protected Member Functions inherited from niftk::ContourTool
 ContourTool ()
 
virtual ~ContourTool ()
 
virtual bool OnMousePressed (mitk::StateMachineAction *action, mitk::InteractionEvent *event)
 Calls the FeedbackContour::OnMousePressed method, then checks for working image, reference image and geometry. More...
 
void Disable3dRenderingOfNode (mitk::DataNode *node)
 This method makes sure that the argument node will not show up in ANY 3D viewer thats currently registered with the global mitk::RenderingManager. More...
 
void AccumulateContourInWorkingData (mitk::ContourModel &contour, int contourIndex)
 Adds the given contour to the Working Data registered with mitk::ToolManager, where the ToolManager can have multiple data sets registered, so we add the contour to the dataset specified by dataSetNumber. More...
 
void ConvertPointInMmToVx (const mitk::Point3D &pointInMm, mitk::Point3D &pointInVx)
 
void ConvertPointToNearestVoxelCentreInVx (const mitk::Point3D &pointInMm, mitk::Point3D &nearestVoxelCentreInVx)
 
void ConvertPointToNearestVoxelCentreInMm (const mitk::Point3D &pointInMm, mitk::Point3D &nearestVoxelCentreInMm)
 
void GetClosestCornerPoint2D (const mitk::Point3D &pointInMm, int *whichTwoAxesInVx, mitk::Point3D &cornerPointInMm)
 
int GetEqualCoordinateAxes (const mitk::Point3D &cornerPoint1InMm, const mitk::Point3D &cornerPoint2InMm, int *whichTwoAxesInVx)
 Compares two coordinates of the points and tells which of them are equal. The axes of the two coordinates to compare are given in whichTwoAxesInVx. Returns 0 if both coordinates are different, 1 if only the first coordinates are equal, 2 if only the second coordinates are equal and 3 the points are the same. More...
 
void GetAdditionalCornerPoint (const mitk::Point3D &cornerPoint1InMm, const mitk::Point3D &point2InMm, const mitk::Point3D &cornerPoint2InMm, int *whichTwoAxesInVx, mitk::Point3D &newCornerPointInMm)
 
bool DrawLineAroundVoxelEdges (const mitk::Image *image, const mitk::BaseGeometry *geometry, const mitk::PlaneGeometry *planeGeometry, const mitk::Point3D &currentPoint, const mitk::Point3D &previousPoint, mitk::ContourModel &contourAroundCorners, mitk::ContourModel &contourAlongLine)
 
mitk::ContourModel * GetBackgroundContour ()
 
void SetBackgroundContour (mitk::ContourModel &)
 
void Disable3dRenderingOfBackgroundContour ()
 
void SetBackgroundContourVisible (bool)
 
void SetBackgroundContourColor (float r, float g, float b)
 
void SetBackgroundContourColorDefault ()
 
- Protected Member Functions inherited from niftk::Tool
 Tool ()
 
virtual ~Tool ()
 
bool FilterEvents (mitk::InteractionEvent *event, mitk::DataNode *dataNode)
 Tells if this tool can handle the given event. More...
 
virtual void RenderCurrentWindow (const mitk::PositionEvent &event)
 Makes the current window re-render. More...
 
virtual void RenderAllWindows ()
 Makes all windows re-render. More...
 
virtual void UpdateWorkingDataNodeBoolProperty (int dataIndex, const std::string &name, bool value)
 Helper method to update a boolean property on a given working data node. More...
 
mitk::DataNode::Pointer GetPointSetNode () const
 The node that contains the point set that is the working data of the seed tool. More...
 
mitk::PointSet::Pointer GetPointSet () const
 The point set that is the working data of the seed tool. More...
 
- Protected Member Functions inherited from niftk::FilteringStateMachine
virtual float CanHandle (const mitk::StateEvent *stateEvent) const
 
virtual bool CanHandle (mitk::InteractionEvent *event)
 

Additional Inherited Members

- Public Types inherited from niftk::Tool
enum  {
  SEGMENTATION, SEEDS, CONTOURS, DRAW_CONTOURS,
  PRIOR_CONTOURS, NEXT_CONTOURS, REGION_GROWING, INITIAL_SEGMENTATION,
  INITIAL_SEEDS
}
 Constants that identify the data needed for the irregular edit tools. They should be used to index the vector of working data. More...
 
- Static Public Member Functions inherited from niftk::ContourTool
static void CopyContour (mitk::ContourModel &a, mitk::ContourModel &b)
 Copies contour from a to b. More...
 
static void CopyContourSet (mitk::ContourModelSet &a, mitk::ContourModelSet &b, bool initialise=true)
 Copies contour set from a to b. More...
 
static void InitialiseContour (mitk::ContourModel &a, mitk::ContourModel &b)
 Initialises the output contour b with properties like, closed, width and selected, copied from the reference contour a. More...
 
- Static Public Member Functions inherited from niftk::Tool
static bool LoadBehaviour (const std::string &fileName, us::Module *module)
 
- Static Public Attributes inherited from niftk::ContourTool
static mitkClassMacro(ContourTool,
Tool) static const std const
std::string 
MIDAS_CONTOUR_TOOL_BACKGROUND_CONTOUR
 We store the name of a property to say we are editing. More...
 
- Static Public Attributes inherited from niftk::Tool
static const std::string SEEDS_NAME = "MIDAS_SEEDS"
 Stores a seed point set name, so all classes have access to the name. More...
 
static const std::string CONTOURS_NAME = "MIDAS_CURRENT_CONTOURS"
 Stores the name of the current slice contours, so all classes have access to the name. More...
 
static const std::string DRAW_CONTOURS_NAME = "MIDAS_DRAW_CONTOURS"
 Stores the name of the draw tool contours, so all classes have access to the name. More...
 
static const std::string PRIOR_CONTOURS_NAME = "MIDAS_PRIOR_CONTOURS"
 Stores the name of the prior contours, so all classes have access to the name. More...
 
static const std::string NEXT_CONTOURS_NAME = "MIDAS_NEXT_CONTOURS"
 Stores the name of the next contours, so all classes have access to the name. More...
 
static const std::string REGION_GROWING_NAME = "MIDAS_REGION_GROWING_IMAGE"
 Stores the name of the region growing image, so all classes have access to the name. More...
 
static const std::string INITIAL_SEGMENTATION_NAME = "MIDAS_INITIAL_SEGMENTATION_IMAGE"
 Stores the name of the initial segmentation image, so all classes have access to the name. More...
 
static const std::string INITIAL_SEEDS_NAME = "MIDAS_INITIAL_SEEDS"
 Stores the name of the initial set of seeds, so all classes have access to the name. More...
 
- Protected Attributes inherited from niftk::ContourTool
int m_ContourWidth
 
bool m_ContourClosed
 
float m_Tolerance
 
mitk::BaseGeometry * m_SegmentationImageGeometry
 
mitk::Image * m_SegmentationImage
 
mitk::Image * m_ReferenceImage
 
mitk::ContourModel::Pointer m_BackgroundContour
 
mitk::DataNode::Pointer m_BackgroundContourNode
 
bool m_BackgroundContourVisible
 

Detailed Description

Tool to draw lines around voxel edges like MIDAS does rather than through them as most of the MITK tools do.

Provides

1. Left mouse button down = start line
2. Move with left button down = continue line
3. Left mouse button release = finish line
4. Middle mouse button down = erase anything within the range given by the Eraser (cursor size).
5. Move with middle mouse button down = same as 4.
6. Middle mouse button release = finish editing.

and includes Undo/Redo functionality.

Constructor & Destructor Documentation

niftk::DrawTool::DrawTool ( )
protected
niftk::DrawTool::~DrawTool ( )
protectedvirtual

Member Function Documentation

void niftk::DrawTool::Activated ( )
protectedvirtual

Called when the tool gets activated (registered to mitk::GlobalInteraction).

Derived tools should call their parents implementation.

Reimplemented from niftk::Tool.

void niftk::DrawTool::Clean ( int  sliceNumber,
int  axisNumber 
)
virtual

Called by the main application to clean the contour, which means, to erase any bits of contour not currently touching the region growing image.

void niftk::DrawTool::ClearWorkingData ( )
virtual

Different to ContourTool::ClearData which clears the Feedback contour, this one finds the working data node, and erases all contours.

void niftk::DrawTool::ConnectActionsAndFunctions ( )
protectedvirtual

Connects state machine actions to functions.

void niftk::DrawTool::ExecuteOperation ( mitk::Operation *  operation)
virtual

Method to enable this class to interact with the Undo/Redo framework.

Reimplemented from niftk::ContourTool.

double niftk::DrawTool::GetCursorSize ( ) const

Gets the cursor size. Default size is 0.5.

const char * niftk::DrawTool::GetName ( ) const
virtual
See also
mitk::Tool::GetName()
const char ** niftk::DrawTool::GetXPM ( ) const
virtual
See also
mitk::Tool::GetXPM()
void niftk::DrawTool::InitializeStateMachine ( )
virtual
bool niftk::DrawTool::KeepDrawing ( mitk::StateMachineAction *  action,
mitk::InteractionEvent *  event 
)
virtual

Continue drawing a line.

As the mouse is moved, we draw a line in 2D slice, round edges of voxels. The complexity lies in the fact that MouseMove events don't give you every pixel (unless you move your mouse slowly), so you have to draw a line between two points that may span more than one voxel, or fractions of a voxel.

bool niftk::DrawTool::KeepErasing ( mitk::StateMachineAction *  action,
mitk::InteractionEvent *  event 
)
virtual

Erase any contours within the distance given by the cursor size in this class, and denoted by the Erase slider in the GUI.

niftk::DrawTool::mitkClassMacro ( DrawTool  ,
ContourTool   
)
void niftk::DrawTool::SetCursorSize ( double  cursorSize)

Sets the cursor size.

bool niftk::DrawTool::StartDrawing ( mitk::StateMachineAction *  action,
mitk::InteractionEvent *  event 
)
virtual

Start drawing a line at the given mouse point.

To start a contour, we initialise the "FeedbackCountour", which is the "Current" contour, and also store the current point, at which the mouse was pressed down. It's the next method OnMouseMoved that starts to draw the line.

bool niftk::DrawTool::StartErasing ( mitk::StateMachineAction *  action,
mitk::InteractionEvent *  event 
)
virtual

Erase any contours within the distance given by the cursor size in this class, and denoted by the Erase slider in the GUI.

bool niftk::DrawTool::StopDrawing ( mitk::StateMachineAction *  action,
mitk::InteractionEvent *  event 
)
virtual

Finish drawing a line.

When we finish a contour, we take the Current contour, and add it to the Cumulative contour. This action should be undo-able, as we are creating data.

Make sure we have a valid position event, otherwise no point continuing.

When the mouse is released, we need to add the contour to the cumulative one.

Re-initialize contours to zero length.

Set this flag to indicate that we have stopped editing, which will trigger an update of the region growing.

bool niftk::DrawTool::StopErasing ( mitk::StateMachineAction *  action,
mitk::InteractionEvent *  event 
)
virtual

Finish editing.

Member Data Documentation

mitk::Message1<double> niftk::DrawTool::CursorSizeChanged

Used to send messages when the cursor size is changed or should be updated in a GUI. */.


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