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