Index: mitk/Core/Code/Interactions/mitkPointSetInteractor.cpp =================================================================== --- mitk/Core/Code/Interactions/mitkPointSetInteractor.cpp (revision 26033) +++ mitk/Core/Code/Interactions/mitkPointSetInteractor.cpp (working copy) @@ -632,7 +632,7 @@ else it++; } } - + ok = true; // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; @@ -1121,32 +1121,47 @@ mitk::PointSet *pointSet = dynamic_cast(m_DataNode->GetData()); if ( pointSet != NULL ) { - int numberOfPoints = pointSet->GetSize( m_TimeStep ); - if (numberOfPoints == 0) - return; //pointset is empty - else if (numberOfPointsExpandStartStateVector(pointSet->GetPointSetSeriesSize()); + + for (unsigned int timestep = 0; timestep < pointSet->GetPointSetSeriesSize(); timestep++) { - //get the currentState to state "SpaceLeft" - const mitk::Event* nullEvent = new mitk::Event(NULL, Type_User, BS_NoButton, BS_NoButton, Key_none); - mitk::StateEvent* newStateEvent = - new mitk::StateEvent(EIDSMALLERN, nullEvent); - this->HandleEvent( newStateEvent ); - delete newStateEvent; - delete nullEvent; - } - else if (numberOfPoints>=m_N) - { - if (numberOfPoints>m_N) + //go to new timestep + this->UpdateTimeStep(timestep); + + int numberOfPoints = pointSet->GetSize( timestep ); + if (numberOfPoints == 0) + continue; //pointset is empty + else { - STATEMACHINE_WARN<<"Point Set contains more points than needed!\n";//display a warning that there are too many points + //we have a set of loaded points. Deselect all points, because they are all set to selected when added! + this->UnselectAll(timestep); + + if (numberOfPointsHandleEvent( newStateEvent ); + delete newStateEvent; + delete nullEvent; + } + else if (numberOfPoints>=m_N) + { + if (numberOfPoints>m_N) + { + STATEMACHINE_WARN<<"Point Set contains more points than needed!\n";//display a warning that there are too many points + } + //get the currentState to state "Set full" + const mitk::Event* nullEvent = new mitk::Event(NULL, Type_User, BS_NoButton, BS_NoButton, Key_none); + mitk::StateEvent* newStateEvent = + new mitk::StateEvent(EIDEQUALSN, nullEvent); + this->HandleEvent( newStateEvent ); + delete newStateEvent; + delete nullEvent; + } } - //get the currentState to state "Set full" - const mitk::Event* nullEvent = new mitk::Event(NULL, Type_User, BS_NoButton, BS_NoButton, Key_none); - mitk::StateEvent* newStateEvent = - new mitk::StateEvent(EIDEQUALSN, nullEvent); - this->HandleEvent( newStateEvent ); - delete newStateEvent; - delete nullEvent; } } return; Index: mitk/Core/Code/Interactions/StateMachine.xml =================================================================== --- mitk/Core/Code/Interactions/StateMachine.xml (revision 26033) +++ mitk/Core/Code/Interactions/StateMachine.xml (working copy) @@ -3105,24 +3105,28 @@ - - + + - - + + + - - + + + - + + + Index: mitk/Core/Code/Testing/mitkPointSetInteractorTest.cpp =================================================================== --- mitk/Core/Code/Testing/mitkPointSetInteractorTest.cpp (revision 26033) +++ mitk/Core/Code/Testing/mitkPointSetInteractorTest.cpp (working copy) @@ -31,6 +31,7 @@ const char* POINTSETINTERACTORNAME = "pointsetinteractor"; const char* ONLYMOVEPOINTSETINTERACTORNAME = "onlymovepointsetinteractor"; const char* SEEDPOINTSETINTERACTORNAME = "seedpointsetinteractor"; +const char* SINGLEPOINTWITHOUTSHIFTCLICKNAME = "singlepointinteractorwithoutshiftclick"; /** *@brief method to send specified events to EventMapper @@ -408,6 +409,88 @@ delete delEvent; } + + void TestSinglePointSetInteractorWithoutShiftClick(const char* name, mitk::DataNode* node, mitk::BaseRenderer* sender) + { + mitk::PointSetInteractor::Pointer interactor = mitk::PointSetInteractor::New(name, node); + MITK_TEST_CONDITION_REQUIRED(interactor.IsNotNull(),"Testing to initialize PointSetInteractor") + std::cout<<"The pattern of the interactor is called: "<GetType()<GetType() == name,"testing pattern name of interactor"); + + //should not be null + MITK_TEST_CONDITION_REQUIRED(node != NULL, "error in test! Node == NULL"); + mitk::PointSet::Pointer pointSet = dynamic_cast(node->GetData()); + MITK_TEST_CONDITION_REQUIRED(pointSet.IsNotNull(), "error in test! PointSet not set"); + + //sending an event now shouln't lead to an addition of a point because interactor is not yet connected to globalinteraction + + mitk::Point3D pos3D; + mitk::Point2D pos2D; + pos3D[0]= 10.0; pos3D[1]= 20.0; pos3D[2]= 30.0; + pos2D[0]= 10; pos2D[0]= 20; + + this->SendPositionEvent(sender, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_NoButton, mitk::Key_none, pos2D, pos3D); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPointSet()->GetNumberOfPoints()==0,"Checking unconnected interactor."); + + //activate interaction + mitk::GlobalInteraction::GetInstance()->AddInteractor(interactor); + + //now one point should be added going from state 1 to state 2 + this->SendPositionEvent(sender, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_NoButton, mitk::Key_none, pos2D, pos3D); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPointSet()->GetNumberOfPoints()==1,"Checking connected interactor by adding a point."); + + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPoint(0) == pos3D,"Testing right addition of point."); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetSelectInfo(0) ,"Testing if point is selected."); + + //trying to delete point + mitk::Event* delEvent = new mitk::Event(sender, mitk::Type_KeyPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_Delete); + mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(delEvent); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPointSet()->GetNumberOfPoints()==0,"Checking deleting point."); + + //adding two points and checking that only the last one remains in point set + pos3D[0]= 11.0; pos3D[1]= 22.0; pos3D[2]= 33.0; + pos2D[0]= 11; pos2D[0]= 22; + this->SendPositionEvent(sender, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_NoButton, mitk::Key_none, pos2D, pos3D); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPointSet()->GetNumberOfPoints()==1,"Checking adding point."); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetSelectInfo(0) ,"Testing if point1 is selected."); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPoint(0) == pos3D,"Testing addition of point."); + + pos3D[0]= 111.0; pos3D[1]= 222.0; pos3D[2]= 333.0; + pos2D[0]= 111; pos2D[0]= 222; + this->SendPositionEvent(sender, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_NoButton, mitk::Key_none, pos2D, pos3D); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPointSet()->GetNumberOfPoints()==1,"Checking that only one point remains in pointset."); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPoint(0) == pos3D,"Testing addition of point."); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetSelectInfo(0) ==true,"Testing if point is selected."); + + //sending delete-event + mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(delEvent); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPointSet()->GetNumberOfPoints()==0,"Checking if the point could be delected."); + //sending delete-event again + mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(delEvent); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPointSet()->GetNumberOfPoints()==0,"Checking Sending Delete again."); + + //adding three points and see if only the third remains + pos3D[0]= 1.0; pos3D[1]= 2.0; pos3D[2]= 3.0; + pos2D[0]= 1; pos2D[0]= 2; + this->SendPositionEvent(sender, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_NoButton, mitk::Key_none, pos2D, pos3D); + + pos3D[0]= 11.0; pos3D[1]= 22.0; pos3D[2]= 33.0; + pos2D[0]= 11; pos2D[0]= 22; + this->SendPositionEvent(sender, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_NoButton, mitk::Key_none, pos2D, pos3D); + + pos3D[0]= 111.0; pos3D[1]= 222.0; pos3D[2]= 333.0; + pos2D[0]= 111; pos2D[0]= 222; + this->SendPositionEvent(sender, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_NoButton, mitk::Key_none, pos2D, pos3D); + + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPointSet()->GetNumberOfPoints()==1,"Checking if only one point could be added."); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetPoint(0) == pos3D,"Testing if the last point was inserted."); + MITK_TEST_CONDITION_REQUIRED(pointSet->GetSelectInfo(0) ,"Testing if the last point added is selected."); + + //removing interactor from GlobalInteraction + mitk::GlobalInteraction::GetInstance()->RemoveInteractor(interactor); + delete delEvent; + } + private: void SendPositionEvent(mitk::BaseRenderer* sender, int type, int button, int buttonState, int key, const mitk::Point2D& displPosition, const mitk::Point3D& worldPosition) @@ -476,7 +559,13 @@ MITK_TEST_OUTPUT(<<"--------Testing "<TestSeedPointSetInteractor(SEEDPOINTSETINTERACTORNAME, node, sender); + + pointSet = mitk::PointSet::New(); + node = mitk::DataNode::New(); + node->SetData(pointSet); - + MITK_TEST_OUTPUT(<<"--------Testing "<TestSinglePointSetInteractorWithoutShiftClick(SINGLEPOINTWITHOUTSHIFTCLICKNAME, node, sender); + MITK_TEST_END() } Index: mitk/CoreUI/Bundles/org.mitk.gui.qt.common/resources/StateMachine.xml =================================================================== --- mitk/CoreUI/Bundles/org.mitk.gui.qt.common/resources/StateMachine.xml (revision 26033) +++ mitk/CoreUI/Bundles/org.mitk.gui.qt.common/resources/StateMachine.xml (working copy) @@ -3105,24 +3105,28 @@ - - + + - - + + + - - + + + - + + +