X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FRepairGUI%2FRepairGUI_DivideEdgeDlg.cxx;h=4e67a04b032f31a5afe60e818b7bcfe6d54c7847;hb=a3cc00537074b4477ecf5585ee51a5860ead8b9f;hp=e7016862167d6e5a1c468011ea443e1c9d885ea5;hpb=392885c1a8d50369708bbe5e6b44033ed8b8ba51;p=modules%2Fgeom.git diff --git a/src/RepairGUI/RepairGUI_DivideEdgeDlg.cxx b/src/RepairGUI/RepairGUI_DivideEdgeDlg.cxx index e70168621..4e67a04b0 100644 --- a/src/RepairGUI/RepairGUI_DivideEdgeDlg.cxx +++ b/src/RepairGUI/RepairGUI_DivideEdgeDlg.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,6 +19,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // GEOM GEOMGUI : GUI for Geometry component // File : RepairGUI_DivideEdgeDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. @@ -28,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -41,8 +42,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -84,7 +87,8 @@ RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg( GeometryGUI* theGeometryGUI, Q myIsParameterGr->addButton( rb2, 1 ); rb1->setChecked( true ); - myValEdt = new SalomeApp_DoubleSpinBox( 0., 1., 0.1, 3, 32, GroupPoints->Box ); + myValEdt = new SalomeApp_DoubleSpinBox( GroupPoints->Box ); + initSpinBox( myValEdt, 0., 1., 0.1, "parametric_precision" ); myValEdt->setValue( 0.5 ); QLabel* aLbl1 = new QLabel( tr( "GEOM_VALUE" ), GroupPoints->Box ); @@ -124,6 +128,7 @@ void RepairGUI_DivideEdgeDlg::Init() myEditCurrentArgument = GroupPoints->LineEdit1; myObject = GEOM::GEOM_Object::_nil(); + myIndex = -1; //myGeomGUI->SetState( 0 ); initSelection(); @@ -138,9 +143,11 @@ void RepairGUI_DivideEdgeDlg::Init() connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); initName( tr( "DEVIDE_EDGE_NEW_OBJECT_NAME" ) ); + resize(100,100); + SelectionIntoArgument(); } //================================================================================= @@ -158,25 +165,32 @@ void RepairGUI_DivideEdgeDlg::ValueChangedInSpinBox() //================================================================================= void RepairGUI_DivideEdgeDlg::displayPreview() { + erasePreview(); if ( myObject->_is_nil() ) return; TopoDS_Shape aShape; gp_Pnt aPnt; - if ( GEOMBase::GetShape( myObject, aShape, TopAbs_SHAPE ) ) { - if (aShape.ShapeType() == TopAbs_EDGE) { - Standard_Real aFP, aLP, aP; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aShape), aFP, aLP); - aP = aFP + (aLP - aFP) * myValEdt->value(); - aPnt = aCurve->Value(aP); - BRepBuilderAPI_MakeVertex mkVertex (aPnt); - aShape = mkVertex.Shape(); - // Build prs - SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aShape ); - if ( aPrs != 0 && !aPrs->IsNull() ) - GEOMBase_Helper::displayPreview( aPrs, false, true ); - } + GEOMBase::GetShape( myObject, aShape, TopAbs_SHAPE ); + + if ( myIndex != -1) { + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes(aShape, aShapes); + aShape = aShapes.FindKey(myIndex); } + + if (aShape.ShapeType() == TopAbs_EDGE) { + Standard_Real aFP, aLP, aP; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aShape), aFP, aLP); + aP = aFP + (aLP - aFP) * myValEdt->value(); + aPnt = aCurve->Value(aP); + BRepBuilderAPI_MakeVertex mkVertex (aPnt); + aShape = mkVertex.Shape(); + // Build prs + SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aShape ); + if ( aPrs != 0 && !aPrs->IsNull() ) + GEOMBase_Helper::displayPreview( aPrs, false, true ); + } } //================================================================================= @@ -203,6 +217,7 @@ bool RepairGUI_DivideEdgeDlg::ClickOnApply() myEditCurrentArgument->setText( "" ); myObject = GEOM::GEOM_Object::_nil(); + myIndex = -1; initSelection(); @@ -220,6 +235,7 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument() myEditCurrentArgument->setText( "" ); myObject = GEOM::GEOM_Object::_nil(); + myIndex = -1; LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); SALOME_ListIO aSelList; @@ -227,47 +243,45 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument() if ( aSelList.Extent() == 1 ) { Handle(SALOME_InteractiveObject) anIO = aSelList.First(); - Standard_Boolean aRes; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) { - QString aName = GEOMBase::GetName( aSelectedObject ); + GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO ); + if ( !CORBA::is_nil( aSelectedObj ) ) + { TopoDS_Shape aShape; - if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) ) { + QString aName = GEOMBase::GetName( aSelectedObj ); + if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) + { const int aType = aShape.ShapeType(); - if ( aType <= TopAbs_EDGE ) { - // edge, wire, face, shell, solid, compound + if ( aType <= TopAbs_EDGE ) // edge, wire, face, shell, solid, compound + { GEOM::short_array anIndexes; TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes( anIO, aMap ); - - if ( aMap.Extent() == 1 ) { // local selection - int anIndex = aMap( 1 ); - myEditCurrentArgument->setText( aName += QString( ":edge_%1" ).arg( anIndex ) ); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); - if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - myObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); - } - else { - myObject = aFindedObject; // get Object from study - } + SalomeApp_Application* anApp = + (SalomeApp_Application*)(SUIT_Session::session()->activeApplication()); + anApp->selectionMgr()->GetIndexes( anIO, aMap ); + + if ( !aMap.IsEmpty() ) // subshape selection + { + myIndex = aMap( 1 ); + myObject = aSelectedObj; + myEditCurrentArgument->setText( aName += QString( ":edge_%1" ).arg( myIndex ) ); } - else if ( aType == TopAbs_EDGE ) { - // single shape selection - myObject = aSelectedObject; + else if ( aType == TopAbs_EDGE ) // single shape selection + { + myIndex = -1; + myObject = aSelectedObj; myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); } - else { - // face, shell, solid or compound was selected, and NOT its subshape. + else // face, shell, solid or compound was selected, and NOT its subshape. + { + myIndex = -1; myObject = GEOM::GEOM_Object::_nil(); } } } } } + displayPreview(); } @@ -306,9 +320,10 @@ void RepairGUI_DivideEdgeDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); // myObject = GEOM::GEOM_Object::_nil(); + myIndex = -1; //myGeomGUI->SetState( 0 ); initSelection(); @@ -350,8 +365,8 @@ bool RepairGUI_DivideEdgeDlg::isValid( QString& msg ) //================================================================================= bool RepairGUI_DivideEdgeDlg::execute( ObjectList& objects ) { - GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->DivideEdge - ( myObject, -1, myValEdt->value(), getIsByParameter() ); + GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() ); + GEOM::GEOM_Object_var anObj = anOper->DivideEdge( myObject, myIndex, myValEdt->value(), getIsByParameter() ); bool aResult = !anObj->_is_nil(); if ( aResult ) { @@ -361,7 +376,7 @@ bool RepairGUI_DivideEdgeDlg::execute( ObjectList& objects ) aParameters << ""; aParameters << myValEdt->text(); aParameters << ""; - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } objects.push_back( anObj._retn() ); } @@ -387,15 +402,3 @@ void RepairGUI_DivideEdgeDlg::initSelection() GEOM::GEOM_Object_var aNullGeomObject; localSelection( aNullGeomObject, TopAbs_EDGE ); // load local selection on ALL objects } - -//================================================================================= -// function : addSubshapeToStudy -// purpose : virtual method to add new SubObjects if local selection -//================================================================================= -void RepairGUI_DivideEdgeDlg::addSubshapesToStudy() -{ - QMap objMap; - objMap[GroupPoints->LineEdit1->text()] = myObject; - - addSubshapesToFather( objMap ); -}