Salome HOME
Merge remote branch 'origin/gdd/translations'
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_CopyMeshDlg.cxx
1 // Copyright (C) 2007-2015  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 ( OBSOLETE )
170   myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments);
171   myKeepIdsCheck->setChecked(true);
172   myKeepIdsCheck->hide();
173
174   // layout
175   GroupArgumentsLayout->addWidget(myTextLabelElements,  0, 0);
176   GroupArgumentsLayout->addWidget(myLineEditElements,   0, 1, 1, 5);
177   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 6);
178   GroupArgumentsLayout->addWidget(myIdSourceCheck,      1, 0, 1, 6);
179   GroupArgumentsLayout->addWidget(meshNameLabel,        2, 0);
180   GroupArgumentsLayout->addWidget(myMeshNameEdit,       2, 1, 1, 5);
181   GroupArgumentsLayout->addWidget(myCopyGroupsCheck,    3, 0, 1, 6);
182   // GroupArgumentsLayout->addWidget(myKeepIdsCheck,       4, 0, 1, 6);
183
184   /***************************************************************/
185   GroupButtons = new QGroupBox(this);
186   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
187   GroupButtonsLayout->setSpacing(SPACING);
188   GroupButtonsLayout->setMargin(MARGIN);
189
190   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
191   buttonOk->setAutoDefault(true);
192   buttonOk->setDefault(true);
193   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
194   buttonApply->setAutoDefault(true);
195   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
196   buttonCancel->setAutoDefault(true);
197   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
198   buttonHelp->setAutoDefault(true);
199
200   GroupButtonsLayout->addWidget(buttonOk);
201   GroupButtonsLayout->addSpacing(10);
202   GroupButtonsLayout->addWidget(buttonApply);
203   GroupButtonsLayout->addSpacing(10);
204   GroupButtonsLayout->addStretch();
205   GroupButtonsLayout->addWidget(buttonCancel);
206   GroupButtonsLayout->addWidget(buttonHelp);
207
208   /***************************************************************/
209   SMESHGUI_CopyMeshDlgLayout->addWidget(ConstructorsBox);
210   SMESHGUI_CopyMeshDlgLayout->addWidget(GroupArguments);
211   SMESHGUI_CopyMeshDlgLayout->addWidget(GroupButtons);
212
213   /* Initialisations */
214   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
215
216   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
217
218   // Selection filter
219   myIdSourceFilter = new SMESH_TypeFilter( SMESH::IDSOURCE );
220
221   myHelpFileName = "copy_mesh_page.html";
222
223   Init();
224
225   /* signals and slots connections */
226   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
227   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
228   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
229   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
230
231   connect(mySMESHGUI,     SIGNAL (SignalDeactivateActiveDialog()),
232           this,           SLOT   (DeactivateActiveDialog()));
233   connect(mySelectionMgr, SIGNAL (currentSelectionChanged()),
234           this,           SLOT   (SelectionIntoArgument()));
235   connect(mySMESHGUI,     SIGNAL (SignalCloseAllDialogs()),/* to close dialog if study change */
236           this,           SLOT   (reject()));
237
238   connect(myLineEditElements, SIGNAL(textChanged(const QString&)),
239           this,               SLOT  (onTextChange(const QString&)));
240   connect(myIdSourceCheck,    SIGNAL(toggled(bool)),
241           this,               SLOT  (onSelectIdSource(bool)));
242
243   SelectionIntoArgument();
244 }
245
246 //=================================================================================
247 // function : ~SMESHGUI_CopyMeshDlg()
248 // purpose  : Destroys the object and frees any allocated resources
249 //=================================================================================
250
251 SMESHGUI_CopyMeshDlg::~SMESHGUI_CopyMeshDlg()
252 {
253   if ( myFilterDlg )
254   {
255     myFilterDlg->setParent( 0 );
256     delete myFilterDlg; myFilterDlg = 0;
257   }
258   if ( myIdSourceFilter )
259   {
260     if ( mySelectionMgr )
261       mySelectionMgr->removeFilter( myIdSourceFilter );
262     delete myIdSourceFilter; myIdSourceFilter=0;
263   }
264 }
265
266 //=================================================================================
267 // function : Init()
268 // purpose  :
269 //=================================================================================
270 void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
271 {
272   myBusy = false;
273
274   myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
275   if ( ResetControls )
276   {
277     myLineEditElements->clear();
278     //myElementsId = "";
279     myNbOkElements = 0;
280
281     buttonOk->setEnabled(false);
282     buttonApply->setEnabled(false);
283
284     myActor = 0;
285     myMesh = SMESH::SMESH_Mesh::_nil();
286
287     myIdSourceCheck->setChecked(true);
288     myCopyGroupsCheck->setChecked(false);
289     myKeepIdsCheck->setChecked(false);
290
291     onSelectIdSource( myIdSourceCheck->isChecked() );
292   }
293 }
294
295 //=================================================================================
296 // function : ClickOnApply()
297 // purpose  :
298 //=================================================================================
299
300 bool SMESHGUI_CopyMeshDlg::ClickOnApply()
301 {
302   if (mySMESHGUI->isActiveStudyLocked())
303     return false;
304
305   if( !isValid() )
306     return false;
307
308   QStringList anEntryList;
309   try
310   {
311     SUIT_OverrideCursor aWaitCursor;
312     SMESH::SMESH_IDSource_wrap aPartToCopy;
313     if ( myIdSourceCheck->isChecked())
314     {
315       aPartToCopy = mySelectedObject;
316       aPartToCopy->Register();
317     }
318     else
319     {
320       QStringList aListElementsId = myLineEditElements->text().split(" ", QString::SkipEmptyParts);
321       SMESH::long_array_var anElementsId = new SMESH::long_array;
322       anElementsId->length(aListElementsId.count());
323       for (int i = 0; i < aListElementsId.count(); i++)
324         anElementsId[i] = aListElementsId[i].toInt();
325
326       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
327       aPartToCopy = aMeshEditor->MakeIDSource( anElementsId, SMESH::ALL );
328     }
329     QByteArray meshName = myMeshNameEdit->text().toLatin1();
330     bool toCopyGroups = ( myCopyGroupsCheck->isChecked() );
331     bool toKeepIDs    = ( myKeepIdsCheck->isChecked() );
332
333     SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
334     SMESH::SMESH_Mesh_var newMesh =
335       gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs);
336     if( !newMesh->_is_nil() )
337       if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
338         anEntryList.append( aSObject->GetID().c_str() );
339   }
340   catch (...) {
341   }
342
343   mySMESHGUI->updateObjBrowser(true);
344   SMESHGUI::Modified();
345
346   if( LightApp_Application* anApp =
347       dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
348     anApp->browseObjects( anEntryList, isApplyAndClose() );
349
350   Init(false);
351   mySelectedObject = SMESH::SMESH_IDSource::_nil();
352   SelectionIntoArgument();
353
354   return true;
355 }
356
357 //=================================================================================
358 // function : ClickOnOk()
359 // purpose  :
360 //=================================================================================
361 void SMESHGUI_CopyMeshDlg::ClickOnOk()
362 {
363   setIsApplyAndClose( true );
364   if( ClickOnApply() )
365     reject();
366 }
367
368 //=================================================================================
369 // function : reject()
370 // purpose  :
371 //=================================================================================
372 void SMESHGUI_CopyMeshDlg::reject()
373 {
374   disconnect(mySelectionMgr, 0, this, 0);
375   if ( mySelectionMgr )
376     mySelectionMgr->removeFilter( myIdSourceFilter );
377   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
378     aViewWindow->SetSelectionMode( ActorSelection );
379   mySMESHGUI->ResetState();
380   QDialog::reject();
381 }
382
383 //=================================================================================
384 // function : ClickOnHelp()
385 // purpose  :
386 //=================================================================================
387 void SMESHGUI_CopyMeshDlg::ClickOnHelp()
388 {
389   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
390   if (app)
391     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
392   else {
393     QString platform;
394 #ifdef WIN32
395     platform = "winapplication";
396 #else
397     platform = "application";
398 #endif
399     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
400                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
401                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
402                                                                  platform)).
403                              arg(myHelpFileName));
404   }
405 }
406
407 //=======================================================================
408 // function : onTextChange()
409 // purpose  :
410 //=======================================================================
411
412 void SMESHGUI_CopyMeshDlg::onTextChange (const QString& theNewText)
413 {
414   QLineEdit* send = (QLineEdit*)sender();
415
416   if (myBusy) return;
417   BusyLocker lock( myBusy );
418
419   //if (send == myLineEditElements)
420   myNbOkElements = 0;
421
422   buttonOk->setEnabled(false);
423   buttonApply->setEnabled(false);
424
425   // hilight entered elements
426   SMDS_Mesh* aMesh = 0;
427   if (myActor)
428     aMesh = myActor->GetObject()->GetMesh();
429
430   QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
431   if (myActor && aMesh)
432   {
433     TColStd_MapOfInteger newIndices;
434     if (send == myLineEditElements) {
435       for (int i = 0; i < aListId.count(); i++)
436         if ( const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()))
437         {
438           newIndices.Add(e->GetID());
439         }
440     }
441     myNbOkElements = newIndices.Extent();
442
443     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
444     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
445     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
446       aViewWindow->highlight( anIO, true, true );
447   }
448   else
449   {
450     myNbOkElements = aListId.count();
451   }
452
453   if (myNbOkElements) {
454     buttonOk->setEnabled(true);
455     buttonApply->setEnabled(true);
456   }
457 }
458
459 //=================================================================================
460 // function : SelectionIntoArgument()
461 // purpose  : Called when selection as changed or other case
462 //=================================================================================
463
464 void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
465 {
466   if (myBusy) return;
467   BusyLocker lock( myBusy );
468
469   // clear
470   myActor = 0;
471   QString aString = "";
472
473   myLineEditElements->setText(aString);
474   myNbOkElements = 0;
475   buttonOk->setEnabled(false);
476   buttonApply->setEnabled(false);
477   myFilterBtn->setEnabled(false);
478
479   // get selected mesh
480   SALOME_ListIO aList;
481   mySelectionMgr->selectedObjects(aList);
482   int nbSel = aList.Extent();
483   if (nbSel != 1)
484     return;
485
486   Handle(SALOME_InteractiveObject) IO = aList.First();
487   mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
488   if ( mySelectedObject->_is_nil() )
489     return;
490
491   myMesh = SMESH::GetMeshByIO(IO);
492   if (myMesh->_is_nil())
493     return;
494
495   myActor = SMESH::FindActorByEntry(IO->getEntry());
496   if (!myActor)
497     myActor = SMESH::FindActorByObject(myMesh);
498
499   if (myIdSourceCheck->isChecked())
500   {
501     SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
502     if ( aString.isEmpty() ) aString = " ";
503     else                     aString = aString.trimmed(); // issue 0021327
504   }
505   else
506   {
507     SMESH::GetNameOfSelectedElements( mySelector, IO, aString );
508     myNbOkElements = aString.size();
509     myFilterBtn->setEnabled(true);
510   }
511   myLineEditElements->setText( aString );
512   bool ok = !aString.isEmpty();
513
514   buttonOk->setEnabled(ok);
515   buttonApply->setEnabled(ok);
516 }
517
518 //=======================================================================
519 //function : onSelectIdSource
520 //purpose  :
521 //=======================================================================
522 void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
523 {
524   if (toSelectMesh)
525     myTextLabelElements->setText(tr("OBJECT_NAME"));
526   else
527     myTextLabelElements->setText(tr("ELEM_IDS"));
528
529   if (toSelectMesh) {
530     myLineEditElements->clear();
531   }
532
533   mySelectionMgr->clearFilters();
534   mySelectionMgr->installFilter(myIdSourceFilter);
535   SMESH::SetPointRepresentation(false);
536
537   if (toSelectMesh) {
538     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
539       aViewWindow->SetSelectionMode( ActorSelection );
540     myLineEditElements->setReadOnly(true);
541     myLineEditElements->setValidator(0);
542   }
543   else
544   {
545     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
546       aViewWindow->SetSelectionMode( CellSelection );
547     myLineEditElements->setReadOnly(false);
548     myLineEditElements->setValidator(myIdValidator);
549     onTextChange(myLineEditElements->text());
550   }
551
552   SelectionIntoArgument();
553 }
554
555 //=================================================================================
556 // function : isValid
557 // purpose  :
558 //=================================================================================
559
560 bool SMESHGUI_CopyMeshDlg::isValid()
561 {
562   if ( myIdSourceCheck->isChecked() )
563     return !mySelectedObject->_is_nil();
564
565   return myNbOkElements > 0;
566 }
567
568 //=================================================================================
569 // function : DeactivateActiveDialog()
570 // purpose  :
571 //=================================================================================
572 void SMESHGUI_CopyMeshDlg::DeactivateActiveDialog()
573 {
574   if (ConstructorsBox->isEnabled()) {
575     ConstructorsBox->setEnabled(false);
576     GroupArguments->setEnabled(false);
577     GroupButtons->setEnabled(false);
578     mySMESHGUI->ResetState();
579     mySMESHGUI->SetActiveDialogBox(0);
580     if ( mySelectionMgr )
581       mySelectionMgr->removeFilter( myIdSourceFilter );
582   }
583 }
584
585 //=================================================================================
586 // function : ActivateThisDialog()
587 // purpose  :
588 //=================================================================================
589 void SMESHGUI_CopyMeshDlg::ActivateThisDialog()
590 {
591   /* Emit a signal to deactivate the active dialog */
592   mySMESHGUI->EmitSignalDeactivateDialog();
593   ConstructorsBox->setEnabled(true);
594   GroupArguments->setEnabled(true);
595   GroupButtons->setEnabled(true);
596
597   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
598
599   onSelectIdSource( myIdSourceCheck->isChecked() );
600
601   SelectionIntoArgument();
602 }
603
604 //=================================================================================
605 // function : enterEvent()
606 // purpose  :
607 //=================================================================================
608 void SMESHGUI_CopyMeshDlg::enterEvent (QEvent*)
609 {
610   if (!ConstructorsBox->isEnabled())
611     ActivateThisDialog();
612 }
613
614 //=================================================================================
615 // function : keyPressEvent()
616 // purpose  :
617 //=================================================================================
618 void SMESHGUI_CopyMeshDlg::keyPressEvent( QKeyEvent* e )
619 {
620   QDialog::keyPressEvent( e );
621   if ( e->isAccepted() )
622     return;
623
624   if ( e->key() == Qt::Key_F1 ) {
625     e->accept();
626     ClickOnHelp();
627   }
628 }
629
630 //=================================================================================
631 // function : setFilters()
632 // purpose  : SLOT. Called when "Filter" button pressed.
633 //=================================================================================
634 void SMESHGUI_CopyMeshDlg::setFilters()
635 {
636   if(myMesh->_is_nil()) {
637     SUIT_MessageBox::critical(this,
638                               tr("SMESH_ERROR"),
639                               tr("NO_MESH_SELECTED"));
640    return;
641   }
642   if ( !myFilterDlg )
643     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
644
645   myFilterDlg->SetSelection();
646   myFilterDlg->SetMesh( myMesh );
647   myFilterDlg->SetSourceWg( myLineEditElements );
648
649   myFilterDlg->show();
650 }
651
652 //================================================================
653 // function : setIsApplyAndClose
654 // Purpose  : Set value of the flag indicating that the dialog is
655 //            accepted by Apply & Close button
656 //================================================================
657 void SMESHGUI_CopyMeshDlg::setIsApplyAndClose( const bool theFlag )
658 {
659   myIsApplyAndClose = theFlag;
660 }
661
662 //================================================================
663 // function : isApplyAndClose
664 // Purpose  : Get value of the flag indicating that the dialog is
665 //            accepted by Apply & Close button
666 //================================================================
667 bool SMESHGUI_CopyMeshDlg::isApplyAndClose() const
668 {
669   return myIsApplyAndClose;
670 }