1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // GEOM RepairGUI : GUI for Geometry component
23 // File : RepairGUI_GlueDlg.cxx
24 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 #include "RepairGUI_GlueDlg.h"
29 #include <GeometryGUI.h>
31 #include <QtxDoubleSpinBox.h>
33 #include <SalomeApp_Application.h>
34 #include <SalomeApp_Notebook.h>
35 #include <LightApp_SelectionMgr.h>
36 #include <SalomeApp_Study.h>
37 #include <SalomeApp_Tools.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_Desktop.h>
40 #include <SUIT_MessageBox.h>
41 #include <SUIT_OverrideCursor.h>
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_ViewWindow.h>
44 #include <SUIT_ViewManager.h>
45 #include <OCCViewer_ViewModel.h>
46 #include <SALOME_ListIteratorOfListIO.hxx>
48 #include <GEOMImpl_Types.hxx>
50 #include <TCollection_AsciiString.hxx>
52 #define DEFAULT_TOLERANCE_VALUE 1e-07
54 //=================================================================================
55 // class : RepairGUI_GlueDlg()
56 // purpose : Constructs a RepairGUI_GlueDlg which is a child of 'parent', with the
57 // name 'name' and widget flags set to 'f'.
58 // The dialog will by default be modeless, unless you set 'modal' to
59 // TRUE to construct a modal dialog.
60 //=================================================================================
61 RepairGUI_GlueDlg::RepairGUI_GlueDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
63 : GEOMBase_Skeleton( theGeometryGUI, parent, modal ),
66 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_GLUE_FACES" ) ) );
67 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_GLUE_FACES2" ) ));
68 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
70 setWindowTitle( tr( "GEOM_GLUE_TITLE" ) );
72 /***************************************************************/
73 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_GLUE_TITLE" ) );
74 mainFrame()->RadioButton1->setIcon( image0 );
75 mainFrame()->RadioButton2->setIcon( image2 );
76 mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
77 mainFrame()->RadioButton3->close();
79 GroupPoints = new DlgRef_1SelExt( centralWidget() );
80 GroupPoints->GroupBox1->setTitle( tr( "GEOM_GLUE" ) );
81 GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
82 GroupPoints->PushButton1->setIcon( image1 );
83 GroupPoints->LineEdit1->setReadOnly( true );
85 QLabel* aTolLab = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints->Box );
86 myTolEdt = new SalomeApp_DoubleSpinBox( 0.0, 100.0, DEFAULT_TOLERANCE_VALUE, 7, 7, GroupPoints->Box );
87 myTolEdt->setValue( DEFAULT_TOLERANCE_VALUE );
89 QGridLayout* boxLayout = new QGridLayout( GroupPoints->Box );
90 boxLayout->setMargin( 0 ); boxLayout->setSpacing( 6 );
91 boxLayout->addWidget( aTolLab, 0, 0 );
92 boxLayout->addWidget( myTolEdt, 0, 2 );
93 /***************************************************************/
95 GroupPoints2 = new DlgRef_1SelExt( centralWidget() );
96 GroupPoints2->GroupBox1->setTitle( tr( "GEOM_GLUE" ) );
97 GroupPoints2->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
98 GroupPoints2->PushButton1->setIcon( image1 );
99 GroupPoints2->LineEdit1->setReadOnly( true );
101 QLabel* aTolLab2 = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints2->Box );
102 myTolEdt2 = new SalomeApp_DoubleSpinBox( GroupPoints2->Box );
103 initSpinBox( myTolEdt2, 0, 100, 1e-7, 7 );
104 myTolEdt2->setValue( DEFAULT_TOLERANCE_VALUE );
106 myDetectBtn = new QPushButton( tr( "GEOM_DETECT" ) + QString( " [%1]" ).arg( tr( "GLUE_FACES" ) ),
108 mySubShapesChk = new QCheckBox( tr( "SELECT_FACES" ), GroupPoints2->Box );
110 boxLayout = new QGridLayout( GroupPoints2->Box );
111 boxLayout->setMargin( 0 ); boxLayout->setSpacing( 6 );
112 boxLayout->addWidget( aTolLab2, 0, 0 );
113 boxLayout->addWidget( myTolEdt2, 0, 2 );
114 boxLayout->addWidget( myDetectBtn, 1, 0, 1, 3 );
115 boxLayout->addWidget( mySubShapesChk, 2, 0, 1, 3 );
117 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
118 layout->setMargin( 0 ); layout->setSpacing( 6 );
119 layout->addWidget( GroupPoints );
120 layout->addWidget( GroupPoints2 );
122 /***************************************************************/
124 setHelpFileName( "glue_faces_operation_page.html" );
126 // Disable second way of gluing if OCC viewer is not active one
127 if ( myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
128 != OCCViewer_Viewer::Type() )
129 mainFrame()->RadioButton2->setEnabled( false );
135 //=================================================================================
136 // function : ~RepairGUI_GlueDlg()
137 // purpose : Destroys the object and frees any allocated resources
138 //=================================================================================
139 RepairGUI_GlueDlg::~RepairGUI_GlueDlg()
144 //=================================================================================
147 //=================================================================================
148 void RepairGUI_GlueDlg::Init()
151 myEditCurrentArgument = GroupPoints->LineEdit1;
153 myObject = GEOM::GEOM_Object::_nil();
155 //myGeomGUI->SetState( 0 );
156 //globalSelection( GEOM_COMPOUND );
158 mainFrame()->GroupBoxPublish->show();
160 /* signals and slots connections */
161 connect( buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
162 connect( buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
164 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
166 connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
167 connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
169 connect( GroupPoints2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
170 connect( GroupPoints2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
171 connect( myTolEdt2, SIGNAL( valueChanged( double ) ), this, SLOT( onTolerChanged( double ) ) );
172 connect( mySubShapesChk, SIGNAL( stateChanged( int ) ), this, SLOT( onSubShapesChk() ) );
174 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
175 this, SLOT( SelectionIntoArgument() ) );
177 connect( myDetectBtn, SIGNAL( clicked() ), this, SLOT( onDetect() ) );
179 initName( tr( "GLUE_NEW_OBJ_NAME" ) );
181 ConstructorsClicked( 0 );
188 //=================================================================================
189 // function : ConstructorsClicked()
190 // purpose : Radio button management
191 //=================================================================================
192 void RepairGUI_GlueDlg::ConstructorsClicked( int constructorId )
194 if ( myCurrConstrId == constructorId )
197 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
199 switch ( constructorId ) {
201 GroupPoints2->hide();
203 GroupPoints->LineEdit1->setText( "" );
204 myEditCurrentArgument = GroupPoints->LineEdit1;
206 if ( myCurrConstrId >= 0 ) {
207 // i.e. it is not initialisation
208 // copy tolerance from previous tolerance field
209 myTolEdt->setValue( myTolEdt2->value() );
214 GroupPoints2->show();
215 GroupPoints->LineEdit1->setText( "" );
216 myEditCurrentArgument = GroupPoints2->LineEdit1;
218 if ( myCurrConstrId >= 0 ) {
219 // i.e. it is not initialisation
220 // copy tolerance from previous tolerance field
221 myTolEdt2->setValue( myTolEdt->value() );
222 mySubShapesChk->setChecked( false );
228 myCurrConstrId = constructorId;
230 myEditCurrentArgument->setFocus();
232 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
233 this, SLOT( SelectionIntoArgument() ) );
235 qApp->processEvents();
237 resize( minimumSizeHint() );
242 SelectionIntoArgument();
246 //=================================================================================
247 // function : ClickOnOk()
248 // purpose : Same than click on apply but close this dialog.
249 //=================================================================================
250 void RepairGUI_GlueDlg::ClickOnOk()
252 if ( ClickOnApply() )
257 //=================================================================================
258 // function : ClickOnApply()
260 //=================================================================================
261 bool RepairGUI_GlueDlg::ClickOnApply()
263 if ( !onAcceptLocal() )
268 //GroupPoints->LineEdit1->setText("");
269 //myObject = GEOM::GEOM_Object::_nil();
271 //globalSelection( GEOM_COMPOUND );
273 ConstructorsClicked( getConstructorId() );
279 //=================================================================================
280 // function : SelectionIntoArgument()
281 // purpose : Called when selection
282 //=================================================================================
283 void RepairGUI_GlueDlg::SelectionIntoArgument()
285 if ( mySubShapesChk->isChecked() && getConstructorId() == 1 ) {
291 myEditCurrentArgument->setText( "" );
292 myObject = GEOM::GEOM_Object::_nil();
294 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
295 SALOME_ListIO aSelList;
296 aSelMgr->selectedObjects(aSelList);
298 if ( aSelList.Extent() == 1 ) {
299 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
300 Standard_Boolean aRes;
301 myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
303 myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) );
308 //=================================================================================
309 // function : SetEditCurrentArgument()
311 //=================================================================================
312 void RepairGUI_GlueDlg::SetEditCurrentArgument()
314 const QObject* send = sender();
315 if ( send == GroupPoints->PushButton1 || send == GroupPoints2->PushButton1 ) {
316 myEditCurrentArgument->setFocus();
317 SelectionIntoArgument();
322 //=================================================================================
323 // function : LineEditReturnPressed()
325 //=================================================================================
326 void RepairGUI_GlueDlg::LineEditReturnPressed()
328 const QObject* send = sender();
329 if ( send == GroupPoints->LineEdit1 ) {
330 myEditCurrentArgument = GroupPoints->LineEdit1;
331 GEOMBase_Skeleton::LineEditReturnPressed();
333 else if ( send == GroupPoints2->LineEdit1 ) {
334 myEditCurrentArgument = GroupPoints2->LineEdit1;
335 GEOMBase_Skeleton::LineEditReturnPressed();
340 //=================================================================================
341 // function : ActivateThisDialog()
343 //=================================================================================
344 void RepairGUI_GlueDlg::ActivateThisDialog()
346 GEOMBase_Skeleton::ActivateThisDialog();
347 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
348 this, SLOT( SelectionIntoArgument() ) );
350 //GroupPoints->LineEdit1->setText("");
351 //GroupPoints2->LineEdit1->setText("");
352 //myObject = GEOM::GEOM_Object::_nil();
354 //myGeomGUI->SetState( 0 );
355 //globalSelection( GEOM_COMPOUND );
360 //=================================================================================
361 // function : enterEvent()
362 // purpose : Mouse enter onto the dialog to activate it
363 //=================================================================================
364 void RepairGUI_GlueDlg::enterEvent( QEvent* )
366 if ( !mainFrame()->GroupConstructors->isEnabled() )
367 ActivateThisDialog();
371 //=================================================================================
372 // function : createOperation
374 //=================================================================================
375 GEOM::GEOM_IOperations_ptr RepairGUI_GlueDlg::createOperation()
377 return getGeomEngine()->GetIShapesOperations( getStudyId() );
380 //=================================================================================
381 // function : isValid
383 //=================================================================================
384 bool RepairGUI_GlueDlg::isValid( QString& msg )
388 switch ( getConstructorId() )
391 v = myTolEdt->value();
392 ok = myTolEdt->isValid( msg, !IsPreview() );
395 v = myTolEdt2->value();
396 ok = myTolEdt2->isValid( msg, !IsPreview() );
399 return !myObject->_is_nil() && ( IsPreview() || v > 0. ) && ok;
402 //=================================================================================
403 // function : execute
405 //=================================================================================
406 bool RepairGUI_GlueDlg::execute( ObjectList& objects )
408 bool aResult = false;
411 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
412 switch ( getConstructorId() ) {
415 GEOM::GEOM_Object_var anObj = anOper->MakeGlueFaces( myObject, myTolEdt->value(), true );
416 aResult = !anObj->_is_nil();
417 if ( aResult && !IsPreview() )
419 myNoteBook->setParameters(anObj, 1, myTolEdt);
420 objects.push_back( anObj._retn() );
427 // if this method is used for displaying preview then we must detect glue faces only
428 ObjectList::iterator anIter;
429 for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter )
430 objects.push_back( GEOM::GEOM_Object::_duplicate( *anIter ) );
431 return myTmpObjs.size() ? true : false;
434 // Make glue face by list.
435 // Iterate through myTmpObjs and verifies where each object is currently selected or not.
436 QMap<QString, char> selected;
438 // Get names of selected objects
439 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
440 SALOME_ListIO aSelList;
441 aSelMgr->selectedObjects(aSelList);
443 SALOME_ListIteratorOfListIO it (aSelList);
444 for (; it.More(); it.Next())
445 selected.insert(it.Value()->getName(), 0);
447 // Iterate through result and select objects with names from selection
448 // ObjectList toRemoveFromEnggine;
450 ObjectList::iterator anIter;
451 for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter ) {
452 if ( selected.contains( myGeomGUI->getApp()->orb()->object_to_string(*anIter) ) )
453 toGlue.push_back( *anIter );
457 GEOM::ListOfGO_var aListForGlue = new GEOM::ListOfGO();
458 aListForGlue->length( toGlue.size() );
459 ObjectList::iterator anIter3 = toGlue.begin();
460 for ( int i = 0; anIter3 != toGlue.end(); ++anIter3, ++i )
461 aListForGlue[ i ] = *anIter3;
462 GEOM::GEOM_Object_var anObj = anOper->MakeGlueFacesByList( myObject, myTolEdt2->value(), aListForGlue, true );
464 aResult = !anObj->_is_nil();
469 myNoteBook->setParameters(anObj, 1, myTolEdt2);
470 objects.push_back( anObj._retn() );
473 // Remove from engine useless objects
485 //=================================================================================
486 // function : restoreSubShapes
488 //=================================================================================
489 void RepairGUI_GlueDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy,
490 SALOMEDS::SObject_ptr theSObject )
492 if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
493 GEOM::find_shape_method aFindMethod = GEOM::FSM_GetInPlace;
494 if ( getConstructorId() == 0 ) // MakeGlueFaces
495 aFindMethod = GEOM::FSM_GetInPlaceByHistory;
497 // empty list of arguments means that all arguments should be restored
498 getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(),
499 aFindMethod, /*theInheritFirstArg=*/true );
503 //================================================================
504 // Function : clearShapeBufferLocal
506 //================================================================
507 void RepairGUI_GlueDlg::clearShapeBufferLocal( GEOM::GEOM_Object_ptr theObj )
509 if ( CORBA::is_nil( theObj ) )
512 CORBA::String_var IOR = myGeomGUI->getApp()->orb()->object_to_string( theObj );
513 TCollection_AsciiString asciiIOR( (char *)( IOR.in() ) );
514 myGeomGUI->GetShapeReader().RemoveShapeFromBuffer( asciiIOR );
516 if ( !getStudy() || !( getStudy()->studyDS() ) )
519 _PTR(Study) aStudy = getStudy()->studyDS();
520 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR.in() ) ) );
524 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
525 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
526 _PTR(GenericAttribute) anAttr;
527 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
528 _PTR(AttributeIOR) anIOR ( anAttr );
529 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
530 myGeomGUI->GetShapeReader().RemoveShapeFromBuffer( asciiIOR );
535 //================================================================
536 // Function : onAccept
537 // Purpose : This method should be called from dialog's slots onOk() and onApply()
538 // It perfroms user input validation, then it
539 // performs a proper operation and manages transactions, etc.
540 //================================================================
541 bool RepairGUI_GlueDlg::onAcceptLocal()
543 if ( !getStudy() || !( getStudy()->studyDS() ) )
546 _PTR(Study) aStudy = getStudy()->studyDS();
548 bool aLocked = aStudy->GetProperties()->IsLocked();
550 MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
551 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ), tr( "WRN_STUDY_LOCKED" ), tr( "BUT_OK" ) );
556 if ( !isValid( msg ) ) {
561 erasePreview( false );
564 if ( openCommand() ) {
565 SUIT_OverrideCursor wc;
567 myGeomGUI->getApp()->putInfo( "" );
570 if ( !execute( objects ) ) {
576 const int nbObjs = objects.size();
577 for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) {
578 QString aName = getNewObjectName();
580 if ( aName.isEmpty() )
581 aName = getPrefix( *it );
582 aName = GEOMBase::GetDefaultName( aName );
585 // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
586 if ( aName.isEmpty() )
587 aName = GEOMBase::GetDefaultName( getPrefix( *it ) );
589 addInStudy( *it, aName.toLatin1().data() );
590 display( *it, false );
596 myGeomGUI->getApp()->putInfo( QObject::tr("GEOM_PRP_DONE") );
602 // JFA 28.12.2004 BEGIN // To enable warnings
603 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
604 if ( !CORBA::is_nil(anOper) && !anOper->IsDone() ) {
606 QString msgw = QObject::tr( anOper->GetErrorCode() );
607 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ), msgw, tr( "BUT_OK" ) );
609 // JFA 28.12.2004 END
613 catch( const SALOME::SALOME_Exception& e ) {
614 SalomeApp_Tools::QtCatchCorbaException( e );
626 //=================================================================================
627 // function : onDetect
629 //=================================================================================
630 void RepairGUI_GlueDlg::onDetect()
634 if ( !isValid( msg ) ) {
639 buttonOk()->setEnabled( false );
640 buttonApply()->setEnabled( false );
641 globalSelection( GEOM_ALLSHAPES );
643 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
644 GEOM::ListOfGO_var aList = anOper->GetGlueFaces( myObject, myTolEdt2->value() );
646 for ( int i = 0, n = aList->length(); i < n; i++ )
647 myTmpObjs.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
649 if ( myTmpObjs.size() > 0 ) {
650 msg = tr( "FACES_FOR_GLUING_ARE_DETECTED" ).arg( myTmpObjs.size() );
651 mySubShapesChk->setChecked( true );
654 msg = tr( "THERE_ARE_NO_FACES_FOR_GLUING" );
657 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
658 this, SLOT( SelectionIntoArgument() ) ) ;
659 SUIT_MessageBox::information( this, tr( "GEOM_FREE_BOUNDS_TLT" ), msg, tr( "Close" ) );
664 //=================================================================================
665 // function : activateSelection
666 // purpose : Redisplay preview and Activate selection
667 //=================================================================================
668 void RepairGUI_GlueDlg::activateSelection()
670 erasePreview( false );
672 int anId = getConstructorId();
674 // Case of whole gluing
675 disconnect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
676 this, SLOT( SelectionIntoArgument() ) );
678 globalSelection( GEOM_ALLSHAPES );
679 if ( myObject->_is_nil())
680 SelectionIntoArgument();
682 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
683 this, SLOT( SelectionIntoArgument() ) );
686 // Second case of gluing
687 if ( !mySubShapesChk->isChecked() )
688 globalSelection( GEOM_ALLSHAPES );
690 displayPreview( true, false, false, 2/*line width*/, 1/*display mode*/, Quantity_NOC_RED );
691 disconnect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
692 this, SLOT( SelectionIntoArgument() ) ) ;
693 globalSelection( GEOM_PREVIEW );
694 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
695 this, SLOT( SelectionIntoArgument() ) ) ;
701 //=================================================================================
702 // function : updateButtonState
703 // purpose : Update button state
704 //=================================================================================
705 void RepairGUI_GlueDlg::updateButtonState()
707 int anId = getConstructorId();
708 bool hasMainObj = !myObject->_is_nil();
710 buttonOk()->setEnabled( hasMainObj );
711 buttonApply()->setEnabled( hasMainObj );
715 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
716 SALOME_ListIO aSelList;
717 aSelMgr->selectedObjects(aSelList);
719 bool wasSelected = false;
720 SALOME_ListIteratorOfListIO it (aSelList);
723 bool wasDetected = myTmpObjs.size() ? true : false;
724 buttonOk()->setEnabled( hasMainObj && wasDetected && wasSelected );
725 buttonApply()->setEnabled( hasMainObj && wasDetected && wasSelected );
726 mySubShapesChk->setEnabled( hasMainObj && wasDetected );
727 myDetectBtn->setEnabled( hasMainObj );
728 if ( !hasMainObj || !wasDetected )
729 mySubShapesChk->setChecked( false );
733 //=================================================================================
734 // function : clearTemporary
735 // purpose : Remove temporary objects from engine
736 //=================================================================================
737 void RepairGUI_GlueDlg::clearTemporary()
739 ObjectList::iterator anIter;
740 for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter )
741 getGeomEngine()->RemoveObject(*anIter);
746 //=================================================================================
747 // function : onTolerChanged
748 // purpose : Remove temporary objects from engine
749 //=================================================================================
750 void RepairGUI_GlueDlg::onTolerChanged( double /*theVal*/ )
757 //=================================================================================
758 // function : onSubShapesChk
759 // purpose : Update selection mode
760 //=================================================================================
761 void RepairGUI_GlueDlg::onSubShapesChk()
763 if ( !mySubShapesChk->isChecked() )
769 //=================================================================================
770 // function : ClickOnCancel
771 // purpose : Remove temporary objects from engine and call method of base class
772 //=================================================================================
773 void RepairGUI_GlueDlg::ClickOnCancel()
776 GEOMBase_Skeleton::ClickOnCancel();