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

Common base class for segmentor tools and interactors. More...

Inheritance diagram for niftk::FilteringStateMachine:
Inheritance graph
[legend]

Public Member Functions

 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)
 
virtual void InstallEventFilter (StateMachineEventFilter *eventFilter)
 Installs an event filter that can reject a state machine event or let it pass through. More...
 
virtual void RemoveEventFilter (StateMachineEventFilter *eventFilter)
 Removes an event filter that can reject a state machine event or let it pass through. More...
 
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...
 

Protected Member Functions

virtual float CanHandle (const mitk::StateEvent *stateEvent) const
 
virtual bool CanHandle (mitk::InteractionEvent *event)
 

Detailed Description

Common base class for segmentor tools and interactors.

Provides a way to define event filters externally and apply them to state machines. This can be used to discard events that come from an unwanted render window. With other words, we can limit the scope of the state machine to certain render windows, e.g. to the active render window of the main display.

The class provides an implementation for the mitk::StateMachine::CanHandleEvent(const mitk::StateEvent* stateEvent) function that first checks if the event is filtered, and if not it calls the protected CanHandle function. Derived classes should override mitk::StateMachine::CanHandleEvent() and delegate the call to the CanHandleEvent() function of this class. They should allow new types of events by overriding the CanHandle function.

Note that this class is not derived from mitk::StateMachine.

Constructor & Destructor Documentation

niftk::FilteringStateMachine::FilteringStateMachine ( )

Constructs a FilteringStateMachine object.

niftk::FilteringStateMachine::~FilteringStateMachine ( )
virtual

Destructs the FilteringStateMachine object.

Member Function Documentation

virtual float niftk::FilteringStateMachine::CanHandle ( const mitk::StateEvent *  stateEvent) const
inlineprotectedvirtual

Tells if this state machine can handle the event. This function is called only if the event has not been rejected by one of the event filters. Derived classes should override this function in favor of mitk::StateMachine::CanHandleEvent if they can process also other kinds of events than what their base class can do.

Reimplemented in niftk::PointSetInteractor.

virtual bool niftk::FilteringStateMachine::CanHandle ( mitk::InteractionEvent *  event)
inlineprotectedvirtual

Reimplemented in niftk::PointSetDataInteractor.

float niftk::FilteringStateMachine::CanHandleEvent ( const mitk::StateEvent *  event) const

This function is to replace the original CanHandleEvent function to support event filtering.

Checks if the event is filtered by one of the registered event filters. If yes, it returns 0. Otherwise, it calls CanHandle(const mitk::StateEvent*) and returns with its result.

Note that this function is not virtual. Derived classes should override the mitk::StateMachine::CanHandleEvent() function and delegate the call to this function.

float CanHandleEvent(const mitk::StateEvent* stateEvent) const { return FilteringStateMachine::CanHandleEvent(stateEvent); }

The original logic should be implemented in the CanHandle function.

See also
mitk::StateMachine::CanHandleEvent
bool niftk::FilteringStateMachine::CanHandleEvent ( mitk::InteractionEvent *  event)
std::vector< StateMachineEventFilter * > niftk::FilteringStateMachine::GetEventFilters ( ) const

Gets the list of the installed event filters.

void niftk::FilteringStateMachine::InstallEventFilter ( StateMachineEventFilter eventFilter)
virtual

Installs an event filter that can reject a state machine event or let it pass through.

Reimplemented in niftk::Tool, and niftk::SeedTool.

bool niftk::FilteringStateMachine::IsFiltered ( const mitk::StateEvent *  stateEvent) const

Tells if the event is rejected by the installed event filters or they let it pass through.

Sanity check.

bool niftk::FilteringStateMachine::IsFiltered ( mitk::InteractionEvent *  event)

Tells if the event is rejected by the installed event filters or they let it pass through.

Sanity check.

void niftk::FilteringStateMachine::RemoveEventFilter ( StateMachineEventFilter eventFilter)
virtual

Removes an event filter that can reject a state machine event or let it pass through.

Reimplemented in niftk::Tool, and niftk::SeedTool.


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