Salome HOME
39665f3a5aa1c179d129e3047a31673e8e6faec2
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_CopyMeshDlg.cxx
1 // Copyright (C) 2007-2014  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_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_wrap aPartToCopy;
312     if ( myIdSourceCheck->isChecked())
313     {
314       aPartToCopy = mySelectedObject;
315       aPartToCopy->Register();
316     }
317     else
318     {
319       QStringList aListElementsId = myLineEditElements->text().split(" ", QString::SkipEmptyParts);
320       SMESH::long_array_var anElementsId = new SMESH::long_array;
321       anElementsId->length(aListElementsId.count());
322       for (int i = 0; i < aListElementsId.count(); i++)
323         anElementsId[i] = aListElementsId[i].toInt();
324
325       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
326       aPartToCopy = aMeshEditor->MakeIDSource( anElementsId, SMESH::ALL );
327     }
328     QByteArray meshName = myMeshNameEdit->text().toLatin1();
329     bool toCopyGroups = ( myCopyGroupsCheck->isChecked() );
330     bool toKeepIDs    = ( myKeepIdsCheck->isChecked() );
331
332     SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
333     SMESH::SMESH_Mesh_var newMesh =
334       gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs);
335     if( !newMesh->_is_nil() )
336       if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
337         anEntryList.append( aSObject->GetID().c_str() );
338   }
339   catch (...) {
340   }
341
342   mySMESHGUI->updateObjBrowser(true);
343   SMESHGUI::Modified();
344
345   if( LightApp_Application* anApp =
346       dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
347     anApp->browseObjects( anEntryList, isApplyAndClose() );
348
349   Init(false);
350   mySelectedObject = SMESH::SMESH_IDSource::_nil();
351   SelectionIntoArgument();
352
353   return true;
354 }
355
356 //=================================================================================
357 // function : ClickOnOk()
358 // purpose  :
359 //=================================================================================
360 void SMESHGUI_CopyMeshDlg::ClickOnOk()
361 {
362   setIsApplyAndClose( true );
363   if( ClickOnApply() )
364     reject();
365 }
366
367 //=================================================================================
368 // function : reject()
369 // purpose  :
370 //=================================================================================
371 void SMESHGUI_CopyMeshDlg::reject()
372 {
373   disconnect(mySelectionMgr, 0, this, 0);
374   if ( mySelectionMgr )
375     mySelectionMgr->removeFilter( myIdSourceFilter );
376   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
377     aViewWindow->SetSelectionMode( ActorSelection );
378   mySMESHGUI->ResetState();
379   QDialog::reject();
380 }
381
382 //=================================================================================
383 // function : ClickOnHelp()
384 // purpose  :
385 //=================================================================================
386 void SMESHGUI_CopyMeshDlg::ClickOnHelp()
387 {
388   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
389   if (app)
390     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
391   else {
392     QString platform;
393 #ifdef WIN32
394     platform = "winapplication";
395 #else
396     platform = "application";
397 #endif
398     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
399                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
400                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
401                                                                  platform)).
402                              arg(myHelpFileName));
403   }
404 }
405
406 //=======================================================================
407 // function : onTextChange()
408 // purpose  :
409 //=======================================================================
410
411 void SMESHGUI_CopyMeshDlg::onTextChange (const QString& theNewText)
412 {
413   QLineEdit* send = (QLineEdit*)sender();
414
415   if (myBusy) return;
416   BusyLocker lock( myBusy );
417
418   //if (send == myLineEditElements)
419   myNbOkElements = 0;
420
421   buttonOk->setEnabled(false);
422   buttonApply->setEnabled(false);
423
424   // hilight entered elements
425   SMDS_Mesh* aMesh = 0;
426   if (myActor)
427     aMesh = myActor->GetObject()->GetMesh();
428
429   QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
430   if (myActor && aMesh)
431   {
432     TColStd_MapOfInteger newIndices;
433     if (send == myLineEditElements) {
434       for (int i = 0; i < aListId.count(); i++)
435         if ( const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()))
436         {
437           newIndices.Add(e->GetID());
438         }
439     }
440     myNbOkElements = newIndices.Extent();
441
442     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
443     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
444     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
445       aViewWindow->highlight( anIO, true, true );
446   }
447   else
448   {
449     myNbOkElements = aListId.count();
450   }
451
452   if (myNbOkElements) {
453     buttonOk->setEnabled(true);
454     buttonApply->setEnabled(true);
455   }
456 }
457
458 //=================================================================================
459 // function : SelectionIntoArgument()
460 // purpose  : Called when selection as changed or other case
461 //=================================================================================
462
463 void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
464 {
465   if (myBusy) return;
466   BusyLocker lock( myBusy );
467
468   // clear
469   myActor = 0;
470   QString aString = "";
471
472   myLineEditElements->setText(aString);
473   myNbOkElements = 0;
474   buttonOk->setEnabled(false);
475   buttonApply->setEnabled(false);
476   myFilterBtn->setEnabled(false);
477
478   // get selected mesh
479   SALOME_ListIO aList;
480   mySelectionMgr->selectedObjects(aList);
481   int nbSel = aList.Extent();
482   if (nbSel != 1)
483     return;
484
485   Handle(SALOME_InteractiveObject) IO = aList.First();
486   mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
487   if ( mySelectedObject->_is_nil() )
488     return;
489
490   myMesh = SMESH::GetMeshByIO(IO);
491   if (myMesh->_is_nil())
492     return;
493
494   myActor = SMESH::FindActorByEntry(IO->getEntry());
495   if (!myActor)
496     myActor = SMESH::FindActorByObject(myMesh);
497
498   if (myIdSourceCheck->isChecked())
499   {
500     SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
501     if ( aString.isEmpty() ) aString = " ";
502     else                     aString = aString.trimmed(); // issue 0021327
503   }
504   else
505   {
506     SMESH::GetNameOfSelectedElements( mySelector, IO, aString );
507     myNbOkElements = aString.size();
508     myFilterBtn->setEnabled(true);
509   }
510   myLineEditElements->setText( aString );
511   bool ok = !aString.isEmpty();
512
513   buttonOk->setEnabled(ok);
514   buttonApply->setEnabled(ok);
515 }
516
517 //=======================================================================
518 //function : onSelectIdSource
519 //purpose  :
520 //=======================================================================
521 void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
522 {
523   if (toSelectMesh)
524     myTextLabelElements->setText(tr("OBJECT_NAME"));
525   else
526     myTextLabelElements->setText(tr("ELEM_IDS"));
527
528   if (toSelectMesh) {
529     myLineEditElements->clear();
530   }
531
532   mySelectionMgr->clearFilters();
533   mySelectionMgr->installFilter(myIdSourceFilter);
534   SMESH::SetPointRepresentation(false);
535
536   if (toSelectMesh) {
537     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
538       aViewWindow->SetSelectionMode( ActorSelection );
539     myLineEditElements->setReadOnly(true);
540     myLineEditElements->setValidator(0);
541   }
542   else
543   {
544     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
545       aViewWindow->SetSelectionMode( CellSelection );
546     myLineEditElements->setReadOnly(false);
547     myLineEditElements->setValidator(myIdValidator);
548     onTextChange(myLineEditElements->text());
549   }
550
551   SelectionIntoArgument();
552 }
553
554 //=================================================================================
555 // function : isValid
556 // purpose  :
557 //=================================================================================
558
559 bool SMESHGUI_CopyMeshDlg::isValid()
560 {
561   if ( myIdSourceCheck->isChecked() )
562     return !mySelectedObject->_is_nil();
563
564   return myNbOkElements > 0;
565 }
566
567 //=================================================================================
568 // function : DeactivateActiveDialog()
569 // purpose  :
570 //=================================================================================
571 void SMESHGUI_CopyMeshDlg::DeactivateActiveDialog()
572 {
573   if (ConstructorsBox->isEnabled()) {
574     ConstructorsBox->setEnabled(false);
575     GroupArguments->setEnabled(false);
576     GroupButtons->setEnabled(false);
577     mySMESHGUI->ResetState();
578     mySMESHGUI->SetActiveDialogBox(0);
579     if ( mySelectionMgr )
580       mySelectionMgr->removeFilter( myIdSourceFilter );
581   }
582 }
583
584 //=================================================================================
585 // function : ActivateThisDialog()
586 // purpose  :
587 //=================================================================================
588 void SMESHGUI_CopyMeshDlg::ActivateThisDialog()
589 {
590   /* Emit a signal to deactivate the active dialog */
591   mySMESHGUI->EmitSignalDeactivateDialog();
592   ConstructorsBox->setEnabled(true);
593   GroupArguments->setEnabled(true);
594   GroupButtons->setEnabled(true);
595
596   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
597
598   onSelectIdSource( myIdSourceCheck->isChecked() );
599
600   SelectionIntoArgument();
601 }
602
603 //=================================================================================
604 // function : enterEvent()
605 // purpose  :
606 //=================================================================================
607 void SMESHGUI_CopyMeshDlg::enterEvent (QEvent*)
608 {
609   if (!ConstructorsBox->isEnabled())
610     ActivateThisDialog();
611 }
612
613 //=================================================================================
614 // function : keyPressEvent()
615 // purpose  :
616 //=================================================================================
617 void SMESHGUI_CopyMeshDlg::keyPressEvent( QKeyEvent* e )
618 {
619   QDialog::keyPressEvent( e );
620   if ( e->isAccepted() )
621     return;
622
623   if ( e->key() == Qt::Key_F1 ) {
624     e->accept();
625     ClickOnHelp();
626   }
627 }
628
629 //=================================================================================
630 // function : setFilters()
631 // purpose  : SLOT. Called when "Filter" button pressed.
632 //=================================================================================
633 void SMESHGUI_CopyMeshDlg::setFilters()
634 {
635   if(myMesh->_is_nil()) {
636     SUIT_MessageBox::critical(this,
637                               tr("SMESH_ERROR"),
638                               tr("NO_MESH_SELECTED"));
639    return;
640   }
641   if ( !myFilterDlg )
642     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
643
644   myFilterDlg->SetSelection();
645   myFilterDlg->SetMesh( myMesh );
646   myFilterDlg->SetSourceWg( myLineEditElements );
647
648   myFilterDlg->show();
649 }
650
651 //================================================================
652 // function : setIsApplyAndClose
653 // Purpose  : Set value of the flag indicating that the dialog is
654 //            accepted by Apply & Close button
655 //================================================================
656 void SMESHGUI_CopyMeshDlg::setIsApplyAndClose( const bool theFlag )
657 {
658   myIsApplyAndClose = theFlag;
659 }
660
661 //================================================================
662 // function : isApplyAndClose
663 // Purpose  : Get value of the flag indicating that the dialog is
664 //            accepted by Apply & Close button
665 //================================================================
666 bool SMESHGUI_CopyMeshDlg::isApplyAndClose() const
667 {
668   return myIsApplyAndClose;
669 }