From b11f36342b28dfeeead3e8835c5600284e443514 Mon Sep 17 00:00:00 2001 From: sln Date: Wed, 11 Apr 2007 12:17:26 +0000 Subject: [PATCH] PAL131191: EDF160 GEOM: in Glue Faces, visualize faces existing twice --- src/RepairGUI/RepairGUI_GlueDlg.cxx | 525 ++++++++++++++++++++++++---- src/RepairGUI/RepairGUI_GlueDlg.h | 36 +- 2 files changed, 481 insertions(+), 80 deletions(-) diff --git a/src/RepairGUI/RepairGUI_GlueDlg.cxx b/src/RepairGUI/RepairGUI_GlueDlg.cxx index bcdb30715..c01a6a00b 100644 --- a/src/RepairGUI/RepairGUI_GlueDlg.cxx +++ b/src/RepairGUI/RepairGUI_GlueDlg.cxx @@ -26,6 +26,8 @@ // Module : GEOM // $Header$ +#include "OCCViewer_ViewModel.h" + #include "RepairGUI_GlueDlg.h" #include "DlgRef_1Sel_Ext.h" #include "GEOMImpl_Types.hxx" @@ -46,6 +48,9 @@ #include #include +#include +#include +#include using namespace std; @@ -60,10 +65,12 @@ using namespace std; //================================================================================= RepairGUI_GlueDlg::RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* parent, const char* name, bool modal, WFlags fl) - :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize | - WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +: GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myCurrConstrId( -1 ) { QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_GLUE_FACES"))); + QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_GLUE_FACES2"))); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); setCaption(tr("GEOM_GLUE_TITLE")); @@ -71,7 +78,8 @@ RepairGUI_GlueDlg::RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* paren /***************************************************************/ GroupConstructors->setTitle(tr("GEOM_GLUE_TITLE")); RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); + RadioButton2->setPixmap(image2); + //RadioButton2->close(TRUE); RadioButton3->close(TRUE); GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); @@ -79,22 +87,51 @@ RepairGUI_GlueDlg::RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* paren GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); GroupPoints->PushButton1->setPixmap(image1); GroupPoints->LineEdit1->setReadOnly( true ); + + int aWidth = GroupPoints->TextLabel1->sizeHint().width() + + GroupPoints->PushButton1->sizeHint().width() + + GroupPoints->getGroupBoxLayout()->spacing(); Layout1->addWidget(GroupPoints, 2, 0); - QGridLayout* aLay = new QGridLayout( 0, 2, 2, 0, 6, "aLay" ); - QLabel* aLbl1 = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints->GroupBox1 ); - myTolEdt = new QtxDblSpinBox( 0, 100, 1e-7, GroupPoints->GroupBox1 ); + QHBox* aHBox = new QHBox( GroupPoints->GroupBox1 ); + aHBox->setSpacing( 5 ); + + (new QLabel( tr( "GEOM_TOLERANCE" ), aHBox ))->setFixedWidth( aWidth ); + myTolEdt = new QtxDblSpinBox( 0, 100, 1e-7, aHBox ); + myTolEdt->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myTolEdt->setPrecision( 10 ); myTolEdt->setValue( DEFAULT_TOLERANCE_VALUE ); + GroupPoints->getGroupBoxLayout()->addWidget( aHBox, 3, 0 ); + /***************************************************************/ - aLay->addWidget( aLbl1, 0, 0 ); - aLay->addWidget( myTolEdt, 0, 1 ); - - GroupPoints->getGroupBoxLayout()->addLayout( aLay, 3, 0 ); + GroupPoints2 = new DlgRef_1Sel_Ext(this, "GroupPoints2"); + GroupPoints2->GroupBox1->setTitle(tr("GEOM_GLUE")); + GroupPoints2->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); + GroupPoints2->PushButton1->setPixmap(image1); + GroupPoints2->LineEdit1->setReadOnly( true ); + Layout1->addWidget(GroupPoints2, 2, 0); + + QGrid* aGrid = new QGrid( 2, Qt::Horizontal, GroupPoints2->GroupBox1 ); + aGrid->setSpacing( 5 ); + (new QLabel( tr( "GEOM_TOLERANCE" ), aGrid ))->setFixedWidth( aWidth );; + myTolEdt2 = new QtxDblSpinBox( 0, 100, 1e-7, aGrid ); + myTolEdt2->setPrecision( 10 ); + myTolEdt2->setValue( DEFAULT_TOLERANCE_VALUE ); + myTolEdt2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + (new QLabel( tr( "GLUE_FACES" ), aGrid ))->setFixedWidth( aWidth );; + myDetectBtn = new QPushButton( tr( "GEOM_DETECT" ), aGrid ); + myDetectBtn->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + mySubShapesChk = new QCheckBox( tr( "SELECT_FACES" ), aGrid ); + GroupPoints2->getGroupBoxLayout()->addWidget( aGrid, 3, 0 ); /***************************************************************/ setHelpFileName("glue_faces.htm"); + + // Disable second way of gluing if OCC viewer is not active one + if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() + != OCCViewer_Viewer::Type()) + RadioButton2->setEnabled(false); Init(); } @@ -121,19 +158,100 @@ void RepairGUI_GlueDlg::Init() myObject = GEOM::GEOM_Object::_nil(); //myGeomGUI->SetState( 0 ); - globalSelection( GEOM_COMPOUND ); + //globalSelection( GEOM_COMPOUND ); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect( myTolEdt2, SIGNAL( valueChanged( double ) ), this, SLOT( onTolerChanged( double ) ) ); + connect( mySubShapesChk, SIGNAL( stateChanged( int ) ), this, SLOT( onSubShapesChk() ) ); + + connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()) ); + + connect(myDetectBtn, SIGNAL(clicked()), this, SLOT(onDetect())); initName( tr( "GLUE_NEW_OBJ_NAME" ) ); + + ConstructorsClicked(0); + + activateSelection(); + updateButtonState(); +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void RepairGUI_GlueDlg::ConstructorsClicked( int constructorId ) +{ + if ( myCurrConstrId == constructorId ) + return; + + disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + + switch ( constructorId ) + { + case 0: + { + GroupPoints2->hide(); + resize( 0, 0 ); + GroupPoints->show(); + GroupPoints->LineEdit1->setText( "" ); + myEditCurrentArgument = GroupPoints->LineEdit1; + + if ( myCurrConstrId >= 0 ) // i.e. it is not initialisation + { + // copy tolerance from previous tolerance field + myTolEdt->setValue( myTolEdt2->value() ); + } + + break; + } + case 1: + { + GroupPoints->hide(); + resize(0, 0); + GroupPoints2->show(); + GroupPoints->LineEdit1->setText(""); + myEditCurrentArgument = GroupPoints2->LineEdit1; + + if ( myCurrConstrId >= 0 ) // i.e. it is not initialisation + { + // copy tolerance from previous tolerance field + myTolEdt2->setValue( myTolEdt->value() ); + mySubShapesChk->setChecked( false ); + clearTemporary(); + } + + break; + } + } + + myCurrConstrId = constructorId; + + myEditCurrentArgument->setFocus(); + + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + qApp->processEvents(); + updateGeometry(); + QSize aSize = minimumSizeHint(); + resize( width(), aSize.height() ); + + displayPreview(); + updateButtonState(); + activateSelection(); + SelectionIntoArgument(); } @@ -159,10 +277,12 @@ bool RepairGUI_GlueDlg::ClickOnApply() initName(); - GroupPoints->LineEdit1->setText(""); - myObject = GEOM::GEOM_Object::_nil(); + //GroupPoints->LineEdit1->setText(""); + //myObject = GEOM::GEOM_Object::_nil(); - globalSelection( GEOM_COMPOUND ); + //globalSelection( GEOM_COMPOUND ); + + ConstructorsClicked( getConstructorId() ); return true; } @@ -174,6 +294,9 @@ bool RepairGUI_GlueDlg::ClickOnApply() //================================================================================= void RepairGUI_GlueDlg::SelectionIntoArgument() { + if ( mySubShapesChk->isChecked() && getConstructorId() == 1 ) + return; + erasePreview(); myEditCurrentArgument->setText(""); myObject = GEOM::GEOM_Object::_nil(); @@ -185,6 +308,7 @@ void RepairGUI_GlueDlg::SelectionIntoArgument() if ( aRes ) myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); } + updateButtonState(); } //================================================================================= @@ -194,7 +318,7 @@ void RepairGUI_GlueDlg::SelectionIntoArgument() void RepairGUI_GlueDlg::SetEditCurrentArgument() { const QObject* send = sender(); - if ( send == GroupPoints->PushButton1 ) { + if ( send == GroupPoints->PushButton1 || send == GroupPoints2->PushButton1 ) { myEditCurrentArgument->setFocus(); SelectionIntoArgument(); } @@ -212,6 +336,10 @@ void RepairGUI_GlueDlg::LineEditReturnPressed() myEditCurrentArgument = GroupPoints->LineEdit1; GEOMBase_Skeleton::LineEditReturnPressed(); } + else if( send == GroupPoints2->LineEdit1 ) { + myEditCurrentArgument = GroupPoints2->LineEdit1; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -225,11 +353,13 @@ void RepairGUI_GlueDlg::ActivateThisDialog() connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - GroupPoints->LineEdit1->setText(""); - myObject = GEOM::GEOM_Object::_nil(); + //GroupPoints->LineEdit1->setText(""); + //GroupPoints2->LineEdit1->setText(""); + //myObject = GEOM::GEOM_Object::_nil(); //myGeomGUI->SetState( 0 ); - globalSelection( GEOM_COMPOUND ); + //globalSelection( GEOM_COMPOUND ); + activateSelection(); } @@ -243,7 +373,6 @@ void RepairGUI_GlueDlg::enterEvent(QEvent* e) ActivateThisDialog(); } - //================================================================================= // function : closeEvent() // purpose : @@ -254,6 +383,7 @@ void RepairGUI_GlueDlg::closeEvent(QCloseEvent* e) GEOMBase_Skeleton::closeEvent( e ); } + //================================================================================= // function : createOperation // purpose : @@ -279,15 +409,74 @@ bool RepairGUI_GlueDlg::isValid( QString& msg ) bool RepairGUI_GlueDlg::execute( ObjectList& objects ) { bool aResult = false; - GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow - ( getOperation() )->MakeGlueFaces( myObject, myTolEdt->value() ); - aResult = !anObj->_is_nil(); - if ( aResult ) - objects.push_back( anObj._retn() ); + objects.clear(); + + switch ( getConstructorId() ) + { + case 0 : + { + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow + ( getOperation() )->MakeGlueFaces( myObject, myTolEdt2->value() ); + aResult = !anObj->_is_nil(); + if ( aResult ) + objects.push_back( anObj._retn() ); + break; + } + case 1 : + if ( IsPreview() ) + { + // if this method is used for displaying preview then we must detect glue faces only + ObjectList::iterator anIter; + for (anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter) + objects.push_back( GEOM::GEOM_Object::_duplicate( *anIter ) ); + return myTmpObjs.size() ? true : false; + } // IsPreview + + // Make glue face by list. + // Iterate through myTmpObjs and verifies where each object is currently selected or not. + QMap selected; + + // Get names of selected objects + SALOME_ListIteratorOfListIO it ( selectedIO() ); + for (; it.More(); it.Next()) + selected.insert( it.Value()->getName(), 0 ); + + // Iterate through result and select objects with names from selection + // ObjectList toRemoveFromEnggine; + ObjectList toGlue; + ObjectList::iterator anIter; + for (anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter) + { + if ( selected.contains( myGeomGUI->getApp()->orb()->object_to_string(*anIter) ) ) + toGlue.push_back(*anIter); + } + + // make glue faces + GEOM::ListOfGO_var aListForGlue = new GEOM::ListOfGO(); + aListForGlue->length( toGlue.size() ); + ObjectList::iterator anIter3 = toGlue.begin(); + for ( int i = 0; anIter3 != toGlue.end(); ++anIter3, ++i ) + aListForGlue[ i ] = *anIter3; + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow + ( getOperation() )->MakeGlueFacesByList( myObject, myTolEdt2->value(), aListForGlue ); + + aResult = !anObj->_is_nil(); + + if ( aResult ) + objects.push_back( anObj._retn() ); + + // Remove from engine useless objects + clearTemporary(); + + updateButtonState(); + + break; + } // case return aResult; } + //================================================================ // Function : clearShapeBufferLocal // Purpose : @@ -326,7 +515,7 @@ void RepairGUI_GlueDlg::clearShapeBufferLocal( GEOM::GEOM_Object_ptr theObj ) // It perfroms user input validation, then it // performs a proper operation and manages transactions, etc. //================================================================ -bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransaction ) +bool RepairGUI_GlueDlg::onAcceptLocal() { if ( !getStudy() || !( getStudy()->studyDS() ) ) return false; @@ -334,76 +523,79 @@ bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransac _PTR(Study) aStudy = getStudy()->studyDS(); bool aLocked = aStudy->GetProperties()->IsLocked(); - if ( aLocked ) { + if ( aLocked ) + { MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked"); SUIT_MessageBox::warn1 ( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED"), - QObject::tr("BUT_OK") ); + QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED"), QObject::tr("BUT_OK") ); return false; } QString msg; - if ( !isValid( msg ) ) { + if ( !isValid( msg ) ) + { showError( msg ); return false; } erasePreview( false ); - try { - if ( ( !publish && !useTransaction ) || openCommand() ) { - + try + { + if ( openCommand() ) + { SUIT_OverrideCursor wc; SUIT_Session::session()->activeApplication()->putInfo( "" ); ObjectList objects; - // JFA 28.12.2004 if ( !execute( objects ) || !getOperation()->IsDone() ) { - if ( !execute( objects ) ) { // JFA 28.12.2004 // To enable warnings - wc.suspend(); + + if ( !execute( objects ) ) + { + wc.suspend(); abortCommand(); - showError(); + showError(); } - else { - const int nbObjs = objects.size(); - bool withChildren = false; - for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) { - if ( publish ) { - QString aName(""); - if ( nbObjs > 1 ) - aName = strlen( getNewObjectName() ) ? GEOMBase::GetDefaultName( getNewObjectName() ) : GEOMBase::GetDefaultName( getPrefix( *it ) ); - else { - aName = getNewObjectName(); - // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName() - if ( aName.isEmpty() ) - aName = GEOMBase::GetDefaultName( getPrefix( *it ) ); - } - addInStudy( *it, aName.latin1() ); - withChildren = false; - display( *it, false ); - } - else { // asv : fix of PAL6454. If publish==false, then the original shape was modified, and need to be re-cached in GEOM_Client - // before redisplay - clearShapeBufferLocal( *it ); - withChildren = true; - redisplay( *it, withChildren, false ); + else + { + const int nbObjs = objects.size(); + bool withChildren = false; + for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) + { + QString aName(""); + if ( nbObjs > 1 ) + { + aName = strlen( getNewObjectName() ) ? GEOMBase::GetDefaultName( getNewObjectName() ) : GEOMBase::GetDefaultName( getPrefix( *it ) ); + } + else + { + aName = getNewObjectName(); + // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName() + if ( aName.isEmpty() ) + aName = GEOMBase::GetDefaultName( getPrefix( *it ) ); } - } - - if ( nbObjs ) { - commitCommand(); - updateObjBrowser(); - SUIT_Session::session()->activeApplication()->putInfo( QObject::tr("GEOM_PRP_DONE") ); - } - else { - abortCommand(); + addInStudy( *it, aName.latin1() ); + withChildren = false; + display( *it, false ); + } + + if ( nbObjs ) + { + commitCommand(); + updateObjBrowser(); + SUIT_Session::session()->activeApplication()->putInfo( QObject::tr("GEOM_PRP_DONE") ); + } + else + { + abortCommand(); } // JFA 28.12.2004 BEGIN // To enable warnings - if ( !getOperation()->_is_nil() ) { - if ( !getOperation()->IsDone() ) { + if ( !getOperation()->_is_nil() ) + { + if ( !getOperation()->IsDone() ) + { wc.suspend(); - QString msgw = QObject::tr( getOperation()->GetErrorCode() ); + QString msgw = QObject::tr( getOperation()->GetErrorCode() ); SUIT_MessageBox::warn1((QWidget*)(SUIT_Session::session()->activeApplication()->desktop()), QObject::tr( "WRN_WARNING" ), msgw, @@ -414,12 +606,195 @@ bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransac } } } - catch( const SALOME::SALOME_Exception& e ) { + catch( const SALOME::SALOME_Exception& e ) + { SalomeApp_Tools::QtCatchCorbaException( e ); abortCommand(); } updateViewer(); + activateSelection(); + updateButtonState(); return true; } + + +//================================================================================= +// function : onDetect +// purpose : +//================================================================================= +void RepairGUI_GlueDlg::onDetect() +{ + clearTemporary(); + QString msg; + if ( !isValid( msg ) ) { + showError( msg ); + return; + } + + GEOM::ListOfGO_var aList = GEOM::GEOM_IShapesOperations::_narrow + ( getOperation() )->GetGlueFaces( myObject, myTolEdt2->value() ); + + for (int i = 0, n = aList->length(); i < n; i++) + myTmpObjs.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); + + if ( myTmpObjs.size() > 0 ) + { + msg = tr( "FACES_FOR_GLUING_ARE_DETECTED" ).arg( myTmpObjs.size() ); + mySubShapesChk->setChecked( true ); + } + else + { + msg = tr( "THERE_ARE_NO_FACES_FOR_GLUING" ); + } + + SUIT_MessageBox::info1( this, tr( "GEOM_FREE_BOUNDS_TLT" ), msg, "Close" ); + updateButtonState(); + activateSelection(); +} + +//================================================================================= +// function : activateSelection +// purpose : Redisplay preview and Activate selection +//================================================================================= +void RepairGUI_GlueDlg::activateSelection() +{ + erasePreview(false); + + int anId = getConstructorId(); + if ( anId == 0 ) // Case of whole gluing + { + disconnect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()) ) ; + + globalSelection( GEOM_ALLSHAPES ); + if (myObject->_is_nil()) + SelectionIntoArgument(); + + connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()) ) ; + } + else // Second case of gluing + { + if ( !mySubShapesChk->isChecked() ) + globalSelection( GEOM_ALLSHAPES ); + else + { + displayPreview( true, false, false, 2/*line width*/, 1/*display mode*/, Quantity_NOC_RED ); + globalSelection( GEOM_PREVIEW ); + } + } + + updateViewer(); +} + +//================================================================================= +// function : updateButtonState +// purpose : Update button state +//================================================================================= +void RepairGUI_GlueDlg::updateButtonState() +{ + int anId = getConstructorId(); + bool hasMainObj = !myObject->_is_nil(); + if ( anId == 0 ) + { + buttonOk->setEnabled( hasMainObj ); + buttonApply->setEnabled( hasMainObj ); + } + else + { + bool wasDetected = myTmpObjs.size() ? true : false; + buttonOk->setEnabled( hasMainObj && wasDetected ); + buttonApply->setEnabled( hasMainObj && wasDetected ); + mySubShapesChk->setEnabled( hasMainObj && wasDetected ); + myDetectBtn->setEnabled( hasMainObj ); + if ( !hasMainObj || !wasDetected ) + mySubShapesChk->setChecked( false ); + } +} + +//================================================================================= +// function : clearTemporary +// purpose : Remove temporary objects from engine +//================================================================================= +void RepairGUI_GlueDlg::clearTemporary() +{ + ObjectList::iterator anIter; + for (anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter) + getGeomEngine()->RemoveObject(*anIter); + + myTmpObjs.clear(); +} + +//================================================================================= +// function : onTolerChanged +// purpose : Remove temporary objects from engine +//================================================================================= +void RepairGUI_GlueDlg::onTolerChanged( double /*theVal*/ ) +{ + clearTemporary(); + activateSelection(); + updateButtonState(); +} + +//================================================================================= +// function : onSubShapesChk +// purpose : Update selection mode +//================================================================================= +void RepairGUI_GlueDlg::onSubShapesChk() +{ + if ( !mySubShapesChk->isChecked() ) + clearTemporary(); + activateSelection(); + updateButtonState(); +} + +//================================================================================= +// function : ClickOnCancel +// purpose : Remove temporary objects from engine and call method of base class +//================================================================================= +void RepairGUI_GlueDlg::ClickOnCancel() +{ + clearTemporary(); + GEOMBase_Skeleton::ClickOnCancel(); +} + +//================================================================ +// Function : getEntry +// Purpose : +//================================================================ +static string getEntry( GEOM::GEOM_Object_ptr object ) +{ + SUIT_Session* session = SUIT_Session::session(); + SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); + if ( app ) + { + string IOR = app->orb()->object_to_string( object ); + if ( IOR != "" ) + { + SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy(); + _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) ); + if ( SO ) + return SO->GetID(); + } + } + return ""; +} + + + + + + + + + + + + + + + + + diff --git a/src/RepairGUI/RepairGUI_GlueDlg.h b/src/RepairGUI/RepairGUI_GlueDlg.h index e23ff3ff2..eef24c2ca 100644 --- a/src/RepairGUI/RepairGUI_GlueDlg.h +++ b/src/RepairGUI/RepairGUI_GlueDlg.h @@ -32,6 +32,7 @@ class QtxDblSpinBox; class DlgRef_1Sel_Ext; +class QCheckBox; //================================================================================= // class : RepairGUI_GlueDlg @@ -42,8 +43,8 @@ class RepairGUI_GlueDlg : public GEOMBase_Skeleton Q_OBJECT public: - RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* parent = 0, - const char* name = 0, bool modal = FALSE, WFlags fl = 0); + RepairGUI_GlueDlg( GeometryGUI* theGeometryGUI, QWidget* parent = 0, + const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~RepairGUI_GlueDlg(); protected: @@ -57,16 +58,34 @@ private: void enterEvent(QEvent* e); void closeEvent(QCloseEvent* e); void initSelection(); + + void clearTemporary(); - bool onAcceptLocal( const bool publish = true, const bool useTransaction = true ); + bool onAcceptLocal(); void clearShapeBufferLocal( GEOM::GEOM_Object_ptr ); // Reimplementation of onAccept for local case of this class. - + + void activateSelection(); + void updateButtonState(); + void selectTmpInViewer(); + +private: + GEOM::GEOM_Object_var myObject; - + ObjectList myTmpObjs; + DlgRef_1Sel_Ext* GroupPoints; + DlgRef_1Sel_Ext* GroupPoints2; QtxDblSpinBox* myTolEdt; + QtxDblSpinBox* myTolEdt2; + QPushButton* myDetectBtn; + QCheckBox* mySubShapesChk; + int myCurrConstrId; + +protected slots: + virtual void ClickOnCancel(); + private slots: void ClickOnOk(); bool ClickOnApply(); @@ -76,6 +95,13 @@ private slots: void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); + + void ConstructorsClicked(int); + //void ValueChangedInSpinBox(); + + void onDetect(); + void onTolerChanged( double ); + void onSubShapesChk(); }; #endif // DIALOGBOX_Glue_H -- 2.39.2