From dc68499f503c4a3b9261f35b9b179a6c8f394f76 Mon Sep 17 00:00:00 2001 From: enk Date: Thu, 8 Sep 2005 10:58:22 +0000 Subject: [PATCH] fix for Bug IPAL9442 3.0.0: It is impossible to select vertices in needed order added new field to BasicGUI_CurveDlg class - myOrderedSel, which keeping for ordered selection from object browser --- src/BasicGUI/BasicGUI_CurveDlg.cxx | 85 ++++++++++++++++++++++++++---- src/BasicGUI/BasicGUI_CurveDlg.h | 2 + 2 files changed, 78 insertions(+), 9 deletions(-) diff --git a/src/BasicGUI/BasicGUI_CurveDlg.cxx b/src/BasicGUI/BasicGUI_CurveDlg.cxx index e5c92ee2e..598c5f47b 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.cxx +++ b/src/BasicGUI/BasicGUI_CurveDlg.cxx @@ -42,6 +42,7 @@ #include "GEOMImpl_Types.hxx" using namespace std; +#include //================================================================================= // class : BasicGUI_CurveDlg() @@ -198,6 +199,54 @@ void BasicGUI_CurveDlg::ClickOnCancel() GEOMBase_Skeleton::ClickOnCancel(); } +//================================================================================= +/*! function : isPointInList() + * purpose : Check is point (theObject) in the list \a thePoints. + * \author enk + * \retval -1, if point not in list, else 1 in list + */ +//================================================================================= +static int isPointInList(list& thePoints, + GEOM::GEOM_Object_var& theObject) +{ + int len = thePoints.size(); + + if(len<1){ + return -1; + } + + for(list::iterator i=thePoints.begin();i!=thePoints.end();i++) + if (string((*i)->GetEntry()) == string(theObject->GetEntry())){ + return 1; + } + + return -1; +} +//================================================================================= +/*! function : removeUnnecessaryPnt() + * purpose : Remove unnecessary point from list \a theOldPoints + * \author enk + * \li \a theOldPoints - ordered sequence with unnecessary point + * \li \a theNewPoints - not ordered sequence with necessary points + */ +//================================================================================= +static void removeUnnecessaryPnt(list& theOldPoints, + GEOM::ListOfGO_var& theNewPoints) +{ + for(list::iterator i=theOldPoints.begin();i!=theOldPoints.end();i++){ + bool found = false; + for (int j=0;jlength() && !found ; j++){ + if(string((*i)->GetEntry()) == string(theNewPoints[j]->GetEntry())){ + found = true; + } + } + if(!found){ + theOldPoints.remove(*i); + return; + } + } +} + //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case @@ -208,19 +257,37 @@ void BasicGUI_CurveDlg::SelectionIntoArgument() Standard_Boolean aRes = Standard_False; int i = 0; - myPoints->length( IObjectCount() ); // this length may be greater than number of objects, - // that will actually be put into myPoints + int IOC = IObjectCount(); + bool is_append = myPoints->length() < IOC; // if true - add point, else remove + myPoints->length( IOC ); // this length may be greater than number of objects, + // that will actually be put into myPoints for ( SALOME_ListIteratorOfListIO anIt( selectedIO() ); anIt.More(); anIt.Next() ) - { - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) { - //TopoDS_Shape aPointShape; - //if ( myGeomBase->GetShape( aSelectedObject, aPointShape, TopAbs_VERTEX ) ) - myPoints[i++] = aSelectedObject; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + //TopoDS_Shape aPointShape; + //if ( myGeomBase->GetShape( aSelectedObject, aPointShape, TopAbs_VERTEX ) ) + int pos = isPointInList(myOrderedSel,aSelectedObject); + if(is_append && pos==-1) + myOrderedSel.push_back(aSelectedObject); + myPoints[i++] = aSelectedObject; + } } - } + myPoints->length( i ); // this is the right length, smaller of equal to the previously set + if(IOC == 0) + myOrderedSel.clear(); + else + removeUnnecessaryPnt(myOrderedSel,myPoints); + + if(myOrderedSel.size() == myPoints->length()){ + int k=0; + for (list::iterator j=myOrderedSel.begin();j!=myOrderedSel.end();j++) + myPoints[k++] = *j; + } else { + cout << "ERROR: Ordered sequence size != selection sequence size! ("<length()<<")"<LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) ); diff --git a/src/BasicGUI/BasicGUI_CurveDlg.h b/src/BasicGUI/BasicGUI_CurveDlg.h index 623d35570..c8a501251 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.h +++ b/src/BasicGUI/BasicGUI_CurveDlg.h @@ -32,6 +32,7 @@ #include "DlgRef_1Sel_QTD.h" #include "BasicGUI.h" +#include #if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS #define BASICGUI_WNT_EXPORT __declspec( dllexport ) #else @@ -67,6 +68,7 @@ private : DlgRef_1Sel_QTD* GroupPoints; GEOM::ListOfGO_var myPoints; + list myOrderedSel;//!< This list used for managing orderes selection private slots: void ClickOnOk(); -- 2.39.2