Page MenuHomePhabricator

Patch4836_PointSetInteraction.patch

Authored By
wegner
Aug 17 2010, 11:26 AM
Size
18 KB
Referenced Files
None
Subscribers
None

Patch4836_PointSetInteraction.patch

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<mitk::PointSet*>(m_DataNode->GetData());
+ if ( pointSet != NULL )
+ {
+ int numberOfPoints = pointSet->GetSize( m_TimeStep );
+ if (numberOfPoints == 0)
+ return; //pointset is empty
+ else if (numberOfPoints<m_N)
+ {
+ //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)
+ {
+ 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 @@
<event NAME="StSMALERNMINUS1 " ID="1010" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />
<event NAME="StLARGERNMINUS1" ID="1011" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />
<!-- -->
- <event NAME="ActivateTool" ID="1300" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />
+ <event NAME="ActivateTool" ID="1300" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />
<!-- -->
<!-- Sonstiges -->
<event NAME="PositionEvent" ID="1012" TYPE="Type_MouseButtonPress" BUTTON="BS_LeftButton" BUTTONSTATE="0x0000" KEY="Key_none" />
<!-- DoubleClick <event NAME="PositionEvent" ID="510" TYPE="4" BUTTON="0x0001" BUTTONSTATE="0x0000" KEY="0xffff" />-->
- <!-- for external thrown Events-->
+ <!--<event NAME="StSmallerN" ID="1014" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />-->
+ <!--<event NAME="StEqualsN" ID="1015" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />-->
+ <!--<event NAME="StLargerN" ID="1016" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />-->
+ <!-- for external thrown Events-->
<event NAME="clear" ID="1100" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />
<!-- Puncture Application -->
<event NAME="print" ID="3001" TYPE="Type_Application" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />
@@ -1964,7 +1967,9 @@
<stateMachine NAME="pointsetinteractor">
<!-- Behaviour of a set of Points. a defined number of points can be set/removed/selected/deselectd/moved -->
<state NAME="no points or loaded points" ID="1" START_STATE="TRUE" X_POS="1066" Y_POS="281" WIDTH="100" HEIGHT="50">
- <transition NAME="addPoint but check n" NEXT_STATE_ID="3" EVENT_ID="3">
+ <transition NAME="0<PointsLoaded<N" NEXT_STATE_ID="2" EVENT_ID="1015" /> <!-- If points have been loaded, goto right state; checked in constructor -->
+ <transition NAME="PointsLoaded=>N" NEXT_STATE_ID="4" EVENT_ID="1016" /> <!-- If points have been loaded, goto right state; checked in constructor -->
+ <transition NAME="addPoint but check n" NEXT_STATE_ID="3" EVENT_ID="3">
<action ID="1101">
<!--AcMODE_SELECT-->
</action>
@@ -2116,11 +2121,14 @@
</transition>
</state>
<state NAME="checkn Delete" ID="30" X_POS="1124" Y_POS="708" WIDTH="100" HEIGHT="50">
- <transition NAME="StNo" NEXT_STATE_ID="2" EVENT_ID="1003">
+ <transition NAME="StillFull" NEXT_STATE_ID="4" EVENT_ID="1015">
<action ID="100" />
</transition>
- <transition NAME="StYes" NEXT_STATE_ID="1" EVENT_ID="1004">
+ <transition NAME="NotEmptyNotFull" NEXT_STATE_ID="2" EVENT_ID="1014">
<action ID="100" />
+ </transition>
+ <transition NAME="WillBeEmpty" NEXT_STATE_ID="1" EVENT_ID="1017">
+ <action ID="100" />
<action ID="1100">
<!--AcMODEDESELECT-->
</action>
@@ -2146,7 +2154,9 @@
<stateMachine NAME="seedpointsetinteractor">
<!-- Behaviour of a Point. -->
<state NAME="no points or loaded points" ID="1" START_STATE="TRUE" X_POS="59" Y_POS="45" WIDTH="169" HEIGHT="50">
- <transition NAME="addPoint but check n" NEXT_STATE_ID="3" EVENT_ID="5">
+ <transition NAME="0SmallerPointsLoadedSmallerN" NEXT_STATE_ID="2" EVENT_ID="1015" /> <!-- If point has been loaded, goto right state; checked in constructor -->
+ <transition NAME="PointsLoadedGreaterEqualsN" NEXT_STATE_ID="4" EVENT_ID="1016" /> <!-- If point has been loaded, goto right state; checked in constructor -->
+ <transition NAME="addPoint but check n" NEXT_STATE_ID="3" EVENT_ID="5">
<action ID="1101">
<!--AcMODESELECT-->
</action>
@@ -2242,11 +2252,14 @@
</transition>
</state>
<state NAME="checkn Delete" ID="30" X_POS="1151" Y_POS="19" WIDTH="100" HEIGHT="50">
- <transition NAME="StNo" NEXT_STATE_ID="2" EVENT_ID="1003">
+ <transition NAME="StillFull" NEXT_STATE_ID="4" EVENT_ID="1015">
<action ID="100" />
</transition>
- <transition NAME="StYes" NEXT_STATE_ID="1" EVENT_ID="1004">
+ <transition NAME="NotEmptyNotFull" NEXT_STATE_ID="2" EVENT_ID="1014">
<action ID="100" />
+ </transition>
+ <transition NAME="WillBeEmpty" NEXT_STATE_ID="1" EVENT_ID="1017">
+ <action ID="100" />
<action ID="1100">
<!--AcMODEDESELECT-->
</action>
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 @@
<event NAME="EIDE" ID="19" />
<event NAME="EIDSTRGANDALTANDA" ID="20" />
<event NAME="EIDSTRGANDALTANDB" ID="21" />
- <event NAME="H" ID="22" />
- <event NAME="Return" ID="23" />
- <event NAME="Enter" ID="24" />
- <event NAME="Space" ID="25" />
+ <event NAME="EIDH" ID="22" />
+ <event NAME="EIDRETURN" ID="23" />
+ <event NAME="EIDENTER" ID="24" />
+ <event NAME="EIDSPACE" ID="25" />
<event NAME="EIDSTRGANDALTANDH" ID="30" />
<event NAME="EIDSTRGANDALTANDI" ID="31" />
<event NAME="EIDSTRGANDALTANDS" ID="40" />
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 @@
<!-- Sonstiges -->
<event NAME="PositionEvent" ID="1012" TYPE="Type_MouseButtonPress" BUTTON="BS_LeftButton" BUTTONSTATE="0x0000" KEY="Key_none" />
<!-- DoubleClick <event NAME="PositionEvent" ID="510" TYPE="4" BUTTON="0x0001" BUTTONSTATE="0x0000" KEY="0xffff" />-->
- <!-- for external thrown Events-->
+ <!--<event NAME="StSmallerN" ID="1014" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />-->
+ <!--<event NAME="StEqualsN" ID="1015" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />-->
+ <!--<event NAME="StLargerN" ID="1016" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />-->
+ <!-- for external thrown Events-->
<event NAME="clear" ID="1100" TYPE="Type_User" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />
<!-- Puncture Application -->
<event NAME="print" ID="3001" TYPE="Type_Application" BUTTON="BS_NoButton" BUTTONSTATE="0x0000" KEY="Key_none" />
@@ -1964,7 +1967,9 @@
<stateMachine NAME="pointsetinteractor">
<!-- Behaviour of a set of Points. a defined number of points can be set/removed/selected/deselectd/moved -->
<state NAME="no points or loaded points" ID="1" START_STATE="TRUE" X_POS="1066" Y_POS="281" WIDTH="100" HEIGHT="50">
- <transition NAME="addPoint but check n" NEXT_STATE_ID="3" EVENT_ID="3">
+ <transition NAME="0SmallerPointsLoadedSmallerN" NEXT_STATE_ID="2" EVENT_ID="1015" /> <!-- If points have been loaded, goto right state; checked in constructor -->
+ <transition NAME="PointsLoadedGreaterEqualsN" NEXT_STATE_ID="4" EVENT_ID="1016" /> <!-- If points have been loaded, goto right state; checked in constructor -->
+ <transition NAME="addPoint but check n" NEXT_STATE_ID="3" EVENT_ID="3">
<action ID="1101">
<!--AcMODE_SELECT-->
</action>
@@ -2116,11 +2121,14 @@
</transition>
</state>
<state NAME="checkn Delete" ID="30" X_POS="1124" Y_POS="708" WIDTH="100" HEIGHT="50">
- <transition NAME="StNo" NEXT_STATE_ID="2" EVENT_ID="1003">
+ <transition NAME="StillFull" NEXT_STATE_ID="4" EVENT_ID="1015">
<action ID="100" />
</transition>
- <transition NAME="StYes" NEXT_STATE_ID="1" EVENT_ID="1004">
+ <transition NAME="NotEmptyNotFull" NEXT_STATE_ID="2" EVENT_ID="1014">
<action ID="100" />
+ </transition>
+ <transition NAME="WillBeEmpty" NEXT_STATE_ID="1" EVENT_ID="1017">
+ <action ID="100" />
<action ID="1100">
<!--AcMODEDESELECT-->
</action>
@@ -2146,7 +2154,9 @@
<stateMachine NAME="seedpointsetinteractor">
<!-- Behaviour of a Point. -->
<state NAME="no points or loaded points" ID="1" START_STATE="TRUE" X_POS="59" Y_POS="45" WIDTH="169" HEIGHT="50">
- <transition NAME="addPoint but check n" NEXT_STATE_ID="3" EVENT_ID="5">
+ <transition NAME="0SmallerPointsLoadedSmallerN" NEXT_STATE_ID="2" EVENT_ID="1015" /> <!-- If point has been loaded, goto right state; checked in constructor -->
+ <transition NAME="PointsLoadedGreaterEqualsN" NEXT_STATE_ID="4" EVENT_ID="1016" /> <!-- If point has been loaded, goto right state; checked in constructor -->
+ <transition NAME="addPoint but check n" NEXT_STATE_ID="3" EVENT_ID="5">
<action ID="1101">
<!--AcMODESELECT-->
</action>
@@ -2242,11 +2252,14 @@
</transition>
</state>
<state NAME="checkn Delete" ID="30" X_POS="1151" Y_POS="19" WIDTH="100" HEIGHT="50">
- <transition NAME="StNo" NEXT_STATE_ID="2" EVENT_ID="1003">
+ <transition NAME="StillFull" NEXT_STATE_ID="4" EVENT_ID="1015">
<action ID="100" />
</transition>
- <transition NAME="StYes" NEXT_STATE_ID="1" EVENT_ID="1004">
+ <transition NAME="NotEmptyNotFull" NEXT_STATE_ID="2" EVENT_ID="1014">
<action ID="100" />
+ </transition>
+ <transition NAME="WillBeEmpty" NEXT_STATE_ID="1" EVENT_ID="1017">
+ <action ID="100" />
<action ID="1100">
<!--AcMODEDESELECT-->
</action>
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 @@
<event NAME="EIDCTRLANDMIDDLEMOUSEBTNRELEASE" ID="539" />
<event NAME="EIDSHIFTANDCTRLANDMIDDLEMOUSEBTN" ID="540" />
<event NAME="EIDSHIFTANDLEFTMOUSEBTNANDMOUSEMOVE" ID="541" />
- <event NAME="SHIFTANDCTRLANDMOUSEMOVE" ID="542" />
- <event NAME="SHIFTANDCTRLANDMOUSERELEASE" ID="543" />
+ <event NAME="EIDSHIFTANDCTRLANDMOUSEMOVE" ID="542" />
+ <event NAME="EIDSHIFTANDCTRLANDMOUSERELEASE" ID="543" />
<event NAME="EIDALTANDLEFTMOUSEBTN" ID="600" />
<event NAME="EIDALTANDLEFTMOUSEBTNANDMOUSEMOVE" ID="610" />
<event NAME="EIDALTANDLEFTMOUSERELEASE" ID="620" />
@@ -56,10 +56,10 @@
<event NAME="EIDE" ID="19" />
<event NAME="EIDSTRGANDALTANDA" ID="20" />
<event NAME="EIDSTRGANDALTANDB" ID="21" />
- <event NAME="H" ID="22" />
- <event NAME="Return" ID="23" />
- <event NAME="Enter" ID="24" />
- <event NAME="Space" ID="25" />
+ <event NAME="EIDH" ID="22" />
+ <event NAME="EIDRETURN" ID="23" />
+ <event NAME="EIDENTER" ID="24" />
+ <event NAME="EIDSPACE" ID="25" />
<event NAME="EIDSTRGANDALTANDH" ID="30" />
<event NAME="EIDSTRGANDALTANDI" ID="31" />
<event NAME="EIDSTRGANDALTANDS" ID="40" />
@@ -81,6 +81,9 @@
<event NAME="EIDSTLARGERNMINUS1" ID="1011" />
<event NAME="EIDPOSITIONEVENT" ID="1012" />
<event NAME="EIDEDIT" ID="1013" />
+ <event NAME="EIDSMALLERN" ID="1014" />
+ <event NAME="EIDEQUALSN" ID="1015" />
+ <event NAME="EIDLARGERN" ID="1016" />
<event NAME="EIDSUBDESELECT" ID="1020" />
<event NAME="EIDSMTOSELECTED" ID="1030" />
<event NAME="EIDSMTODESELECTED" ID="1031" />

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
548
Default Alt Text
Patch4836_PointSetInteraction.patch (18 KB)

Event Timeline

patch containing initial changes