Index: mitk/Core/Code/Interactions/mitkInteractionConst.h =================================================================== --- mitk/Core/Code/Interactions/mitkInteractionConst.h (revision 25504) +++ mitk/Core/Code/Interactions/mitkInteractionConst.h (working copy) @@ -69,8 +69,8 @@ EIDCTRLANDMIDDLEMOUSEBTNRELEASE = 539, EIDSHIFTANDCTRLANDMIDDLEMOUSEBTN = 540, EIDSHIFTANDLEFTMOUSEBTNANDMOUSEMOVE = 541, - SHIFTANDCTRLANDMOUSEMOVE = 542, - SHIFTANDCTRLANDMOUSERELEASE = 543, + EIDSHIFTANDCTRLANDMOUSEMOVE = 542, + EIDSHIFTANDCTRLANDMOUSERELEASE = 543, EIDALTANDLEFTMOUSEBTN = 600, EIDALTANDLEFTMOUSEBTNANDMOUSEMOVE = 610, EIDALTANDLEFTMOUSERELEASE = 620, @@ -94,10 +94,10 @@ EIDE = 19, EIDSTRGANDALTANDA = 20, EIDSTRGANDALTANDB = 21, - H = 22, - Return = 23, - Enter = 24, - Space = 25, + EIDH = 22, + EIDRETURN = 23, + EIDENTER = 24, + EIDSPACE = 25, EIDPLUS = 26, EIDMINUS = 27, EIDSTRGANDALTANDH = 30, @@ -119,6 +119,10 @@ EIDSTLARGERNMINUS1 = 1011, EIDPOSITIONEVENT = 1012, EIDEDIT = 1013, + EIDSMALLERN = 1014, + EIDEQUALSN = 1015, + EIDLARGERN = 1016, + EIDEMPTY = 1017, EIDSUBDESELECT = 1020, EIDSMTOSELECTED = 1030, EIDSMTODESELECTED = 1031, @@ -139,8 +143,6 @@ EV_NEW_LANDMARK = 5551009, EV_REMOVE_LANDMARK = 5551010, EIDINSIDE = 2500 - - }; //##Constants for Operations Index: mitk/Core/Code/Interactions/mitkPointSetInteractor.cpp =================================================================== --- mitk/Core/Code/Interactions/mitkPointSetInteractor.cpp (revision 25504) +++ mitk/Core/Code/Interactions/mitkPointSetInteractor.cpp (working copy) @@ -41,8 +41,16 @@ ::PointSetInteractor(const char * type, DataNode* dataNode, int n) :Interactor(type, dataNode), m_N(n), m_Precision(PRECISION) { + if (m_N==0) + { + MITK_WARN<<"Instanciation of PointSetInteractor which takes care of 0 points does't make sense!\n"; + MITK_WARN<<"Setting number of points to 1!\n"; + m_N = 1; + } + m_LastPoint.Fill(0); m_SumVec.Fill(0); + this->InitAccordingToNumberOfPoints(); } mitk::PointSetInteractor::~PointSetInteractor() @@ -793,23 +801,35 @@ case AcCHECKEQUALS1: { - //the number of points in the list is 1 (or smaler) + //the number of points in the list is 1 (or smaler), so will be empty after delete if (pointSet->GetSize( m_TimeStep ) <= 1) { mitk::StateEvent* newStateEvent = - new mitk::StateEvent(EIDYES, stateEvent->GetEvent()); + new mitk::StateEvent(EIDEMPTY, stateEvent->GetEvent()); this->HandleEvent( newStateEvent ); delete newStateEvent; ok = true; } - else //more than 1 points in list, so stay in the state! + else if (pointSet->GetSize( m_TimeStep ) <= m_N || m_N <= -1) + //m_N is set to unlimited points allowed or more than 1 points in list, but not full, so stay in the state! { mitk::StateEvent* newStateEvent = - new mitk::StateEvent(EIDNO, stateEvent->GetEvent()); + new mitk::StateEvent(EIDSMALLERN, stateEvent->GetEvent()); this->HandleEvent(newStateEvent ); delete newStateEvent; ok = true; } + else + //pointSet->GetSize( m_TimeStep ) >=m_N. + // This can happen if the points were not added + // by interaction but by loading a .mps file + { + mitk::StateEvent* newStateEvent = + new mitk::StateEvent(EIDEQUALSN, stateEvent->GetEvent()); + this->HandleEvent(newStateEvent ); + delete newStateEvent; + ok = true; + } } break; @@ -1050,3 +1070,39 @@ this->ResetStatemachineToStartState(timeStep); } + +void mitk::PointSetInteractor::InitAccordingToNumberOfPoints() +{ + 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 (numberOfPointsHandleEvent( newStateEvent ); + delete newStateEvent; + delete nullEvent; + } + else if (numberOfPoints>=m_N) + { + if (numberOfPoints>m_N) + { + MITK_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(EIDLARGERN, nullEvent); + this->HandleEvent( newStateEvent ); + delete newStateEvent; + delete nullEvent; + } + } + return; +} Index: mitk/Core/Code/Interactions/mitkPointSetInteractor.h =================================================================== --- mitk/Core/Code/Interactions/mitkPointSetInteractor.h (revision 25504) +++ mitk/Core/Code/Interactions/mitkPointSetInteractor.h (working copy) @@ -31,6 +31,14 @@ * \brief Interaction with a set of points. * * Points can be added, removed and moved. + * In case the interaction shall be done on a + * loaded set of points, the associated data + * object (mitkPointSet) needs to be loaded + * prior to the instanciation of this object. + * The number of points are checked and the internal + * statemachine set to the apropriate state. + * The management of 0 points is not supported. + * In this case, the amount of managed points is set to 1. * \ingroup Interaction */ class MITK_CORE_EXPORT PointSetInteractor : public Interactor @@ -62,7 +70,8 @@ /** * \brief Constructor with Param n for limited Set of Points * - * if no n is set, then the number of points is unlimited* + * If no n is set, then the number of points is unlimited + * n=0 is not supported. In this case, n is set to 1. */ PointSetInteractor(const char * type, DataNode* dataNode, int n = -1); @@ -104,6 +113,11 @@ /** \brief to store the value of precision to pick a point */ unsigned int m_Precision; + + /** + * @brief Init the StatateMachine according to the current number of points in case of a loaded pointset. + **/ + void InitAccordingToNumberOfPoints(); }; } #endif /* MITKPOINTSETINTERACTOR_H_HEADER_INCLUDED_C11202FF */ Index: mitk/Core/Code/Interactions/StateMachine.xml =================================================================== --- mitk/Core/Code/Interactions/StateMachine.xml (revision 25504) +++ mitk/Core/Code/Interactions/StateMachine.xml (working copy) @@ -154,12 +154,15 @@ - + - + + + + @@ -1964,7 +1967,9 @@ - + + + @@ -2116,11 +2121,14 @@ - + - + + + + @@ -2146,7 +2154,9 @@ - + + + @@ -2242,11 +2252,14 @@ - + - + + + + Index: mitk/CoreUI/Bundles/org.mitk.gui.qt.common/resources/mitkEventAndActionConstants.xml =================================================================== --- mitk/CoreUI/Bundles/org.mitk.gui.qt.common/resources/mitkEventAndActionConstants.xml (revision 25504) +++ mitk/CoreUI/Bundles/org.mitk.gui.qt.common/resources/mitkEventAndActionConstants.xml (working copy) @@ -60,10 +60,10 @@ - - - - + + + + Index: mitk/CoreUI/Bundles/org.mitk.gui.qt.common/resources/StateMachine.xml =================================================================== --- mitk/CoreUI/Bundles/org.mitk.gui.qt.common/resources/StateMachine.xml (revision 25504) +++ mitk/CoreUI/Bundles/org.mitk.gui.qt.common/resources/StateMachine.xml (working copy) @@ -159,7 +159,10 @@ - + + + + @@ -1964,7 +1967,9 @@ - + + + @@ -2116,11 +2121,14 @@ - + - + + + + @@ -2146,7 +2154,9 @@ - + + + @@ -2242,11 +2252,14 @@ - + - + + + + Index: mitk/Modules/MitkExt/Interactions/mitkEventAndActionConstants.xml =================================================================== --- mitk/Modules/MitkExt/Interactions/mitkEventAndActionConstants.xml (revision 25504) +++ mitk/Modules/MitkExt/Interactions/mitkEventAndActionConstants.xml (working copy) @@ -31,8 +31,8 @@ - - + + @@ -56,10 +56,10 @@ - - - - + + + + @@ -81,6 +81,9 @@ + + +