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