Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::PlanarFigureInteractor Class Reference

Interactor for creating, editing, and manipulating PlanarFigure objects. More...

#include <mitkPlanarFigureInteractor.h>

Inheritance diagram for mitk::PlanarFigureInteractor:
Collaboration diagram for mitk::PlanarFigureInteractor:

Public Member Functions

 mitkClassMacro (PlanarFigureInteractor, DataInteractor)
 
Pointer Clone () const
 
void SetPrecision (ScalarType precision)
 Sets the precision for picking control points and figure edges. More...
 
void SetMinimumPointDistance (ScalarType minimumDistance)
 Sets the minimal distance between two control points. More...
 
void EnableContinuousPointsMode ()
 Enables continuous points mode. More...
 
- Public Member Functions inherited from mitk::DataInteractor
 mitkClassMacro (DataInteractor, EventStateMachine)
 
Pointer Clone () const
 
DataNode * GetDataNode () const
 Get the DataNode associated with this interactor. More...
 
virtual void SetDataNode (DataNode *dataNode)
 Set the DataNode that this interactor operates on. More...
 
int GetLayer () const
 Get the rendering layer of the associated DataNode. More...
 
ProcessEventMode GetMode () const
 Get the current event processing mode from the state machine's current state. More...
 
- Public Member Functions inherited from mitk::EventStateMachine
 mitkClassMacro (EventStateMachine, InteractionEventHandler)
 
bool LoadStateMachine (const std::string &filename, const us::Module *module=nullptr)
 Load a state machine pattern from an XML resource file. More...
 
bool HandleEvent (InteractionEvent *event, DataNode *dataNode)
 Process an incoming interaction event. More...
 
void EnableUndo (bool enable)
 Enable or disable the undo mechanism for this state machine. More...
 
void EnableInteraction (bool enable)
 Enable or disable the state machine. More...
 
- Public Member Functions inherited from mitk::InteractionEventHandler
 mitkClassMacroItkParent (InteractionEventHandler, itk::Object)
 
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...
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from mitk::DataInteractor
static Pointer New ()
 

Protected Member Functions

 PlanarFigureInteractor ()
 
 ~PlanarFigureInteractor () override
 
void ConnectActionsAndFunctions () override
 Overwrite this function to connect actions from StateMachine description with functions. More...
 
bool CheckFigurePlaced (const InteractionEvent *interactionEvent)
 
bool CheckFigureHovering (const InteractionEvent *interactionEvent)
 
bool CheckControlPointHovering (const InteractionEvent *interactionEvent)
 
bool CheckSelection (const InteractionEvent *interactionEvent)
 
bool CheckPointValidity (const InteractionEvent *interactionEvent)
 
bool CheckFigureFinished (const InteractionEvent *interactionEvent)
 
bool CheckResetOnPointSelect (const InteractionEvent *interactionEvent)
 
bool CheckFigureOnRenderingGeometry (const InteractionEvent *interactionEvent)
 
bool CheckMinimalFigureFinished (const InteractionEvent *interactionEvent)
 
bool CheckFigureIsExtendable (const InteractionEvent *interactionEvent)
 
bool CheckFigureIsDeletable (const InteractionEvent *interactionEvent)
 
bool CheckFigureIsEditable (const InteractionEvent *interactionEvent)
 
bool CheckContinuousPointsMode (const InteractionEvent *interactionEvent)
 
void FinalizeFigure (StateMachineAction *, InteractionEvent *interactionEvent)
 
void MoveCurrentPoint (StateMachineAction *, InteractionEvent *interactionEvent)
 
void DeselectPoint (StateMachineAction *, InteractionEvent *interactionEvent)
 
void AddPoint (StateMachineAction *, InteractionEvent *interactionEvent)
 
void AddInitialPoint (StateMachineAction *, InteractionEvent *interactionEvent)
 
void StartHovering (StateMachineAction *, InteractionEvent *interactionEvent)
 
void EndHovering (StateMachineAction *, InteractionEvent *interactionEvent)
 
void DeleteFigure (StateMachineAction *, InteractionEvent *interactionEvent)
 
void PerformPointResetOnSelect (StateMachineAction *, InteractionEvent *interactionEvent)
 
void SetPreviewPointPosition (StateMachineAction *, InteractionEvent *interactionEvent)
 
void HidePreviewPoint (StateMachineAction *, InteractionEvent *interactionEvent)
 
void HideControlPoints (StateMachineAction *, InteractionEvent *interactionEvent)
 
void RemoveSelectedPoint (StateMachineAction *, InteractionEvent *interactionEvent)
 
void RequestContextMenu (StateMachineAction *, InteractionEvent *interactionEvent)
 
void SelectFigure (StateMachineAction *, InteractionEvent *interactionEvent)
 
void SelectPoint (StateMachineAction *, InteractionEvent *interactionEvent)
 
