#include <mitkCoordinateSupplier.h>


Public Types | |
| typedef CoordinateSupplier | 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 Point3D & | GetCurrentPoint () |
Static Public Member Functions | |
| static Pointer | New (const char *_arga, OperationActor *_argb) |
Protected Member Functions | |
| CoordinateSupplier (const char *type, OperationActor *operationActor) | |
| Constructor with needed arguments. | |
| ~CoordinateSupplier () | |
| virtual bool | ExecuteAction (Action *action, mitk::StateEvent const *stateEvent) |
| executes the actions that are sent to this statemachine derived from StateMachine | |
sends a Point, that can be processed in its own OperationActor
Definition at line 36 of file mitkCoordinateSupplier.h.
| typedef itk::SmartPointer<const Self> mitk::CoordinateSupplier::ConstPointer |
Reimplemented from mitk::StateMachine.
Definition at line 39 of file mitkCoordinateSupplier.h.
| typedef itk::SmartPointer<Self> mitk::CoordinateSupplier::Pointer |
Reimplemented from mitk::StateMachine.
Definition at line 39 of file mitkCoordinateSupplier.h.
Reimplemented from mitk::StateMachine.
Definition at line 39 of file mitkCoordinateSupplier.h.
Reimplemented from mitk::StateMachine.
Definition at line 39 of file mitkCoordinateSupplier.h.
| mitk::CoordinateSupplier::CoordinateSupplier | ( | const char * | type, |
| mitk::OperationActor * | operationActor | ||
| ) | [protected] |
Constructor with needed arguments.
| type,: | string, that describes the StateMachine-Scheme to take from all SM (see XML-File) |
| operationActor,: | the Data, operations (+ points) are send to |
Definition at line 34 of file mitkCoordinateSupplier.cpp.
: mitk::StateMachine(type), m_Destination(operationActor) { m_CurrentPoint.Fill(0); }
| mitk::CoordinateSupplier::~CoordinateSupplier | ( | ) | [protected] |
Definition at line 40 of file mitkCoordinateSupplier.cpp.
{
}
| bool mitk::CoordinateSupplier::ExecuteAction | ( | Action * | action, |
| mitk::StateEvent const * | stateEvent | ||
| ) | [protected, virtual] |
executes the actions that are sent to this statemachine derived from StateMachine
Reimplemented from mitk::StateMachine.
Definition at line 45 of file mitkCoordinateSupplier.cpp.
References mitk::AcFINISHMOVEMENT, mitk::AcINITMOVEMENT, mitk::AcMOVE, mitk::AcMOVEPOINT, mitk::AcNEWPOINT, mitk::Action::GetActionId(), mitk::BaseRenderer::GetCurrentWorldGeometry2D(), mitk::StateEvent::GetEvent(), mitk::OperationEvent::GetOperation(), mitk::PointOperation::GetPoint(), mitk::Event::GetSender(), mitk::Geometry3D::GetTimeBounds(), mitk::DisplayPositionEvent::GetWorldPosition(), mitk::OpADD, mitk::OpDELETE, mitk::OpMOVE, and mitk::OpTERMINATE.
{
bool ok = false;
const PositionEvent* posEvent = dynamic_cast<const PositionEvent*>(stateEvent->GetEvent());
PointOperation* doOp=NULL;
if(posEvent!=NULL)
{
ScalarType timeInMS = 0;
if(stateEvent->GetEvent()->GetSender()!=NULL)
{
const Geometry2D* worldGeometry = stateEvent->GetEvent()->GetSender()->GetCurrentWorldGeometry2D();
assert( worldGeometry != NULL );
timeInMS = worldGeometry->GetTimeBounds()[ 0 ];
}
else
{
itkWarningMacro(<<"StateEvent::GetSender()==NULL - setting timeInMS to 0");
}
switch (action->GetActionId())
{
case AcNEWPOINT:
{
if (m_Destination == NULL)
return false;
m_OldPoint = posEvent->GetWorldPosition();
doOp = new mitk::PointOperation(OpADD, timeInMS, m_OldPoint, 0);
//Undo
if (m_UndoEnabled)
{
PointOperation* undoOp = new PointOperation(OpDELETE, m_OldPoint, 0);
OperationEvent *operationEvent = new OperationEvent( m_Destination, doOp, undoOp );
m_UndoController->SetOperationEvent(operationEvent);
}
//execute the Operation
m_Destination->ExecuteOperation(doOp);
ok = true;
break;
}
case AcINITMOVEMENT:
{
if (m_Destination == NULL)
return false;
//move the point to the coordinate //not used, cause same to MovePoint... check xml-file
mitk::Point3D movePoint = posEvent->GetWorldPosition();
doOp = new mitk::PointOperation(OpMOVE, timeInMS, movePoint, 0);
//execute the Operation
m_Destination->ExecuteOperation(doOp);
ok = true;
break;
}
case AcMOVEPOINT:
case AcMOVE:
{
mitk::Point3D movePoint = posEvent->GetWorldPosition();
m_CurrentPoint = movePoint;
if (m_Destination == NULL)
return false;
doOp = new mitk::PointOperation(OpMOVE, timeInMS, movePoint, 0);
//execute the Operation
m_Destination->ExecuteOperation(doOp);
ok = true;
break;
}
case AcFINISHMOVEMENT:
{
if (m_Destination == NULL)
return false;
/*finishes a Movement from the coordinate supplier:
gets the lastpoint from the undolist and writes an undo-operation so
that the movement of the coordinatesupplier is undoable.*/
mitk::Point3D movePoint = posEvent->GetWorldPosition();
mitk::Point3D oldMovePoint; oldMovePoint.Fill(0);
doOp = new mitk::PointOperation(OpMOVE, timeInMS, movePoint, 0);
PointOperation* finishOp = new mitk::PointOperation(OpTERMINATE, movePoint, 0);
if (m_UndoEnabled )
{
//get the last Position from the UndoList
OperationEvent *lastOperationEvent = m_UndoController->GetLastOfType(m_Destination, OpMOVE);
if (lastOperationEvent != NULL)
{
PointOperation* lastOp = dynamic_cast<PointOperation *>(lastOperationEvent->GetOperation());
if (lastOp != NULL)
{
oldMovePoint = lastOp->GetPoint();
}
}
PointOperation* undoOp = new PointOperation(OpMOVE, timeInMS, oldMovePoint, 0, "Move slices");
OperationEvent *operationEvent = new OperationEvent(m_Destination, doOp, undoOp, "Move slices");
m_UndoController->SetOperationEvent(operationEvent);
}
//execute the Operation
m_Destination->ExecuteOperation(doOp);
m_Destination->ExecuteOperation(finishOp);
ok = true;
delete finishOp;
break;
}
default:
ok = false;
break;
}
return ok;
}
const mitk::DisplayPositionEvent* displPosEvent = dynamic_cast<const mitk::DisplayPositionEvent *>(stateEvent->GetEvent());
if(displPosEvent!=NULL)
{
return true;
}
return false;
}
| virtual const char* mitk::CoordinateSupplier::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::StateMachine.
| virtual const Point3D& mitk::CoordinateSupplier::GetCurrentPoint | ( | ) | [virtual] |
| static Pointer mitk::CoordinateSupplier::New | ( | const char * | _arga, |
| OperationActor * | _argb | ||
| ) | [inline, static] |
Definition at line 40 of file mitkCoordinateSupplier.h.
Referenced by QmitkStdMultiWidget::InitializeWidget().
:
//##Documentation
1.7.2