Salome HOME
untabify
[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(300, 200);
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="<b>" + tr("ENTITY_TYPE") + ":</b> ";
443     if(e->GetType() == SMDSAbs_Node) {
444       anInfo+=tr("MESH_NODE")+"<br>";
445       //const SMDS_MeshNode *en = (SMDS_MeshNode*) e; // VSR: not used!
446     } else if (e->GetType() == SMDSAbs_0DElement) {
447       anInfo+=tr("SMESH_ELEM0D")+"<br>";
448     } else if(e->GetType() == SMDSAbs_Edge) {
449       anInfo+=tr("SMESH_EDGE")+"<br>";
450       anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";
451       const SMDS_MeshEdge *ee = (SMDS_MeshEdge*) e;
452       anInfo+=(ee->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+"<br>";
453     } else if(e->GetType() == SMDSAbs_Face) {
454       const SMDS_MeshFace *ef = (SMDS_MeshFace*) e;
455       anInfo+=tr("SMESH_FACE")+"<br>";
456       anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";
457       if(!ef->IsPoly())
458         anInfo+=(ef->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
459       switch(ef->NbNodes()) {
460       case 3:
461       case 6:
462         {
463           anInfo+=tr("SMESH_TRIANGLE");
464           break;
465         }
466       case 4:
467       case 8:
468         {
469           anInfo+=tr("SMESH_QUADRANGLE");
470           break;
471         }
472       default:
473         break;
474       }
475       anInfo+="<br>";
476     } else if(e->GetType() == SMDSAbs_Volume) {
477       anInfo+=tr("SMESH_VOLUME")+"<br>";
478       anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";
479       const SMDS_MeshVolume *ev = (SMDS_MeshVolume*) e;
480       SMDS_VolumeTool vt(ev);
481       if(vt.GetVolumeType() != SMDS_VolumeTool::POLYHEDA)
482         anInfo+=(ev->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
483       switch(vt.GetVolumeType()) {
484       case SMDS_VolumeTool::TETRA:
485       case SMDS_VolumeTool::QUAD_TETRA:
486         {
487           anInfo+=tr("SMESH_TETRAS");
488           break;
489         }
490       case SMDS_VolumeTool::PYRAM:
491       case SMDS_VolumeTool::QUAD_PYRAM:
492         {
493           anInfo+=tr("SMESH_PYRAMID");
494           break;
495         }
496       case SMDS_VolumeTool::PENTA:
497       case SMDS_VolumeTool::QUAD_PENTA:
498         {
499           anInfo+=tr("SMESH_PRISM");
500           break;
501         }
502       case SMDS_VolumeTool::HEXA:
503       case SMDS_VolumeTool::QUAD_HEXA:
504         {
505           anInfo+=tr("SMESH_HEXAS");
506           break;
507         }
508       case SMDS_VolumeTool::POLYHEDA:
509         {
510           anInfo+=tr("SMESH_POLYEDRON");
511           break;
512         }
513       default:
514         break;
515       }
516       anInfo+="<br>";
517     }
518     gp_XYZ anXYZ(0.,0.,0.);
519     SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
520     int nbNodes = 0;
521     QString aNodesInfo="";
522     for( ; nodeIt->more(); nbNodes++) {
523       const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
524       anXYZ.Add( gp_XYZ( node->X(), node->Y(), node->Z() ) );
525       if(e->GetType() != SMDSAbs_Node)
526         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());
527       // Calculate Connectivity
528       SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
529       if (it) {
530         aNodesInfo+="<b>" + tr("CONNECTED_ELEMENTS") + ":</b>";
531         while (it->more()) {
532           const SMDS_MeshElement* elem = it->next();
533           aNodesInfo+=QString(" %1").arg(elem->GetID());
534         }
535         if ( (nbNodes+1) != e->NbNodes())
536           aNodesInfo+=QString("<br><br>");
537       }
538     }
539     if(e->GetType() != SMDSAbs_Node)
540       anInfo+="<b>" + tr("GRAVITY_CENTER") + ":</b><br>";
541     anXYZ.Divide(e->NbNodes());
542     anInfo+=QString("X=%1, Y=%2, Z=%3").arg(anXYZ.X()).arg(anXYZ.Y()).arg(anXYZ.Z());
543     if(e->GetType() != SMDSAbs_Node)
544       anInfo+="<br>";
545     if (aNodesInfo!="")
546       anInfo+= "<br>" + aNodesInfo;
547     Info->setText(anInfo);
548   }
549
550   if(!curBusy) {
551     myBusy = true;
552     LineEditElements->setText(aString);
553     myBusy = false;
554   }
555 }
556
557 //=================================================================================
558 // function : DeactivateActiveDialog()
559 // purpose  :
560 //=================================================================================
561 void SMESHGUI_WhatIsDlg::DeactivateActiveDialog()
562 {
563   if (GroupArguments->isEnabled()) {
564     GroupSelections->setEnabled(false);
565     GroupMesh->setEnabled(false);
566     GroupArguments->setEnabled(false);
567     GroupButtons->setEnabled(false);
568     mySMESHGUI->ResetState();
569     mySMESHGUI->SetActiveDialogBox(0);
570   }
571 }
572
573 //=================================================================================
574 // function : ActivateThisDialog()
575 // purpose  :
576 //=================================================================================
577 void SMESHGUI_WhatIsDlg::ActivateThisDialog()
578 {
579   /* Emit a signal to deactivate the active dialog */
580   mySMESHGUI->EmitSignalDeactivateDialog();
581   GroupArguments->setEnabled(true);
582   GroupButtons->setEnabled(true);
583   GroupSelections->setEnabled(true);
584   GroupMesh->setEnabled(true);
585
586   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
587
588   if ( SMESH::GetViewWindow( mySMESHGUI ))
589     SelectionsClicked(RadioButtonNodes->isChecked()?0:1);
590
591   SelectionIntoArgument();
592 }
593
594 //=================================================================================
595 // function : enterEvent()
596 // purpose  :
597 //=================================================================================
598 void SMESHGUI_WhatIsDlg::enterEvent (QEvent*)
599 {
600   if (!GroupArguments->isEnabled())
601     ActivateThisDialog();
602 }
603
604 //=================================================================================
605 // function : closeEvent()
606 // purpose  :
607 //=================================================================================
608 void SMESHGUI_WhatIsDlg::closeEvent (QCloseEvent*)
609 {
610   /* same than click on cancel button */
611   ClickOnCancel();
612 }
613
614 //=======================================================================
615 //function : hideEvent
616 //purpose  : caused by ESC key
617 //=======================================================================
618 void SMESHGUI_WhatIsDlg::hideEvent (QHideEvent*)
619 {
620   if (!isMinimized())
621     ClickOnCancel();
622 }
623
624 //=================================================================================
625 // function : keyPressEvent()
626 // purpose  :
627 //=================================================================================
628 void SMESHGUI_WhatIsDlg::keyPressEvent( QKeyEvent* e )
629 {
630   QDialog::keyPressEvent( e );
631   if ( e->isAccepted() )
632     return;
633
634   if ( e->key() == Qt::Key_F1 ) {
635     e->accept();
636     ClickOnHelp();
637   }
638 }