1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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
23 // GEOM RepairGUI : GUI for Geometry component
24 // File : RepairGUI_GlueDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
27 #include "RepairGUI_GlueDlg.h"
30 #include <GeometryGUI.h>
32 #include <SalomeApp_DoubleSpinBox.h>
34 #include <SalomeApp_Application.h>
35 #include <SalomeApp_Study.h>
36 #include <SalomeApp_Tools.h>
37 #include <LightApp_SelectionMgr.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_ListIO.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,
62 bool modal, TopAbs_ShapeEnum theGlueMode)
63 : GEOMBase_Skeleton(theGeometryGUI, parent, modal),
64 myCurrConstrId(-1), myGlueMode(theGlueMode)
66 QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
67 QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_FACES")));
68 QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_FACES2")));
69 QPixmap image3 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_EDGES")));
70 QPixmap image4 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_EDGES2")));
73 if (theGlueMode == TopAbs_FACE)
74 aTitle = tr("GEOM_GLUE_FACES_TITLE");
75 else if (theGlueMode == TopAbs_EDGE)
76 aTitle = tr("GEOM_GLUE_EDGES_TITLE");
77 setWindowTitle(aTitle);
79 /***************************************************************/
80 mainFrame()->GroupConstructors->setTitle(aTitle);
81 if (theGlueMode == TopAbs_FACE) {
82 mainFrame()->RadioButton1->setIcon(image1);
83 mainFrame()->RadioButton2->setIcon(image2);
85 else if (theGlueMode == TopAbs_EDGE) {
86 mainFrame()->RadioButton1->setIcon(image3);
87 mainFrame()->RadioButton2->setIcon(image4);
89 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
90 mainFrame()->RadioButton3->close();
92 GroupPoints = new DlgRef_1SelExt(centralWidget());
93 GroupPoints->GroupBox1->setTitle(tr("GEOM_GLUE"));
94 GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPES"));
95 GroupPoints->PushButton1->setIcon(image0);
96 GroupPoints->LineEdit1->setReadOnly(true);
98 QLabel* aTolLab = new QLabel(tr("GEOM_TOLERANCE"), GroupPoints->Box);
99 myTolEdt = new SalomeApp_DoubleSpinBox(GroupPoints->Box);
100 initSpinBox(myTolEdt, 0., 100., DEFAULT_TOLERANCE_VALUE, "len_tol_precision");
101 myTolEdt->setValue(DEFAULT_TOLERANCE_VALUE);
103 QGridLayout* boxLayout = new QGridLayout(GroupPoints->Box);
104 boxLayout->setMargin(0); boxLayout->setSpacing(6);
105 boxLayout->addWidget(aTolLab, 0, 0);
106 boxLayout->addWidget(myTolEdt, 0, 2);
107 /***************************************************************/
109 GroupPoints2 = new DlgRef_1SelExt(centralWidget());
110 GroupPoints2->GroupBox1->setTitle(tr("GEOM_GLUE"));
111 GroupPoints2->TextLabel1->setText(tr("GEOM_SELECTED_SHAPES"));
112 GroupPoints2->PushButton1->setIcon(image0);
113 GroupPoints2->LineEdit1->setReadOnly(true);
115 QLabel* aTolLab2 = new QLabel(tr("GEOM_TOLERANCE"), GroupPoints2->Box);
116 myTolEdt2 = new SalomeApp_DoubleSpinBox(GroupPoints2->Box);
117 initSpinBox(myTolEdt2, 0., 100., DEFAULT_TOLERANCE_VALUE, "len_tol_precision");
118 myTolEdt2->setValue(DEFAULT_TOLERANCE_VALUE);
120 QString aGlueString (" [%1]");
122 if (theGlueMode == TopAbs_FACE) {
123 aGlueString = aGlueString.arg(tr("GLUE_FACES"));
124 aSelString = tr("SELECT_FACES");
126 else if (theGlueMode == TopAbs_EDGE) {
127 aGlueString = aGlueString.arg(tr("GLUE_EDGES"));
128 aSelString = tr("SELECT_EDGES");
130 myDetectBtn = new QPushButton (tr("GEOM_DETECT") + aGlueString, GroupPoints2->Box);
131 mySubShapesChk = new QCheckBox (aSelString, GroupPoints2->Box);
132 myGlueAllEdgesChk = 0;
134 boxLayout = new QGridLayout(GroupPoints2->Box);
135 boxLayout->setMargin(0); boxLayout->setSpacing(6);
136 boxLayout->addWidget(aTolLab2, 0, 0);
137 boxLayout->addWidget(myTolEdt2, 0, 2);
138 boxLayout->addWidget(myDetectBtn, 1, 0, 1, 3);
139 boxLayout->addWidget(mySubShapesChk, 2, 0, 1, 3);
141 if (theGlueMode == TopAbs_FACE) {
142 myGlueAllEdgesChk = new QCheckBox (tr("GLUE_ALL_EDGES"), GroupPoints2->Box);
143 boxLayout->addWidget(myGlueAllEdgesChk, 3, 0, 1, 3);
144 myGlueAllEdgesChk->setChecked(false);
147 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
148 layout->setMargin(0); layout->setSpacing(6);
149 layout->addWidget(GroupPoints);
150 layout->addWidget(GroupPoints2);
152 /***************************************************************/
154 QString aHelpFileName;
155 switch ( myGlueMode ) {
158 aHelpFileName = "glue_edges_operation_page.html";
163 aHelpFileName = "glue_faces_operation_page.html";
167 setHelpFileName(aHelpFileName);
169 // Disable second way of gluing if OCC viewer is not active one
170 if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
171 != OCCViewer_Viewer::Type())
172 mainFrame()->RadioButton2->setEnabled(false);
177 //=================================================================================
178 // function : ~RepairGUI_GlueDlg()
179 // purpose : Destroys the object and frees any allocated resources
180 //=================================================================================
181 RepairGUI_GlueDlg::~RepairGUI_GlueDlg()
185 //=================================================================================
188 //=================================================================================
189 void RepairGUI_GlueDlg::Init()
192 myEditCurrentArgument = GroupPoints->LineEdit1;
196 //myGeomGUI->SetState(0);
197 //globalSelection(GEOM_COMPOUND);
199 mainFrame()->GroupBoxPublish->show();
200 //Hide preview checkbox
201 mainFrame()->CheckBoxPreview->hide();
203 /* signals and slots connections */
204 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
205 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
207 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
209 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
210 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
212 connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
213 connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
214 connect(myTolEdt2, SIGNAL(valueChanged(double)), this, SLOT(onTolerChanged(double)));
215 connect(mySubShapesChk, SIGNAL(stateChanged(int)), this, SLOT(onSubShapesChk()));
217 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
218 this, SLOT(SelectionIntoArgument()));
220 connect(myDetectBtn, SIGNAL(clicked()), this, SLOT(onDetect()));
222 initName(tr("GLUE_NEW_OBJ_NAME"));
224 ConstructorsClicked(0);
230 //=================================================================================
231 // function : ConstructorsClicked()
232 // purpose : Radio button management
233 //=================================================================================
234 void RepairGUI_GlueDlg::ConstructorsClicked(int constructorId)
236 if (myCurrConstrId == constructorId)
239 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
241 switch (constructorId) {
243 GroupPoints2->hide();
245 GroupPoints->LineEdit1->setText("");
246 myEditCurrentArgument = GroupPoints->LineEdit1;
248 if (myCurrConstrId >= 0) {
249 // i.e. it is not initialisation
250 // copy tolerance from previous tolerance field
251 myTolEdt->setValue(myTolEdt2->value());
256 GroupPoints2->show();
257 GroupPoints->LineEdit1->setText("");
258 myEditCurrentArgument = GroupPoints2->LineEdit1;
260 if (myCurrConstrId >= 0) {
261 // i.e. it is not initialisation
262 // copy tolerance from previous tolerance field
263 myTolEdt2->setValue(myTolEdt->value());
264 mySubShapesChk->setChecked(false);
270 myCurrConstrId = constructorId;
272 myEditCurrentArgument->setFocus();
274 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
275 this, SLOT(SelectionIntoArgument()));
277 qApp->processEvents();
279 resize(minimumSizeHint());
284 SelectionIntoArgument();
287 //=================================================================================
288 // function : ClickOnOk()
289 // purpose : Same than click on apply but close this dialog.
290 //=================================================================================
291 void RepairGUI_GlueDlg::ClickOnOk()
293 setIsApplyAndClose(true);
298 //=================================================================================
299 // function : ClickOnApply()
301 //=================================================================================
302 bool RepairGUI_GlueDlg::ClickOnApply()
304 if (!onAcceptLocal())
309 //GroupPoints->LineEdit1->setText("");
310 //myObject = GEOM::GEOM_Object::_nil();
312 //globalSelection(GEOM_COMPOUND);
314 ConstructorsClicked(getConstructorId());
320 //=================================================================================
321 // function : SelectionIntoArgument()
322 // purpose : Called when selection
323 //=================================================================================
324 void RepairGUI_GlueDlg::SelectionIntoArgument()
326 if (mySubShapesChk->isChecked() && getConstructorId() == 1) {
332 myEditCurrentArgument->setText("");
335 myObjects = getSelected( TopAbs_SHAPE, -1 );
337 if ( !myObjects.isEmpty() ) {
338 QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
339 myEditCurrentArgument->setText( aName );
344 //=================================================================================
345 // function : SetEditCurrentArgument()
347 //=================================================================================
348 void RepairGUI_GlueDlg::SetEditCurrentArgument()
350 const QObject* send = sender();
351 if (send == GroupPoints->PushButton1 || send == GroupPoints2->PushButton1) {
352 myEditCurrentArgument->setFocus();
353 SelectionIntoArgument();
357 //=================================================================================
358 // function : LineEditReturnPressed()
360 //=================================================================================
361 void RepairGUI_GlueDlg::LineEditReturnPressed()
363 const QObject* send = sender();
364 if (send == GroupPoints->LineEdit1) {
365 myEditCurrentArgument = GroupPoints->LineEdit1;
366 GEOMBase_Skeleton::LineEditReturnPressed();
368 else if (send == GroupPoints2->LineEdit1) {
369 myEditCurrentArgument = GroupPoints2->LineEdit1;
370 GEOMBase_Skeleton::LineEditReturnPressed();
374 //=================================================================================
375 // function : ActivateThisDialog()
377 //=================================================================================
378 void RepairGUI_GlueDlg::ActivateThisDialog()
380 GEOMBase_Skeleton::ActivateThisDialog();
381 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
382 this, SLOT(SelectionIntoArgument()));
384 //GroupPoints->LineEdit1->setText("");
385 //GroupPoints2->LineEdit1->setText("");
386 //myObject = GEOM::GEOM_Object::_nil();
388 //myGeomGUI->SetState(0);
389 //globalSelection(GEOM_COMPOUND);
393 //=================================================================================
394 // function : enterEvent()
395 // purpose : Mouse enter onto the dialog to activate it
396 //=================================================================================
397 void RepairGUI_GlueDlg::enterEvent(QEvent*)
399 if (!mainFrame()->GroupConstructors->isEnabled())
400 ActivateThisDialog();
403 //=================================================================================
404 // function : createOperation
406 //=================================================================================
407 GEOM::GEOM_IOperations_ptr RepairGUI_GlueDlg::createOperation()
409 return getGeomEngine()->GetIShapesOperations(getStudyId());
412 //=================================================================================
413 // function : isValid
415 //=================================================================================
416 bool RepairGUI_GlueDlg::isValid(QString& msg)
420 switch (getConstructorId())
423 v = myTolEdt->value();
424 ok = myTolEdt->isValid(msg, !IsPreview());
427 v = myTolEdt2->value();
428 ok = myTolEdt2->isValid(msg, !IsPreview());
431 return !myObjects.isEmpty() && (IsPreview() || v > 0.) && ok;
434 //=================================================================================
435 // function : execute
437 //=================================================================================
438 bool RepairGUI_GlueDlg::execute(ObjectList& objects)
440 bool aResult = false;
443 GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
444 objList->length( myObjects.count() );
445 for ( int i = 0; i < myObjects.count(); ++i )
446 objList[i] = myObjects[i].copy();
448 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
449 switch (getConstructorId()) {
452 GEOM::GEOM_Object_var anObj;
453 if (myGlueMode == TopAbs_FACE)
454 anObj = anOper->MakeGlueFaces( objList, myTolEdt->value(), true);
455 else if (myGlueMode == TopAbs_EDGE)
456 anObj = anOper->MakeGlueEdges( objList, myTolEdt->value());
458 aResult = !anObj->_is_nil();
459 if (aResult && !IsPreview())
461 QStringList aParameters;
462 aParameters << myTolEdt->text();
463 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
465 objects.push_back(anObj._retn());
472 // if this method is used for displaying preview then we must detect glue faces/edges only
473 for (int i = 0; i < myTmpObjs.count(); i++) {
474 myTmpObjs[i].get()->Register(); // increment counter, since calling function will call UnRegister()
475 objects.push_back(myTmpObjs[i].copy());
477 return !myTmpObjs.isEmpty();
480 // Make glue faces/edges by list.
481 // Iterate through myTmpObjs and verifies where each object is currently selected or not.
482 QSet<QString> selected;
484 // Get names of selected objects
485 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
486 SALOME_ListIO aSelList;
487 aSelMgr->selectedObjects(aSelList);
489 SALOME_ListIteratorOfListIO it (aSelList);
490 for (; it.More(); it.Next())
491 selected.insert(it.Value()->getName());
493 // Iterate through result and select objects with names from selection
494 // ObjectList toRemoveFromEnggine;
496 // make glue faces/edges
497 GEOM::ListOfGO_var aListForGlue = new GEOM::ListOfGO();
498 aListForGlue->length(myTmpObjs.count());
500 for (int i = 0; i < myTmpObjs.count(); i++) {
501 CORBA::String_var tmpior = myGeomGUI->getApp()->orb()->object_to_string(myTmpObjs[i].get());
502 if (selected.contains(tmpior.in()))
503 aListForGlue[ added++ ] = myTmpObjs[i].copy();
505 aListForGlue->length(added);
507 GEOM::GEOM_Object_var anObj;
508 if (myGlueMode == TopAbs_FACE) {
509 bool doGlueAllEdges = myGlueAllEdgesChk->isChecked();
510 anObj = anOper->MakeGlueFacesByList( objList, myTolEdt2->value(), aListForGlue.in(),
511 true, doGlueAllEdges);
513 else if (myGlueMode == TopAbs_EDGE)
514 anObj = anOper->MakeGlueEdgesByList( objList, myTolEdt2->value(), aListForGlue.in());
516 aResult = !anObj->_is_nil();
520 QStringList aParameters;
521 aParameters << myTolEdt2->text();
522 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
524 objects.push_back(anObj._retn());
527 // Remove from engine useless objects
539 //=================================================================================
540 // function : restoreSubShapes
542 //=================================================================================
543 void RepairGUI_GlueDlg::restoreSubShapes(SALOMEDS::Study_ptr theStudy,
544 SALOMEDS::SObject_ptr theSObject)
546 if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
547 GEOM::find_shape_method aFindMethod = GEOM::FSM_GetInPlace;
548 if (getConstructorId() == 0) // MakeGlueFaces or MakeGlueEdges
549 aFindMethod = GEOM::FSM_GetInPlaceByHistory;
551 // empty list of arguments means that all arguments should be restored
552 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
553 aFindMethod, /*theInheritFirstArg=*/true,
554 mainFrame()->CheckBoxAddPrefix->isChecked());
558 //================================================================
559 // Function : clearShapeBufferLocal
561 //================================================================
562 void RepairGUI_GlueDlg::clearShapeBufferLocal(GEOM::GEOM_Object_ptr theObj)
564 if (CORBA::is_nil(theObj))
567 CORBA::String_var IOR = myGeomGUI->getApp()->orb()->object_to_string(theObj);
568 TCollection_AsciiString asciiIOR((char *)(IOR.in()));
569 myGeomGUI->GetShapeReader().RemoveShapeFromBuffer(asciiIOR);
571 if (!getStudy() || !(getStudy()->studyDS()))
574 _PTR(Study) aStudy = getStudy()->studyDS();
575 _PTR(SObject) aSObj (aStudy->FindObjectIOR(std::string(IOR.in())));
579 _PTR(ChildIterator) anIt (aStudy->NewChildIterator(aSObj));
580 for (anIt->InitEx(true); anIt->More(); anIt->Next()) {
581 _PTR(GenericAttribute) anAttr;
582 if (anIt->Value()->FindAttribute(anAttr, "AttributeIOR")) {
583 _PTR(AttributeIOR) anIOR (anAttr);
584 TCollection_AsciiString asciiIOR((char*)anIOR->Value().c_str());
585 myGeomGUI->GetShapeReader().RemoveShapeFromBuffer(asciiIOR);
590 //================================================================
591 // Function : onAccept
592 // Purpose : This method should be called from dialog's slots onOk() and onApply()
593 // It perfroms user input validation, then it
594 // performs a proper operation and manages transactions, etc.
595 //================================================================
596 bool RepairGUI_GlueDlg::onAcceptLocal()
598 if (!getStudy() || !(getStudy()->studyDS()))
601 _PTR(Study) aStudy = getStudy()->studyDS();
603 bool aLocked = aStudy->GetProperties()->IsLocked();
605 MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
606 SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_STUDY_LOCKED"), tr("BUT_OK"));
620 SUIT_OverrideCursor wc;
622 myGeomGUI->getApp()->putInfo("");
625 if (!execute(objects)) {
631 const int nbObjs = objects.size();
632 for (ObjectList::iterator it = objects.begin(); it != objects.end(); ++it) {
633 QString aName = getNewObjectName();
636 aName = getPrefix(*it);
637 aName = GEOMBase::GetDefaultName(aName);
640 // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
642 aName = GEOMBase::GetDefaultName(getPrefix(*it));
644 addInStudy(*it, aName.toLatin1().data());
651 myGeomGUI->getApp()->putInfo(QObject::tr("GEOM_PRP_DONE"));
657 // JFA 28.12.2004 BEGIN // To enable warnings
658 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
659 if (!CORBA::is_nil(anOper) && !anOper->IsDone()) {
661 QString msgw = QObject::tr(anOper->GetErrorCode());
662 SUIT_MessageBox::warning(this, tr("WRN_WARNING"), msgw, tr("BUT_OK"));
664 // JFA 28.12.2004 END
668 catch(const SALOME::SALOME_Exception& e) {
669 SalomeApp_Tools::QtCatchCorbaException(e);
680 //=================================================================================
681 // function : onDetect
683 //=================================================================================
684 void RepairGUI_GlueDlg::onDetect()
693 buttonOk()->setEnabled(false);
694 buttonApply()->setEnabled(false);
695 globalSelection(GEOM_ALLSHAPES);
697 GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
698 objList->length( myObjects.count() );
699 for ( int i = 0; i < myObjects.count(); ++i )
700 objList[i] = myObjects[i].copy();
702 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
703 GEOM::ListOfGO_var aList;
704 if (myGlueMode == TopAbs_FACE)
705 aList = anOper->GetGlueFaces( objList, myTolEdt2->value());
706 else if (myGlueMode == TopAbs_EDGE)
707 aList = anOper->GetGlueEdges( objList, myTolEdt2->value());
709 for (int i = 0, n = aList->length(); i < n; i++)
710 myTmpObjs << GEOM::GeomObjPtr(aList[i].in());
712 if (!myTmpObjs.isEmpty()) {
713 if (myGlueMode == TopAbs_FACE)
714 msg = tr("FACES_FOR_GLUING_ARE_DETECTED").arg(myTmpObjs.count());
715 else if (myGlueMode == TopAbs_EDGE)
716 msg = tr("EDGES_FOR_GLUING_ARE_DETECTED").arg(myTmpObjs.count());
717 mySubShapesChk->setChecked(true);
720 if (myGlueMode == TopAbs_FACE)
721 msg = tr("THERE_ARE_NO_FACES_FOR_GLUING");
722 else if (myGlueMode == TopAbs_EDGE)
723 msg = tr("THERE_ARE_NO_EDGES_FOR_GLUING");
726 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
727 this, SLOT(SelectionIntoArgument())) ;
728 if ( myGlueMode == TopAbs_FACE )
729 SUIT_MessageBox::information(this, tr("GEOM_GLUE_FACES_DETECT_TITLE"), msg, tr("Close"));
731 SUIT_MessageBox::information(this, tr("GEOM_GLUE_EDGES_DETECT_TITLE"), msg, tr("Close"));
736 //=================================================================================
737 // function : activateSelection
738 // purpose : Redisplay preview and Activate selection
739 //=================================================================================
740 void RepairGUI_GlueDlg::activateSelection()
744 int anId = getConstructorId();
746 // Case of whole gluing
747 disconnect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
748 this, SLOT(SelectionIntoArgument()));
750 globalSelection(GEOM_ALLSHAPES);
751 if ( myObjects.isEmpty() )
752 SelectionIntoArgument();
754 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
755 this, SLOT(SelectionIntoArgument()));
758 // Second case of gluing
759 if (!mySubShapesChk->isChecked())
760 globalSelection(GEOM_ALLSHAPES);
762 displayPreview(true, true, false, false, 2/*line width*/, 1/*display mode*/, Quantity_NOC_RED);
763 disconnect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
764 this, SLOT(SelectionIntoArgument())) ;
765 globalSelection(GEOM_PREVIEW);
766 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
767 this, SLOT(SelectionIntoArgument())) ;
773 //=================================================================================
774 // function : updateButtonState
775 // purpose : Update button state
776 //=================================================================================
777 void RepairGUI_GlueDlg::updateButtonState()
779 int anId = getConstructorId();
780 bool hasMainObj = !myObjects.isEmpty();
782 buttonOk()->setEnabled(hasMainObj);
783 buttonApply()->setEnabled(hasMainObj);
787 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
788 SALOME_ListIO aSelList;
789 aSelMgr->selectedObjects(aSelList);
791 SALOME_ListIteratorOfListIO it (aSelList);
792 bool wasSelected = it.More() > 0;
793 bool wasDetected = !myTmpObjs.isEmpty();
794 buttonOk()->setEnabled(hasMainObj && wasDetected && wasSelected);
795 buttonApply()->setEnabled(hasMainObj && wasDetected && wasSelected);
796 mySubShapesChk->setEnabled(hasMainObj && wasDetected);
797 myDetectBtn->setEnabled(hasMainObj);
798 if (!hasMainObj || !wasDetected)
799 mySubShapesChk->setChecked(false);
803 //=================================================================================
804 // function : clearTemporary
805 // purpose : Remove temporary objects from engine
806 //=================================================================================
807 void RepairGUI_GlueDlg::clearTemporary()
812 //=================================================================================
813 // function : onTolerChanged
814 // purpose : Remove temporary objects from engine
815 //=================================================================================
816 void RepairGUI_GlueDlg::onTolerChanged(double /*theVal*/)
823 //=================================================================================
824 // function : onSubShapesChk
825 // purpose : Update selection mode
826 //=================================================================================
827 void RepairGUI_GlueDlg::onSubShapesChk()
829 if (!mySubShapesChk->isChecked())
835 //=================================================================================
836 // function : ClickOnCancel
837 // purpose : Remove temporary objects from engine and call method of base class
838 //=================================================================================
839 void RepairGUI_GlueDlg::ClickOnCancel()
842 GEOMBase_Skeleton::ClickOnCancel();