Salome HOME
Merge from V5_1_main 10/12/2010
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_CopyMeshDlg.cxx
1 //  Copyright (C) 2007-2010  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 //  SMESH SMESHGUI : GUI for SMESH component
23 //  File   : SMESHGUI_CopyMeshDlg.cxx
24
25 #include "SMESHGUI_CopyMeshDlg.h"
26
27 #include "SMESHGUI.h"
28 #include "SMESHGUI_SpinBox.h"
29 #include "SMESHGUI_Utils.h"
30 #include "SMESHGUI_VTKUtils.h"
31 #include "SMESHGUI_MeshUtils.h"
32 #include "SMESHGUI_IdValidator.h"
33 #include "SMESHGUI_FilterDlg.h"
34
35 #include <SMESH_Actor.h>
36 #include <SMESH_TypeFilter.hxx>
37 #include <SMDS_Mesh.hxx>
38
39 // SALOME GUI includes
40 #include <SUIT_Desktop.h>
41 #include <SUIT_ResourceMgr.h>
42 #include <SUIT_Session.h>
43 #include <SUIT_MessageBox.h>
44 #include <SUIT_OverrideCursor.h>
45
46 #include <LightApp_Application.h>
47 #include <LightApp_SelectionMgr.h>
48
49 #include <SVTK_ViewModel.h>
50 #include <SVTK_ViewWindow.h>
51 #include <SALOME_ListIO.hxx>
52
53 // SALOME KERNEL includes
54 #include <SALOMEDSClient_SObject.hxx>
55
56 // OCCT includes
57 #include <TColStd_MapOfInteger.hxx>
58
59 // Qt includes
60 #include <QApplication>
61 #include <QButtonGroup>
62 #include <QGroupBox>
63 #include <QLabel>
64 #include <QLineEdit>
65 #include <QPushButton>
66 #include <QRadioButton>
67 #include <QCheckBox>
68 #include <QHBoxLayout>
69 #include <QVBoxLayout>
70 #include <QGridLayout>
71 #include <QSpinBox>
72 #include <QKeyEvent>
73
74 // IDL includes
75 #include <SALOMEconfig.h>
76 #include CORBA_SERVER_HEADER(SMESH_Group)
77 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
78
79 /*!
80   \class BusyLocker
81   \brief Simple 'busy state' flag locker.
82   \internal
83 */
84
85 namespace
86 {
87   class BusyLocker
88   {
89   public:
90     //! Constructor. Sets passed boolean flag to \c true.
91     BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
92     //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
93     ~BusyLocker() { myBusy = false; }
94   private:
95     bool& myBusy; //! External 'busy state' boolean flag
96   };
97 }
98
99 #define SPACING 6
100 #define MARGIN  11
101
102 //To disable automatic genericobj management, the following line should be commented.
103 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
104 #define WITHGENERICOBJ
105
106
107 //================================================================================
108 /*!
109  * \brief Constructor
110  */
111 //================================================================================
112
113 SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
114   : QDialog( SMESH::GetDesktop( theModule ) ),
115     mySMESHGUI( theModule ),
116     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
117     myFilterDlg(0),
118     mySelectedObject(SMESH::SMESH_IDSource::_nil())
119 {
120   QPixmap image (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH")));
121
122   setModal(false);
123   setAttribute(Qt::WA_DeleteOnClose, true);
124   setWindowTitle(tr("SMESH_COPY_MESH_TITLE"));
125   setSizeGripEnabled(true);
126
127   QVBoxLayout* SMESHGUI_CopyMeshDlgLayout = new QVBoxLayout(this);
128   SMESHGUI_CopyMeshDlgLayout->setSpacing(SPACING);
129   SMESHGUI_CopyMeshDlgLayout->setMargin(MARGIN);
130
131   /***************************************************************/
132   ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this);
133   QButtonGroup* GroupConstructors = new QButtonGroup(this);
134   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
135   ConstructorsBoxLayout->setSpacing(SPACING);
136   ConstructorsBoxLayout->setMargin(MARGIN);
137
138   QRadioButton* RadioButton1= new QRadioButton(ConstructorsBox);
139   RadioButton1->setIcon(image);
140   GroupConstructors->addButton(RadioButton1, 0);
141
142   ConstructorsBoxLayout->addWidget(RadioButton1);
143   RadioButton1->setChecked(true);
144   GroupConstructors->addButton(RadioButton1, 0);
145
146   /***************************************************************/
147   GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
148   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
149   GroupArgumentsLayout->setSpacing(SPACING);
150   GroupArgumentsLayout->setMargin(MARGIN);
151
152   myIdValidator = new SMESHGUI_IdValidator(this);
153
154   // Controls for idSource/elements selection
155   myTextLabelElements = new QLabel(tr("OBJECT_NAME"), GroupArguments);
156   myLineEditElements = new QLineEdit(GroupArguments);
157   myLineEditElements->setValidator(myIdValidator);
158   myLineEditElements->setMaxLength(-1);
159   myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
160   connect(myFilterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
161
162   // Control for the mesh objects selection
163   myIdSourceCheck = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
164
165   // Name of a mesh to create
166   QLabel* meshNameLabel = new QLabel(tr("NEW_NAME"), GroupArguments);
167   myMeshNameEdit = new QLineEdit(GroupArguments);
168
169   // CheckBox for copying groups
170   myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
171   myCopyGroupsCheck->setChecked(false);
172
173   // CheckBox for keeping ids
174   myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments);
175   myKeepIdsCheck->setChecked(true);
176
177   // layout
178   GroupArgumentsLayout->addWidget(myTextLabelElements,  0, 0);
179   GroupArgumentsLayout->addWidget(myLineEditElements,   0, 1, 1, 5);
180   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 6);
181   GroupArgumentsLayout->addWidget(myIdSourceCheck,      1, 0, 1, 6);
182   GroupArgumentsLayout->addWidget(meshNameLabel,        2, 0);
183   GroupArgumentsLayout->addWidget(myMeshNameEdit,       2, 1, 1, 5);
184   GroupArgumentsLayout->addWidget(myCopyGroupsCheck,    3, 0, 1, 6);
185   GroupArgumentsLayout->addWidget(myKeepIdsCheck,       4, 0, 1, 6);
186
187   /***************************************************************/
188   GroupButtons = new QGroupBox(this);
189   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
190   GroupButtonsLayout->setSpacing(SPACING);
191   GroupButtonsLayout->setMargin(MARGIN);
192
193   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
194   buttonOk->setAutoDefault(true);
195   buttonOk->setDefault(true);
196   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
197   buttonApply->setAutoDefault(true);
198   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
199   buttonCancel->setAutoDefault(true);
200   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
201   buttonHelp->setAutoDefault(true);
202
203   GroupButtonsLayout->addWidget(buttonOk);
204   GroupButtonsLayout->addSpacing(10);
205   GroupButtonsLayout->addWidget(buttonApply);
206   GroupButtonsLayout->addSpacing(10);
207   GroupButtonsLayout->addStretch();
208   GroupButtonsLayout->addWidget(buttonCancel);
209   GroupButtonsLayout->addWidget(buttonHelp);
210
211   /***************************************************************/
212   SMESHGUI_CopyMeshDlgLayout->addWidget(ConstructorsBox);
213   SMESHGUI_CopyMeshDlgLayout->addWidget(GroupArguments);
214   SMESHGUI_CopyMeshDlgLayout->addWidget(GroupButtons);
215
216   /* Initialisations */
217   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
218
219   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
220
221   // Selection filter
222   myIdSourceFilter = new SMESH_TypeFilter( IDSOURCE );
223
224   myHelpFileName = "copy_mesh_page.html";
225
226   Init();
227
228   /* signals and slots connections */
229   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
230   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
231   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
232   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
233
234   connect(mySMESHGUI,     SIGNAL (SignalDeactivateActiveDialog()),
235           this,           SLOT   (DeactivateActiveDialog()));
236   connect(mySelectionMgr, SIGNAL (currentSelectionChanged()),
237           this,           SLOT   (SelectionIntoArgument()));
238   connect(mySMESHGUI,     SIGNAL (SignalCloseAllDialogs()),/* to close dialog if study change */
239           this,           SLOT   (ClickOnCancel()));
240
241   connect(myLineEditElements, SIGNAL(textChanged(const QString&)),
242           this,               SLOT  (onTextChange(const QString&)));
243   connect(myIdSourceCheck,    SIGNAL(toggled(bool)),
244           this,               SLOT  (onSelectIdSource(bool)));
245
246   SelectionIntoArgument();
247 }
248
249 //=================================================================================
250 // function : ~SMESHGUI_CopyMeshDlg()
251 // purpose  : Destroys the object and frees any allocated resources
252 //=================================================================================
253
254 SMESHGUI_CopyMeshDlg::~SMESHGUI_CopyMeshDlg()
255 {
256   if ( myFilterDlg )
257   {
258     myFilterDlg->setParent( 0 );
259     delete myFilterDlg; myFilterDlg = 0;
260   }
261   if ( myIdSourceFilter )
262   {
263     if ( mySelectionMgr )
264       mySelectionMgr->removeFilter( myIdSourceFilter );
265     delete myIdSourceFilter; myIdSourceFilter=0;
266   }
267 }
268
269 //=================================================================================
270 // function : Init()
271 // purpose  :
272 //=================================================================================
273 void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
274 {
275   myBusy = false;
276
277   myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
278   if ( ResetControls )
279   {
280     myLineEditElements->clear();
281     //myElementsId = "";
282     myNbOkElements = 0;
283
284     buttonOk->setEnabled(false);
285     buttonApply->setEnabled(false);
286
287     myActor = 0;
288     myMesh = SMESH::SMESH_Mesh::_nil();
289
290     myIdSourceCheck->setChecked(true);
291     myCopyGroupsCheck->setChecked(false);
292     myKeepIdsCheck->setChecked(false);
293
294     onSelectIdSource( myIdSourceCheck->isChecked() );
295   }
296 }
297
298 //=================================================================================
299 // function : ClickOnApply()
300 // purpose  :
301 //=================================================================================
302
303 bool SMESHGUI_CopyMeshDlg::ClickOnApply()
304 {
305   if (mySMESHGUI->isActiveStudyLocked())
306     return false;
307
308   if( !isValid() )
309     return false;
310
311   try
312   {
313     SUIT_OverrideCursor aWaitCursor;
314     SMESH::SMESH_IDSource_var aPartToCopy;
315     if ( myIdSourceCheck->isChecked())
316     {
317       aPartToCopy = mySelectedObject;
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 #ifdef WITHGENERICOBJ
338     // obj has been published in study. Its refcount has been incremented.
339     // It is safe to decrement its refcount
340     // so that it will be destroyed when the entry in study will be removed
341     newMesh->Destroy();
342 #endif
343   } catch (...) {
344   }
345
346   mySMESHGUI->updateObjBrowser(true);
347   SMESHGUI::Modified();
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   if( ClickOnApply() )
363     ClickOnCancel();
364 }
365
366 //=================================================================================
367 // function : ClickOnCancel()
368 // purpose  :
369 //=================================================================================
370 void SMESHGUI_CopyMeshDlg::ClickOnCancel()
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   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   }
502   else
503   {
504     SMESH::GetNameOfSelectedElements( mySelector, IO, aString );
505     myNbOkElements = aString.size();
506     myFilterBtn->setEnabled(true);
507   }
508   myLineEditElements->setText( aString );
509   bool ok = !aString.isEmpty();
510
511   buttonOk->setEnabled(ok);
512   buttonApply->setEnabled(ok);
513 }
514
515 //=======================================================================
516 //function : onSelectIdSource
517 //purpose  :
518 //=======================================================================
519 void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
520 {
521   if (toSelectMesh)
522     myTextLabelElements->setText(tr("OBJECT_NAME"));
523   else
524     myTextLabelElements->setText(tr("ELEM_IDS"));
525
526   if (toSelectMesh) {
527     myLineEditElements->clear();
528   }
529
530   mySelectionMgr->clearFilters();
531   mySelectionMgr->installFilter(myIdSourceFilter);
532   SMESH::SetPointRepresentation(false);
533
534   if (toSelectMesh) {
535     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
536       aViewWindow->SetSelectionMode( ActorSelection );
537     myLineEditElements->setReadOnly(true);
538     myLineEditElements->setValidator(0);
539   }
540   else
541   {
542     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
543       aViewWindow->SetSelectionMode( CellSelection );
544     myLineEditElements->setReadOnly(false);
545     myLineEditElements->setValidator(myIdValidator);
546     onTextChange(myLineEditElements->text());
547   }
548
549   SelectionIntoArgument();
550 }
551
552 //=================================================================================
553 // function : isValid
554 // purpose  :
555 //=================================================================================
556
557 bool SMESHGUI_CopyMeshDlg::isValid()
558 {
559   if ( myIdSourceCheck->isChecked() )
560     return !mySelectedObject->_is_nil();
561
562   return myNbOkElements > 0;
563 }
564
565 //=================================================================================
566 // function : DeactivateActiveDialog()
567 // purpose  :
568 //=================================================================================
569 void SMESHGUI_CopyMeshDlg::DeactivateActiveDialog()
570 {
571   if (ConstructorsBox->isEnabled()) {
572     ConstructorsBox->setEnabled(false);
573     GroupArguments->setEnabled(false);
574     GroupButtons->setEnabled(false);
575     mySMESHGUI->ResetState();
576     mySMESHGUI->SetActiveDialogBox(0);
577     if ( mySelectionMgr )
578       mySelectionMgr->removeFilter( myIdSourceFilter );
579   }
580 }
581
582 //=================================================================================
583 // function : ActivateThisDialog()
584 // purpose  :
585 //=================================================================================
586 void SMESHGUI_CopyMeshDlg::ActivateThisDialog()
587 {
588   /* Emit a signal to deactivate the active dialog */
589   mySMESHGUI->EmitSignalDeactivateDialog();
590   ConstructorsBox->setEnabled(true);
591   GroupArguments->setEnabled(true);
592   GroupButtons->setEnabled(true);
593
594   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
595
596   onSelectIdSource( myIdSourceCheck->isChecked() );
597
598   SelectionIntoArgument();
599 }
600
601 //=================================================================================
602 // function : enterEvent()
603 // purpose  :
604 //=================================================================================
605 void SMESHGUI_CopyMeshDlg::enterEvent (QEvent*)
606 {
607   if (!ConstructorsBox->isEnabled())
608     ActivateThisDialog();
609 }
610
611 //=================================================================================
612 // function : closeEvent()
613 // purpose  :
614 //=================================================================================
615 void SMESHGUI_CopyMeshDlg::closeEvent (QCloseEvent*)
616 {
617   /* same than click on cancel button */
618   ClickOnCancel();
619 }
620
621 //=======================================================================
622 //function : hideEvent
623 //purpose  : caused by ESC key
624 //=======================================================================
625 void SMESHGUI_CopyMeshDlg::hideEvent (QHideEvent*)
626 {
627   if (!isMinimized())
628     ClickOnCancel();
629 }
630
631 //=================================================================================
632 // function : keyPressEvent()
633 // purpose  :
634 //=================================================================================
635 void SMESHGUI_CopyMeshDlg::keyPressEvent( QKeyEvent* e )
636 {
637   QDialog::keyPressEvent( e );
638   if ( e->isAccepted() )
639     return;
640
641   if ( e->key() == Qt::Key_F1 ) {
642     e->accept();
643     ClickOnHelp();
644   }
645 }
646
647 //=================================================================================
648 // function : setFilters()
649 // purpose  : SLOT. Called when "Filter" button pressed.
650 //=================================================================================
651 void SMESHGUI_CopyMeshDlg::setFilters()
652 {
653   if(myMesh->_is_nil()) {
654     SUIT_MessageBox::critical(this,
655                               tr("SMESH_ERROR"),
656                               tr("NO_MESH_SELECTED"));
657    return;
658   }
659   if ( !myFilterDlg )
660     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
661
662   myFilterDlg->SetSelection();
663   myFilterDlg->SetMesh( myMesh );
664   myFilterDlg->SetSourceWg( myLineEditElements );
665
666   myFilterDlg->show();
667 }