1 // Copyright (C) 2007-2015 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>
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>
49 #include <GEOMImpl_Types.hxx>
51 #include <TCollection_AsciiString.hxx>
53 #define DEFAULT_TOLERANCE_VALUE 1e-07
55 //=================================================================================
56 // class : RepairGUI_GlueDlg()
57 // purpose : Constructs a RepairGUI_GlueDlg which is a child of 'parent', with the
58 // name 'name' and widget flags set to 'f'.
59 // The dialog will by default be modeless, unless you set 'modal' to
60 // TRUE to construct a modal dialog.
61 //=================================================================================
62 RepairGUI_GlueDlg::RepairGUI_GlueDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
63 bool modal, TopAbs_ShapeEnum theGlueMode)
64 : GEOMBase_Skeleton(theGeometryGUI, parent, modal),
65 myCurrConstrId(-1), myGlueMode(theGlueMode)
67 QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
68 QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_FACES")));
69 QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_FACES2")));
70 QPixmap image3 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_EDGES")));
71 QPixmap image4 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GLUE_EDGES2")));
74 if (theGlueMode == TopAbs_FACE)
75 aTitle = tr("GEOM_GLUE_FACES_TITLE");
76 else if (theGlueMode == TopAbs_EDGE)
77 aTitle = tr("GEOM_GLUE_EDGES_TITLE");
78 setWindowTitle(aTitle);
80 /***************************************************************/
81 mainFrame()->GroupConstructors->setTitle(aTitle);
82 if (theGlueMode == TopAbs_FACE) {
83 mainFrame()->RadioButton1->setIcon(image1);
84 mainFrame()->RadioButton2->setIcon(image2);
86 else if (theGlueMode == TopAbs_EDGE) {
87 mainFrame()->RadioButton1->setIcon(image3);
88 mainFrame()->RadioButton2->setIcon(image4);
90 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
91 mainFrame()->RadioButton3->close();
93 GroupPoints = new DlgRef_1SelExt(centralWidget());
94 GroupPoints->GroupBox1->setTitle(tr("GEOM_GLUE"));
95 GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPES"));
96 GroupPoints->PushButton1->setIcon(image0);
97 GroupPoints->LineEdit1->setReadOnly(true);
99 QLabel* aTolLab = new QLabel(tr("GEOM_TOLERANCE"), GroupPoints->Box);
100 myTolEdt = new SalomeApp_DoubleSpinBox(GroupPoints->Box);
101 initSpinBox(myTolEdt, 0., 100., DEFAULT_TOLERANCE_VALUE, "len_tol_precision");
102 myTolEdt->setValue(DEFAULT_TOLERANCE_VALUE);
104 QGridLayout* boxLayout = new QGridLayout(GroupPoints->Box);
105 boxLayout->setMargin(0); boxLayout->setSpacing(6);
106 boxLayout->addWidget(aTolLab, 0, 0);
107 boxLayout->addWidget(myTolEdt, 0, 2);
108 /***************************************************************/
110 GroupPoints2 = new DlgRef_1SelExt(centralWidget());
111 GroupPoints2->GroupBox1->setTitle(tr("GEOM_GLUE"));
112 GroupPoints2->TextLabel1->setText(tr("GEOM_SELECTED_SHAPES"));
113 GroupPoints2->PushButton1->setIcon(image0);
114 GroupPoints2->LineEdit1->setReadOnly(true);
116 QLabel* aTolLab2 = new QLabel(tr("GEOM_TOLERANCE"), GroupPoints2->Box);
117 myTolEdt2 = new SalomeApp_DoubleSpinBox(GroupPoints2->Box);
118 initSpinBox(myTolEdt2, 0., 100., DEFAULT_TOLERANCE_VALUE, "len_tol_precision");
119 myTolEdt2->setValue(DEFAULT_TOLERANCE_VALUE);
121 QString aGlueString (" [%1]");
123 if (theGlueMode == TopAbs_FACE) {
124 aGlueString = aGlueString.arg(tr("GLUE_FACES"));
125 aSelString = tr("SELECT_FACES");
127 else if (theGlueMode == TopAbs_EDGE) {
128 aGlueString = aGlueString.arg(tr("GLUE_EDGES"));
129 aSelString = tr("SELECT_EDGES");
131 myDetectBtn = new QPushButton (tr("GEOM_DETECT") + aGlueString, GroupPoints2->Box);
132 mySubShapesChk = new QCheckBox (aSelString, GroupPoints2->Box);
133 myGlueAllEdgesChk = 0;
135 boxLayout = new QGridLayout(GroupPoints2->Box);
136 boxLayout->setMargin(0); boxLayout->setSpacing(6);
137 boxLayout->addWidget(aTolLab2, 0, 0);
138 boxLayout->addWidget(myTolEdt2, 0, 2);
139 boxLayout->addWidget(myDetectBtn, 1, 0, 1, 3);
140 boxLayout->addWidget(mySubShapesChk, 2, 0, 1, 3);
142 if (theGlueMode == TopAbs_FACE) {
143 myGlueAllEdgesChk = new QCheckBox (tr("GLUE_ALL_EDGES"), GroupPoints2->Box);
144 boxLayout->addWidget(myGlueAllEdgesChk, 3, 0, 1, 3);
145 myGlueAllEdgesChk->setChecked(false);
148 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
149 layout->setMargin(0); layout->setSpacing(6);
150 layout->addWidget(GroupPoints);
151 layout->addWidget(GroupPoints2);
153 /***************************************************************/
155 QString aHelpFileName;
156 switch ( myGlueMode ) {
159 aHelpFileName = "glue_edges_operation_page.html";
164 aHelpFileName = "glue_faces_operation_page.html";
168 setHelpFileName(aHelpFileName);
170 // Disable second way of gluing if OCC viewer is not active one
171 if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
172 != OCCViewer_Viewer::Type())
173 mainFrame()->RadioButton2->setEnabled(false);
178 //=================================================================================
179 // function : ~RepairGUI_GlueDlg()
180 // purpose : Destroys the object and frees any allocated resources
181 //=================================================================================
182 RepairGUI_GlueDlg::~RepairGUI_GlueDlg()
186 //=================================================================================
189 //=================================================================================
190 void RepairGUI_GlueDlg::Init()
193 myEditCurrentArgument = GroupPoints->LineEdit1;
197 //myGeomGUI->SetState(0);
198 //globalSelection(GEOM_COMPOUND);
200 mainFrame()->GroupBoxPublish->show();
201 //Hide preview checkbox
202 mainFrame()->CheckBoxPreview->hide();
204 /* signals and slots connections */
205 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
206 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
208 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
210 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
211 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
213 connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
214 connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
215 connect(myTolEdt2, SIGNAL(valueChanged(double)), this, SLOT(onTolerChanged(double)));
216 connect(mySubShapesChk, SIGNAL(stateChanged(int)), this, SLOT(onSubShapesChk()));
218 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
219 this, SLOT(SelectionIntoArgument()));
221 connect(myDetectBtn, SIGNAL(clicked()), this, SLOT(onDetect()));
223 initName(tr("GLUE_NEW_OBJ_NAME"));
225 ConstructorsClicked(0);
231 //=================================================================================
232 // function : ConstructorsClicked()
233 // purpose : Radio button management
234 //=================================================================================
235 void RepairGUI_GlueDlg::ConstructorsClicked(int constructorId)
237 if (myCurrConstrId == constructorId)
240 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
242 switch (constructorId) {
244 GroupPoints2->hide();
246 GroupPoints->LineEdit1->setText("");
247 myEditCurrentArgument = GroupPoints->LineEdit1;
249 if (myCurrConstrId >= 0) {
250 // i.e. it is not initialisation
251 // copy tolerance from previous tolerance field
252 myTolEdt->setValue(myTolEdt2->value());
257 GroupPoints2->show();
258 GroupPoints->LineEdit1->setText("");
259 myEditCurrentArgument = GroupPoints2->LineEdit1;
261 if (myCurrConstrId >= 0) {
262 // i.e. it is not initialisation
263 // copy tolerance from previous tolerance field
264 myTolEdt2->setValue(myTolEdt->value());
265 mySubShapesChk->setChecked(false);
271 myCurrConstrId = constructorId;
273 myEditCurrentArgument->setFocus();
275 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
276 this, SLOT(SelectionIntoArgument()));
278 qApp->processEvents();
280 resize(minimumSizeHint());
285 SelectionIntoArgument();
288 //=================================================================================
289 // function : ClickOnOk()
290 // purpose : Same than click on apply but close this dialog.
291 //=================================================================================
292 void RepairGUI_GlueDlg::ClickOnOk()
294 setIsApplyAndClose(true);
299 //=================================================================================
300 // function : ClickOnApply()
302 //=================================================================================
303 bool RepairGUI_GlueDlg::ClickOnApply()
305 if (!onAcceptLocal())
310 //GroupPoints->LineEdit1->setText("");
311 //myObject = GEOM::GEOM_Object::_nil();
313 //globalSelection(GEOM_COMPOUND);
315 ConstructorsClicked(getConstructorId());
321 //=================================================================================
322 // function : SelectionIntoArgument()
323 // purpose : Called when selection
324 //=================================================================================
325 void RepairGUI_GlueDlg::SelectionIntoArgument()
327 if (mySubShapesChk->isChecked() && getConstructorId() == 1) {
333 myEditCurrentArgument->setText("");
336 myObjects = getSelected( TopAbs_SHAPE, -1 );
338 if ( !myObjects.isEmpty() ) {
339 QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
340 myEditCurrentArgument->setText( aName );
345 //=================================================================================
346 // function : SetEditCurrentArgument()
348 //=================================================================================
349 void RepairGUI_GlueDlg::SetEditCurrentArgument()
351 const QObject* send = sender();
352 if (send == GroupPoints->PushButton1 || send == GroupPoints2->PushButton1) {
353 myEditCurrentArgument->setFocus();
354 SelectionIntoArgument();
358 //=================================================================================
359 // function : LineEditReturnPressed()
361 //=================================================================================
362 void RepairGUI_GlueDlg::LineEditReturnPressed()
364 const QObject* send = sender();
365 if (send == GroupPoints->LineEdit1) {
366 myEditCurrentArgument = GroupPoints->LineEdit1;
367 GEOMBase_Skeleton::LineEditReturnPressed();
369 else if (send == GroupPoints2->LineEdit1) {
370 myEditCurrentArgument = GroupPoints2->LineEdit1;
371 GEOMBase_Skeleton::LineEditReturnPressed();
375 //=================================================================================
376 // function : ActivateThisDialog()
378 //=================================================================================
379 void RepairGUI_GlueDlg::ActivateThisDialog()
381 GEOMBase_Skeleton::ActivateThisDialog();
382 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
383 this, SLOT(SelectionIntoArgument()));
385 //GroupPoints->LineEdit1->setText("");
386 //GroupPoints2->LineEdit1->setText("");
387 //myObject = GEOM::GEOM_Object::_nil();
389 //myGeomGUI->SetState(0);
390 //globalSelection(GEOM_COMPOUND);
394 //=================================================================================
395 // function : enterEvent()
396 // purpose : Mouse enter onto the dialog to activate it
397 //=================================================================================
398 void RepairGUI_GlueDlg::enterEvent(QEvent*)
400 if (!mainFrame()->GroupConstructors->isEnabled())
401 ActivateThisDialog();
404 //=================================================================================
405 // function : createOperation
407 //=================================================================================
408 GEOM::GEOM_IOperations_ptr RepairGUI_GlueDlg::createOperation()
410 return getGeomEngine()->GetIShapesOperations(getStudyId());
413 //=================================================================================
414 // function : isValid
416 //=================================================================================
417 bool RepairGUI_GlueDlg::isValid(QString& msg)
421 switch (getConstructorId())
424 v = myTolEdt->value();
425 ok = myTolEdt->isValid(msg, !IsPreview());
428 v = myTolEdt2->value();
429 ok = myTolEdt2->isValid(msg, !IsPreview());
432 return !myObjects.isEmpty() && (IsPreview() || v > 0.) && ok;
435 //=================================================================================
436 // function : execute
438 //=================================================================================
439 bool RepairGUI_GlueDlg::execute(ObjectList& objects)
441 bool aResult = false;
444 GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
445 objList->length( myObjects.count() );
446 for ( int i = 0; i < myObjects.count(); ++i )
447 objList[i] = myObjects[i].copy();
449 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
450 switch (getConstructorId()) {
453 GEOM::GEOM_Object_var anObj;
454 if (myGlueMode == TopAbs_FACE)
455 anObj = anOper->MakeGlueFaces( objList, myTolEdt->value(), true);
456 else if (myGlueMode == TopAbs_EDGE)
457 anObj = anOper->MakeGlueEdges( objList, myTolEdt->value());
459 aResult = !anObj->_is_nil();
460 if (aResult && !IsPreview())
462 QStringList aParameters;
463 aParameters << myTolEdt->text();
464 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
466 objects.push_back(anObj._retn());
473 // if this method is used for displaying preview then we must detect glue faces/edges only
474 for (int i = 0; i < myTmpObjs.count(); i++) {
475 myTmpObjs[i].get()->Register(); // increment counter, since calling function will call UnRegister()
476 objects.push_back(myTmpObjs[i].copy());
478 return !myTmpObjs.isEmpty();
481 // Make glue faces/edges by list.
482 // Iterate through myTmpObjs and verifies where each object is currently selected or not.
483 QSet<QString> selected;
485 // Get names of selected objects
486 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
487 SALOME_ListIO aSelList;
488 aSelMgr->selectedObjects(aSelList);
490 SALOME_ListIteratorOfListIO it (aSelList);
491 for (; it.More(); it.Next())
492 selected.insert(it.Value()->getName());
494 // Iterate through result and select objects with names from selection
495 // ObjectList toRemoveFromEnggine;
497 // make glue faces/edges
498 GEOM::ListOfGO_var aListForGlue = new GEOM::ListOfGO();
499 aListForGlue->length(myTmpObjs.count());
501 for (int i = 0; i < myTmpObjs.count(); i++) {
502 CORBA::String_var tmpior = myGeomGUI->getApp()->orb()->object_to_string(myTmpObjs[i].get());
503 if (selected.contains(tmpior.in()))
504 aListForGlue[ added++ ] = myTmpObjs[i].copy();
506 aListForGlue->length(added);
508 GEOM::GEOM_Object_var anObj;
509 if (myGlueMode == TopAbs_FACE) {
510 bool doGlueAllEdges = myGlueAllEdgesChk->isChecked();
511 anObj = anOper->MakeGlueFacesByList( objList, myTolEdt2->value(), aListForGlue.in(),
512 true, doGlueAllEdges);
514 else if (myGlueMode == TopAbs_EDGE)
515 anObj = anOper->MakeGlueEdgesByList( objList, myTolEdt2->value(), aListForGlue.in());
517 aResult = !anObj->_is_nil();
521 QStringList aParameters;
522 aParameters << myTolEdt2->text();
523 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
525 objects.push_back(anObj._retn());
528 // Remove from engine useless objects
540 //=================================================================================
541 // function : restoreSubShapes
543 //=================================================================================
544 void RepairGUI_GlueDlg::restoreSubShapes(SALOMEDS::Study_ptr theStudy,
545 SALOMEDS::SObject_ptr theSObject)
547 if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
548 GEOM::find_shape_method aFindMethod = GEOM::FSM_GetInPlace;
549 if (getConstructorId() == 0) // MakeGlueFaces or MakeGlueEdges
550 aFindMethod = GEOM::FSM_GetInPlaceByHistory;
552 // empty list of arguments means that all arguments should be restored
553 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
554 aFindMethod, /*theInheritFirstArg=*/true,
555 mainFrame()->CheckBoxAddPrefix->isChecked());
559 //================================================================
560 // Function : clearShapeBufferLocal
562 //================================================================
563 void RepairGUI_GlueDlg::clearShapeBufferLocal(GEOM::GEOM_Object_ptr theObj)
565 if (CORBA::is_nil(theObj))
568 CORBA::String_var IOR = myGeomGUI->getApp()->orb()->object_to_string(theObj);
569 TCollection_AsciiString asciiIOR((char *)(IOR.in()));
570 myGeomGUI->GetShapeReader().RemoveShapeFromBuffer(asciiIOR);
572 if (!getStudy() || !(getStudy()->studyDS()))
575 _PTR(Study) aStudy = getStudy()->studyDS();
576 _PTR(SObject) aSObj (aStudy->FindObjectIOR(std::string(IOR.in())));
580 _PTR(ChildIterator) anIt (aStudy->NewChildIterator(aSObj));
581 for (anIt->InitEx(true); anIt->More(); anIt->Next()) {
582 _PTR(GenericAttribute) anAttr;
583 if (anIt->Value()->FindAttribute(anAttr, "AttributeIOR")) {
584 _PTR(AttributeIOR) anIOR (anAttr);
585 TCollection_AsciiString asciiIOR((char*)anIOR->Value().c_str());
586 myGeomGUI->GetShapeReader().RemoveShapeFromBuffer(asciiIOR);
591 //================================================================
592 // Function : onAccept
593 // Purpose : This method should be called from dialog's slots onOk() and onApply()
594 // It perfroms user input validation, then it
595 // performs a proper operation and manages transactions, etc.
596 //================================================================
597 bool RepairGUI_GlueDlg::onAcceptLocal()
599 if (!getStudy() || !(getStudy()->studyDS()))
602 _PTR(Study) aStudy = getStudy()->studyDS();
604 bool aLocked = aStudy->GetProperties()->IsLocked();
606 MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
607 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.toLatin1().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);
681 //=================================================================================
682 // function : onDetect
684 //=================================================================================
685 void RepairGUI_GlueDlg::onDetect()
694 buttonOk()->setEnabled(false);
695 buttonApply()->setEnabled(false);
696 globalSelection(GEOM_ALLSHAPES);
698 GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
699 objList->length( myObjects.count() );
700 for ( int i = 0; i < myObjects.count(); ++i )
701 objList[i] = myObjects[i].copy();
703 GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
704 GEOM::ListOfGO_var aList;
705 if (myGlueMode == TopAbs_FACE)
706 aList = anOper->GetGlueFaces( objList, myTolEdt2->value());
707 else if (myGlueMode == TopAbs_EDGE)
708 aList = anOper->GetGlueEdges( objList, myTolEdt2->value());
710 for (int i = 0, n = aList->length(); i < n; i++)
711 myTmpObjs << GEOM::GeomObjPtr(aList[i].in());
713 if (!myTmpObjs.isEmpty()) {
714 if (myGlueMode == TopAbs_FACE)
715 msg = tr("FACES_FOR_GLUING_ARE_DETECTED").arg(myTmpObjs.count());
716 else if (myGlueMode == TopAbs_EDGE)
717 msg = tr("EDGES_FOR_GLUING_ARE_DETECTED").arg(myTmpObjs.count());
718 mySubShapesChk->setChecked(true);
721 if (myGlueMode == TopAbs_FACE)
722 msg = tr("THERE_ARE_NO_FACES_FOR_GLUING");
723 else if (myGlueMode == TopAbs_EDGE)
724 msg = tr("THERE_ARE_NO_EDGES_FOR_GLUING");
727 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
728 this, SLOT(SelectionIntoArgument())) ;
729 if ( myGlueMode == TopAbs_FACE )
730 SUIT_MessageBox::information(this, tr("GEOM_GLUE_FACES_DETECT_TITLE"), msg, tr("Close"));
732 SUIT_MessageBox::information(this, tr("GEOM_GLUE_EDGES_DETECT_TITLE"), msg, tr("Close"));
737 //=================================================================================
738 // function : activateSelection
739 // purpose : Redisplay preview and Activate selection
740 //=================================================================================
741 void RepairGUI_GlueDlg::activateSelection()
745 int anId = getConstructorId();
747 // Case of whole gluing
748 disconnect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
749 this, SLOT(SelectionIntoArgument()));
751 globalSelection(GEOM_ALLSHAPES);
752 if ( myObjects.isEmpty() )
753 SelectionIntoArgument();
755 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
756 this, SLOT(SelectionIntoArgument()));
759 // Second case of gluing
760 if (!mySubShapesChk->isChecked())
761 globalSelection(GEOM_ALLSHAPES);
763 displayPreview(true, true, false, false, 2/*line width*/, 1/*display mode*/, Quantity_NOC_RED);
764 disconnect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
765 this, SLOT(SelectionIntoArgument())) ;
766 globalSelection(GEOM_PREVIEW);
767 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
768 this, SLOT(SelectionIntoArgument())) ;
774 //=================================================================================
775 // function : updateButtonState
776 // purpose : Update button state
777 //=================================================================================
778 void RepairGUI_GlueDlg::updateButtonState()
780 int anId = getConstructorId();
781 bool hasMainObj = !myObjects.isEmpty();
783 buttonOk()->setEnabled(hasMainObj);
784 buttonApply()->setEnabled(hasMainObj);
788 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
789 SALOME_ListIO aSelList;
790 aSelMgr->selectedObjects(aSelList);
792 SALOME_ListIteratorOfListIO it (aSelList);
793 bool wasSelected = it.More() > 0;
794 bool wasDetected = !myTmpObjs.isEmpty();
795 buttonOk()->setEnabled(hasMainObj && wasDetected && wasSelected);
796 buttonApply()->setEnabled(hasMainObj && wasDetected && wasSelected);
797 mySubShapesChk->setEnabled(hasMainObj && wasDetected);
798 myDetectBtn->setEnabled(hasMainObj);
799 if (!hasMainObj || !wasDetected)
800 mySubShapesChk->setChecked(false);
804 //=================================================================================
805 // function : clearTemporary
806 // purpose : Remove temporary objects from engine
807 //=================================================================================
808 void RepairGUI_GlueDlg::clearTemporary()
813 //=================================================================================
814 // function : onTolerChanged
815 // purpose : Remove temporary objects from engine
816 //=================================================================================
817 void RepairGUI_GlueDlg::onTolerChanged(double /*theVal*/)
824 //=================================================================================
825 // function : onSubShapesChk
826 // purpose : Update selection mode
827 //=================================================================================
828 void RepairGUI_GlueDlg::onSubShapesChk()
830 if (!mySubShapesChk->isChecked())
836 //=================================================================================
837 // function : ClickOnCancel
838 // purpose : Remove temporary objects from engine and call method of base class
839 //=================================================================================
840 void RepairGUI_GlueDlg::ClickOnCancel()
843 GEOMBase_Skeleton::ClickOnCancel();