Salome HOME
#19765 EDF 21730 - long time to load med file file with huge amount of groups
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_BuildCompoundDlg.cxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SMESHGUI_BuildCompoundDlg.cxx
23 //  Author : Alexander KOVALEV, Open CASCADE S.A.S.
24 //  SMESH includes
25
26 #include "SMESHGUI_BuildCompoundDlg.h"
27
28 #include "SMESHGUI.h"
29 #include "SMESHGUI_Utils.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_VTKUtils.h"
32
33 #include <SMESH_TypeFilter.hxx>
34
35 // SALOME GUI includes
36 #include <SUIT_Desktop.h>
37 #include <SUIT_Session.h>
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_ResourceMgr.h>
40 #include <SalomeApp_Study.h>
41 #include <SUIT_OverrideCursor.h>
42
43 #include <LightApp_Application.h>
44 #include <LightApp_SelectionMgr.h>
45 #include <SALOME_ListIO.hxx>
46
47 // Qt includes
48 #include <QApplication>
49 #include <QGroupBox>
50 #include <QLabel>
51 #include <QLineEdit>
52 #include <QPushButton>
53 #include <QRadioButton>
54 #include <QHBoxLayout>
55 #include <QVBoxLayout>
56 #include <QGridLayout>
57 #include <QCheckBox>
58 #include <QComboBox>
59 #include <QKeyEvent>
60 #include <QButtonGroup>
61
62 // STL includes
63 #include <set>
64
65 #define SPACING 6
66 #define MARGIN  11
67
68 enum { NEW_MESH_ID, APPEND_TO_ID };
69
70 //=================================================================================
71 // name    : SMESHGUI_BuildCompoundDlg
72 // Purpose :
73 //=================================================================================
74 SMESHGUI_BuildCompoundDlg::SMESHGUI_BuildCompoundDlg( SMESHGUI* theModule )
75   : QDialog(SMESH::GetDesktop(theModule)),
76     mySMESHGUI(theModule),
77     mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
78     myIsApplyAndClose( false )
79 {
80   setModal(false);
81   setAttribute(Qt::WA_DeleteOnClose, true);
82   setWindowTitle(tr("SMESH_BUILD_COMPOUND_TITLE"));
83
84   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
85   QPixmap image0 (aResMgr->loadPixmap("SMESH", tr("ICON_DLG_BUILD_COMPOUND_MESH")));
86   QPixmap image1 (aResMgr->loadPixmap("SMESH", tr("ICON_SELECT")));
87
88   setSizeGripEnabled(true);
89
90   QVBoxLayout* aTopLayout = new QVBoxLayout(this);
91   aTopLayout->setSpacing(SPACING);
92   aTopLayout->setMargin(MARGIN);
93
94   /***************************************************************/
95   GroupConstructors = new QGroupBox(tr("COMPOUND"), this);
96   QButtonGroup* ButtonGroup = new QButtonGroup(this);
97   QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
98   GroupConstructorsLayout->setSpacing(SPACING);
99   GroupConstructorsLayout->setMargin(MARGIN);
100
101   Constructor1 = new QRadioButton(GroupConstructors);
102   Constructor1->setIcon(image0);
103   Constructor1->setChecked(true);
104   GroupConstructorsLayout->addWidget(Constructor1);
105   ButtonGroup->addButton(Constructor1, 0);
106
107   /***************************************************************/
108   GroupResult = new QGroupBox(tr("RESULT_NAME"), this);
109   QGridLayout* GroupResultLayout = new QGridLayout(GroupResult);
110   GroupResultLayout->setSpacing(SPACING);
111   GroupResultLayout->setMargin(MARGIN);
112
113   QRadioButton* newMeshRadioBtn = new QRadioButton( tr("NEW_MESH_NAME"), GroupResult );
114   QRadioButton* appendToRadioBtn = new QRadioButton( tr("MESH_APPEND_TO"), GroupResult );
115   LineEditNewName = new QLineEdit(GroupResult);
116   LineEditAppendTo = new QLineEdit(GroupResult);
117   SelectButtonAppendTo = new QPushButton(GroupResult);
118   SelectButtonAppendTo->setIcon(image1);
119   SelectButtonAppendTo->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
120   ResultButtonGroup = new QButtonGroup( GroupResult );
121   ResultButtonGroup->addButton( newMeshRadioBtn,  NEW_MESH_ID );
122   ResultButtonGroup->addButton( appendToRadioBtn, APPEND_TO_ID );
123   newMeshRadioBtn->setChecked( true );
124
125   GroupResultLayout->addWidget( newMeshRadioBtn,      0, 0, 1, 2 );
126   GroupResultLayout->addWidget( LineEditNewName,      0, 2 );
127   GroupResultLayout->addWidget( appendToRadioBtn,     1, 0 );
128   GroupResultLayout->addWidget( SelectButtonAppendTo, 1, 1 );
129   GroupResultLayout->addWidget( LineEditAppendTo,     1, 2 );
130
131   /***************************************************************/
132   GroupArgs = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
133   QGridLayout* GroupArgsLayout = new QGridLayout(GroupArgs);
134   GroupArgsLayout->setSpacing(SPACING);
135   GroupArgsLayout->setMargin(MARGIN);
136
137   TextLabelMeshes = new QLabel(tr("MESHES"), GroupArgs);
138   SelectButton = new QPushButton(GroupArgs);
139   SelectButton->setIcon(image1);
140   SelectButton->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
141   LineEditMeshes = new QLineEdit(GroupArgs);
142   LineEditMeshes->setReadOnly(true);
143
144   TextLabelUnion = new QLabel(tr("PROCESSING_IDENTICAL_GROUPS"), GroupArgs);
145   ComboBoxUnion = new QComboBox(GroupArgs);
146
147   CheckBoxCommon = new QCheckBox(tr("CREATE_COMMON_GROUPS"), GroupArgs);
148
149   CheckBoxMerge = new QCheckBox(tr("MERGE_NODES_AND_ELEMENTS"), GroupArgs);
150
151   TextLabelTol = new QLabel(tr("SMESH_TOLERANCE"), GroupArgs);
152   //TextLabelTol->setAlignment(Qt::AlignCenter);
153   SpinBoxTol = new SMESHGUI_SpinBox(GroupArgs);
154   SpinBoxTol->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision" );
155
156   GroupArgsLayout->addWidget(TextLabelMeshes, 0, 0);
157   GroupArgsLayout->addWidget(SelectButton,    0, 1);
158   GroupArgsLayout->addWidget(LineEditMeshes,  0, 2, 1, 2);
159   GroupArgsLayout->addWidget(TextLabelUnion,  1, 0, 1, 3);
160   GroupArgsLayout->addWidget(ComboBoxUnion,   1, 3);
161   GroupArgsLayout->addWidget(CheckBoxCommon,  2, 0, 1, 4);
162   GroupArgsLayout->addWidget(CheckBoxMerge,   3, 0, 1, 4);
163   GroupArgsLayout->addWidget(TextLabelTol,    4, 0);
164   GroupArgsLayout->addWidget(SpinBoxTol,      4, 1, 1, 3);
165
166   /***************************************************************/
167   GroupButtons = new QGroupBox(this);
168   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
169   GroupButtonsLayout->setSpacing(SPACING);
170   GroupButtonsLayout->setMargin(MARGIN);
171
172   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
173   buttonOk->setAutoDefault(true);
174   buttonOk->setDefault(true);
175   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
176   buttonApply->setAutoDefault(true);
177   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
178   buttonCancel->setAutoDefault(true);
179   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
180   buttonHelp->setAutoDefault(true);
181
182   GroupButtonsLayout->addWidget(buttonOk);
183   GroupButtonsLayout->addSpacing(10);
184   GroupButtonsLayout->addWidget(buttonApply);
185   GroupButtonsLayout->addSpacing(10);
186   GroupButtonsLayout->addStretch();
187   GroupButtonsLayout->addWidget(buttonCancel);
188   GroupButtonsLayout->addWidget(buttonHelp);
189
190   /***************************************************************/
191   aTopLayout->addWidget(GroupConstructors);
192   aTopLayout->addWidget(GroupResult);
193   aTopLayout->addWidget(GroupArgs);
194   aTopLayout->addWidget(GroupButtons);
195
196   myHelpFileName = "building_compounds.html";
197
198   Init(); // Initialisations
199 }
200
201 //=================================================================================
202 // function : ~SMESHGUI_BuildCompoundDlg()
203 // purpose  : Destroys the object and frees any allocated resources
204 //=================================================================================
205 SMESHGUI_BuildCompoundDlg::~SMESHGUI_BuildCompoundDlg()
206 {
207 }
208
209 //=================================================================================
210 // function : Init()
211 // purpose  :
212 //=================================================================================
213 void SMESHGUI_BuildCompoundDlg::Init()
214 {
215   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
216
217   myMeshToAppendTo = SMESH::SMESH_Mesh::_nil();
218   myMeshArray      = new SMESH::ListOfIDSources();
219
220   myMeshFilter     = new SMESH_TypeFilter (SMESH::IDSOURCE);
221   myAppendToFilter = new SMESH_TypeFilter (SMESH::MESH);
222
223   // signals and slots connections
224   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
225   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
226   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
227   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
228
229   connect(ResultButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(onResultTypeChange(int)));
230
231   connect(SelectButtonAppendTo, SIGNAL(clicked()), this, SLOT(onSelectionButton()));
232   connect(SelectButton, SIGNAL(clicked()), this, SLOT(onSelectionButton()));
233
234   connect(CheckBoxMerge, SIGNAL(toggled(bool)), this, SLOT(onSelectMerge(bool)));
235
236   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
237
238   connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
239   connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()),        this, SLOT(reject()));
240
241   LineEditNewName->setText(GetDefaultName(tr("COMPOUND_MESH")));
242
243   ComboBoxUnion->addItem(tr("UNITE"));
244   ComboBoxUnion->addItem(tr("RENAME"));
245   ComboBoxUnion->setCurrentIndex(0);
246
247   CheckBoxMerge->setChecked(true);
248
249   TextLabelTol->setEnabled(CheckBoxMerge->isChecked());
250   SpinBoxTol->SetValue(1e-05);
251
252   SpinBoxTol->setEnabled(CheckBoxMerge->isChecked());
253
254   onResultTypeChange( ResultButtonGroup->checkedId() );
255
256   onSelectionButton();
257 }
258
259 //=================================================================================
260 // function : GetDefaultName()
261 // purpose  :
262 //=================================================================================
263 QString SMESHGUI_BuildCompoundDlg::GetDefaultName(const QString& theOperation)
264 {
265   QString aName = "";
266
267   // collect all object names of SMESH component
268   _PTR(Study) aStudy = SMESH::getStudy();
269
270   std::set<std::string> aSet;
271   _PTR(SComponent) aMeshCompo (aStudy->FindComponent("SMESH"));
272   if (aMeshCompo) {
273     _PTR(ChildIterator) it (aStudy->NewChildIterator(aMeshCompo));
274     _PTR(SObject) obj;
275     for (it->InitEx(true); it->More(); it->Next()) {
276       obj = it->Value();
277       aSet.insert(obj->GetName());
278     }
279   }
280
281   // build a unique name
282   int aNumber = 0;
283   bool isUnique = false;
284   while (!isUnique) {
285     aName = theOperation + "_" + QString::number(++aNumber);
286     isUnique = (aSet.count(aName.toUtf8().data()) == 0);
287   }
288
289   return aName;
290 }
291
292 //=================================================================================
293 // function : ClickOnApply()
294 // purpose  :
295 //=================================================================================
296 bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
297 {
298   if (SMESHGUI::isStudyLocked())
299     return false;
300
301   if (!isValid())
302     return false;
303
304   SUIT_OverrideCursor aWaitCursor;
305
306   SMESH::SMESH_Mesh_var aMesh;
307
308   int nbMeshes = myMeshArray->length() + ( !myMeshToAppendTo->_is_nil() );
309
310   if ( nbMeshes > 1 )
311   {
312     QStringList aParameters;
313     aParameters << (CheckBoxMerge->isChecked() ? SpinBoxTol->text() : QString(" "));
314
315     QStringList anEntryList;
316     try {
317
318       aMesh = myMeshArray[0]->GetMesh();
319       aMesh->SetParameters( aParameters.join(":").toUtf8().constData() );
320
321       SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
322       // concatenate meshes
323       if(CheckBoxCommon->isChecked())
324         aMesh = aSMESHGen->ConcatenateWithGroups(myMeshArray,
325                                                  !(ComboBoxUnion->currentIndex()),
326                                                  CheckBoxMerge->isChecked(),
327                                                  SpinBoxTol->GetValue(),
328                                                  myMeshToAppendTo);
329       else
330         aMesh = aSMESHGen->Concatenate(myMeshArray,
331                                        !(ComboBoxUnion->currentIndex()),
332                                        CheckBoxMerge->isChecked(),
333                                        SpinBoxTol->GetValue(),
334                                        myMeshToAppendTo);
335
336       _PTR(SObject) aSO = SMESH::FindSObject( aMesh );
337       if( aSO ) {
338         if ( myMeshToAppendTo->_is_nil() )
339           SMESH::SetName( aSO, LineEditNewName->text() );
340         anEntryList.append( aSO->GetID().c_str() );
341       }
342       mySMESHGUI->updateObjBrowser();
343     } catch(...) {
344       return false;
345     }
346
347     LineEditNewName->setText(GetDefaultName(tr("COMPOUND_MESH")));
348
349     // IPAL21468 Compound is hidden after creation.
350     if ( SMESHGUI::automaticUpdate() ) {
351       mySelectionMgr->clearSelected();
352       SMESH::UpdateView();
353
354       _PTR(SObject) aSO = SMESH::FindSObject(aMesh.in());
355       if ( SMESH_Actor* anActor = SMESH::CreateActor( aSO->GetID().c_str()) ) {
356         SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor);
357         SMESH::UpdateView();
358       }
359     }// end IPAL21468
360
361     if( LightApp_Application* anApp =
362         dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
363       anApp->browseObjects( anEntryList, isApplyAndClose() );
364
365     SMESHGUI::Modified();
366
367     return true;
368   }
369   return false;
370 }
371
372 //=================================================================================
373 // function : ClickOnOk()
374 // purpose  :
375 //=================================================================================
376 void SMESHGUI_BuildCompoundDlg::ClickOnOk()
377 {
378   setIsApplyAndClose( true );
379   if (ClickOnApply())
380     reject();
381 }
382
383 //=================================================================================
384 // function : reject()
385 // purpose  :
386 //=================================================================================
387 void SMESHGUI_BuildCompoundDlg::reject()
388 {
389   //mySelectionMgr->clearSelected();
390   mySelectionMgr->clearFilters();
391   disconnect(mySelectionMgr, 0, this, 0);
392   mySMESHGUI->ResetState();
393   QDialog::reject();
394 }
395
396 //=================================================================================
397 // function : ClickOnHelp()
398 // purpose  :
399 //=================================================================================
400 void SMESHGUI_BuildCompoundDlg::ClickOnHelp()
401 {
402   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
403   if (app)
404     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
405   else {
406     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
407                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
408                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
409                                                                  "application")).
410                              arg(myHelpFileName));
411   }
412 }
413
414 //=================================================================================
415 // function : SelectionIntoArgument()
416 // purpose  : Called when selection as changed or other case
417 //=================================================================================
418 void SMESHGUI_BuildCompoundDlg::SelectionIntoArgument()
419 {
420   if (!GroupButtons->isEnabled()) // inactive
421     return;
422
423   QString aString = "";
424   SALOME_ListIO aList;
425
426   mySelectionMgr->selectedObjects(aList);
427   int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
428
429   bool toAppend = ( CurrentLineEdit == LineEditAppendTo );
430   bool     isOk = toAppend ? ( nbSel == 1 ) : ( nbSel > 0 );
431   if ( !isOk )
432     aString = "";
433
434   if ( toAppend )
435   {
436     myMeshToAppendTo = SMESH::SMESH_Mesh::_nil();
437     if ( isOk )
438       myMeshToAppendTo = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( aList.First() );
439   }
440   else
441   {
442     myMeshArray->length( nbSel );
443     for ( int i = 0; !aList.IsEmpty(); i++ ) {
444       myMeshArray[i] = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(aList.First());
445       aList.RemoveFirst();
446     }
447   }
448   CurrentLineEdit->setText(aString);
449
450   bool isEnabled;
451   if ( ResultButtonGroup->checkedId() == NEW_MESH_ID )
452     isEnabled = ( myMeshArray->length() > 1 );
453   else
454     isEnabled = ( myMeshArray->length() > 0 &&
455                   !myMeshToAppendTo->_is_nil() &&
456                   LineEditAppendTo->text() != LineEditMeshes->text() );
457   buttonOk   ->setEnabled( isEnabled );
458   buttonApply->setEnabled( isEnabled );
459 }
460
461 //=================================================================================
462 // function : DeactivateActiveDialog()
463 // purpose  :
464 //=================================================================================
465 void SMESHGUI_BuildCompoundDlg::DeactivateActiveDialog()
466 {
467   if (GroupConstructors->isEnabled()) {
468     GroupConstructors->setEnabled(false);
469     GroupResult->setEnabled(false);
470     GroupArgs->setEnabled(false);
471     GroupButtons->setEnabled(false);
472     mySMESHGUI->ResetState();
473     mySMESHGUI->SetActiveDialogBox(0);
474   }
475 }
476
477 //=================================================================================
478 // function : ActivateThisDialog()
479 // purpose  :
480 //=================================================================================
481 void SMESHGUI_BuildCompoundDlg::ActivateThisDialog()
482 {
483   /* Emit a signal to deactivate the active dialog */
484   mySMESHGUI->EmitSignalDeactivateDialog();
485   GroupConstructors->setEnabled(true);
486   GroupResult->setEnabled(true);
487   GroupArgs->setEnabled(true);
488   GroupButtons->setEnabled(true);
489
490   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
491   SelectionIntoArgument();
492 }
493
494 //=================================================================================
495 // function : enterEvent()
496 // purpose  :
497 //=================================================================================
498 void SMESHGUI_BuildCompoundDlg::enterEvent( QEvent* )
499 {
500   if (GroupConstructors->isEnabled())
501     return;
502   ActivateThisDialog();
503 }
504
505 //=================================================================================
506 // function : keyPressEvent()
507 // purpose  :
508 //=================================================================================
509 void SMESHGUI_BuildCompoundDlg::keyPressEvent( QKeyEvent* e )
510 {
511   QDialog::keyPressEvent( e );
512   if ( e->isAccepted() )
513     return;
514
515   if ( e->key() == Qt::Key_F1 ) {
516     e->accept();
517     ClickOnHelp();
518   }
519 }
520
521
522 //=================================================================================
523 // function : onSelectMerge()
524 // purpose  :
525 //=================================================================================
526 void SMESHGUI_BuildCompoundDlg::onSelectMerge(bool toMerge)
527 {
528   TextLabelTol->setEnabled(toMerge);
529   SpinBoxTol->setEnabled(toMerge);
530   if(!toMerge)
531     SpinBoxTol->SetValue(1e-05);
532 }
533
534 //=======================================================================
535 //function : onResultTypeChange
536 //purpose  : 
537 //=======================================================================
538
539 void SMESHGUI_BuildCompoundDlg::onResultTypeChange( int buttonID )
540 {
541   LineEditNewName     ->setEnabled( buttonID == NEW_MESH_ID );
542   SelectButtonAppendTo->setEnabled( buttonID == APPEND_TO_ID );
543   LineEditAppendTo    ->setEnabled( buttonID == APPEND_TO_ID );
544
545   if ( CurrentLineEdit == LineEditAppendTo && buttonID == NEW_MESH_ID )
546     onSelectionButton(); // to select into myMeshArray
547     
548   if ( buttonID == NEW_MESH_ID )
549   {
550     myMeshToAppendTo = SMESH::SMESH_Mesh::_nil();
551     LineEditAppendTo->setText("");
552   }
553   else
554   {
555     // activate selection of myMeshToAppendTo
556     SelectButtonAppendTo->click();
557     LineEditAppendTo->setFocus();
558   }
559 }
560
561 //=======================================================================
562 //function : onSelectionButton
563 //purpose  : 
564 //=======================================================================
565
566 void SMESHGUI_BuildCompoundDlg::onSelectionButton()
567 {
568   mySelectionMgr->clearFilters();
569   if ( sender() == SelectButtonAppendTo )
570   {
571     mySelectionMgr->installFilter( myAppendToFilter );
572     CurrentLineEdit = LineEditAppendTo;
573   }
574   else
575   {
576     mySelectionMgr->installFilter( myMeshFilter );
577     CurrentLineEdit = LineEditMeshes;
578   }
579   CurrentLineEdit->setFocus();
580
581   SelectionIntoArgument();
582 }
583
584 //=================================================================================
585 // function : isValid
586 // purpose  :
587 //=================================================================================
588 bool SMESHGUI_BuildCompoundDlg::isValid()
589 {
590   QString msg;
591   bool ok=true;
592   if(CheckBoxMerge->isChecked())
593     ok = SpinBoxTol->isValid( msg, true );
594
595   if( !ok ) {
596     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
597     if ( !msg.isEmpty() )
598       str += "\n" + msg;
599     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
600     return false;
601   }
602   return true;
603 }
604
605 //================================================================
606 // function : setIsApplyAndClose
607 // Purpose  : Set value of the flag indicating that the dialog is
608 //            accepted by Apply & Close button
609 //================================================================
610 void SMESHGUI_BuildCompoundDlg::setIsApplyAndClose( const bool theFlag )
611 {
612   myIsApplyAndClose = theFlag;
613 }
614
615 //================================================================
616 // function : isApplyAndClose
617 // Purpose  : Get value of the flag indicating that the dialog is
618 //            accepted by Apply & Close button
619 //================================================================
620 bool SMESHGUI_BuildCompoundDlg::isApplyAndClose() const
621 {
622   return myIsApplyAndClose;
623 }