Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_WhatIsDlg.cxx
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  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 //
23 //
24 //  File   : SMESHGUI_WhatIsDlg.cxx
25 //  Author : Vladimir TURIN
26 //  Module : SMESH
27 //  $Header: 
28
29 #include "SMESHGUI_WhatIsDlg.h"
30
31 #include "SMESHGUI.h"
32 #include "SMESHGUI_SpinBox.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36 #include "SMESHGUI_IdValidator.h"
37
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMESH_LogicalFilter.hxx"
41 #include "SMDS_Mesh.hxx"
42 #include "SMDS_VolumeTool.hxx"
43
44 #include "SUIT_Desktop.h"
45 #include "SUIT_ResourceMgr.h"
46 #include "SUIT_Session.h"
47 #include "SUIT_MessageBox.h"
48
49 #include "LightApp_Application.h"
50
51 #include "SVTK_ViewModel.h"
52 #include "SVTK_Selection.h"
53 #include "SVTK_ViewWindow.h"
54 #include "SVTK_Selector.h"
55 #include "SALOME_ListIO.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 = "/files/viewing_mesh_info.htm#element_infos";
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   myActor = SMESH::FindActorByObject(myMesh);
421   if (!myActor)
422     myActor = SMESH::FindActorByEntry(IO->getEntry());
423   if (!myActor)
424     return;
425
426   QString aName;
427   SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
428   MeshName->setText(aName);
429   if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) {
430     GroupMesh->setTitle(tr("SMESH_MESH"));
431   } else if(!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) {
432     GroupMesh->setTitle(tr("SMESH_SUBMESH"));
433   } else if(!SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) {
434     GroupMesh->setTitle(tr("SMESH_GROUP"));
435   }
436
437   int aNbUnits = 0;
438   
439   aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
440   
441   if (aNbUnits < 1)
442     return;
443
444   const SMDS_MeshElement * e = RadioButtonNodes->isChecked()?
445     myActor->GetObject()->GetMesh()->FindNode(aString.toInt()):
446     myActor->GetObject()->GetMesh()->FindElement(aString.toInt());
447   if (e) {
448     QString anInfo;
449     anInfo=tr("ENTITY_TYPE") + ": ";
450     if(e->GetType() == SMDSAbs_Node) {
451       anInfo+=tr("MESH_NODE")+"\n";
452       const SMDS_MeshNode *en = (SMDS_MeshNode*) e;
453     } else if(e->GetType() == SMDSAbs_Edge) {
454       anInfo+=tr("SMESH_EDGE")+"\n";
455       anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
456       const SMDS_MeshEdge *ee = (SMDS_MeshEdge*) e;
457       anInfo+=(ee->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+"\n";
458     } else if(e->GetType() == SMDSAbs_Face) {
459       const SMDS_MeshFace *ef = (SMDS_MeshFace*) e;
460       anInfo+=tr("SMESH_FACE")+"\n";
461       anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
462       if(!ef->IsPoly())
463         anInfo+=(ef->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
464       switch(ef->NbNodes()) {
465       case 3:
466       case 6:
467         {
468           anInfo+=tr("SMESH_TRIANGLE");
469           break;
470         }
471       case 4:
472       case 8:
473         {
474           anInfo+=tr("SMESH_QUADRANGLE");
475           break;
476         }
477       default:
478         break;
479       }
480       anInfo+="\n";
481     } else if(e->GetType() == SMDSAbs_Volume) {
482       anInfo+=tr("SMESH_VOLUME")+"\n";
483       anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
484       const SMDS_MeshVolume *ev = (SMDS_MeshVolume*) e;
485       SMDS_VolumeTool vt(ev);
486       if(vt.GetVolumeType() != SMDS_VolumeTool::POLYHEDA)
487         anInfo+=(ev->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
488       switch(vt.GetVolumeType()) {
489       case SMDS_VolumeTool::TETRA:
490       case SMDS_VolumeTool::QUAD_TETRA:
491         {
492           anInfo+=tr("SMESH_TETRAS");
493           break;
494         }
495       case SMDS_VolumeTool::PYRAM:
496       case SMDS_VolumeTool::QUAD_PYRAM:
497         {
498           anInfo+=tr("SMESH_PYRAMID");
499           break;
500         }
501       case SMDS_VolumeTool::PENTA:
502       case SMDS_VolumeTool::QUAD_PENTA:
503         {
504           anInfo+=tr("SMESH_PRISM");
505           break;
506         }
507       case SMDS_VolumeTool::HEXA:
508       case SMDS_VolumeTool::QUAD_HEXA:
509         {
510           anInfo+=tr("SMESH_HEXAS");
511           break;
512         }
513       case SMDS_VolumeTool::POLYHEDA:
514         {
515           anInfo+=tr("SMESH_POLYEDRON");
516           break;
517         }
518       default:
519         break;
520       }
521       anInfo+="\n";
522     }
523     if(e->GetType() != SMDSAbs_Node)
524       anInfo+=tr("GRAVITY_CENTER") + ":\n";
525     gp_XYZ anXYZ(0.,0.,0.);
526     SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
527     int nbNodes = 0;
528     for(; nodeIt->more(); nbNodes++) {
529       const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
530       anXYZ.Add( gp_XYZ( node->X(), node->Y(), node->Z() ) );
531     }
532     anXYZ.Divide(e->NbNodes()) ;
533     anInfo+=QString("X=%1\nY=%2\nZ=%3\n").arg(anXYZ.X()).arg(anXYZ.Y()).arg(anXYZ.Z());
534     Info->setText(anInfo);
535   }
536
537   if(!curBusy) {
538     myBusy = true;
539     LineEditElements->setText(aString);
540     myBusy = false;
541   }
542 }
543
544 //=================================================================================
545 // function : DeactivateActiveDialog()
546 // purpose  :
547 //=================================================================================
548 void SMESHGUI_WhatIsDlg::DeactivateActiveDialog()
549 {
550   if (GroupArguments->isEnabled()) {
551     GroupSelections->setEnabled(false);
552     GroupMesh->setEnabled(false);
553     GroupArguments->setEnabled(false);
554     GroupButtons->setEnabled(false);
555     mySMESHGUI->ResetState();
556     mySMESHGUI->SetActiveDialogBox(0);
557   }
558 }
559
560 //=================================================================================
561 // function : ActivateThisDialog()
562 // purpose  :
563 //=================================================================================
564 void SMESHGUI_WhatIsDlg::ActivateThisDialog()
565 {
566   /* Emit a signal to deactivate the active dialog */
567   mySMESHGUI->EmitSignalDeactivateDialog();
568   GroupArguments->setEnabled(true);
569   GroupButtons->setEnabled(true);
570   GroupSelections->setEnabled(true);
571   GroupMesh->setEnabled(true);
572
573   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
574
575   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
576     SelectionsClicked(RadioButtonNodes->isChecked()?0:1);
577
578   SelectionIntoArgument();
579 }
580
581 //=================================================================================
582 // function : enterEvent()
583 // purpose  :
584 //=================================================================================
585 void SMESHGUI_WhatIsDlg::enterEvent (QEvent*)
586 {
587   if (!GroupArguments->isEnabled())
588     ActivateThisDialog();
589 }
590
591 //=================================================================================
592 // function : closeEvent()
593 // purpose  :
594 //=================================================================================
595 void SMESHGUI_WhatIsDlg::closeEvent (QCloseEvent*)
596 {
597   /* same than click on cancel button */
598   this->ClickOnCancel();
599 }
600
601 //=======================================================================
602 //function : hideEvent
603 //purpose  : caused by ESC key
604 //=======================================================================
605 void SMESHGUI_WhatIsDlg::hideEvent (QHideEvent*)
606 {
607   if (!isMinimized())
608     ClickOnCancel();
609 }
610
611 //=================================================================================
612 // function : keyPressEvent()
613 // purpose  :
614 //=================================================================================
615 void SMESHGUI_WhatIsDlg::keyPressEvent( QKeyEvent* e )
616 {
617   QDialog::keyPressEvent( e );
618   if ( e->isAccepted() )
619     return;
620
621   if ( e->key() == Key_F1 )
622     {
623       e->accept();
624       ClickOnHelp();
625     }
626 }