Salome HOME
IMP: SMESH: Japanese translations
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_CopyMeshDlg.cxx
1 // Copyright (C) 2007-2013  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.
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_CopyMeshDlg.cxx
23
24 #include "SMESHGUI_CopyMeshDlg.h"
25
26 #include "SMESHGUI.h"
27 #include "SMESHGUI_SpinBox.h"
28 #include "SMESHGUI_Utils.h"
29 #include "SMESHGUI_VTKUtils.h"
30 #include "SMESHGUI_MeshUtils.h"
31 #include "SMESHGUI_IdValidator.h"
32 #include "SMESHGUI_FilterDlg.h"
33
34 #include <SMESH_Actor.h>
35 #include <SMESH_TypeFilter.hxx>
36 #include <SMDS_Mesh.hxx>
37
38 // SALOME GUI includes
39 #include <SUIT_Desktop.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SUIT_Session.h>
42 #include <SUIT_MessageBox.h>
43 #include <SUIT_OverrideCursor.h>
44
45 #include <LightApp_Application.h>
46 #include <LightApp_SelectionMgr.h>
47
48 #include <SVTK_ViewModel.h>
49 #include <SVTK_ViewWindow.h>
50 #include <SALOME_ListIO.hxx>
51
52 // SALOME KERNEL includes
53 #include <SALOMEDSClient_SObject.hxx>
54
55 // OCCT includes
56 #include <TColStd_MapOfInteger.hxx>
57
58 // Qt includes
59 #include <QApplication>
60 #include <QButtonGroup>
61 #include <QGroupBox>
62 #include <QLabel>
63 #include <QLineEdit>
64 #include <QPushButton>
65 #include <QRadioButton>
66 #include <QCheckBox>
67 #include <QHBoxLayout>
68 #include <QVBoxLayout>
69 #include <QGridLayout>
70 #include <QSpinBox>
71 #include <QKeyEvent>
72
73 // IDL includes
74 #include <SALOMEconfig.h>
75 #include CORBA_SERVER_HEADER(SMESH_Group)
76 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
77
78 /*!
79   \class BusyLocker
80   \brief Simple 'busy state' flag locker.
81   \internal
82 */
83
84 namespace
85 {
86   class BusyLocker
87   {
88   public:
89     //! Constructor. Sets passed boolean flag to \c true.
90     BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
91     //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
92     ~BusyLocker() { myBusy = false; }
93   private:
94     bool& myBusy; //! External 'busy state' boolean flag
95   };
96 }
97
98 #define SPACING 6
99 #define MARGIN  11
100
101
102 //================================================================================
103 /*!
104  * \brief Constructor
105  */
106 //================================================================================
107
108 SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
109   : QDialog( SMESH::GetDesktop( theModule ) ),
110     mySMESHGUI( theModule ),
111     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
112     myFilterDlg(0),
113     mySelectedObject(SMESH::SMESH_IDSource::_nil()),
114     myIsApplyAndClose( false )
115 {
116   QPixmap image (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH")));
117
118   setModal(false);
119   setAttribute(Qt::WA_DeleteOnClose, true);
120   setWindowTitle(tr("SMESH_COPY_MESH_TITLE"));
121   setSizeGripEnabled(true);
122
123   QVBoxLayout* SMESHGUI_CopyMeshDlgLayout = new QVBoxLayout(this);
124   SMESHGUI_CopyMeshDlgLayout->setSpacing(SPACING);
125   SMESHGUI_CopyMeshDlgLayout->setMargin(MARGIN);
126
127   /***************************************************************/
128   ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this);
129   QButtonGroup* GroupConstructors = new QButtonGroup(this);
130   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
131   ConstructorsBoxLayout->setSpacing(SPACING);
132   ConstructorsBoxLayout->setMargin(MARGIN);
133
134   QRadioButton* RadioButton1= new QRadioButton(ConstructorsBox);
135   RadioButton1->setIcon(image);
136   GroupConstructors->addButton(RadioButton1, 0);
137
138   ConstructorsBoxLayout->addWidget(RadioButton1);
139   RadioButton1->setChecked(true);
140   GroupConstructors->addButton(RadioButton1, 0);
141
142   /***************************************************************/
143   GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
144   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
145   GroupArgumentsLayout->setSpacing(SPACING);
146   GroupArgumentsLayout->setMargin(MARGIN);
147
148   myIdValidator = new SMESHGUI_IdValidator(this);
149
150   // Controls for idSource/elements selection
151   myTextLabelElements = new QLabel(tr("OBJECT_NAME"), GroupArguments);
152   myLineEditElements = new QLineEdit(GroupArguments);
153   myLineEditElements->setValidator(myIdValidator);
154   myLineEditElements->setMaxLength(-1);
155   myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
156   connect(myFilterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
157
158   // Control for the mesh objects selection
159   myIdSourceCheck = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
160
161   // Name of a mesh to create
162   QLabel* meshNameLabel = new QLabel(tr("NEW_NAME"), GroupArguments);
163   myMeshNameEdit = new QLineEdit(GroupArguments);
164
165   // CheckBox for copying groups
166   myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
167   myCopyGroupsCheck->setChecked(false);
168
169   // CheckBox for keeping ids
170   myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments);
171   myKeepIdsCheck->setChecked(true);
172
173   // layout
174   GroupArgumentsLayout->addWidget(myTextLabelElements,  0, 0);
175   GroupArgumentsLayout->addWidget(myLineEditElements,   0, 1, 1, 5);
176   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 6);
177   GroupArgumentsLayout->addWidget(myIdSourceCheck,      1, 0, 1, 6);
178   GroupArgumentsLayout->addWidget(meshNameLabel,        2, 0);
179   GroupArgumentsLayout->addWidget(myMeshNameEdit,       2, 1, 1, 5);
180   GroupArgumentsLayout->addWidget(myCopyGroupsCheck,    3, 0, 1, 6);
181   GroupArgumentsLayout->addWidget(myKeepIdsCheck,       4, 0, 1, 6);
182
183   /***************************************************************/
184   GroupButtons = new QGroupBox(this);
185   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
186   GroupButtonsLayout->setSpacing(SPACING);
187   GroupButtonsLayout->setMargin(MARGIN);
188
189   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
190   buttonOk->setAutoDefault(true);
191   buttonOk->setDefault(true);
192   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
193   buttonApply->setAutoDefault(true);
194   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
195   buttonCancel->setAutoDefault(true);
196   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
197   buttonHelp->setAutoDefault(true);
198
199   GroupButtonsLayout->addWidget(buttonOk);
200   GroupButtonsLayout->addSpacing(10);
201   GroupButtonsLayout->addWidget(buttonApply);
202   GroupButtonsLayout->addSpacing(10);
203   GroupButtonsLayout->addStretch();
204   GroupButtonsLayout->addWidget(buttonCancel);
205   GroupButtonsLayout->addWidget(buttonHelp);
206
207   /***************************************************************/
208   SMESHGUI_CopyMeshDlgLayout->addWidget(ConstructorsBox);
209   SMESHGUI_CopyMeshDlgLayout->addWidget(GroupArguments);
210   SMESHGUI_CopyMeshDlgLayout->addWidget(GroupButtons);
211
212   /* Initialisations */
213   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
214
215   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
216
217   // Selection filter
218   myIdSourceFilter = new SMESH_TypeFilter( SMESH::IDSOURCE );
219
220   myHelpFileName = "copy_mesh_page.html";
221
222   Init();
223
224   /* signals and slots connections */
225   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
226   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
227   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
228   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
229
230   connect(mySMESHGUI,     SIGNAL (SignalDeactivateActiveDialog()),
231           this,           SLOT   (DeactivateActiveDialog()));
232   connect(mySelectionMgr, SIGNAL (currentSelectionChanged()),
233           this,           SLOT   (SelectionIntoArgument()));
234   connect(mySMESHGUI,     SIGNAL (SignalCloseAllDialogs()),/* to close dialog if study change */
235           this,           SLOT   (reject()));
236
237   connect(myLineEditElements, SIGNAL(textChanged(const QString&)),
238           this,               SLOT  (onTextChange(const QString&)));
239   connect(myIdSourceCheck,    SIGNAL(toggled(bool)),
240           this,               SLOT  (onSelectIdSource(bool)));
241
242   SelectionIntoArgument();
243 }
244
245 //=================================================================================
246 // function : ~SMESHGUI_CopyMeshDlg()
247 // purpose  : Destroys the object and frees any allocated resources
248 //=================================================================================
249
250 SMESHGUI_CopyMeshDlg::~SMESHGUI_CopyMeshDlg()
251 {
252   if ( myFilterDlg )
253   {
254     myFilterDlg->setParent( 0 );
255     delete myFilterDlg; myFilterDlg = 0;
256   }
257   if ( myIdSourceFilter )
258   {
259     if ( mySelectionMgr )
260       mySelectionMgr->removeFilter( myIdSourceFilter );
261     delete myIdSourceFilter; myIdSourceFilter=0;
262   }
263 }
264
265 //=================================================================================
266 // function : Init()
267 // purpose  :
268 //=================================================================================
269 void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
270 {
271   myBusy = false;
272
273   myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
274   if ( ResetControls )
275   {
276     myLineEditElements->clear();
277     //myElementsId = "";
278     myNbOkElements = 0;
279
280     buttonOk->setEnabled(false);
281     buttonApply->setEnabled(false);
282
283     myActor = 0;
284     myMesh = SMESH::SMESH_Mesh::_nil();
285
286     myIdSourceCheck->setChecked(true);
287     myCopyGroupsCheck->setChecked(false);
288     myKeepIdsCheck->setChecked(false);
289
290     onSelectIdSource( myIdSourceCheck->isChecked() );
291   }
292 }
293
294 //=================================================================================
295 // function : ClickOnApply()
296 // purpose  :
297 //=================================================================================
298
299 bool SMESHGUI_CopyMeshDlg::ClickOnApply()
300 {
301   if (mySMESHGUI->isActiveStudyLocked())
302     return false;
303
304   if( !isValid() )
305     return false;
306
307   QStringList anEntryList;
308   try
309   {
310     SUIT_OverrideCursor aWaitCursor;
311     SMESH::SMESH_IDSource_var aPartToCopy;
312     if ( myIdSourceCheck->isChecked())
313     {
314       aPartToCopy = mySelectedObject;
315     }
316     else
317     {
318       QStringList aListElementsId = myLineEditElements->text().split(" ", QString::SkipEmptyParts);
319       SMESH::long_array_var anElementsId = new SMESH::long_array;
320       anElementsId->length(aListElementsId.count());
321       for (int i = 0; i < aListElementsId.count(); i++)
322         anElementsId[i] = aListElementsId[i].toInt();
323
324       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
325       aPartToCopy = aMeshEditor->MakeIDSource( anElementsId, SMESH::ALL );
326     }
327     QByteArray meshName = myMeshNameEdit->text().toLatin1();
328     bool toCopyGroups = ( myCopyGroupsCheck->isChecked() );
329     bool toKeepIDs    = ( myKeepIdsCheck->isChecked() );
330
331     SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
332     SMESH::SMESH_Mesh_var newMesh =
333       gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs);
334     if( !newMesh->_is_nil() )
335       if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
336         anEntryList.append( aSObject->GetID().c_str() );
337   }
338   catch (...) {
339   }
340
341   mySMESHGUI->updateObjBrowser(true);
342   SMESHGUI::Modified();
343
344   if( LightApp_Application* anApp =
345       dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
346     anApp->browseObjects( anEntryList, isApplyAndClose() );
347
348   Init(false);
349   mySelectedObject = SMESH::SMESH_IDSource::_nil();
350   SelectionIntoArgument();
351
352   return true;
353 }
354
355 //=================================================================================
356 // function : ClickOnOk()
357 // purpose  :
358 //=================================================================================
359 void SMESHGUI_CopyMeshDlg::ClickOnOk()
360 {
361   setIsApplyAndClose( true );
362   if( ClickOnApply() )
363     reject();
364 }
365
366 //=================================================================================
367 // function : reject()
368 // purpose  :
369 //=================================================================================
370 void SMESHGUI_CopyMeshDlg::reject()
371 {
372   disconnect(mySelectionMgr, 0, this, 0);
373   if ( mySelectionMgr )
374     mySelectionMgr->removeFilter( myIdSourceFilter );
375   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
376     aViewWindow->SetSelectionMode( ActorSelection );
377   mySMESHGUI->ResetState();
378   QDialog::reject();
379 }
380
381 //=================================================================================
382 // function : ClickOnHelp()
383 // purpose  :
384 //=================================================================================
385 void SMESHGUI_CopyMeshDlg::ClickOnHelp()
386 {
387   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
388   if (app)
389     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
390   else {
391     QString platform;
392 #ifdef WIN32
393     platform = "winapplication";
394 #else
395     platform = "application";
396 #endif
397     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
398                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
399                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
400                                                                  platform)).
401                              arg(myHelpFileName));
402   }
403 }
404
405 //=======================================================================
406 // function : onTextChange()
407 // purpose  :
408 //=======================================================================
409
410 void SMESHGUI_CopyMeshDlg::onTextChange (const QString& theNewText)
411 {
412   QLineEdit* send = (QLineEdit*)sender();
413
414   if (myBusy) return;
415   BusyLocker lock( myBusy );
416
417   //if (send == myLineEditElements)
418   myNbOkElements = 0;
419
420   buttonOk->setEnabled(false);
421   buttonApply->setEnabled(false);
422
423   // hilight entered elements
424   SMDS_Mesh* aMesh = 0;
425   if (myActor)
426     aMesh = myActor->GetObject()->GetMesh();
427
428   QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
429   if (myActor && aMesh)
430   {
431     TColStd_MapOfInteger newIndices;
432     if (send == myLineEditElements) {
433       for (int i = 0; i < aListId.count(); i++)
434         if ( const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()))
435         {
436           newIndices.Add(e->GetID());
437         }
438     }
439     myNbOkElements = newIndices.Extent();
440
441     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
442     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
443     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
444       aViewWindow->highlight( anIO, true, true );
445   }
446   else
447   {
448     myNbOkElements = aListId.count();
449   }
450
451   if (myNbOkElements) {
452     buttonOk->setEnabled(true);
453     buttonApply->setEnabled(true);
454   }
455 }
456
457 //=================================================================================
458 // function : SelectionIntoArgument()
459 // purpose  : Called when selection as changed or other case
460 //=================================================================================
461
462 void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
463 {
464   if (myBusy) return;
465   BusyLocker lock( myBusy );
466
467   // clear
468   myActor = 0;
469   QString aString = "";
470
471   myLineEditElements->setText(aString);
472   myNbOkElements = 0;
473   buttonOk->setEnabled(false);
474   buttonApply->setEnabled(false);
475   myFilterBtn->setEnabled(false);
476
477   // get selected mesh
478   SALOME_ListIO aList;
479   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
480   int nbSel = aList.Extent();
481   if (nbSel != 1)
482     return;
483
484   Handle(SALOME_InteractiveObject) IO = aList.First();
485   mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
486   if ( mySelectedObject->_is_nil() )
487     return;
488
489   myMesh = SMESH::GetMeshByIO(IO);
490   if (myMesh->_is_nil())
491     return;
492
493   myActor = SMESH::FindActorByEntry(IO->getEntry());
494   if (!myActor)
495     myActor = SMESH::FindActorByObject(myMesh);
496
497   if (myIdSourceCheck->isChecked())
498   {
499     SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
500     if ( aString.isEmpty() ) aString = " ";
501     else                     aString = aString.trimmed(); // issue 0021327
502   }
503   else
504   {
505     SMESH::GetNameOfSelectedElements( mySelector, IO, aString );
506     myNbOkElements = aString.size();
507     myFilterBtn->setEnabled(true);
508   }
509   myLineEditElements->setText( aString );
510   bool ok = !aString.isEmpty();
511
512   buttonOk->setEnabled(ok);
513   buttonApply->setEnabled(ok);
514 }
515
516 //=======================================================================
517 //function : onSelectIdSource
518 //purpose  :
519 //=======================================================================
520 void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
521 {
522   if (toSelectMesh)
523     myTextLabelElements->setText(tr("OBJECT_NAME"));
524   else
525     myTextLabelElements->setText(tr("ELEM_IDS"));
526
527   if (toSelectMesh) {
528     myLineEditElements->clear();
529   }
530
531   mySelectionMgr->clearFilters();
532   mySelectionMgr->installFilter(myIdSourceFilter);
533   SMESH::SetPointRepresentation(false);
534
535   if (toSelectMesh) {
536     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
537       aViewWindow->SetSelectionMode( ActorSelection );
538     myLineEditElements->setReadOnly(true);
539     myLineEditElements->setValidator(0);
540   }
541   else
542   {
543     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
544       aViewWindow->SetSelectionMode( CellSelection );
545     myLineEditElements->setReadOnly(false);
546     myLineEditElements->setValidator(myIdValidator);
547     onTextChange(myLineEditElements->text());
548   }
549
550   SelectionIntoArgument();
551 }
552
553 //=================================================================================
554 // function : isValid
555 // purpose  :
556 //=================================================================================
557
558 bool SMESHGUI_CopyMeshDlg::isValid()
559 {
560   if ( myIdSourceCheck->isChecked() )
561     return !mySelectedObject->_is_nil();
562
563   return myNbOkElements > 0;
564 }
565
566 //=================================================================================
567 // function : DeactivateActiveDialog()
568 // purpose  :
569 //=================================================================================
570 void SMESHGUI_CopyMeshDlg::DeactivateActiveDialog()
571 {
572   if (ConstructorsBox->isEnabled()) {
573     ConstructorsBox->setEnabled(false);
574     GroupArguments->setEnabled(false);
575     GroupButtons->setEnabled(false);
576     mySMESHGUI->ResetState();
577     mySMESHGUI->SetActiveDialogBox(0);
578     if ( mySelectionMgr )
579       mySelectionMgr->removeFilter( myIdSourceFilter );
580   }
581 }
582
583 //=================================================================================
584 // function : ActivateThisDialog()
585 // purpose  :
586 //=================================================================================
587 void SMESHGUI_CopyMeshDlg::ActivateThisDialog()
588 {
589   /* Emit a signal to deactivate the active dialog */
590   mySMESHGUI->EmitSignalDeactivateDialog();
591   ConstructorsBox->setEnabled(true);
592   GroupArguments->setEnabled(true);
593   GroupButtons->setEnabled(true);
594
595   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
596
597   onSelectIdSource( myIdSourceCheck->isChecked() );
598
599   SelectionIntoArgument();
600 }
601
602 //=================================================================================
603 // function : enterEvent()
604 // purpose  :
605 //=================================================================================
606 void SMESHGUI_CopyMeshDlg::enterEvent (QEvent*)
607 {
608   if (!ConstructorsBox->isEnabled())
609     ActivateThisDialog();
610 }
611
612 //=================================================================================
613 // function : keyPressEvent()
614 // purpose  :
615 //=================================================================================
616 void SMESHGUI_CopyMeshDlg::keyPressEvent( QKeyEvent* e )
617 {
618   QDialog::keyPressEvent( e );
619   if ( e->isAccepted() )
620     return;
621
622   if ( e->key() == Qt::Key_F1 ) {
623     e->accept();
624     ClickOnHelp();
625   }
626 }
627
628 //=================================================================================
629 // function : setFilters()
630 // purpose  : SLOT. Called when "Filter" button pressed.
631 //=================================================================================
632 void SMESHGUI_CopyMeshDlg::setFilters()
633 {
634   if(myMesh->_is_nil()) {
635     SUIT_MessageBox::critical(this,
636                               tr("SMESH_ERROR"),
637                               tr("NO_MESH_SELECTED"));
638    return;
639   }
640   if ( !myFilterDlg )
641     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
642
643   myFilterDlg->SetSelection();
644   myFilterDlg->SetMesh( myMesh );
645   myFilterDlg->SetSourceWg( myLineEditElements );
646
647   myFilterDlg->show();
648 }
649
650 //================================================================
651 // function : setIsApplyAndClose
652 // Purpose  : Set value of the flag indicating that the dialog is
653 //            accepted by Apply & Close button
654 //================================================================
655 void SMESHGUI_CopyMeshDlg::setIsApplyAndClose( const bool theFlag )
656 {
657   myIsApplyAndClose = theFlag;
658 }
659
660 //================================================================
661 // function : isApplyAndClose
662 // Purpose  : Get value of the flag indicating that the dialog is
663 //            accepted by Apply & Close button
664 //================================================================
665 bool SMESHGUI_CopyMeshDlg::isApplyAndClose() const
666 {
667   return myIsApplyAndClose;
668 }