void EndInteraction (StateMachineAction *, InteractionEvent *interactionEvent)
 
bool FilterEvents (InteractionEvent *interactionEvent, DataNode *) override
 
bool IsMousePositionAcceptableAsNewControlPoint (const mitk::InteractionPositionEvent *positionEvent, const PlanarFigure *)
 Used when clicking to determine if a point is too close to the previous point. More...
 
bool TransformPositionEventToPoint2D (const InteractionPositionEvent *positionEvent, const PlaneGeometry *planarFigureGeometry, Point2D &point2D)
 
bool TransformObjectToDisplay (const mitk::Point2D &point2D, mitk::Point2D &displayPoint, const mitk::PlaneGeometry *objectGeometry, const mitk::PlaneGeometry *rendererGeometry, const mitk::BaseRenderer *renderer) const
 
bool IsPointNearLine (const mitk::Point2D &point, const mitk::Point2D &startPoint, const mitk::Point2D &endPoint, mitk::Point2D &projectedPoint) const
 Returns true if the first specified point is in proximity of the line defined the other two point; false otherwise. More...
 
int IsPositionOverFigure (const InteractionPositionEvent *positionEvent, PlanarFigure *planarFigure, const PlaneGeometry *planarFigureGeometry, const PlaneGeometry *rendererGeometry, Point2D &pointProjectedOntoLine) const
 Returns true if the point contained in the passed event (in display coordinates) is over the planar figure (with a pre-defined tolerance range); false otherwise. More...
 
int IsPositionInsideMarker (const InteractionPositionEvent *positionEvent, const PlanarFigure *planarFigure, const PlaneGeometry *planarFigureGeometry, const PlaneGeometry *rendererGeometry, const BaseRenderer *renderer) const
 Returns the index of the marker (control point) over which the point contained in the passed event (in display coordinates) currently is; -1 if the point is not over a marker. More...
 
void LogPrintPlanarFigureQuantities (const PlanarFigure *planarFigure)
 
void ConfigurationChanged () override
 
- Protected Member Functions inherited from mitk::DataInteractor
 DataInteractor ()
 
 ~DataInteractor () override
 
virtual void DataNodeChanged ()
 Is called when a DataNode is initially set or changed To be implemented by sub-classes for initialization code which require a DataNode. More...
 
virtual void NotifyStart ()
 Sends StartInteraction event via the mitk::DataNode. More...
 
virtual void NotifyResultReady ()
 NotifyResultReady Sends ResultReady event via the mitk::DataNode. More...
 
- Protected Member Functions inherited from mitk::EventStateMachine
 EventStateMachine ()
 
 ~EventStateMachine () override
 
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 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 ()
 
 ~InteractionEventHandler () override
 
PropertyList::Pointer GetAttributes () const
 
std::string MapToEventVariant (InteractionEvent *interactionEvent)
 

Additional Inherited Members

- Public Types inherited from mitk::EventStateMachine
typedef itk::SmartPointer< StateMachineState > StateMachineStateType
 
- Static Public Attributes inherited from mitk::DataInteractor
static const std::string IntDeactivateMe
 Internal signal name to request deactivation of this interactor. More...
 
static const std::string IntLeaveWidget
 Internal signal name indicating the pointer left the widget area. More...
 
static const std::string IntEnterWidget
 Internal signal name indicating the pointer entered the widget area. More...
 
- Protected Types inherited from mitk::EventStateMachine
typedef MessageAbstractDelegate2< StateMachineAction *, InteractionEvent *, void > ActionFunctionDelegate
 
typedef MessageAbstractDelegate1< const InteractionEvent *, bool > ConditionFunctionDelegate
 
- Protected Attributes inherited from mitk::EventStateMachine
bool m_IsActive
 
UndoController * m_UndoController
 
bool m_UndoEnabled
 

Detailed Description

Interactor for creating, editing, and manipulating PlanarFigure objects.

Handles mouse-based interaction with PlanarFigure objects, including:

  • Placement of new planar figures by clicking control points
  • Selection and hovering of existing figures
  • Moving control points to modify figure geometry
  • Adding and removing control points
  • Context menu requests

Emits various events (StartPlacementPlanarFigureEvent, EndPlacementPlanarFigureEvent, SelectPlanarFigureEvent, etc.) that other components can observe.

The interaction behavior is defined by a state machine configuration loaded during construction.

See also
PlanarFigure, PlanarFigureMapper2D, DataInteractor

Definition at line 79 of file mitkPlanarFigureInteractor.h.

Constructor & Destructor Documentation

◆ PlanarFigureInteractor()

mitk::PlanarFigureInteractor::PlanarFigureInteractor ( )
protected

◆ ~PlanarFigureInteractor()

mitk::PlanarFigureInteractor::~PlanarFigureInteractor ( )
overrideprotected

