Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

mitk::SeedsInteractor Class Reference
[Interaction Classes]

SeedsInteractor handles all actions on the seedsimage. More...

#include <mitkSeedsInteractor.h>

Inheritance diagram for mitk::SeedsInteractor:
Inheritance graph
[legend]
Collaboration diagram for mitk::SeedsInteractor:
Collaboration graph
[legend]

List of all members.

Public Types

typedef SeedsInteractor Self
typedef Interactor Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
void SetRadius (int val)
 sets the radius of the seeds.
void SetCurrentDrawState (int val)
virtual void SetConfig (unsigned int _arg)
virtual unsigned int GetConfig ()

Static Public Member Functions

static Pointer New (const char *_arga, DataNode *_argb)
 NewMacro with two parameters for calling itk::Lightobject::New(..) method.

Protected Member Functions

 SeedsInteractor (const char *type, DataNode *dataNode)
 Default Constructor.
virtual ~SeedsInteractor ()
 Default Destructor.
virtual bool ExecuteAction (Action *action, StateEvent const *stateEvent)
 Method called in HandleEvent after Statechange.

Protected Attributes

SeedsImage::Pointer m_SeedsImage
SeedsImage::Pointer m_LastSeedsImage
Point3D event_point
Point3D last_point
int m_Radius
int m_DrawState
int m_CurrentDrawState
unsigned int m_Config

Detailed Description

SeedsInteractor handles all actions on the seedsimage.

Definition at line 35 of file mitkSeedsInteractor.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::SeedsInteractor::ConstPointer

Reimplemented from mitk::Interactor.

Definition at line 38 of file mitkSeedsInteractor.h.

typedef itk::SmartPointer<Self> mitk::SeedsInteractor::Pointer

Reimplemented from mitk::Interactor.

Definition at line 38 of file mitkSeedsInteractor.h.

Reimplemented from mitk::Interactor.

Definition at line 38 of file mitkSeedsInteractor.h.

Reimplemented from mitk::Interactor.

Definition at line 38 of file mitkSeedsInteractor.h.


Constructor & Destructor Documentation

mitk::SeedsInteractor::SeedsInteractor ( const char *  type,
mitk::DataNode dataNode 
) [protected]

Default Constructor.

Definition at line 33 of file mitkSeedsInteractor.cpp.

References m_Config, m_CurrentDrawState, and m_Radius.

  : mitk::Interactor(type, dataNode)
{
  m_Radius = 1;
  m_Config = 0; // default config 254, 255 are added for fore- and backgrund seeds
  m_CurrentDrawState = 255;
}
mitk::SeedsInteractor::~SeedsInteractor (  ) [protected, virtual]

Default Destructor.

Definition at line 41 of file mitkSeedsInteractor.cpp.

{
}

Member Function Documentation

bool mitk::SeedsInteractor::ExecuteAction ( mitk::Action action,
mitk::StateEvent const *  stateEvent 
) [protected, virtual]

Method called in HandleEvent after Statechange.

look up which object method is associated to the given action and call the method

Each statechange has actions, which can be assigned by it's number. If you are developing a new statemachine, declare all your operations here and send them to Undo-Controller and to the Data. Object- and group-EventId can also be accessed through static methods from OperationEvent

Reimplemented from mitk::StateMachine.

Definition at line 46 of file mitkSeedsInteractor.cpp.

References mitk::AcADD, mitk::AcFINISH, mitk::AcINITBACKGROUND, mitk::AcINITFOREGROUND, mitk::AcINITNEUTRAL, mitk::AcMOVE, mitk::Action::GetActionId(), mitk::StateEvent::GetEvent(), mitk::DisplayPositionEvent::GetWorldPosition(), mitk::OpADD, mitk::OpMOVE, mitk::OpUNDOADD, and mitk::OpUNDOMOVE.

