Salome HOME
8eb5e67cece16eaef81766b254d58472d5776c12
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MoveNodesDlg.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_MoveNodesDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #include "SMESHGUI_MoveNodesDlg.h"
30
31 #include "SMESHGUI.h"
32 #include "SMESHGUI_SpinBox.h"
33 #include "SMESHGUI_IdValidator.h"
34 #include "SMESHGUI_Utils.h"
35 #include "SMESHGUI_VTKUtils.h"
36 #include "SMESHGUI_MeshUtils.h"
37
38 #include "SMESH_Actor.h"
39 #include "SMDS_Mesh.hxx"
40 #include "SMDS_MeshNode.hxx"
41
42 #include "LightApp_SelectionMgr.h"
43 #include "LightApp_Application.h"
44 #include "SUIT_ResourceMgr.h"
45 #include "SUIT_Desktop.h"
46 #include "SUIT_Session.h"
47 #include "SUIT_MessageBox.h"
48
49 #include "SVTK_Selector.h"
50 #include "SVTK_ViewModel.h"
51 #include "SVTK_ViewWindow.h"
52 #include "SALOME_ListIO.hxx"
53
54 #include "SVTK_ViewWindow.h"
55 #include "VTKViewer_CellLocationsArray.h"
56
57 #include "utilities.h"
58
59 // OCCT includes
60 #include <TColStd_MapOfInteger.hxx>
61
62 // VTK includes
63 #include <vtkCell.h>
64 #include <vtkIdList.h>
65 #include <vtkCellArray.h>
66 #include <vtkUnsignedCharArray.h>
67 #include <vtkUnstructuredGrid.h>
68 #include <vtkDataSetMapper.h>
69 #include <vtkProperty.h>
70
71 // QT includes
72 #include <qgroupbox.h>
73 #include <qlabel.h>
74 #include <qlineedit.h>
75 #include <qpushbutton.h>
76 #include <qradiobutton.h>
77 #include <qlayout.h>
78 #include <qpixmap.h>
79 #include <qmessagebox.h>
80 #include <qbuttongroup.h>
81
82 // IDL Headers
83 #include <SALOMEconfig.h>
84 #include CORBA_SERVER_HEADER(SMESH_Mesh)
85 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
86
87 #define MARGIN  10
88 #define SPACING 5
89
90
91 //=================================================================================
92 // name    : SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg
93 // Purpose :
94 //=================================================================================
95 SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg (SMESHGUI* theModule, 
96                                               const char* theName):
97   QDialog(SMESH::GetDesktop(theModule), 
98           theName, 
99           false,
100           WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
101   mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
102   mySMESHGUI(theModule)
103 {
104   myPreviewActor = 0;
105   myBusy = false;
106
107   setCaption(tr("CAPTION"));
108
109   QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING);
110
111   QFrame* aMainFrame = createMainFrame  (this);
112   QFrame* aBtnFrame  = createButtonFrame(this);
113
114   aDlgLay->addWidget(aMainFrame);
115   aDlgLay->addWidget(aBtnFrame);
116
117   aDlgLay->setStretchFactor(aMainFrame, 1);
118
119   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
120
121   myHelpFileName = "/files/displacing_nodes.htm";
122
123   Init();
124 }
125
126 //=======================================================================
127 // name    : SMESHGUI_MoveNodesDlg::createButtonFrame
128 // Purpose : Create frame containing buttons
129 //=======================================================================
130 QFrame* SMESHGUI_MoveNodesDlg::createButtonFrame (QWidget* theParent)
131 {
132   QFrame* aFrame = new QFrame(theParent);
133   aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
134
135   myOkBtn     = new QPushButton(tr("SMESH_BUT_OK"   ), aFrame);
136   myApplyBtn  = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
137   myCloseBtn  = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
138   myHelpBtn   = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
139
140   QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
141
142   QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
143
144   aLay->addWidget(myOkBtn);
145   aLay->addWidget(myApplyBtn);
146   aLay->addItem(aSpacer);
147   aLay->addWidget(myCloseBtn);
148   aLay->addWidget(myHelpBtn);
149
150   connect(myOkBtn,    SIGNAL(clicked()), SLOT(onOk()));
151   connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
152   connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
153   connect(myHelpBtn,  SIGNAL(clicked()), SLOT(onHelp()));
154
155   return aFrame;
156 }
157
158 //=======================================================================
159 // name    : SMESHGUI_MoveNodesDlg::createMainFrame
160 // Purpose : Create frame containing dialog's input fields
161 //=======================================================================
162 QFrame* SMESHGUI_MoveNodesDlg::createMainFrame (QWidget* theParent)
163 {
164   QFrame* aFrame = new QFrame(theParent);
165
166   QPixmap iconMoveNode (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE")));
167   QPixmap iconSelect   (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
168
169   QButtonGroup* aPixGrp = new QButtonGroup(1, Qt::Vertical, tr("MESH_NODE"), aFrame);
170   aPixGrp->setExclusive(TRUE);
171   QRadioButton* aRBut = new QRadioButton(aPixGrp);
172   aRBut->setPixmap(iconMoveNode);
173   aRBut->setChecked(TRUE);
174
175   QGroupBox* anIdGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_MOVE"), aFrame);
176   new QLabel(tr("NODE_ID"), anIdGrp);
177   (new QPushButton(anIdGrp))->setPixmap(iconSelect);
178   myId = new QLineEdit(anIdGrp);
179   myId->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
180
181   QGroupBox* aCoordGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_COORDINATES"), aFrame);
182   QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp);
183   aXLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
184   myX = new SMESHGUI_SpinBox(aCoordGrp);
185
186   QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp);
187   aYLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
188   myY = new SMESHGUI_SpinBox(aCoordGrp);
189
190   QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp);
191   aZLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
192   myZ = new SMESHGUI_SpinBox(aCoordGrp);
193
194   myX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 25.0, 3);
195   myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 25.0, 3);
196   myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 25.0, 3);
197
198   QVBoxLayout* aLay = new QVBoxLayout(aFrame);
199   aLay->addWidget(aPixGrp);
200   aLay->addWidget(anIdGrp);
201   aLay->addWidget(aCoordGrp);
202
203   // connect signale and slots
204   connect(myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
205   connect(myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
206   connect(myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
207   connect(myId, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
208
209   return aFrame;
210 }
211
212 //=======================================================================
213 // name    : SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg
214 // Purpose :
215 //=======================================================================
216 SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg()
217 {
218   erasePreview();
219 }
220
221 //=======================================================================
222 // name    : SMESHGUI_MoveNodesDlg::Init
223 // Purpose : Init dialog fields
224 //=======================================================================
225 void SMESHGUI_MoveNodesDlg::Init()
226 {
227   myPreviewActor = 0;
228   myMeshActor = 0;
229   myBusy = false;
230
231   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
232
233   // selection and SMESHGUI
234   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
235   connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
236   connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
237
238   reset();
239   setEnabled(true);
240
241   this->show();
242
243   // set selection mode
244   SMESH::SetPointRepresentation(true);
245   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
246     aViewWindow->SetSelectionMode(NodeSelection);
247
248   onSelectionDone();
249 }
250
251 //=======================================================================
252 // name    : SMESHGUI_MoveNodesDlg::isValid
253 // Purpose : Verify validity of entry information
254 //=======================================================================
255 bool SMESHGUI_MoveNodesDlg::isValid (const bool theMess) const
256 {
257   if (myId->text().isEmpty()) {
258     if (theMess)
259       QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WARNING"),
260                                tr("NODE_ID_IS_NOT_DEFINED"), QMessageBox::Ok);
261     return false;
262   }
263   return true;
264 }
265
266 //=======================================================================
267 // name    : SMESHGUI_MoveNodesDlg::reset
268 // Purpose : Reset the dialog state
269 //=======================================================================
270 void SMESHGUI_MoveNodesDlg::reset()
271 {
272   myId->clear();
273   myX->SetValue(0);
274   myY->SetValue(0);
275   myZ->SetValue(0);
276   redisplayPreview();
277   updateButtons();
278 }
279
280 //=======================================================================
281 // name    : SMESHGUI_MoveNodesDlg::onApply
282 // Purpose : SLOT called when "Apply" button pressed.
283 //=======================================================================
284 bool SMESHGUI_MoveNodesDlg::onApply()
285 {
286   if (mySMESHGUI->isActiveStudyLocked())
287     return false;
288
289   if (!isValid(true))
290     return false;
291
292   SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
293   if (aMesh->_is_nil()) {
294     QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
295                              tr("SMESHG_NO_MESH"), QMessageBox::Ok);
296     return false;
297   }
298
299   SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
300   if (aMeshEditor->_is_nil())
301     return false;
302
303   int anId = myId->text().toInt();
304   bool aResult = false;
305   try {
306     aResult = aMeshEditor->MoveNode(anId, myX->GetValue(), myY->GetValue(), myZ->GetValue());
307   } catch (...) {
308   }
309
310   if (aResult) {
311     SALOME_ListIO aList;
312     aList.Append(myMeshActor->getIO());
313     mySelectionMgr->setSelectedObjects(aList,false);
314     SMESH::UpdateView();
315     reset();
316   }
317
318   return aResult;
319 }
320
321 //=======================================================================
322 // name    : SMESHGUI_MoveNodesDlg::onOk
323 // Purpose : SLOT called when "Ok" button pressed.
324 //=======================================================================
325 void SMESHGUI_MoveNodesDlg::onOk()
326 {
327   if (onApply())
328     onClose();
329 }
330
331 //=======================================================================
332 // name    : SMESHGUI_MoveNodesDlg::onClose
333 // Purpose : SLOT called when "Close" button pressed. Close dialog
334 //=======================================================================
335 void SMESHGUI_MoveNodesDlg::onClose()
336 {
337   //mySelectionMgr->clearSelected();
338   SMESH::SetPointRepresentation(false);
339   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
340     aViewWindow->SetSelectionMode(ActorSelection);
341   disconnect(mySelectionMgr, 0, this, 0);
342   disconnect(mySMESHGUI, 0, this, 0);
343   erasePreview();
344   mySMESHGUI->ResetState();
345   reject();
346 }
347
348 //=================================================================================
349 // function : onHelp()
350 // purpose  :
351 //=================================================================================
352 void SMESHGUI_MoveNodesDlg::onHelp()
353 {
354   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
355   if (app) 
356     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
357   else {
358                 QString platform;
359 #ifdef WIN32
360                 platform = "winapplication";
361 #else
362                 platform = "application";
363 #endif
364     SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
365                            QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
366                            arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
367                            QObject::tr("BUT_OK"));
368   }
369 }
370
371 //=======================================================================
372 // name    : SMESHGUI_MoveNodesDlg::onTextChange
373 // Purpose :
374 //=======================================================================
375 void SMESHGUI_MoveNodesDlg::onTextChange (const QString& theNewText)
376 {
377   if (myBusy) return;
378
379   myOkBtn->setEnabled(false);
380   myApplyBtn->setEnabled(false);
381   erasePreview();
382
383   // select entered node
384   if(myMeshActor){
385     if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()){
386       myBusy = true;
387       Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO();
388       SALOME_ListIO aList;
389       aList.Append(anIO);
390       mySelectionMgr->setSelectedObjects(aList,false);
391       myBusy = false;
392
393       if(const SMDS_MeshElement *anElem = aMesh->FindElement(theNewText.toInt())) {
394         TColStd_MapOfInteger aListInd;
395         aListInd.Add(anElem->GetID());
396         mySelector->AddOrRemoveIndex(anIO,aListInd, false);
397         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
398           aViewWindow->highlight(anIO,true,true);
399         
400         onSelectionDone();
401       }
402     }
403   }
404 }
405
406 //=======================================================================
407 // name    : SMESHGUI_MoveNodesDlg::onSelectionDone
408 // Purpose : SLOT called when selection changed
409 //=======================================================================
410 void SMESHGUI_MoveNodesDlg::onSelectionDone()
411 {
412   if (myBusy) return;
413   myMeshActor = 0;
414
415   SALOME_ListIO aList;
416   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
417
418   if (aList.Extent() == 1) {
419     Handle(SALOME_InteractiveObject) anIO = aList.First();
420     myMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
421     if(myMeshActor){
422       QString aText;
423       if (SMESH::GetNameOfSelectedNodes(mySelector,anIO,aText) == 1) {
424         if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) {
425           if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
426             myBusy = true;
427             myId->setText(aText);
428             myX->SetValue(aNode->X());
429             myY->SetValue(aNode->Y());
430             myZ->SetValue(aNode->Z());
431             myBusy = false;
432             erasePreview(); // avoid overlapping of a selection and a preview
433             updateButtons();
434             return;
435           }
436         }
437       }
438     }
439   }
440
441   reset();
442 }
443
444 //=======================================================================
445 // name    : SMESHGUI_MoveNodesDlg::onDeactivate
446 // Purpose : SLOT called when dialog must be deativated
447 //=======================================================================
448 void SMESHGUI_MoveNodesDlg::onDeactivate()
449 {
450   setEnabled(false);
451   erasePreview();
452 }
453
454 //=======================================================================
455 // name    : SMESHGUI_MoveNodesDlg::enterEvent
456 // Purpose : Event filter
457 //=======================================================================
458 void SMESHGUI_MoveNodesDlg::enterEvent (QEvent*)
459 {
460   if (!isEnabled()) {
461     mySMESHGUI->EmitSignalDeactivateDialog();
462
463     // set selection mode
464     SMESH::SetPointRepresentation(true);
465     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
466       aViewWindow->SetSelectionMode(NodeSelection);
467
468     redisplayPreview();
469
470     setEnabled(true);
471   }
472 }
473
474 //=======================================================================
475 // name    : SMESHGUI_MoveNodesDlg::closeEvent
476 // Purpose :
477 //=======================================================================
478 void SMESHGUI_MoveNodesDlg::closeEvent (QCloseEvent*)
479 {
480   onClose();
481   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
482     aViewWindow->Repaint();
483 }
484
485 //=======================================================================
486 // name    : SMESHGUI_MoveNodesDlg::hideEvent
487 // Purpose : may be caused by ESC key
488 //=======================================================================
489 void SMESHGUI_MoveNodesDlg::hideEvent (QHideEvent*)
490 {
491   if (!isMinimized())
492     onClose();
493 }
494
495 //=======================================================================
496 // name    : SMESHGUI_MoveNodesDlg::updateButtons
497 // Purpose : Update buttons state
498 //=======================================================================
499 void SMESHGUI_MoveNodesDlg::updateButtons()
500 {
501   bool isEnabled = isValid(false);
502   myOkBtn->setEnabled(isEnabled);
503   myApplyBtn->setEnabled(isEnabled);
504 }
505
506 //=======================================================================
507 // name    : SMESHGUI_MoveNodesDlg::erasePreview
508 // Purpose : Erase preview
509 //=======================================================================
510 void  SMESHGUI_MoveNodesDlg::erasePreview()
511 {
512   if (myPreviewActor == 0)
513     return;
514
515   SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
516   if (aViewWindow)
517     aViewWindow->RemoveActor(myPreviewActor);
518   myPreviewActor->Delete();
519   myPreviewActor = 0;
520   if (aViewWindow)
521     aViewWindow->Repaint();
522 }
523
524 //=======================================================================
525 // name    : SMESHGUI_MoveNodesDlg::redisplayPreview
526 // Purpose : Redisplay preview
527 //=======================================================================
528 void SMESHGUI_MoveNodesDlg::redisplayPreview()
529 {
530   if (myBusy)
531     return;
532
533   if (myPreviewActor != 0)
534     erasePreview();
535
536   if (!isValid(false))
537     return;
538
539   vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
540
541   vtkPoints* aPoints = vtkPoints::New();
542   aPoints->SetNumberOfPoints(1);
543   aPoints->SetPoint(0, myX->GetValue(), myY->GetValue(), myZ->GetValue());
544
545   // Create cells
546
547   vtkIdList *anIdList = vtkIdList::New();
548   anIdList->SetNumberOfIds(1);
549
550   vtkCellArray *aCells = vtkCellArray::New();
551   aCells->Allocate(2, 0);
552
553   vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
554   aCellTypesArray->SetNumberOfComponents(1);
555   aCellTypesArray->Allocate(1);
556
557   anIdList->SetId(0, 0);
558   aCells->InsertNextCell(anIdList);
559   aCellTypesArray->InsertNextValue(VTK_VERTEX);
560   anIdList->Delete();
561
562   VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
563   aCellLocationsArray->SetNumberOfComponents(1);
564   aCellLocationsArray->SetNumberOfTuples(1);
565
566   aCells->InitTraversal();
567   vtkIdType npts;
568   aCellLocationsArray->SetValue(0, aCells->GetTraversalLocation(npts));
569
570   aGrid->SetPoints(aPoints);
571   aPoints->Delete();
572
573   aGrid->SetCells(aCellTypesArray,aCellLocationsArray,aCells);
574   aCellLocationsArray->Delete();
575   aCellTypesArray->Delete();
576   aCells->Delete();
577
578   // Create and display actor
579   vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
580   aMapper->SetInput(aGrid);
581   aGrid->Delete();
582
583   myPreviewActor = SALOME_Actor::New();
584   myPreviewActor->PickableOff();
585   myPreviewActor->SetMapper(aMapper);
586   aMapper->Delete();
587
588   vtkProperty* aProp = vtkProperty::New();
589   aProp->SetRepresentationToWireframe();
590   aProp->SetColor(250, 0, 250);
591   aProp->SetPointSize(5);
592   myPreviewActor->SetProperty(aProp);
593   aProp->Delete();
594
595   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
596     {
597       aViewWindow->AddActor(myPreviewActor);
598       aViewWindow->Repaint();
599     }
600 }
601
602 //=================================================================================
603 // function : keyPressEvent()
604 // purpose  :
605 //=================================================================================
606 void SMESHGUI_MoveNodesDlg::keyPressEvent( QKeyEvent* e )
607 {
608   QDialog::keyPressEvent( e );
609   if ( e->isAccepted() )
610     return;
611
612   if ( e->key() == Key_F1 )
613     {
614       e->accept();
615       onHelp();
616     }
617 }