X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBuildGUI%2FBuildGUI_WireDlg.cxx;h=a769ce1c1ea6d2b1cf35353607b4cf13c150c315;hb=8b1511ff6327ae63c450b10e49714d3c83577eda;hp=29f54f67138b360f67ad4b936cc27ec782d4d700;hpb=0b6826bc5f36b5420f41af1475e1a79371a25323;p=modules%2Fgeom.git diff --git a/src/BuildGUI/BuildGUI_WireDlg.cxx b/src/BuildGUI/BuildGUI_WireDlg.cxx index 29f54f671..a769ce1c1 100644 --- a/src/BuildGUI/BuildGUI_WireDlg.cxx +++ b/src/BuildGUI/BuildGUI_WireDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -19,10 +19,11 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // GEOM GEOMGUI : GUI for Geometry component // File : BuildGUI_WireDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. - +// #include "BuildGUI_WireDlg.h" #include @@ -35,8 +36,11 @@ #include #include #include +#include #include +#include +#include #include //================================================================================= @@ -62,8 +66,14 @@ BuildGUI_WireDlg::BuildGUI_WireDlg( GeometryGUI* theGeometryGUI, QWidget* parent mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->close(); - GroupArgs = new DlgRef_1Sel1Spin( centralWidget() ); + GroupType = new DlgRef_3Radio( centralWidget() ); + GroupType->GroupBox1->setTitle( tr( "GEOM_OBJECT_TYPE" ) ); + GroupType->RadioButton1->setText( tr( "GEOM_EDGE" ) ); + GroupType->RadioButton2->setText( tr( "GEOM_WIRE" ) ); + GroupType->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); + GroupType->RadioButton3->close(); + GroupArgs = new DlgRef_1Sel1Spin( centralWidget() ); GroupArgs->GroupBox1->setTitle( tr( "GEOM_WIRE_CONNECT" ) ); GroupArgs->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); GroupArgs->PushButton1->setIcon( image1 ); @@ -72,11 +82,12 @@ BuildGUI_WireDlg::BuildGUI_WireDlg( GeometryGUI* theGeometryGUI, QWidget* parent GroupArgs->TextLabel2->setText( tr( "GEOM_TOLERANCE" ) ); double SpecificStep = 0.0001; double prec = Precision::Confusion(); - initSpinBox(GroupArgs->SpinBox_DX, prec, MAX_NUMBER, SpecificStep, 9); + initSpinBox(GroupArgs->SpinBox_DX, prec, MAX_NUMBER, SpecificStep, "len_tol_precision" ); GroupArgs->SpinBox_DX->setValue(prec); QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); + layout->addWidget( GroupType ); layout->addWidget( GroupArgs ); /***************************************************************/ @@ -106,13 +117,11 @@ void BuildGUI_WireDlg::Init() /* init variables */ myEditCurrentArgument = GroupArgs->LineEdit1; GroupArgs->LineEdit1->setReadOnly( true ); + GroupType->RadioButton1->setChecked(true); myOkEdgesAndWires = false; - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_WIRE ); - aMap.Add( GEOM_EDGE ); - globalSelection( aMap ); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); /* signals and slots connections */ connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); @@ -120,8 +129,15 @@ void BuildGUI_WireDlg::Init() connect( GroupArgs->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + connect( GroupType->RadioButton1, SIGNAL( clicked() ), this, SLOT( TypeButtonClicked() ) ); + connect( GroupType->RadioButton2, SIGNAL( clicked() ), this, SLOT( TypeButtonClicked() ) ); + + connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); + connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); initName( tr( "GEOM_WIRE" ) ); + SelectionIntoArgument(); } @@ -142,13 +158,36 @@ void BuildGUI_WireDlg::ClickOnOk() //================================================================================= bool BuildGUI_WireDlg::ClickOnApply() { - if ( !onAccept() ) + if ( !onAccept() || !myOkEdgesAndWires ) return false; initName(); + TypeButtonClicked(); + myMapToStudy.clear(); + myEdgesAndWires.length(0); + myOkEdgesAndWires = false; + myEditCurrentArgument->setText( "" ); return true; } +//================================================================================= +// function : TypeBittonClicked() +// purpose : Radio button management +//================================================================================= +void BuildGUI_WireDlg::TypeButtonClicked() +{ + if ( GroupType->RadioButton1->isChecked() ) { + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + GroupArgs->TextLabel1->setText( tr( "GEOM_EDGE" ) ); + } + else if ( GroupType->RadioButton2->isChecked() ) { + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_WIRE ); + GroupArgs->TextLabel1->setText( tr( "GEOM_WIRE" ) ); + } + SelectionIntoArgument(); +} //================================================================================= // function : SelectionIntoArgument() @@ -166,14 +205,71 @@ void BuildGUI_WireDlg::SelectionIntoArgument() myOkEdgesAndWires = false; int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString); - if ( nbSel == 0 ) - return; - if ( nbSel != 1 ) - aString = tr( "%1_objects" ).arg( nbSel ); - - GEOMBase::ConvertListOfIOInListOfGO(aSelList, myEdgesAndWires); - if ( !myEdgesAndWires.length() ) + if ( nbSel == 0 ) { + myMapToStudy.clear(); return; + } + + TopAbs_ShapeEnum aNeedType = TopAbs_EDGE; + if (GroupType->RadioButton2->isChecked()) + aNeedType = TopAbs_WIRE; + + std::list aList; // subshapes list + TopoDS_Shape aShape; + Standard_Boolean aRes = Standard_False; + for (SALOME_ListIteratorOfListIO anIt (aSelList); anIt.More(); anIt.Next()) { + TColStd_IndexedMapOfInteger aMap; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes ); + if ( !CORBA::is_nil(aSelectedObject) && aRes && GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + aSelMgr->GetIndexes( anIt.Value(), aMap ); + + if ( aMap.Extent() > 0 ) { // local selection + for (int ind = 1; ind <= aMap.Extent(); ind++) { + aString = aSelectedObject->GetName(); + int anIndex = aMap(ind); + if ( aNeedType == TopAbs_EDGE ) + aString += QString( ":edge_%1" ).arg( anIndex ); + else + aString += QString( ":wire_%1" ).arg( anIndex ); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aString ); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); + aList.push_back( aShapesOp->GetSubShape( aSelectedObject, anIndex ) ); + myMapToStudy[aString] = aShapesOp->GetSubShape( aSelectedObject, anIndex ); + } + else { + aList.push_back( aFindedObject ); // get Object from study + } + } + } else { // global selection + if ( aShape.ShapeType() == aNeedType ) { + GEOMBase::ConvertListOfIOInListOfGO(aSelList, myEdgesAndWires); + } else { + aList.clear(); + myEdgesAndWires.length(0); + } + } + } + } + + // convert aList in listofgo + if ( aList.size() ) { + myEdgesAndWires.length( aList.size() ); + int k = 0; + for ( std::list::iterator j = aList.begin(); j != aList.end(); j++ ) + myEdgesAndWires[k++] = *j; + } + + if ( myEdgesAndWires.length() > 1 ) + aString = tr( "%1_objects" ).arg( myEdgesAndWires.length() ); + + if ( !myEdgesAndWires.length() ) { + aString = ""; + myMapToStudy.clear(); + } myEditCurrentArgument->setText( aString ); myOkEdgesAndWires = true; @@ -190,10 +286,7 @@ void BuildGUI_WireDlg::SetEditCurrentArgument() if ( send != GroupArgs->PushButton1 ) return; - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_WIRE ); - aMap.Add( GEOM_EDGE ); - globalSelection( aMap ); + TypeButtonClicked(); myEditCurrentArgument = GroupArgs->LineEdit1; myEditCurrentArgument->setFocus(); @@ -210,12 +303,18 @@ void BuildGUI_WireDlg::ActivateThisDialog() GEOMBase_Skeleton::ActivateThisDialog(); connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_WIRE ); - aMap.Add( GEOM_EDGE ); - globalSelection( aMap ); + + TypeButtonClicked(); } +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void BuildGUI_WireDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); +} //================================================================================= // function : enterEvent() @@ -260,3 +359,12 @@ bool BuildGUI_WireDlg::execute (ObjectList& objects) return true; } + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void BuildGUI_WireDlg::addSubshapesToStudy() +{ + addSubshapesToFather( myMapToStudy ); +}