{
  const mitk::DisplayPositionEvent* posEvent = dynamic_cast<const mitk::DisplayPositionEvent*>(stateEvent->GetEvent());
  if (posEvent == NULL)
    return false;
  
  event_point = posEvent->GetWorldPosition();

  m_DataNode->SetVisibility(true);
  m_SeedsImage = dynamic_cast<mitk::SeedsImage*>(m_DataNode->GetData());


  bool ok = false;
  switch (action->GetActionId())
  {
  case mitk::AcINITFOREGROUND:
    {
      if (m_Config == 0)      m_DrawState = m_CurrentDrawState;
      else                    m_DrawState = 1;
      ok = true;
      break;
    }
  case mitk::AcINITBACKGROUND:
    {
      if (m_Config == 0)      m_DrawState = 254;
      else                    m_DrawState = -1;
      ok = true;
      break;
    }
  case mitk::AcINITNEUTRAL:
    {
      m_DrawState = 0;
      ok = true;
      break;
    }
  case mitk::AcADD:
    {
      last_point = event_point;
      mitk::DrawOperation* doOp = new mitk::DrawOperation(OpADD, event_point, last_point, m_DrawState, m_Radius);
      if (m_UndoEnabled){ //write to UndoMechanism/ Can probably be removed!
        mitk::DrawOperation* undoOp = new mitk::DrawOperation(OpUNDOADD, event_point, last_point, m_DrawState, m_Radius);
        mitk::OperationEvent *operationEvent = new mitk::OperationEvent(m_SeedsImage, doOp, undoOp, "Add seed point");
        m_UndoController->SetOperationEvent(operationEvent);
      }
      //execute the Operation
      m_SeedsImage->ExecuteOperation(doOp);
      ok = true;
      break;
    }
  case mitk::AcMOVE:
    {
      last_point = event_point;
      mitk::DrawOperation* doOp = new mitk::DrawOperation(OpMOVE, event_point, last_point, m_DrawState, m_Radius);
      if (m_UndoEnabled){ //write to UndoMechanism/ Can probably be removed!
        mitk::DrawOperation* undoOp = new mitk::DrawOperation(OpUNDOMOVE, event_point, last_point, m_DrawState, m_Radius);
        mitk::OperationEvent *operationEvent = new mitk::OperationEvent(m_SeedsImage, doOp, undoOp, "Move seed point");
        m_UndoController->SetOperationEvent(operationEvent);
      }
      //execute the Operation
      m_SeedsImage->ExecuteOperation(doOp);   
      ok = true;
      //this->Modified();
      break;
    }
  case mitk::AcFINISH:
    {
      last_point = event_point;
      ok = true;
      this->Modified();
      
      this->InvokeEvent( itk::EndEvent() );

      break;
    }
  default:
    return Superclass::ExecuteAction( action, stateEvent );
  }
  return ok;
}
virtual const char* mitk::SeedsInteractor::GetClassName (  ) const [virtual]

Reimplemented from mitk::Interactor.

virtual unsigned int mitk::SeedsInteractor::GetConfig (  ) [virtual]
static Pointer mitk::SeedsInteractor::New ( const char *  _arga,
DataNode _argb 
) [inline, static]

NewMacro with two parameters for calling itk::Lightobject::New(..) method.

Reimplemented from mitk::Interactor.

Definition at line 39 of file mitkSeedsInteractor.h.

Referenced by mitkDataNodeExtTestClass::TestInteractorSetting().

{m_Radius=val;};
virtual void mitk::SeedsInteractor::SetConfig ( unsigned int  _arg ) [virtual]
void mitk::SeedsInteractor::SetCurrentDrawState ( int  val ) [inline]

Definition at line 43 of file mitkSeedsInteractor.h.

void mitk::SeedsInteractor::SetRadius ( int  val ) [inline]

sets the radius of the seeds.

Definition at line 42 of file mitkSeedsInteractor.h.

{m_Radius=val;};

Member Data Documentation

Definition at line 63 of file mitkSeedsInteractor.h.

Point3D mitk::SeedsInteractor::last_point [protected]

Definition at line 64 of file mitkSeedsInteractor.h.

unsigned int mitk::SeedsInteractor::m_Config [protected]

Definition at line 69 of file mitkSeedsInteractor.h.

Referenced by SeedsInteractor().

Definition at line 68 of file mitkSeedsInteractor.h.

Referenced by SeedsInteractor().

Definition at line 67 of file mitkSeedsInteractor.h.

Definition at line 62 of file mitkSeedsInteractor.h.

Definition at line 66 of file mitkSeedsInteractor.h.

Referenced by SeedsInteractor().

Definition at line 61 of file mitkSeedsInteractor.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines