X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FRepairGUI%2FRepairGUI_SewingDlg.cxx;h=c9e0095d589d74d2a638e45ef7f88158b630f966;hb=edc3389ff160fc98d843b33167125268072db3e8;hp=79e78405b2def5e23625bc7f19e52c7477bf207d;hpb=d3dd282390888d7dc091ba2c2ffe7923bd7458e6;p=modules%2Fgeom.git diff --git a/src/RepairGUI/RepairGUI_SewingDlg.cxx b/src/RepairGUI/RepairGUI_SewingDlg.cxx index 79e78405b..c9e0095d5 100644 --- a/src/RepairGUI/RepairGUI_SewingDlg.cxx +++ b/src/RepairGUI/RepairGUI_SewingDlg.cxx @@ -1,6 +1,6 @@ -// GEOM GEOMGUI : GUI for Geometry component +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 @@ -17,31 +17,33 @@ // 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// -// -// File : RepairGUI_SewingDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ -using namespace std; +// GEOM GEOMGUI : GUI for Geometry component +// File : RepairGUI_SewingDlg.cxx +// Author : Lucien PIGNOLONI, Open CASCADE S.A.S. +// #include "RepairGUI_SewingDlg.h" -#include "QAD_RightFrame.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "OCCViewer_Viewer3d.h" -#include "SALOME_ListIteratorOfListIO.hxx" +#include +#include +#include +#include -#include "GEOMImpl_Types.hxx" +#include +#include +#include +#include +#include + +#include #include +#include #define DEFAULT_TOLERANCE_VALUE 1e-07 - //================================================================================= // class : RepairGUI_SewingDlg() // purpose : Constructs a RepairGUI_SewingDlg which is a child of 'parent', with the @@ -49,42 +51,48 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -RepairGUI_SewingDlg::RepairGUI_SewingDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +RepairGUI_SewingDlg::RepairGUI_SewingDlg( GeometryGUI* theGeometryGUI, QWidget* parent, + bool modal ) + : GEOMBase_Skeleton( theGeometryGUI, parent, modal ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SEWING"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_SEWING" ) ) ); + QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_SEWING_TITLE")); + setWindowTitle( tr( "GEOM_SEWING_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_SEWING_TITLE")); - RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_SEWING")); - GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); - GroupPoints->PushButton1->setPixmap(image1); + mainFrame()->GroupConstructors->setTitle( tr( "GEOM_SEWING_TITLE" ) ); + mainFrame()->RadioButton1->setIcon( image0 ); + mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->RadioButton3->close(); + + GroupPoints = new DlgRef_1SelExt( centralWidget() ); + GroupPoints->GroupBox1->setTitle( tr( "GEOM_SEWING" ) ); + GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) ); + GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->LineEdit1->setReadOnly( true ); - Layout1->addWidget(GroupPoints, 2, 0); - - QGridLayout* aLay = new QGridLayout( 0, 2, 2, 0, 6, "aLay" ); - myTolEdt = new QAD_SpinBoxDbl( GroupPoints->GroupBox1, 0, 100, 1e-7, 10, 1e-10 ); + QGridLayout* aLay = new QGridLayout( GroupPoints->Box ); + aLay->setMargin( 0 ); aLay->setSpacing( 6 ); + myTolEdt = new SalomeApp_DoubleSpinBox( GroupPoints->Box ); + initSpinBox( myTolEdt, 0.0, 100.0, DEFAULT_TOLERANCE_VALUE, "len_tol_precision" ); myTolEdt->setValue( DEFAULT_TOLERANCE_VALUE ); - QLabel* aLbl1 = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints->GroupBox1 ); - myFreeBoundBtn = new QPushButton( tr( "GEOM_DETECT" ), GroupPoints->GroupBox1 ); - QLabel* aLbl2 = new QLabel( tr( "GEOM_FREE_BOUNDARIES" ), GroupPoints->GroupBox1 ); - aLay->addWidget( aLbl1, 0, 0 ); - aLay->addWidget( myTolEdt, 0, 1 ); - aLay->addWidget( aLbl2, 1, 0 ); - aLay->addWidget( myFreeBoundBtn, 1, 1 ); - - GroupPoints->getGroupBoxLayout()->addLayout( aLay, 3, 0 ); + QLabel* aLbl1 = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints->Box ); + myFreeBoundBtn = new QPushButton( tr( "GEOM_DETECT" ) + QString( " [%1]" ).arg( tr( "GEOM_FREE_BOUNDARIES" ) ), + GroupPoints->Box ); + aLay->addWidget( aLbl1, 0, 0 ); + aLay->addWidget( myTolEdt, 0, 1 ); + aLay->addWidget( myFreeBoundBtn, 1, 0, 1, 2 ); + + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); + layout->setMargin( 0 ); layout->setSpacing( 6 ); + layout->addWidget( GroupPoints ); /***************************************************************/ + setHelpFileName( "sewing_operation_page.html" ); + Init(); } @@ -109,28 +117,27 @@ void RepairGUI_SewingDlg::Init() myObject = GEOM::GEOM_Object::_nil(); - myGeomGUI->SetState( 0 ); + //myGeomGUI->SetState( 0 ); initSelection(); myClosed = -1; myOpen = -1; - + /* signals and slots connections */ - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect(myFreeBoundBtn, SIGNAL(clicked()), this, SLOT(onDetect())); + connect( myFreeBoundBtn, SIGNAL( clicked() ), this, SLOT( onDetect() ) ); initName( tr( "SEWING_NEW_OBJ_NAME" ) ); + resize(100,100); + SelectionIntoArgument(); } @@ -140,12 +147,11 @@ void RepairGUI_SewingDlg::Init() //================================================================================= void RepairGUI_SewingDlg::ClickOnOk() { + setIsApplyAndClose( true ); if ( ClickOnApply() ) ClickOnCancel(); } - - //================================================================================= // function : ClickOnApply() // purpose : @@ -153,11 +159,11 @@ void RepairGUI_SewingDlg::ClickOnOk() bool RepairGUI_SewingDlg::ClickOnApply() { if ( !onAccept() ) - return false; + return false; initName(); - GroupPoints->LineEdit1->setText(""); + GroupPoints->LineEdit1->setText( "" ); myObject = GEOM::GEOM_Object::_nil(); initSelection(); @@ -166,16 +172,6 @@ bool RepairGUI_SewingDlg::ClickOnApply() } -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void RepairGUI_SewingDlg::ClickOnCancel() -{ - GEOMBase_Skeleton::ClickOnCancel(); -} - - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection @@ -183,15 +179,17 @@ void RepairGUI_SewingDlg::ClickOnCancel() void RepairGUI_SewingDlg::SelectionIntoArgument() { erasePreview(); - myEditCurrentArgument->setText(""); + myEditCurrentArgument->setText( "" ); myObject = GEOM::GEOM_Object::_nil(); - if ( mySelection->IObjectCount() == 1 ) - { - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); - Standard_Boolean aRes; - myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); - if ( aRes ) + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + if ( aSelList.Extent() == 1 ) { + Handle(SALOME_InteractiveObject) anIO = aSelList.First(); + myObject = GEOMBase::ConvertIOinGEOMObject( anIO ); + if ( !CORBA::is_nil( myObject ) ) myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); } } @@ -203,8 +201,7 @@ void RepairGUI_SewingDlg::SelectionIntoArgument() void RepairGUI_SewingDlg::SetEditCurrentArgument() { const QObject* send = sender(); - if ( send == GroupPoints->PushButton1 ) - { + if ( send == GroupPoints->PushButton1 ) { myEditCurrentArgument->setFocus(); SelectionIntoArgument(); } @@ -218,25 +215,13 @@ void RepairGUI_SewingDlg::SetEditCurrentArgument() void RepairGUI_SewingDlg::LineEditReturnPressed() { const QObject* send = sender(); - if( send == GroupPoints->LineEdit1 ) - { + if( send == GroupPoints->LineEdit1 ) { myEditCurrentArgument = GroupPoints->LineEdit1; GEOMBase_Skeleton::LineEditReturnPressed(); } } -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void RepairGUI_SewingDlg::DeactivateActiveDialog() -{ - myGeomGUI->SetState( -1 ); - GEOMBase_Skeleton::DeactivateActiveDialog(); -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -244,15 +229,16 @@ void RepairGUI_SewingDlg::DeactivateActiveDialog() void RepairGUI_SewingDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - GroupPoints->LineEdit1->setText(""); + GroupPoints->LineEdit1->setText( "" ); myObject = GEOM::GEOM_Object::_nil(); myClosed = -1; myOpen = -1; - myGeomGUI->SetState( 0 ); + //myGeomGUI->SetState( 0 ); initSelection(); } @@ -261,23 +247,13 @@ void RepairGUI_SewingDlg::ActivateThisDialog() // function : enterEvent() // purpose : Mouse enter onto the dialog to activate it //================================================================================= -void RepairGUI_SewingDlg::enterEvent(QEvent* e) +void RepairGUI_SewingDlg::enterEvent( QEvent* ) { - if ( !GroupConstructors->isEnabled() ) + if ( !mainFrame()->GroupConstructors->isEnabled() ) ActivateThisDialog(); } -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void RepairGUI_SewingDlg::closeEvent(QCloseEvent* e) -{ - myGeomGUI->SetState( -1 ); - GEOMBase_Skeleton::closeEvent( e ); -} - //================================================================================= // function : createOperation // purpose : @@ -294,7 +270,8 @@ GEOM::GEOM_IOperations_ptr RepairGUI_SewingDlg::createOperation() bool RepairGUI_SewingDlg::isValid( QString& msg ) { myClosed = -1; - return !myObject->_is_nil() && ( IsPreview() || myTolEdt->value() > 0. ); + bool ok = myTolEdt->isValid( msg, !IsPreview() ); + return !myObject->_is_nil() && ( IsPreview() || myTolEdt->value() > 0. ) && ok; } //================================================================================= @@ -304,31 +281,38 @@ bool RepairGUI_SewingDlg::isValid( QString& msg ) bool RepairGUI_SewingDlg::execute( ObjectList& objects ) { bool aResult = false; - if ( IsPreview() ) // called from onDetect(): detect free boundary edges, highlight them (add to objects), display message dialog - { + GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() ); + + if ( IsPreview() ) { // called from onDetect(): detect free boundary edges, highlight them (add to objects), display message dialog GEOM::ListOfGO_var aClosed, anOpen; - aResult = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->GetFreeBoundary( myObject, aClosed, anOpen ); + aResult = anOper->GetFreeBoundary( myObject, aClosed, anOpen ); - if ( aResult ) - { + if ( aResult ) { myClosed = aClosed->length(); myOpen = anOpen->length(); int i; for ( i = 0; i < myClosed; i++ ) - objects.push_back( aClosed[i]._retn() ); + objects.push_back( aClosed[i]._retn() ); for ( i = 0; i < myOpen; i++ ) - objects.push_back( anOpen[i]._retn() ); + objects.push_back( anOpen[i]._retn() ); } else myClosed = -1; } - else - { - GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->Sew( myObject, myTolEdt->value() ); + else { + GEOM::GEOM_Object_var anObj = anOper->Sew( myObject, myTolEdt->value() ); aResult = !anObj->_is_nil(); if ( aResult ) + { + if ( !IsPreview() ) + { + QStringList aParameters; + aParameters << myTolEdt->text(); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + } objects.push_back( anObj._retn() ); + } } return aResult; @@ -353,7 +337,7 @@ void RepairGUI_SewingDlg::initSelection() //================================================================================= void RepairGUI_SewingDlg::onDetect() { - displayPreview( false, true, true, 3 ); + displayPreview( true, false, true, true, 3 ); // field myClosed,myOpen is initialized in execute() method, called by displayPreview(). QString msg; @@ -361,5 +345,5 @@ void RepairGUI_SewingDlg::onDetect() msg = tr( "GEOM_FREE_BOUNDS_MSG" ).arg( myClosed + myOpen ).arg( myClosed ).arg( myOpen ); else msg = tr( "GEOM_FREE_BOUNDS_ERROR" ); - QAD_MessageBox::info1( this, tr( "GEOM_FREE_BOUNDS_TLT" ), msg, "Close" ); + SUIT_MessageBox::information( this, tr( "GEOM_FREE_BOUNDS_TLT" ), msg ); }