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