Member Function Documentation

◆ AddInitialPoint()

void mitk::PlanarFigureInteractor::AddInitialPoint ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ AddPoint()

void mitk::PlanarFigureInteractor::AddPoint ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ CheckContinuousPointsMode()

bool mitk::PlanarFigureInteractor::CheckContinuousPointsMode ( const InteractionEvent *  interactionEvent)
protected

◆ CheckControlPointHovering()

bool mitk::PlanarFigureInteractor::CheckControlPointHovering ( const InteractionEvent *  interactionEvent)
protected

◆ CheckFigureFinished()

bool mitk::PlanarFigureInteractor::CheckFigureFinished ( const InteractionEvent *  interactionEvent)
protected

◆ CheckFigureHovering()

bool mitk::PlanarFigureInteractor::CheckFigureHovering ( const InteractionEvent *  interactionEvent)
protected

◆ CheckFigureIsDeletable()

bool mitk::PlanarFigureInteractor::CheckFigureIsDeletable ( const InteractionEvent *  interactionEvent)
protected

◆ CheckFigureIsEditable()

bool mitk::PlanarFigureInteractor::CheckFigureIsEditable ( const InteractionEvent *  interactionEvent)
protected

◆ CheckFigureIsExtendable()

bool mitk::PlanarFigureInteractor::CheckFigureIsExtendable ( const InteractionEvent *  interactionEvent)
protected

◆ CheckFigureOnRenderingGeometry()

bool mitk::PlanarFigureInteractor::CheckFigureOnRenderingGeometry ( const InteractionEvent *  interactionEvent)
protected

◆ CheckFigurePlaced()

bool mitk::PlanarFigureInteractor::CheckFigurePlaced ( const InteractionEvent *  interactionEvent)
protected

◆ CheckMinimalFigureFinished()

bool mitk::PlanarFigureInteractor::CheckMinimalFigureFinished ( const InteractionEvent *  interactionEvent)
protected

◆ CheckPointValidity()

bool mitk::PlanarFigureInteractor::CheckPointValidity ( const InteractionEvent *  interactionEvent)
protected

◆ CheckResetOnPointSelect()

bool mitk::PlanarFigureInteractor::CheckResetOnPointSelect ( const InteractionEvent *  interactionEvent)
protected

◆ CheckSelection()

bool mitk::PlanarFigureInteractor::CheckSelection ( const InteractionEvent *  interactionEvent)
protected

◆ Clone()

Pointer mitk::PlanarFigureInteractor::Clone ( ) const

◆ ConfigurationChanged()

void mitk::PlanarFigureInteractor::ConfigurationChanged ( )
overrideprotectedvirtual

Is called whenever a new config object is set. Overwrite this method e.g. to initialize EventHandler with parameters in configuration file.

Reimplemented from mitk::InteractionEventHandler.

◆ ConnectActionsAndFunctions()

void mitk::PlanarFigureInteractor::ConnectActionsAndFunctions ( )
overrideprotectedvirtual

Overwrite this function to connect actions from StateMachine description with functions.

Following example shows how to connect the 'addpoint' action from the StateMachine XML description using the CONNECT_FUNCTION macro with the AddPoint() function in the TestInteractor.

void mitk::TestInteractor::ConnectActionsAndFunctions()
{
}
void AddPoint(StateMachineAction *, InteractionEvent *interactionEvent)
#define CONNECT_FUNCTION(a, f)

Reimplemented from mitk::DataInteractor.

◆ DeleteFigure()

void mitk::PlanarFigureInteractor::DeleteFigure ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ DeselectPoint()

void mitk::PlanarFigureInteractor::DeselectPoint ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ EnableContinuousPointsMode()

void mitk::PlanarFigureInteractor::EnableContinuousPointsMode ( )

Enables continuous points mode.

In this mode, control points are added continuously while moving the mouse, rather than requiring individual clicks.

◆ EndHovering()

void mitk::PlanarFigureInteractor::EndHovering ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ EndInteraction()

void mitk::PlanarFigureInteractor::EndInteraction ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ FilterEvents()

bool mitk::PlanarFigureInteractor::FilterEvents ( InteractionEvent *  interactionEvent,
DataNode *  dataNode 
)
overrideprotectedvirtual

Implements filter scheme for events. Standard implementation accepts events from 2d and 3d windows, and rejects events if DataNode is not visible.

Returns
true if event is accepted, else false

Overwrite this function to adapt for your own needs, for example to filter out events from 3d windows like this:

bool mitk::EventStateMachine::FilterEvents(InteractionEvent* interactionEvent, DataNode*dataNode)
{
return interactionEvent->GetSender()->GetMapperID() == BaseRenderer::Standard2D; // only 2D mappers
}
@ Standard2D
Use 2D mappers for rendering.
virtual bool FilterEvents(InteractionEvent *interactionEvent, DataNode *dataNode)

