X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPrimitiveGUI%2FPrimitiveGUI_FaceDlg.cxx;h=7395f7cb25ceea376b6f1b8e2e2113c494897cf2;hb=4df412f5db44d67db5ad624250c204b44b1ba217;hp=93a5036aa7965d57dcc6f144da3d5fbba36ec19d;hpb=917ced834c4338e094440a4af95c4534ad556040;p=modules%2Fgeom.git diff --git a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx index 93a5036aa..7395f7cb2 100755 --- a/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_FaceDlg.cxx @@ -1,28 +1,28 @@ -// GEOM GEOMGUI : GUI for Geometry component +// Copyright (C) 2007-2008 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 +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// GEOM GEOMGUI : GUI for Geometry component // File : PrimitiveGUI_FaceDlg.cxx // Author : Dmitry Matveitchev, OCN. // - #include "PrimitiveGUI_FaceDlg.h" #include @@ -53,16 +53,16 @@ PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget bool modal, Qt::WindowFlags fl ) : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FACE_VEC_HW" ) ) ); - QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); - QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FACE_HW" ) ) ); + QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_FACE_OBJ_HW"))); + QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_FACE_HW"))); setWindowTitle( tr( "GEOM_FACE_TITLE" ) ); /***************************************************************/ mainFrame()->GroupConstructors->setTitle( tr( "GEOM_FACE" ) ); - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setIcon( image2 ); + mainFrame()->RadioButton1->setIcon( image2 ); + mainFrame()->RadioButton2->setIcon( image0 ); mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->close(); @@ -74,12 +74,19 @@ PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget GroupPlane->PushButton1->setIcon( image1 ); GroupPlane->LineEdit1->setReadOnly( true ); + GroupType = new DlgRef_3Radio( centralWidget() ); + GroupType->GroupBox1->setTitle( tr( "GEOM_OBJECT_TYPE" ) ); + GroupType->RadioButton1->setText( tr( "GEOM_EDGE" ) ); + GroupType->RadioButton2->setText( tr( "GEOM_FACE" ) ); + GroupType->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); + GroupType->RadioButton3->close(); + GroupDimensions = new DlgRef_2Spin( centralWidget() ); GroupDimensions->GroupBox1->setTitle( tr( "GEOM_BOX_OBJ" ) ); GroupDimensions->TextLabel1->setText( tr( "GEOM_HEIGHT" ) ); GroupDimensions->TextLabel2->setText( tr( "GEOM_WIDTH" ) ); - GroupOrientation = new DlgRef_3Check( centralWidget() ); + GroupOrientation = new DlgRef_3Radio( centralWidget() ); GroupOrientation->GroupBox1->setTitle( tr( "GEOM_ORIENTATION" ) ); GroupOrientation->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) ); @@ -88,13 +95,14 @@ PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); + layout->addWidget( GroupType ); layout->addWidget( GroupPlane ); layout->addWidget( GroupDimensions ); layout->addWidget( GroupOrientation ); /***************************************************************/ - setHelpFileName( "create_face_page.html" ); + setHelpFileName( "create_squareface_page.html" ); Init(); } @@ -117,9 +125,11 @@ void PrimitiveGUI_FaceDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPlane->LineEdit1; + GroupType->RadioButton1->setChecked(true); myEdge = GEOM::GEOM_Object::_nil(); + myFace = GEOM::GEOM_Object::_nil(); globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + // localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); myOrientationType = 1; @@ -129,14 +139,14 @@ void PrimitiveGUI_FaceDlg::Init() double aDefaultSize = 100.0; /* min, max, step and decimals for spin boxes */ - initSpinBox( GroupPlane->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + initSpinBox( GroupPlane->SpinBox_DX, 0.00001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY GroupPlane->SpinBox_DX->setValue( aDefaultSize ); - initSpinBox( GroupPlane->SpinBox_DY, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + initSpinBox( GroupPlane->SpinBox_DY, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY GroupPlane->SpinBox_DY->setValue( aDefaultSize ); - initSpinBox( GroupDimensions->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + initSpinBox( GroupDimensions->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY GroupDimensions->SpinBox_DX->setValue( aDefaultSize ); - initSpinBox( GroupDimensions->SpinBox_DY, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY + initSpinBox( GroupDimensions->SpinBox_DY, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY GroupDimensions->SpinBox_DY->setValue( aDefaultSize ); @@ -162,6 +172,9 @@ void PrimitiveGUI_FaceDlg::Init() connect( GroupOrientation->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); connect( GroupOrientation->RadioButton3, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); + connect( GroupType->RadioButton1, SIGNAL( clicked() ), this, SLOT( TypeButtonClicked() ) ); + connect( GroupType->RadioButton2, SIGNAL( clicked() ), this, SLOT( TypeButtonClicked() ) ); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -204,6 +217,24 @@ void PrimitiveGUI_FaceDlg::RadioButtonClicked() displayPreview(); } +//================================================================================= +// function : TypeBittonClicked() +// purpose : Radio button management +//================================================================================= +void PrimitiveGUI_FaceDlg::TypeButtonClicked() +{ + if ( GroupType->RadioButton1->isChecked() ) { + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + GroupPlane->TextLabel1->setText( tr( "GEOM_EDGE" ) ); + } + else if ( GroupType->RadioButton2->isChecked() ) { + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); + GroupPlane->TextLabel1->setText( tr( "GEOM_FACE" ) ); + } +} + //================================================================================= // function : ClickOnOk() // purpose : @@ -237,37 +268,42 @@ bool PrimitiveGUI_FaceDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId ) { + erasePreview(); switch ( constructorId ) { case 0: + { + globalSelection(); // close local contexts, if any + GroupPlane->hide(); + GroupDimensions->show(); + GroupOrientation->show(); + GroupType->hide(); + GroupOrientation->RadioButton1->setChecked( true ); + myOrientationType = 1; + break; + } + case 1: { globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); - myEditCurrentArgument = GroupPlane->LineEdit1; myEditCurrentArgument->setText(""); myEdge = GEOM::GEOM_Object::_nil(); + myFace = GEOM::GEOM_Object::_nil(); + GroupType->RadioButton1->setChecked( true ); + TypeButtonClicked(); GroupDimensions->hide(); GroupOrientation->hide(); + GroupType->show(); GroupPlane->show(); break; } - case 1: - { - globalSelection(); // close local contexts, if any - GroupPlane->hide(); - GroupDimensions->show(); - GroupOrientation->show(); - GroupOrientation->RadioButton1->setChecked( true ); - myOrientationType = 1; - break; - } } qApp->processEvents(); updateGeometry(); resize( minimumSize() ); SelectionIntoArgument(); - displayPreview(); + //displayPreview(); } //================================================================================= @@ -276,32 +312,42 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId ) //================================================================================= void PrimitiveGUI_FaceDlg::SelectionIntoArgument() { - if (getConstructorId() != 0) { + if (getConstructorId() == 0) { displayPreview(); return; } myEditCurrentArgument->setText( "" ); - if ( IObjectCount() != 1 ) { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + if ( aSelList.Extent() != 1 ) { if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge = GEOM::GEOM_Object::_nil(); return; } // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); + TopAbs_ShapeEnum aNeedType = TopAbs_EDGE; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First(), aRes ); if ( !CORBA::is_nil( aSelectedObject ) && aRes ) { QString aName = GEOMBase::GetName( aSelectedObject ); TopoDS_Shape aShape; if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + if (GroupType->RadioButton2->isChecked()) + aNeedType = TopAbs_FACE; + TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes( firstIObject(), aMap ); + aSelMgr->GetIndexes( aSelList.First(), aMap ); if ( aMap.Extent() == 1 ) { // Local Selection int anIndex = aMap( 1 ); - aName += QString( ":edge_%1" ).arg( anIndex ); + if ( aNeedType == TopAbs_EDGE ) + aName += QString( ":edge_%1" ).arg( anIndex ); + else + aName += QString( ":face_%1" ).arg( anIndex ); //Find SubShape Object in Father GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); @@ -314,7 +360,7 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() aSelectedObject = aFindedObject; // get Object from study } else { // Global Selection - if ( aShape.ShapeType() != TopAbs_EDGE ) { + if ( aShape.ShapeType() != aNeedType ) { aSelectedObject = GEOM::GEOM_Object::_nil(); aName = ""; } @@ -322,7 +368,10 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument() } myEditCurrentArgument->setText( aName ); - if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge = aSelectedObject; + if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_EDGE ) + myEdge = aSelectedObject; + else if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_FACE ) + myFace = aSelectedObject; } displayPreview(); } @@ -339,7 +388,10 @@ void PrimitiveGUI_FaceDlg::SetEditCurrentArgument() globalSelection(); // close previous local contexts if ( send == GroupPlane->PushButton1 ) { myEditCurrentArgument = GroupPlane->LineEdit1; - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + if (GroupType->RadioButton1->isChecked()) + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); + else if (GroupType->RadioButton1->isChecked()) + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); } myEditCurrentArgument->setFocus(); @@ -409,9 +461,13 @@ bool PrimitiveGUI_FaceDlg::isValid( QString& msg ) { const int id = getConstructorId(); if ( id == 0 ) - return !myEdge->_is_nil(); - else if ( id == 1 ) return true; + else if ( id == 1 ) { + if (GroupType->RadioButton1->isChecked()) + return !myEdge->_is_nil(); + else if (GroupType->RadioButton2->isChecked()) + return !myFace->_is_nil(); + } return false; } @@ -419,23 +475,30 @@ bool PrimitiveGUI_FaceDlg::isValid( QString& msg ) // function : execute // purpose : //================================================================================= -bool PrimitiveGUI_FaceDlg::execute( ObjectList& objects ) +bool PrimitiveGUI_FaceDlg::execute (ObjectList& objects) { bool res = false; GEOM::GEOM_Object_var anObj; - switch ( getConstructorId() ) { - case 0 : - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceVecHW( myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value() ); + switch (getConstructorId()) { + case 0: + anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> + MakeFaceHW(GroupDimensions->SpinBox_DX->value(), + GroupDimensions->SpinBox_DY->value(), myOrientationType); res = true; break; - case 1 : - anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceHW( GroupDimensions->SpinBox_DX->value(), GroupDimensions->SpinBox_DY->value(), myOrientationType ); + case 1: + if (GroupType->RadioButton1->isChecked()) + anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> + MakeFaceObjHW(myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()); + else if (GroupType->RadioButton2->isChecked()) + anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> + MakeFaceObjHW(myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()); res = true; break; } - - if ( !anObj->_is_nil() ) - objects.push_back( anObj._retn() ); + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); return res; } @@ -448,8 +511,11 @@ void PrimitiveGUI_FaceDlg::addSubshapesToStudy() { QMap objMap; switch ( getConstructorId() ) { - case 0 : - objMap[GroupPlane->LineEdit1->text()] = myEdge; + case 1 : + if ( GroupType->RadioButton1->isChecked() ) + objMap[GroupPlane->LineEdit1->text()] = myEdge; + if ( GroupType->RadioButton2->isChecked() ) + objMap[GroupPlane->LineEdit1->text()] = myFace; break; } addSubshapesToFather( objMap );