Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkSeedsInteractor.h"
00019
00020 #include "mitkProperties.h"
00021 #include "mitkStringProperty.h"
00022 #include "mitkAction.h"
00023 #include "mitkDisplayPositionEvent.h"
00024 #include "mitkOperationEvent.h"
00025 #include "mitkInteractionConst.h"
00026 #include "mitkUndoController.h"
00027 #include "mitkDataNode.h"
00028 #include "mitkStateEvent.h"
00029 #include "mitkState.h"
00030 #include "mitkDrawOperation.h"
00031
00032
00033 mitk::SeedsInteractor::SeedsInteractor(const char * type, mitk::DataNode* dataNode)
00034 : mitk::Interactor(type, dataNode)
00035 {
00036 m_Radius = 1;
00037 m_Config = 0;
00038 m_CurrentDrawState = 255;
00039 }
00040
00041 mitk::SeedsInteractor::~SeedsInteractor()
00042 {
00043 }
00044
00045
00046 bool mitk::SeedsInteractor::ExecuteAction(mitk::Action* action, mitk::StateEvent const* stateEvent)
00047 {
00048 const mitk::DisplayPositionEvent* posEvent = dynamic_cast<const mitk::DisplayPositionEvent*>(stateEvent->GetEvent());
00049 if (posEvent == NULL)
00050 return false;
00051
00052 event_point = posEvent->GetWorldPosition();
00053
00054 m_DataNode->SetVisibility(true);
00055 m_SeedsImage = dynamic_cast<mitk::SeedsImage*>(m_DataNode->GetData());
00056
00057
00058 bool ok = false;
00059 switch (action->GetActionId())
00060 {
00061 case mitk::AcINITFOREGROUND:
00062 {
00063 if (m_Config == 0) m_DrawState = m_CurrentDrawState;
00064 else m_DrawState = 1;
00065 ok = true;
00066 break;
00067 }
00068 case mitk::AcINITBACKGROUND:
00069 {
00070 if (m_Config == 0) m_DrawState = 254;
00071 else m_DrawState = -1;
00072 ok = true;
00073 break;
00074 }
00075 case mitk::AcINITNEUTRAL:
00076 {
00077 m_DrawState = 0;
00078 ok = true;
00079 break;
00080 }
00081 case mitk::AcADD:
00082 {
00083 last_point = event_point;
00084 mitk::DrawOperation* doOp = new mitk::DrawOperation(OpADD, event_point, last_point, m_DrawState, m_Radius);
00085 if (m_UndoEnabled){
00086 mitk::DrawOperation* undoOp = new mitk::DrawOperation(OpUNDOADD, event_point, last_point, m_DrawState, m_Radius);
00087 mitk::OperationEvent *operationEvent = new mitk::OperationEvent(m_SeedsImage, doOp, undoOp, "Add seed point");
00088 m_UndoController->SetOperationEvent(operationEvent);
00089 }
00090
00091 m_SeedsImage->ExecuteOperation(doOp);
00092 ok = true;
00093 break;
00094 }
00095 case mitk::AcMOVE:
00096 {
00097 last_point = event_point;
00098 mitk::DrawOperation* doOp = new mitk::DrawOperation(OpMOVE, event_point, last_point, m_DrawState, m_Radius);
00099 if (m_UndoEnabled){
00100 mitk::DrawOperation* undoOp = new mitk::DrawOperation(OpUNDOMOVE, event_point, last_point, m_DrawState, m_Radius);
00101 mitk::OperationEvent *operationEvent = new mitk::OperationEvent(m_SeedsImage, doOp, undoOp, "Move seed point");
00102 m_UndoController->SetOperationEvent(operationEvent);
00103 }
00104
00105 m_SeedsImage->ExecuteOperation(doOp);
00106 ok = true;
00107
00108 break;
00109 }
00110 case mitk::AcFINISH:
00111 {
00112 last_point = event_point;
00113 ok = true;
00114 this->Modified();
00115
00116 this->InvokeEvent( itk::EndEvent() );
00117
00118 break;
00119 }
00120 default:
00121 return Superclass::ExecuteAction( action, stateEvent );
00122 }
00123 return ok;
00124 }