1 // Copyright (C) 2007-2024 CEA, EDF, 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>
33 #include "utilities.h"
35 #include <SalomeApp_Application.h>
36 #include <SalomeApp_Study.h>
37 #include <SalomeApp_Tools.h>
38 #include <LightApp_SelectionMgr.h>
39 #include <SUIT_Session.h>
40 #include <SUIT_Desktop.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_OverrideCursor.h>
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_ViewWindow.h>
45 #include <SUIT_ViewManager.h>
46 #include <OCCViewer_ViewModel.h>
47 #include <SALOME_ListIO.hxx>
48 #include "utilities.h"
50 #include <GEOMImpl_Types.hxx>
52 #include <TCollection_AsciiString.hxx>
54 #define DEFAULT_TOLERANCE_VALUE 1e-07
56 //=================================================================================
57 // class : RepairGUI_GlueDlg()
58 // purpose : Constructs a RepairGUI_GlueDlg which is a child of 'parent', with the
59 // name 'name' and widget flags set to 'f'.
60 // The dialog will by default be modeless, unless you set 'modal' to
61 // TRUE to construct a modal dialog.
62 //=================================================================================
63 RepairGUI_GlueDlg::RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
64 bool modal, TopAbs_ShapeEnum theGlueMode)
65 : GEOMBase_Skeleton(theGeometryGUI, parent, modal),
66 myCurrConstrId(-1), myGlueMode(theGlueMode)
68 QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
69 QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_FACES")));
70 QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_FACES2")));
71 QPixmap image3 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_EDGES")));
72 QPixmap image4 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_EDGES2")));
75 if (theGlueMode == TopAbs_FACE)
76 aTitle = tr("GEOM_GLUE_FACES_TITLE");
77 else if (theGlueMode == TopAbs_EDGE)
78 aTitle = tr("GEOM_GLUE_EDGES_TITLE");
79 setWindowTitle(aTitle);
81 /***************************************************************/
82 mainFrame()->GroupConstructors->setTitle(aTitle);
83 if (theGlueMode == TopAbs_FACE) {
84 mainFrame()->RadioButton1->setIcon(image1);
85 mainFrame()->RadioButton2->setIcon(image2);
87 else if (theGlueMode == TopAbs_EDGE) {
88 mainFrame()->RadioButton1->setIcon(image3);
89 mainFrame()->RadioButton2->setIcon(image4);
91 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
92 mainFrame()->RadioButton3->close();
94 GroupPoints = new DlgRef_1SelExt(centralWidget());
95 GroupPoints->GroupBox1->setTitle(tr("GEOM_GLUE"));
96 GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPES"));
97 GroupPoints->PushButton1->setIcon(image0);
98 GroupPoints->LineEdit1->setReadOnly(true);
100 QLabel* aTolLab = new QLabel(tr("GEOM_TOLERANCE"), GroupPoints->Box);
101 myTolEdt = new SalomeApp_DoubleSpinBox(GroupPoints->Box);
102 initSpinBox(myTolEdt, 0., 100., DEFAULT_TOLERANCE_VALUE, "len_tol_precision");
103 myTolEdt->setValue(DEFAULT_TOLERANCE_VALUE);
105 QGridLayout* boxLayout = new QGridLayout(GroupPoints->Box);
106 boxLayout->setMargin(0); boxLayout->setSpacing(6);
107 boxLayout->addWidget(aTolLab, 0, 0);
108 boxLayout->addWidget(myTolEdt, 0, 2);
109 /***************************************************************/
111 GroupPoints2 = new DlgRef_1SelExt(centralWidget());
112 GroupPoints2->GroupBox1->setTitle(tr("GEOM_GLUE"));
113 GroupPoints2->TextLabel1->setText(tr("GEOM_SELECTED_SHAPES"));
114 GroupPoints2->PushButton1->setIcon(image0);
115 GroupPoints2->LineEdit1->setReadOnly(true);
117 QLabel* aTolLab2 = new QLabel(tr("GEOM_TOLERANCE"), GroupPoints2->Box);
118 myTolEdt2 = new SalomeApp_DoubleSpinBox(GroupPoints2->Box);
119 initSpinBox(myTolEdt2, 0., 100., DEFAULT_TOLERANCE_VALUE, "len_tol_precision");
120 myTolEdt2->setValue(DEFAULT_TOLERANCE_VALUE);
122 QString aGlueString (" [%1]");
124 if (theGlueMode == TopAbs_FACE) {
125 aGlueString = aGlueString.arg(tr("GLUE_FACES"));
126 aSelString = tr("SELECT_FACES");
128 else if (theGlueMode == TopAbs_EDGE) {
129 aGlueString = aGlueString.arg(tr("GLUE_EDGES"));
130 aSelString = tr("SELECT_EDGES");
132 myDetectBtn = new QPushButton (tr("GEOM_DETECT") + aGlueString, GroupPoints2->Box);
133 mySubShapesChk = new QCheckBox (aSelString, GroupPoints2->Box);
134 myGlueAllEdgesChk = 0;
136 boxLayout = new QGridLayout(GroupPoints2->Box);
137 boxLayout->setMargin(0); boxLayout->setSpacing(6);
138 boxLayout->addWidget(aTolLab2, 0, 0);
139 boxLayout->addWidget(myTolEdt2, 0, 2);
140 boxLayout->addWidget(myDetectBtn, 1, 0, 1, 3);
141 boxLayout->addWidget(mySubShapesChk, 2, 0, 1, 3);
143 if (theGlueMode == TopAbs_FACE) {
144 myGlueAllEdgesChk = new QCheckBox (tr("GLUE_ALL_EDGES"), GroupPoints2->Box);
145 boxLayout->addWidget(myGlueAllEdgesChk, 3, 0, 1, 3);
146 myGlueAllEdgesChk->setChecked(false);
149 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
150 layout->setMargin(0); layout->setSpacing(6);
151 layout->addWidget(GroupPoints);
152 layout->addWidget(GroupPoints2);
154 /***************************************************************/
156 QString aHelpFileName;
157 switch ( myGlueMode ) {
160 aHelpFileName = "glue_edges_operation_page.html";
165 aHelpFileName = "glue_faces_operation_page.html";
171 setHelpFileName(aHelpFileName);
173 // Disable second way of gluing if OCC viewer is not active one
174 if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
175 != OCCViewer_Viewer::Type())
176 mainFrame()->RadioButton2->setEnabled(false);
181 //=================================================================================
182 // function : ~RepairGUI_GlueDlg()
183 // purpose : Destroys the object and frees any allocated resources
184 //=================================================================================
185 RepairGUI_GlueDlg::~RepairGUI_GlueDlg()
189 //=================================================================================
192 //=================================================================================
193 void RepairGUI_GlueDlg::Init()
196 myEditCurrentArgument = GroupPoints->LineEdit1;
200 //myGeomGUI->SetState(0);
201 //globalSelection(GEOM_COMPOUND);
203 mainFrame()->GroupBoxPublish->show();
204 //Hide preview checkbox
205 mainFrame()->CheckBoxPreview->hide();
207 /* signals and slots connections */
208 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
209 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
211 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
213 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
214 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
216 connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
217 connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
218 connect(myTolEdt2, SIGNAL(valueChanged(double)), this, SLOT(onTolerChanged(double)));
219 connect(mySubShapesChk, SIGNAL(stateChanged(int)), this, SLOT(onSubShapesChk()));
221 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
222 this, SLOT(SelectionIntoArgument()));
224 connect(myDetectBtn, SIGNAL(clicked()), this, SLOT(onDetect()));
226 initName(tr("GLUE_NEW_OBJ_NAME"));
228 ConstructorsClicked(0);
234 //=================================================================================
235 // function : ConstructorsClicked()
236 // purpose : Radio button management
237 //=================================================================================
238 void RepairGUI_GlueDlg::ConstructorsClicked(int constructorId)
240 if (myCurrConstrId == constructorId)
243 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
245 switch (constructorId) {
247 GroupPoints2->hide();
249 GroupPoints->LineEdit1->setText("");
250 myEditCurrentArgument = GroupPoints->LineEdit1;
252 if (myCurrConstrId >= 0) {
253 // i.e. it is not initialisation
254 // copy tolerance from previous tolerance field
255 myTolEdt->setValue(myTolEdt2->value());
260 GroupPoints2->show();
261 GroupPoints->LineEdit1->setText("");
262 myEditCurrentArgument = GroupPoints2->LineEdit1;
264 if (myCurrConstrId >= 0) {
265 // i.e. it is not initialisation
266 // copy tolerance from previous tolerance field
267 myTolEdt2->setValue(myTolEdt->value());
268 mySubShapesChk->setChecked(false);
274 myCurrConstrId = constructorId;
276 myEditCurrentArgument->setFocus();
278 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
279 this, SLOT(SelectionIntoArgument()));
281 qApp->processEvents();
283 resize(minimumSizeHint());
288 SelectionIntoArgument();
291 //=================================================================================
292 // function : ClickOnOk()
293 // purpose : Same than click on apply but close this dialog.
294 //=================================================================================
295 void RepairGUI_GlueDlg::ClickOnOk()
297 setIsApplyAndClose(true);
302 //=================================================================================
303 // function : ClickOnApply()
305 //=================================================================================
306 bool RepairGUI_GlueDlg::ClickOnApply()
308 if (!onAcceptLocal())
313 //GroupPoints->LineEdit1->setText("");
314 //myObject = GEOM::GEOM_Object::_nil();
316 //globalSelection(GEOM_COMPOUND);
318 ConstructorsClicked(getConstructorId());
324 //=================================================================================
325 // function : SelectionIntoArgument()
326 // purpose : Called when selection
327 //=================================================================================
328 void RepairGUI_GlueDlg::SelectionIntoArgument()
330 if (mySubShapesChk->isChecked() && getConstructorId() == 1) {
336 myEditCurrentArgument->setText("");
339 myObjects = getSelected( TopAbs_SHAPE, -1 );
341 if ( !myObjects.isEmpty() ) {
342 QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
343 myEditCurrentArgument->setText( aName );
348 //=================================================================================
349 // function : SetEditCurrentArgument()
351 //=================================================================================
352 void RepairGUI_GlueDlg::SetEditCurrentArgument()
354 const QObject* send = sender();
355 if (send == GroupPoints->PushButton1 || send == GroupPoints2->PushButton1) {
356 myEditCurrentArgument->setFocus();
357 SelectionIntoArgument();
361 //=================================================================================
362 // function : LineEditReturnPressed()
364 //=================================================================================
365 void RepairGUI_GlueDlg::LineEditReturnPressed()
367 const QObject* send = sender();
368 if (send == GroupPoints->LineEdit1) {
369 myEditCurrentArgument = GroupPoints->LineEdit1;
370 GEOMBase_Skeleton::LineEditReturnPressed();
372 else if (send == GroupPoints2->LineEdit1) {
373 myEditCurrentArgument = GroupPoints2->LineEdit1;
374 GEOMBase_Skeleton::LineEditReturnPressed();
378 //=================================================================================
379 // function : ActivateThisDialog()
381 //=================================================================================
382 void RepairGUI_GlueDlg::ActivateThisDialog()
384 GEOMBase_Skeleton::ActivateThisDialog();
385 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
386 this, SLOT(SelectionIntoArgument()));
388 //GroupPoints->LineEdit1->setText("");
389 //GroupPoints2->LineEdit1->setText("");
390 //myObject = GEOM::GEOM_Object::_nil();
392 //myGeomGUI->SetState(0);
393 //globalSelection(GEOM_COMPOUND);
397 //=================================================================================
398 // function : enterEvent()
399 // purpose : Mouse enter onto the dialog to activate it
400 //=================================================================================
401 void RepairGUI_GlueDlg::enterEvent(QEvent*)
403 if (!mainFrame()->GroupConstructors->isEnabled())
404 ActivateThisDialog();
407 //=================================================================================
408 // function : createOperation
410 //=================================================================================
411 GEOM::GEOM_IOperations_ptr RepairGUI_GlueDlg::createOperation()
413 return getGeomEngine()->GetIShapesOperations();
416 //=================================================================================
417 // function : isValid
419 //=================================================================================
420 bool RepairGUI_GlueDlg::isValid(QString& msg)
424 switch (getConstructorId())
427 v = myTolEdt->value();
428 ok = myTolEdt->isValid(msg, !IsPreview());
431 v = myTolEdt2->value();
432 ok = myTolEdt2->isValid(msg, !IsPreview());
435 return !myObjects.isEmpty() && (IsPreview() || v > 0.) && ok;
438 //=================================================================================
439 // function : execute
441 //=================================================================================
442 bool RepairGUI_GlueDlg::execute(ObjectList& objects)
444 bool aResult = false;
447 GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
448 objList->length( myObjects.count() );
449 for ( int i = 0; i < myObjects.count(); ++i )
450 objList[i] = myObjects[i].copy();
452 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
453 switch (getConstructorId()) {
456 GEOM::GEOM_Object_var anObj;
457 if (myGlueMode == TopAbs_FACE)
458 anObj = anOper->MakeGlueFaces( objList, myTolEdt->value(), true);
459 else if (myGlueMode == TopAbs_EDGE)
460 anObj = anOper->MakeGlueEdges( objList, myTolEdt->value());
462 aResult = !anObj->_is_nil();
463 if (aResult && !IsPreview())
465 QStringList aParameters;
466 aParameters << myTolEdt->text();
467 anObj->SetParameters(aParameters.join(":").toUtf8().constData());
469 objects.push_back(anObj._retn());
476 // if this method is used for displaying preview then we must detect glue faces/edges only
477 for (int i = 0; i < myTmpObjs.count(); i++) {
478 myTmpObjs[i].get()->Register(); // increment counter, since calling function will call UnRegister()
479 objects.push_back(myTmpObjs[i].copy());
481 return !myTmpObjs.isEmpty();
484 // Make glue faces/edges by list.
485 // Iterate through myTmpObjs and verifies where each object is currently selected or not.
486 QSet<QString> selected;
488 // Get names of selected objects
489 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
490 SALOME_ListIO aSelList;
491 aSelMgr->selectedObjects(aSelList);
493 SALOME_ListIteratorOfListIO it (aSelList);
494 for (; it.More(); it.Next())
495 selected.insert(it.Value()->getName());
497 // Iterate through result and select objects with names from selection
498 // ObjectList toRemoveFromEnggine;
500 // make glue faces/edges
501 GEOM::ListOfGO_var aListForGlue = new GEOM::ListOfGO();
502 aListForGlue->length(myTmpObjs.count());
504 for (int i = 0; i < myTmpObjs.count(); i++) {
505 CORBA::String_var tmpior = myGeomGUI->getApp()->orb()->object_to_string(myTmpObjs[i].get());
506 if (selected.contains(tmpior.in()))
507 aListForGlue[ added++ ] = myTmpObjs[i].copy();
509 aListForGlue->length(added);
511 GEOM::GEOM_Object_var anObj;
512 if (myGlueMode == TopAbs_FACE) {
513 bool doGlueAllEdges = myGlueAllEdgesChk->isChecked();
514 anObj = anOper->MakeGlueFacesByList( objList, myTolEdt2->value(), aListForGlue.in(),
515 true, doGlueAllEdges);
517 else if (myGlueMode == TopAbs_EDGE)
518 anObj = anOper->MakeGlueEdgesByList( objList, myTolEdt2->value(), aListForGlue.in());
520 aResult = !anObj->_is_nil();
524 QStringList aParameters;
525 aParameters << myTolEdt2->text();
526 anObj->SetParameters(aParameters.join(":").toUtf8().constData());
528 objects.push_back(anObj._retn());
531 // Remove from engine useless objects
543 //=================================================================================
544 // function : restoreSubShapes
546 //=================================================================================
547 void RepairGUI_GlueDlg::restoreSubShapes( SALOMEDS::SObject_ptr theSObject)
549 if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
550 GEOM::find_shape_method aFindMethod = GEOM::FSM_GetInPlace;
551 if (getConstructorId() == 0) // MakeGlueFaces or MakeGlueEdges
552 aFindMethod = GEOM::FSM_GetInPlaceByHistory;
554 // empty list of arguments means that all arguments should be restored
555 getGeomEngine()->RestoreSubShapesSO( theSObject, GEOM::ListOfGO(),
556 aFindMethod, /*theInheritFirstArg=*/true,
557 mainFrame()->CheckBoxAddPrefix->isChecked());
561 //================================================================
562 // Function : clearShapeBufferLocal
564 //================================================================
565 void RepairGUI_GlueDlg::clearShapeBufferLocal(GEOM::GEOM_Object_ptr theObj)
567 if (CORBA::is_nil(theObj))
570 CORBA::String_var IOR = myGeomGUI->getApp()->orb()->object_to_string(theObj);
571 TCollection_AsciiString asciiIOR((char *)(IOR.in()));
572 myGeomGUI->GetShapeReader().RemoveShapeFromBuffer(asciiIOR);
574 if (!getStudy() || !(getStudy()->studyDS()))
577 _PTR(Study) aStudy = getStudy()->studyDS();
578 _PTR(SObject) aSObj (aStudy->FindObjectIOR(std::string(IOR.in())));
582 _PTR(ChildIterator) anIt (aStudy->NewChildIterator(aSObj));
583 for (anIt->InitEx(true); anIt->More(); anIt->Next()) {
584 _PTR(GenericAttribute) anAttr;
585 if (anIt->Value()->FindAttribute(anAttr, "AttributeIOR")) {
586 _PTR(AttributeIOR) anIOR (anAttr);
587 TCollection_AsciiString asciiIOR((char*)anIOR->Value().c_str());
588 myGeomGUI->GetShapeReader().RemoveShapeFromBuffer(asciiIOR);
593 //================================================================
594 // Function : onAccept
595 // Purpose : This method should be called from dialog's slots onOk() and onApply()
596 // It performs user input validation, then it
597 // performs a proper operation and manages transactions, etc.
598 //================================================================
599 bool RepairGUI_GlueDlg::onAcceptLocal()
601 if (!getStudy() || !(getStudy()->studyDS()))
604 _PTR(Study) aStudy = getStudy()->studyDS();
606 bool aLocked = aStudy->GetProperties()->IsLocked();
608 MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
609 SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_STUDY_LOCKED"), tr("BUT_OK"));
621 SUIT_OverrideCursor wc;
623 myGeomGUI->getApp()->putInfo("");
626 if (!execute(objects)) {
632 const int nbObjs = objects.size();
633 for (ObjectList::iterator it = objects.begin(); it != objects.end(); ++it) {
634 QString aName = getNewObjectName();
637 aName = getPrefix(*it);
638 aName = GEOMBase::GetDefaultName(aName);
641 // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
643 aName = GEOMBase::GetDefaultName(getPrefix(*it));
645 addInStudy(*it, aName.toUtf8().data());
652 myGeomGUI->getApp()->putInfo(QObject::tr("GEOM_PRP_DONE"));
658 // JFA 28.12.2004 BEGIN // To enable warnings
659 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
660 if (!CORBA::is_nil(anOper) && !anOper->IsDone()) {
662 QString msgw = QObject::tr(anOper->GetErrorCode());
663 SUIT_MessageBox::warning(this, tr("WRN_WARNING"), msgw, tr("BUT_OK"));
665 // JFA 28.12.2004 END
669 catch(const SALOME::SALOME_Exception& e) {
670 SalomeApp_Tools::QtCatchCorbaException(e);
683 //=================================================================================
684 // function : onDetect
686 //=================================================================================
687 void RepairGUI_GlueDlg::onDetect()
696 buttonOk()->setEnabled(false);
697 buttonApply()->setEnabled(false);
698 globalSelection(GEOM_ALLSHAPES);
700 GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
701 objList->length( myObjects.count() );
702 for ( int i = 0; i < myObjects.count(); ++i )
703 objList[i] = myObjects[i].copy();
705 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
706 GEOM::ListOfGO_var aList;
707 if (myGlueMode == TopAbs_FACE)
708 aList = anOper->GetGlueFaces( objList, myTolEdt2->value());
709 else if (myGlueMode == TopAbs_EDGE)
710 aList = anOper->GetGlueEdges( objList, myTolEdt2->value());
712 for (int i = 0, n = aList->length(); i < n; i++)
713 myTmpObjs << GEOM::GeomObjPtr(aList[i].in());
715 if (!myTmpObjs.isEmpty()) {
716 if (myGlueMode == TopAbs_FACE)
717 msg = tr("FACES_FOR_GLUING_ARE_DETECTED").arg(myTmpObjs.count());
718 else if (myGlueMode == TopAbs_EDGE)
719 msg = tr("EDGES_FOR_GLUING_ARE_DETECTED").arg(myTmpObjs.count());
720 mySubShapesChk->setChecked(true);
723 if (myGlueMode == TopAbs_FACE)
724 msg = tr("THERE_ARE_NO_FACES_FOR_GLUING");
725 else if (myGlueMode == TopAbs_EDGE)
726 msg = tr("THERE_ARE_NO_EDGES_FOR_GLUING");
729 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
730 this, SLOT(SelectionIntoArgument())) ;
731 if ( myGlueMode == TopAbs_FACE )
732 SUIT_MessageBox::information(this, tr("GEOM_GLUE_FACES_DETECT_TITLE"), msg, tr("Close"));
734 SUIT_MessageBox::information(this, tr("GEOM_GLUE_EDGES_DETECT_TITLE"), msg, tr("Close"));
739 //=================================================================================
740 // function : activateSelection
741 // purpose : Redisplay preview and Activate selection
742 //=================================================================================
743 void RepairGUI_GlueDlg::activateSelection()
747 int anId = getConstructorId();
749 // Case of whole gluing
750 disconnect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
751 this, SLOT(SelectionIntoArgument()));
753 globalSelection(GEOM_ALLSHAPES);
754 if ( myObjects.isEmpty() )
755 SelectionIntoArgument();
757 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
758 this, SLOT(SelectionIntoArgument()));
761 // Second case of gluing
762 if (!mySubShapesChk->isChecked())
763 globalSelection(GEOM_ALLSHAPES);
765 displayPreview(true, true, false, false, 2/*line width*/, 1/*display mode*/, Quantity_NOC_RED);
766 disconnect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
767 this, SLOT(SelectionIntoArgument())) ;
768 globalSelection(GEOM_PREVIEW);
769 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
770 this, SLOT(SelectionIntoArgument())) ;
776 //=================================================================================
777 // function : updateButtonState
778 // purpose : Update button state
779 //=================================================================================
780 void RepairGUI_GlueDlg::updateButtonState()
782 int anId = getConstructorId();
783 bool hasMainObj = !myObjects.isEmpty();
785 buttonOk()->setEnabled(hasMainObj);
786 buttonApply()->setEnabled(hasMainObj);
790 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
791 SALOME_ListIO aSelList;
792 aSelMgr->selectedObjects(aSelList);
794 SALOME_ListIteratorOfListIO it (aSelList);
795 bool wasSelected = it.More() > 0;
796 bool wasDetected = !myTmpObjs.isEmpty();
797 buttonOk()->setEnabled(hasMainObj && wasDetected && wasSelected);
798 buttonApply()->setEnabled(hasMainObj && wasDetected && wasSelected);
799 mySubShapesChk->setEnabled(hasMainObj && wasDetected);
800 myDetectBtn->setEnabled(hasMainObj);
801 if (!hasMainObj || !wasDetected)
802 mySubShapesChk->setChecked(false);
806 //=================================================================================
807 // function : clearTemporary
808 // purpose : Remove temporary objects from engine
809 //=================================================================================
810 void RepairGUI_GlueDlg::clearTemporary()
815 //=================================================================================
816 // function : onTolerChanged
817 // purpose : Remove temporary objects from engine
818 //=================================================================================
819 void RepairGUI_GlueDlg::onTolerChanged(double /*theVal*/)
826 //=================================================================================
827 // function : onSubShapesChk
828 // purpose : Update selection mode
829 //=================================================================================
830 void RepairGUI_GlueDlg::onSubShapesChk()
832 if (!mySubShapesChk->isChecked())
838 //=================================================================================
839 // function : ClickOnCancel
840 // purpose : Remove temporary objects from engine and call method of base class
841 //=================================================================================
842 void RepairGUI_GlueDlg::ClickOnCancel()
845 GEOMBase_Skeleton::ClickOnCancel();
848 //=================================================================================
849 // function : getSourceObjects
850 // purpose : virtual method to get source objects
851 //=================================================================================
852 QList<GEOM::GeomObjPtr> RepairGUI_GlueDlg::getSourceObjects()
854 QList<GEOM::GeomObjPtr> res(myObjects);
855 for (int i = 0; i < myTmpObjs.count(); i++)