From: skv Date: Mon, 20 Oct 2014 11:06:23 +0000 (+0400) Subject: Implement GUI X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1355dedeb9aef3a6e1e15b8777097366c8677622;p=modules%2Fgeom.git Implement GUI --- diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 1fa4e9d9d..e3afdf6cb 100755 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -54,6 +54,7 @@ SET( _res_files build_edge_wire.png build_edge_curve.png build_face.png + build_face_surface.png build_shell.png build_solid.png build_wire.png diff --git a/resources/build_face_surface.png b/resources/build_face_surface.png new file mode 100644 index 000000000..328f5a944 Binary files /dev/null and b/resources/build_face_surface.png differ diff --git a/src/BuildGUI/BuildGUI_FaceDlg.cxx b/src/BuildGUI/BuildGUI_FaceDlg.cxx index bdd72265b..3420aa2af 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.cxx +++ b/src/BuildGUI/BuildGUI_FaceDlg.cxx @@ -49,18 +49,20 @@ // TRUE to construct a modal dialog. //================================================================================= BuildGUI_FaceDlg::BuildGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget* parent ) - : GEOMBase_Skeleton( theGeometryGUI, parent ) + : GEOMBase_Skeleton( theGeometryGUI, parent ), + GroupWire (0), + myGroupSurf (0) { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BUILD_FACE" ) ) ); - QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BUILD_FACE" ) ) ); + QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BUILD_FACE_SURFACE" ) ) ); setWindowTitle( tr( "GEOM_FACE_TITLE" ) ); /***************************************************************/ mainFrame()->GroupConstructors->setTitle( tr( "GEOM_FACE" ) ); - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); - mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton1->setIcon( image1 ); + mainFrame()->RadioButton2->setIcon( image2 ); mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->close(); @@ -69,11 +71,20 @@ BuildGUI_FaceDlg::BuildGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget* parent GroupWire->GroupBox1->setTitle( tr( "GEOM_FACE_FFW" ) ); GroupWire->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); GroupWire->CheckButton1->setText( tr( "GEOM_FACE_OPT" ) ); - GroupWire->PushButton1->setIcon( image1 ); + GroupWire->PushButton1->setIcon( image0 ); + + myGroupSurf = new DlgRef_2Sel(centralWidget()); + + myGroupSurf->GroupBox1->setTitle(tr("GEOM_FACE_FROM_SURFACE" ) ); + myGroupSurf->TextLabel1->setText(tr("GEOM_FACE")); + myGroupSurf->TextLabel2->setText(tr("GEOM_WIRE")); + myGroupSurf->PushButton1->setIcon(image0); + myGroupSurf->PushButton2->setIcon(image0); QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( GroupWire ); + layout->addWidget(myGroupSurf); /***************************************************************/ setHelpFileName("create_face_page.html"); @@ -102,27 +113,79 @@ void BuildGUI_FaceDlg::Init() /* init variables */ myEditCurrentArgument = GroupWire->LineEdit1; GroupWire->LineEdit1->setReadOnly( true ); + myGroupSurf->LineEdit1->setReadOnly( true ); + myGroupSurf->LineEdit2->setReadOnly( true ); GroupWire->CheckButton1->setChecked( true ); myWires.clear(); - - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_EDGE ); - aMap.Add( GEOM_WIRE ); - globalSelection( aMap ); + myFace.nullify(); + myWire.nullify(); /* signals and slots connections */ + connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + + connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); + connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect( GroupWire->LineEdit1, SIGNAL( returnPressed()), this, SLOT( LineEditReturnPressed() ) ); connect( GroupWire->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( myGroupSurf->LineEdit1, SIGNAL( returnPressed()), this, SLOT( LineEditReturnPressed() ) ); + connect( myGroupSurf->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( myGroupSurf->LineEdit2, SIGNAL( returnPressed()), this, SLOT( LineEditReturnPressed() ) ); + connect( myGroupSurf->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); initName( tr( "GEOM_FACE" ) ); - SelectionIntoArgument(); + + ConstructorsClicked(0); } +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BuildGUI_FaceDlg::ConstructorsClicked(int constructorId) +{ + switch (constructorId) { + case 0: + { + TColStd_MapOfInteger aMap; + + aMap.Add(GEOM_EDGE); + aMap.Add(GEOM_WIRE); + globalSelection(aMap); + + myEditCurrentArgument = GroupWire->LineEdit1; + GroupWire->LineEdit1->setText(""); + GroupWire->show(); + myGroupSurf->hide(); + break; + } + case 1: + { + globalSelection(GEOM_FACE); // For the first element. + + myEditCurrentArgument = myGroupSurf->LineEdit1; + myGroupSurf->LineEdit1->setText(""); + myGroupSurf->PushButton1->setDown(true); + myGroupSurf->PushButton2->setDown(false); + GroupWire->hide(); + myGroupSurf->show(); + break; + } + } + + myWires.clear(); + myFace.nullify(); + myWire.nullify(); + qApp->processEvents(); + updateGeometry(); + resize(minimumSizeHint()); + SelectionIntoArgument(); +} //================================================================================= // function : ClickOnOk() @@ -156,16 +219,44 @@ bool BuildGUI_FaceDlg::ClickOnApply() //================================================================================= void BuildGUI_FaceDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText( "" ); + if (myEditCurrentArgument == GroupWire->LineEdit1) { + myEditCurrentArgument->setText( "" ); + + QList types; + types << TopAbs_EDGE << TopAbs_WIRE; + myWires = getSelected( types, -1 ); - QList types; - types << TopAbs_EDGE << TopAbs_WIRE; - myWires = getSelected( types, -1 ); + if ( !myWires.isEmpty() ) { + QString aName = myWires.count() > 1 ? QString( "%1_objects").arg( myWires.count() ) : GEOMBase::GetName( myWires[0].get() ); + myEditCurrentArgument->setText( aName ); + } + } else if (myEditCurrentArgument == myGroupSurf->LineEdit1 || + myEditCurrentArgument == myGroupSurf->LineEdit2) { + const bool isEditFace = myEditCurrentArgument == myGroupSurf->LineEdit1; + const TopAbs_ShapeEnum aType = isEditFace ? TopAbs_FACE : TopAbs_WIRE; + GEOM::GeomObjPtr aSelectedObject = getSelected(aType); + GEOM::GeomObjPtr &anObj = isEditFace ? myFace : myWire; + + if (aSelectedObject) { + myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject.get())); + anObj = aSelectedObject; + } else { + myEditCurrentArgument->setText(""); + anObj.nullify(); + } - if ( !myWires.isEmpty() ) { - QString aName = myWires.count() > 1 ? QString( "%1_objects").arg( myWires.count() ) : GEOMBase::GetName( myWires[0].get() ); - myEditCurrentArgument->setText( aName ); + if (isEditFace) { + if (myFace && !myWire) { + myGroupSurf->PushButton2->click(); + } + } else { + if (!myFace && myWire) { + myGroupSurf->PushButton1->click(); + } + } } + + displayPreview(true); } @@ -176,18 +267,33 @@ void BuildGUI_FaceDlg::SelectionIntoArgument() void BuildGUI_FaceDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if ( send != GroupWire->PushButton1 ) - return; - - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_EDGE ); - aMap.Add( GEOM_WIRE ); - globalSelection( aMap ); - myEditCurrentArgument = GroupWire->LineEdit1; + if (send == GroupWire->PushButton1) { + TColStd_MapOfInteger aMap; + + aMap.Add(GEOM_EDGE); + aMap.Add(GEOM_WIRE); + globalSelection(aMap); + myEditCurrentArgument = GroupWire->LineEdit1; + } + else if (send == myGroupSurf->PushButton1) { + globalSelection(GEOM_FACE); + myEditCurrentArgument = myGroupSurf->LineEdit1; + myGroupSurf->PushButton2->setDown(false); + myGroupSurf->LineEdit2->setEnabled(false); + } + else if (send == myGroupSurf->PushButton2) { + globalSelection(GEOM_WIRE); + myEditCurrentArgument = myGroupSurf->LineEdit2; + myGroupSurf->PushButton1->setDown(false); + myGroupSurf->LineEdit1->setEnabled(false); + } + // enable line edit + myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setFocus(); - SelectionIntoArgument(); + send->setDown(true); + displayPreview(true); } @@ -198,12 +304,11 @@ void BuildGUI_FaceDlg::SetEditCurrentArgument() void BuildGUI_FaceDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_EDGE ); - aMap.Add( GEOM_WIRE ); - globalSelection( aMap ); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + ConstructorsClicked(getConstructorId()); } @@ -232,7 +337,20 @@ GEOM::GEOM_IOperations_ptr BuildGUI_FaceDlg::createOperation() //================================================================================= bool BuildGUI_FaceDlg::isValid( QString& ) { - return !myWires.isEmpty(); + bool ok = false; + + switch (getConstructorId()) { + case 0: + ok = !myWires.isEmpty(); + break; + case 1: + ok = myFace && myWire; + break; + default: + break; + } + + return ok; } //================================================================================= @@ -241,14 +359,32 @@ bool BuildGUI_FaceDlg::isValid( QString& ) //================================================================================= bool BuildGUI_FaceDlg::execute( ObjectList& objects ) { + bool res = false; GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); + GEOM::GEOM_Object_var anObj; - GEOM::ListOfGO_var objlist = new GEOM::ListOfGO(); - objlist->length( myWires.count() ); - for ( int i = 0; i < myWires.count(); i++ ) - objlist[i] = myWires[i].copy(); + switch (getConstructorId()) { + case 0: + { + GEOM::ListOfGO_var objlist = new GEOM::ListOfGO(); + + objlist->length( myWires.count() ); - GEOM::GEOM_Object_var anObj = anOper->MakeFaceWires( objlist.in(), GroupWire->CheckButton1->isChecked() ); + for ( int i = 0; i < myWires.count(); i++ ) { + objlist[i] = myWires[i].copy(); + } + + anObj = anOper->MakeFaceWires( objlist.in(), GroupWire->CheckButton1->isChecked() ); + res = true; + } + break; + case 1: + anObj = anOper->MakeFaceFromSurface(myFace.get(), myWire.get()); + res = true; + break; + default: + break; + } if (!anObj->_is_nil()) { objects.push_back(anObj._retn()); @@ -262,5 +398,5 @@ bool BuildGUI_FaceDlg::execute( ObjectList& objects ) } } - return true; + return res; } diff --git a/src/BuildGUI/BuildGUI_FaceDlg.h b/src/BuildGUI/BuildGUI_FaceDlg.h index d0e667072..570961c4c 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.h +++ b/src/BuildGUI/BuildGUI_FaceDlg.h @@ -31,6 +31,7 @@ #include "GEOM_GenericObjPtr.h" class DlgRef_1Sel1Check; +class DlgRef_2Sel; //================================================================================= // class : BuildGUI_FaceDlg @@ -56,10 +57,14 @@ private: private: QList myWires; + GEOM::GeomObjPtr myFace; + GEOM::GeomObjPtr myWire; DlgRef_1Sel1Check* GroupWire; + DlgRef_2Sel *myGroupSurf; private slots: + void ConstructorsClicked (int); void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 115e51e67..900d965ad 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -159,6 +159,10 @@ ICON_DLG_BUILD_FACE build_face.png + + ICON_DLG_BUILD_FACE_SURFACE + build_face_surface.png + ICON_DLG_FACE_HW face_hw.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 5b5c8bb63..ff3ded107 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -691,6 +691,10 @@ Please, select face, shell or solid and try again GEOM_FACE_FFW Face creation from wires and/or edges + + GEOM_FACE_FROM_SURFACE + Face creation from surface bounded by wire + GEOM_FACE_OPT Try to create a planar face