or to enforce that the interactor only reacts when the corresponding DataNode is selected in the DataManager view..

Reimplemented from mitk::EventStateMachine.

◆ FinalizeFigure()

void mitk::PlanarFigureInteractor::FinalizeFigure ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ HideControlPoints()

void mitk::PlanarFigureInteractor::HideControlPoints ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ HidePreviewPoint()

void mitk::PlanarFigureInteractor::HidePreviewPoint ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ IsMousePositionAcceptableAsNewControlPoint()

bool mitk::PlanarFigureInteractor::IsMousePositionAcceptableAsNewControlPoint ( const mitk::InteractionPositionEvent *  positionEvent,
const PlanarFigure *   
)
protected

Used when clicking to determine if a point is too close to the previous point.

◆ IsPointNearLine()

bool mitk::PlanarFigureInteractor::IsPointNearLine ( const mitk::Point2D &  point,
const mitk::Point2D &  startPoint,
const mitk::Point2D &  endPoint,
mitk::Point2D &  projectedPoint 
) const
protected

Returns true if the first specified point is in proximity of the line defined the other two point; false otherwise.

Proximity is defined as the rectangle around the line with pre-defined distance from the line.

◆ IsPositionInsideMarker()

int mitk::PlanarFigureInteractor::IsPositionInsideMarker ( const InteractionPositionEvent *  positionEvent,
const PlanarFigure *  planarFigure,
const PlaneGeometry *  planarFigureGeometry,
const PlaneGeometry *  rendererGeometry,
const BaseRenderer *  renderer 
) const
protected

Returns the index of the marker (control point) over which the point contained in the passed event (in display coordinates) currently is; -1 if the point is not over a marker.

◆ IsPositionOverFigure()

int mitk::PlanarFigureInteractor::IsPositionOverFigure ( const InteractionPositionEvent *  positionEvent,
PlanarFigure *  planarFigure,
const PlaneGeometry *  planarFigureGeometry,
const PlaneGeometry *  rendererGeometry,
Point2D &  pointProjectedOntoLine 
) const
protected

Returns true if the point contained in the passed event (in display coordinates) is over the planar figure (with a pre-defined tolerance range); false otherwise.

◆ LogPrintPlanarFigureQuantities()

void mitk::PlanarFigureInteractor::LogPrintPlanarFigureQuantities ( const PlanarFigure *  planarFigure)
protected

◆ mitkClassMacro()

mitk::PlanarFigureInteractor::mitkClassMacro ( PlanarFigureInteractor  ,
DataInteractor   
)

◆ MoveCurrentPoint()

void mitk::PlanarFigureInteractor::MoveCurrentPoint ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ New()

static Pointer mitk::PlanarFigureInteractor::New ( )
static

◆ PerformPointResetOnSelect()

void mitk::PlanarFigureInteractor::PerformPointResetOnSelect ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ RemoveSelectedPoint()

void mitk::PlanarFigureInteractor::RemoveSelectedPoint ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ RequestContextMenu()

void mitk::PlanarFigureInteractor::RequestContextMenu ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ SelectFigure()

void mitk::PlanarFigureInteractor::SelectFigure ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ SelectPoint()

void mitk::PlanarFigureInteractor::SelectPoint ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ SetMinimumPointDistance()

void mitk::PlanarFigureInteractor::SetMinimumPointDistance ( ScalarType  minimumDistance)

Sets the minimal distance between two control points.

Prevents adding a new control point too close to an existing one.

Parameters
[in]minimumDistanceThe minimum allowed distance between control points.

◆ SetPrecision()

void mitk::PlanarFigureInteractor::SetPrecision ( ScalarType  precision)

Sets the precision for picking control points and figure edges.

Defines how close (in display coordinates) a mouse click must be to a control point or figure edge to select it.

Parameters
[in]precisionThe precision value in display units.

◆ SetPreviewPointPosition()

void mitk::PlanarFigureInteractor::SetPreviewPointPosition ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ StartHovering()

void mitk::PlanarFigureInteractor::StartHovering ( StateMachineAction *  ,
InteractionEvent *  interactionEvent 
)
protected

◆ TransformObjectToDisplay()

bool mitk::PlanarFigureInteractor::TransformObjectToDisplay ( const mitk::Point2D &  point2D,
mitk::Point2D &  displayPoint,
const mitk::PlaneGeometry *  objectGeometry,
const mitk::PlaneGeometry *  rendererGeometry,
const mitk::BaseRenderer *  renderer 
) const
protected

◆ TransformPositionEventToPoint2D()

bool mitk::PlanarFigureInteractor::TransformPositionEventToPoint2D ( const InteractionPositionEvent *  positionEvent,
const PlaneGeometry *  planarFigureGeometry,
Point2D &  point2D 
)
protected

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