Salome HOME
2e62e9c5c43fbeafca5fb419e2419a14578f22f4
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_WhatIsDlg.cxx
1 //  Copyright (C) 2007-2008  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_WhatIsDlg.cxx
24 // Author : Vladimir TURIN, Open CASCADE S.A.S.
25 // SMESH includes
26 //
27 #include "SMESHGUI_WhatIsDlg.h"
28
29 #include "SMESHGUI.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_MeshUtils.h"
33 #include "SMESHGUI_IdValidator.h"
34
35 #include "SMESH_Actor.h"
36 #include "SMESH_TypeFilter.hxx"
37 #include "SMESH_LogicalFilter.hxx"
38 #include "SMDS_Mesh.hxx"
39 #include "SMDS_VolumeTool.hxx"
40
41 // SALOME GUI includes
42 #include <SUIT_Desktop.h>
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_MessageBox.h>
46
47 #include <LightApp_Application.h>
48 #include <LightApp_SelectionMgr.h>
49
50 #include <SVTK_ViewModel.h>
51 #include <SVTK_Selection.h>
52 #include <SVTK_ViewWindow.h>
53 #include <SALOME_ListIO.hxx>
54 #include <SALOME_ListIteratorOfListIO.hxx>
55
56 // OCCT includes
57 #include <TColStd_MapOfInteger.hxx>
58 #include <gp_XYZ.hxx>
59
60 // Qt includes
61 #include <QButtonGroup>
62 #include <QGroupBox>
63 #include <QLabel>
64 #include <QLineEdit>
65 #include <QPushButton>
66 #include <QRadioButton>
67 #include <QTextBrowser>
68 #include <QHBoxLayout>
69 #include <QVBoxLayout>
70 #include <QGridLayout>
71 #include <QKeyEvent>
72
73 // IDL includes
74 #include <SALOMEconfig.h>
75 #include CORBA_SERVER_HEADER(SMESH_Group)
76
77 #define SPACING 6
78 #define MARGIN  11
79
80 //=================================================================================
81 // class    : SMESHGUI_WhatIsDlg()
82 // purpose  :
83 //=================================================================================
84 SMESHGUI_WhatIsDlg::SMESHGUI_WhatIsDlg( SMESHGUI* theModule )
85   : QDialog( SMESH::GetDesktop( theModule ) ),
86     mySMESHGUI( theModule ),
87     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
88 {
89   setModal( false );
90   setAttribute( Qt::WA_DeleteOnClose, true );
91   setWindowTitle(tr("SMESH_WHAT_IS_TITLE"));
92   setSizeGripEnabled(true);
93   QVBoxLayout* SMESHGUI_WhatIsDlgLayout = new QVBoxLayout(this);
94   SMESHGUI_WhatIsDlgLayout->setSpacing(SPACING);
95   SMESHGUI_WhatIsDlgLayout->setMargin(MARGIN);
96   
97   /***************************************************************/
98   GroupMesh = new QGroupBox(this);
99   QHBoxLayout* GroupMeshLayout = new QHBoxLayout(GroupMesh);
100   GroupMeshLayout->setSpacing(SPACING);
101   GroupMeshLayout->setMargin(MARGIN);
102
103   MeshLabel = new QLabel(tr("SMESH_NAME"), GroupMesh);
104   GroupMeshLayout->addWidget(MeshLabel);
105   MeshName = new QLineEdit(GroupMesh);
106   MeshName->setReadOnly(true);
107   GroupMeshLayout->addWidget(MeshName);
108
109   /***************************************************************/
110   GroupSelections = new QGroupBox(tr("ENTITY_TYPE"), this);
111   QButtonGroup* GroupSel = new QButtonGroup(this);
112   QHBoxLayout* GroupSelectionsLayout = new QHBoxLayout(GroupSelections);
113   GroupSelectionsLayout->setSpacing(SPACING);
114   GroupSelectionsLayout->setMargin(MARGIN);
115
116   RadioButtonNodes = new QRadioButton(tr("SMESH_NODES"), GroupSelections);
117   GroupSelectionsLayout->addWidget(RadioButtonNodes);
118   GroupSel->addButton(RadioButtonNodes, 0);
119   RadioButtonElements = new QRadioButton(tr("SMESH_ELEMENTS"), GroupSelections);
120   GroupSelectionsLayout->addWidget(RadioButtonElements);
121   GroupSel->addButton(RadioButtonElements, 1);
122
123   /***************************************************************/
124   GroupArguments = new QGroupBox(tr("SMESH_INFORMATION"), this);
125   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
126   GroupArgumentsLayout->setSpacing(SPACING);
127   GroupArgumentsLayout->setMargin(MARGIN);
128
129   // Controls for elements selection
130   TextLabelElements  = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
131   GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
132
133   LineEditElements  = new QLineEdit(GroupArguments);
134   LineEditElements->setValidator(new SMESHGUI_IdValidator(this));
135   GroupArgumentsLayout->addWidget(LineEditElements, 0, 1);
136
137   // information text browser
138   Info = new QTextBrowser(GroupArguments);
139   Info->setMinimumSize(200, 150);
140   GroupArgumentsLayout->addWidget(Info, 1, 0, 1, 2);
141
142   /***************************************************************/
143   GroupButtons = new QGroupBox(this);
144   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
145   GroupButtonsLayout->setSpacing(SPACING);
146   GroupButtonsLayout->setMargin(MARGIN);
147
148   buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons);
149   buttonOk->setAutoDefault(true);
150   buttonOk->setDefault(true);
151   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
152   buttonHelp->setAutoDefault(true);
153
154   GroupButtonsLayout->addWidget(buttonOk);
155   GroupButtonsLayout->addSpacing(10);
156   GroupButtonsLayout->addStretch();
157   GroupButtonsLayout->addWidget(buttonHelp);
158
159   SMESHGUI_WhatIsDlgLayout->addWidget(GroupMesh);
160   SMESHGUI_WhatIsDlgLayout->addWidget(GroupSelections);
161   SMESHGUI_WhatIsDlgLayout->addWidget(GroupArguments);
162   SMESHGUI_WhatIsDlgLayout->addWidget(GroupButtons);
163
164   RadioButtonNodes->setChecked(true);
165
166   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
167
168   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
169
170   // Costruction of the logical filter
171   SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
172   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
173
174   QList<SUIT_SelectionFilter*> aListOfFilters;
175   if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
176   if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
177
178   myMeshOrSubMeshOrGroupFilter =
179     new SMESH_LogicalFilter(aListOfFilters, SMESH_LogicalFilter::LO_OR);
180
181   myHelpFileName = "mesh_infos_page.html#mesh_element_info_anchor";
182
183   Init();
184
185   /* signals and slots connections */
186   connect(buttonOk,         SIGNAL(clicked()),     this, SLOT(ClickOnOk()));
187   connect(buttonHelp,       SIGNAL(clicked()),     this, SLOT(ClickOnHelp()));
188   connect(GroupSel,         SIGNAL(buttonClicked(int)), SLOT(SelectionsClicked(int)));
189
190   connect(mySMESHGUI,       SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
191   connect(mySelectionMgr,   SIGNAL(currentSelectionChanged()),      this, SLOT(SelectionIntoArgument()));
192   /* to close dialog if study change */
193   connect(mySMESHGUI,       SIGNAL(SignalCloseAllDialogs()),  this, SLOT(ClickOnCancel()));
194   connect(LineEditElements, SIGNAL(textChanged(const QString&)),    SLOT(onTextChange(const QString&)));
195
196   SelectionsClicked(0);
197   SelectionIntoArgument();
198 }
199
200 //=================================================================================
201 // function : ~SMESHGUI_WhatIsDlg()
202 // purpose  : Destroys the object and frees any allocated resources
203 //=================================================================================
204 SMESHGUI_WhatIsDlg::~SMESHGUI_WhatIsDlg()
205 {
206 }
207
208 //=================================================================================
209 // function : Init()
210 // purpose  :
211 //=================================================================================
212 void SMESHGUI_WhatIsDlg::Init (bool ResetControls)
213 {
214   myBusy = false;
215
216   LineEditElements->clear();
217
218   myActor = 0;
219   myMesh = SMESH::SMESH_Mesh::_nil();
220
221   if (ResetControls) {
222     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
223       aViewWindow->SetSelectionMode( CellSelection );
224     onTextChange(LineEditElements->text());
225     
226     SelectionIntoArgument();
227   }
228 }
229
230 //=================================================================================
231 // function : SelectionsClicked()
232 // purpose  : Radio button management
233 //=================================================================================
234 void SMESHGUI_WhatIsDlg::SelectionsClicked (int selectionId)
235 {
236   disconnect(mySelectionMgr, 0, this, 0);
237
238   mySelectionMgr->clearFilters();
239
240   switch (selectionId) {
241   case 0:
242     {
243       SMESH::SetPointRepresentation(true);
244       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
245         aViewWindow->SetSelectionMode( NodeSelection );
246       break;
247     }    
248   case 1:
249     {
250       SMESH::SetPointRepresentation(false);
251       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
252         aViewWindow->SetSelectionMode( CellSelection );
253       break;
254     }
255   }
256
257   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
258   SelectionIntoArgument();
259 }
260
261 //=================================================================================
262 // function : ClickOnOk()
263 // purpose  :
264 //=================================================================================
265 void SMESHGUI_WhatIsDlg::ClickOnOk()
266 {
267   if (mySMESHGUI->isActiveStudyLocked())
268     return;
269
270   SMESH::UpdateView();
271   Init(false);
272   SelectionIntoArgument();
273   ClickOnCancel();
274 }
275
276 //=================================================================================
277 // function : ClickOnCancel()
278 // purpose  :
279 //=================================================================================
280 void SMESHGUI_WhatIsDlg::ClickOnCancel()
281 {
282   disconnect(mySelectionMgr, 0, this, 0);
283   mySelectionMgr->clearFilters();
284   SMESH::SetPointRepresentation(false);
285   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
286     aViewWindow->SetSelectionMode( ActorSelection );
287   mySMESHGUI->ResetState();
288   reject();
289 }
290
291 //=================================================================================
292 // function : ClickOnHelp()
293 // purpose  :
294 //=================================================================================
295 void SMESHGUI_WhatIsDlg::ClickOnHelp()
296 {
297   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
298   if (app) 
299     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
300   else {
301     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
302                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
303                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
304                                                                  "application")).
305                              arg(myHelpFileName));
306   }
307 }
308
309 //=======================================================================
310 // function : onTextChange()
311 // purpose  :
312 //=======================================================================
313 void SMESHGUI_WhatIsDlg::onTextChange (const QString& theNewText)
314 {
315   if (myBusy) return;
316   myBusy = true;
317
318   // hilight entered elements
319   SMDS_Mesh* aMesh = 0;
320   if (myActor)
321     aMesh = myActor->GetObject()->GetMesh();
322
323   if (aMesh) {
324     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
325     
326     TColStd_MapOfInteger newIndices;
327
328     QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
329
330     for (int i = 0; i < aListId.count(); i++) {
331       const SMDS_MeshElement * e = RadioButtonNodes->isChecked()?
332         aMesh->FindNode(aListId[ i ].toInt()):
333         aMesh->FindElement(aListId[ i ].toInt());
334       if (e)
335         newIndices.Add(e->GetID());
336     }
337
338     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
339     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
340       aViewWindow->highlight( anIO, true, true );
341   }
342
343   SelectionIntoArgument();
344
345   myBusy = false;
346 }
347
348 //=================================================================================
349 // function : SelectionIntoArgument()
350 // purpose  : Called when selection as changed or other case
351 //=================================================================================
352 void SMESHGUI_WhatIsDlg::SelectionIntoArgument()
353 {
354   int curBusy = myBusy;
355
356   // clear
357   myActor = 0;
358   QString aString = "";
359
360   myBusy = true;
361   if(!curBusy)
362     LineEditElements->setText(aString);
363   MeshName->setText(aString);
364   GroupMesh->setTitle(tr(""));
365   Info->clear();
366   myBusy = curBusy;
367
368   if (!GroupButtons->isEnabled()) // inactive
369     return;
370
371   // get selected mesh
372   SALOME_ListIO aList;
373   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
374
375   int nbSel = aList.Extent();
376
377   if (nbSel < 1)
378     return;
379
380   Handle(SALOME_InteractiveObject) IO = aList.First();
381   myMesh = SMESH::GetMeshByIO(IO);
382   if (myMesh->_is_nil())
383     return;
384
385   if (nbSel != 1) {
386     //check if all selected objects belongs to one mesh
387     SALOME_ListIteratorOfListIO io( aList );
388     for (io.Next(); io.More(); io.Next() ) {
389       SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(io.Value());
390       if (!mesh->_is_nil() && !mesh->_is_equivalent( myMesh ))
391         return;
392     }
393     // select IO with any element selected (for case of selection by rectangle)
394     IO.Nullify();
395     for (io.Initialize(aList); io.More() && IO.IsNull(); io.Next() )
396       if ( mySelector->HasIndex( io.Value() ))
397         IO = io.Value();
398     if ( IO.IsNull() ) return;
399     // unhilight others
400     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
401       for (io.Initialize(aList); io.More(); io.Next() )
402         if ( !IO->isSame( io.Value() ))
403           aViewWindow->highlight( io.Value(), false, true );
404     }
405   }
406
407   myActor = SMESH::FindActorByObject(myMesh);
408   if (!myActor)
409     myActor = SMESH::FindActorByEntry(IO->getEntry());
410   if (!myActor)
411     return;
412
413   QString aName = IO->getName();
414   // cut off wite spaces from tail, else meaningful head is not visible
415   int size = aName.length();
416   while (size && aName.at(size-1).isSpace() )
417     --size;
418   if ( size != aName.length() )
419     aName.truncate( size );
420   MeshName->setText(aName); // can be something like "2 objects"
421
422   if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) {
423     GroupMesh->setTitle(tr("SMESH_MESH"));
424   } else if(!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) {
425     GroupMesh->setTitle(tr("SMESH_SUBMESH"));
426   } else if(!SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) {
427     GroupMesh->setTitle(tr("SMESH_GROUP"));
428   }
429
430   int aNbUnits = 0;
431   
432   aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
433   
434   if (aNbUnits < 1)
435     return;
436
437   const SMDS_MeshElement * e = RadioButtonNodes->isChecked()?
438     myActor->GetObject()->GetMesh()->FindNode(aString.toInt()):
439     myActor->GetObject()->GetMesh()->FindElement(aString.toInt());
440   if (e) {
441     QString anInfo;
442     anInfo=tr("ENTITY_TYPE") + ": ";
443     if(e->GetType() == SMDSAbs_Node) {
444       anInfo+=tr("MESH_NODE")+"\n";
445       //const SMDS_MeshNode *en = (SMDS_MeshNode*) e; // VSR: not used!
446     } else if(e->GetType() == SMDSAbs_Edge) {
447       anInfo+=tr("SMESH_EDGE")+"\n";
448       anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
449       const SMDS_MeshEdge *ee = (SMDS_MeshEdge*) e;
450       anInfo+=(ee->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+"\n";
451     } else if(e->GetType() == SMDSAbs_Face) {
452       const SMDS_MeshFace *ef = (SMDS_MeshFace*) e;
453       anInfo+=tr("SMESH_FACE")+"\n";
454       anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
455       if(!ef->IsPoly())
456         anInfo+=(ef->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
457       switch(ef->NbNodes()) {
458       case 3:
459       case 6:
460         {
461           anInfo+=tr("SMESH_TRIANGLE");
462           break;
463         }
464       case 4:
465       case 8:
466         {
467           anInfo+=tr("SMESH_QUADRANGLE");
468           break;
469         }
470       default:
471         break;
472       }
473       anInfo+="\n";
474     } else if(e->GetType() == SMDSAbs_Volume) {
475       anInfo+=tr("SMESH_VOLUME")+"\n";
476       anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
477       const SMDS_MeshVolume *ev = (SMDS_MeshVolume*) e;
478       SMDS_VolumeTool vt(ev);
479       if(vt.GetVolumeType() != SMDS_VolumeTool::POLYHEDA)
480         anInfo+=(ev->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
481       switch(vt.GetVolumeType()) {
482       case SMDS_VolumeTool::TETRA:
483       case SMDS_VolumeTool::QUAD_TETRA:
484         {
485           anInfo+=tr("SMESH_TETRAS");
486           break;
487         }
488       case SMDS_VolumeTool::PYRAM:
489       case SMDS_VolumeTool::QUAD_PYRAM:
490         {
491           anInfo+=tr("SMESH_PYRAMID");
492           break;
493         }
494       case SMDS_VolumeTool::PENTA:
495       case SMDS_VolumeTool::QUAD_PENTA:
496         {
497           anInfo+=tr("SMESH_PRISM");
498           break;
499         }
500       case SMDS_VolumeTool::HEXA:
501       case SMDS_VolumeTool::QUAD_HEXA:
502         {
503           anInfo+=tr("SMESH_HEXAS");
504           break;
505         }
506       case SMDS_VolumeTool::POLYHEDA:
507         {
508           anInfo+=tr("SMESH_POLYEDRON");
509           break;
510         }
511       default:
512         break;
513       }
514       anInfo+="\n";
515     }
516     if(e->GetType() != SMDSAbs_Node)
517       anInfo+=tr("GRAVITY_CENTER") + ":\n";
518     gp_XYZ anXYZ(0.,0.,0.);
519     SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
520     int nbNodes = 0;
521     for( ; nodeIt->more(); nbNodes++) {
522       const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
523       anXYZ.Add( gp_XYZ( node->X(), node->Y(), node->Z() ) );
524     }
525     anXYZ.Divide(e->NbNodes());
526     anInfo+=QString("X=%1\nY=%2\nZ=%3\n").arg(anXYZ.X()).arg(anXYZ.Y()).arg(anXYZ.Z());
527     Info->setText(anInfo);
528   }
529
530   if(!curBusy) {
531     myBusy = true;
532     LineEditElements->setText(aString);
533     myBusy = false;
534   }
535 }
536
537 //=================================================================================
538 // function : DeactivateActiveDialog()
539 // purpose  :
540 //=================================================================================
541 void SMESHGUI_WhatIsDlg::DeactivateActiveDialog()
542 {
543   if (GroupArguments->isEnabled()) {
544     GroupSelections->setEnabled(false);
545     GroupMesh->setEnabled(false);
546     GroupArguments->setEnabled(false);
547     GroupButtons->setEnabled(false);
548     mySMESHGUI->ResetState();
549     mySMESHGUI->SetActiveDialogBox(0);
550   }
551 }
552
553 //=================================================================================
554 // function : ActivateThisDialog()
555 // purpose  :
556 //=================================================================================
557 void SMESHGUI_WhatIsDlg::ActivateThisDialog()
558 {
559   /* Emit a signal to deactivate the active dialog */
560   mySMESHGUI->EmitSignalDeactivateDialog();
561   GroupArguments->setEnabled(true);
562   GroupButtons->setEnabled(true);
563   GroupSelections->setEnabled(true);
564   GroupMesh->setEnabled(true);
565
566   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
567
568   if ( SMESH::GetViewWindow( mySMESHGUI ))
569     SelectionsClicked(RadioButtonNodes->isChecked()?0:1);
570
571   SelectionIntoArgument();
572 }
573
574 //=================================================================================
575 // function : enterEvent()
576 // purpose  :
577 //=================================================================================
578 void SMESHGUI_WhatIsDlg::enterEvent (QEvent*)
579 {
580   if (!GroupArguments->isEnabled())
581     ActivateThisDialog();
582 }
583
584 //=================================================================================
585 // function : closeEvent()
586 // purpose  :
587 //=================================================================================
588 void SMESHGUI_WhatIsDlg::closeEvent (QCloseEvent*)
589 {
590   /* same than click on cancel button */
591   ClickOnCancel();
592 }
593
594 //=======================================================================
595 //function : hideEvent
596 //purpose  : caused by ESC key
597 //=======================================================================
598 void SMESHGUI_WhatIsDlg::hideEvent (QHideEvent*)
599 {
600   if (!isMinimized())
601     ClickOnCancel();
602 }
603
604 //=================================================================================
605 // function : keyPressEvent()
606 // purpose  :
607 //=================================================================================
608 void SMESHGUI_WhatIsDlg::keyPressEvent( QKeyEvent* e )
609 {
610   QDialog::keyPressEvent( e );
611   if ( e->isAccepted() )
612     return;
613
614   if ( e->key() == Qt::Key_F1 ) {
615     e->accept();
616     ClickOnHelp();
617   }
618 }