+
+
+//=================================================================================
+// function : onDetect
+// purpose :
+//=================================================================================
+void RepairGUI_GlueDlg::onDetect()
+{
+ clearTemporary();
+ QString msg;
+ if ( !isValid( msg ) ) {
+ showError( msg );
+ return;
+ }
+
+ buttonOk()->setEnabled( false );
+ buttonApply()->setEnabled( false );
+ globalSelection( GEOM_ALLSHAPES );
+
+ GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
+ GEOM::ListOfGO_var aList = anOper->GetGlueFaces( myObject.in(), myTolEdt2->value() );
+
+ for ( int i = 0, n = aList->length(); i < n; i++ )
+ myTmpObjs << GEOM::GeomObjPtr( aList[i].in() );
+
+ if ( !myTmpObjs.isEmpty() ) {
+ msg = tr( "FACES_FOR_GLUING_ARE_DETECTED" ).arg( myTmpObjs.count() );
+ mySubShapesChk->setChecked( true );
+ }
+ else {
+ msg = tr( "THERE_ARE_NO_FACES_FOR_GLUING" );
+ }
+
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) ) ;
+ SUIT_MessageBox::information( this, tr( "GEOM_FREE_BOUNDS_TLT" ), msg, tr( "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( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) );
+
+ globalSelection( GEOM_ALLSHAPES );
+ if ( myObject->_is_nil())
+ SelectionIntoArgument();
+
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) );
+ }
+ else {
+ // Second case of gluing
+ if ( !mySubShapesChk->isChecked() )
+ globalSelection( GEOM_ALLSHAPES );
+ else {
+ displayPreview( true, true, false, false, 2/*line width*/, 1/*display mode*/, Quantity_NOC_RED );
+ disconnect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) ) ;
+ globalSelection( GEOM_PREVIEW );
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) ) ;
+ }
+ }
+ 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
+ {
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ SALOME_ListIteratorOfListIO it (aSelList);
+ bool wasSelected = it.More() > 0;
+ bool wasDetected = !myTmpObjs.isEmpty();
+ buttonOk()->setEnabled( hasMainObj && wasDetected && wasSelected );
+ buttonApply()->setEnabled( hasMainObj && wasDetected && wasSelected );
+ 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()
+{
+ 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();
+}