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