Salome HOME
Update copyright
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_DuplicateNodesDlg.cxx
1 // Copyright (C) 2007-2011  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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_DuplicateNodesDlg.cxx
25 // Author : Michael ZORIN, Open CASCADE S.A.S.
26
27 // SMESH includes
28 #include "SMESHGUI_DuplicateNodesDlg.h"
29
30 #include "SMESHGUI.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33
34 #include <SMESH_TypeFilter.hxx>
35
36 // SALOME GUI includes
37 #include <SUIT_Session.h>
38 #include <SUIT_ResourceMgr.h>
39 #include <SUIT_Desktop.h>
40 #include <SUIT_MessageBox.h>
41 #include <SUIT_OverrideCursor.h>
42
43 #include <LightApp_Application.h>
44 #include <LightApp_SelectionMgr.h>
45
46 #include <SalomeApp_Tools.h>
47
48 #include <SVTK_ViewWindow.h>
49 #include <SALOME_ListIO.hxx>
50 #include <SALOME_ListIteratorOfListIO.hxx>
51
52 // Qt includes
53 #include <QApplication>
54 #include <QButtonGroup>
55 #include <QGroupBox>
56 #include <QLabel>
57 #include <QLineEdit>
58 #include <QPushButton>
59 #include <QRadioButton>
60 #include <QCheckBox>
61 #include <QHBoxLayout>
62 #include <QVBoxLayout>
63 #include <QKeyEvent>
64
65 #include <utilities.h>
66
67 // IDL includes
68 #include <SALOMEconfig.h>
69 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
70
71 #define SPACING 6
72 #define MARGIN  11
73
74 /*!
75   \class BusyLocker
76   \brief Simple 'busy state' flag locker.
77   \internal
78 */
79
80 class BusyLocker
81 {
82 public:
83   //! Constructor. Sets passed boolean flag to \c true.
84   BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
85   //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
86   ~BusyLocker() { myBusy = false; }
87 private:
88   bool& myBusy; //! External 'busy state' boolean flag
89 };
90
91 /*!
92   \brief Constructor
93   \param theModule Mesh module instance
94 */
95 SMESHGUI_DuplicateNodesDlg::SMESHGUI_DuplicateNodesDlg( SMESHGUI* theModule )
96   : QDialog( SMESH::GetDesktop( theModule ) ),
97     mySMESHGUI( theModule ),
98     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
99 {
100   // Dialog attributes
101   setModal(false);
102   setAttribute(Qt::WA_DeleteOnClose, true);
103   setWindowTitle(tr("SMESH_DUPLICATE_TITLE"));
104   setSizeGripEnabled(true);
105
106   // Icons for the dialog operation modes and selection button
107   SUIT_ResourceMgr* aResMgr = SMESH::GetResourceMgr( mySMESHGUI );
108   QPixmap iconWithoutElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES")));
109   QPixmap iconWithElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES_WITH_ELEM")));
110   QPixmap iconSelect (aResMgr->loadPixmap("SMESH", tr("ICON_SELECT")));
111
112   // Main layout
113   QVBoxLayout* aMainLayout = new QVBoxLayout(this);
114   aMainLayout->setSpacing(SPACING);
115   aMainLayout->setMargin(MARGIN);
116
117   // Operation modes selector
118   QGroupBox* aConstructorsBox = new QGroupBox(tr("DUPLICATION_MODE"), this);
119   myGroupConstructors = new QButtonGroup(this);
120   QHBoxLayout* aConstructorsBoxLayout = new QHBoxLayout(aConstructorsBox);
121   aConstructorsBoxLayout->setSpacing(SPACING);
122   aConstructorsBoxLayout->setMargin(MARGIN);
123
124   QRadioButton* aRadioButton1 = new QRadioButton(aConstructorsBox);
125   aRadioButton1->setIcon(iconWithoutElem);
126   QRadioButton* aRadioButton2 = new QRadioButton(aConstructorsBox);
127   aRadioButton2->setIcon(iconWithElem);
128   
129   aConstructorsBoxLayout->addWidget(aRadioButton1);
130   aConstructorsBoxLayout->addWidget(aRadioButton2);
131   myGroupConstructors->addButton(aRadioButton1, 0);
132   myGroupConstructors->addButton(aRadioButton2, 1);
133
134   // Arguments
135   myGroupArguments = new QGroupBox(this);
136   QGridLayout* aGroupArgumentsLayout = new QGridLayout(myGroupArguments);
137   aGroupArgumentsLayout->setSpacing(SPACING);
138   aGroupArgumentsLayout->setMargin(MARGIN);
139     
140   myTextLabel1 = new QLabel(myGroupArguments);
141   mySelectButton1 = new QPushButton(myGroupArguments);
142   mySelectButton1->setIcon(iconSelect);
143   myLineEdit1 = new QLineEdit(myGroupArguments);
144   myLineEdit1->setReadOnly(true);
145
146   myTextLabel2 = new QLabel(myGroupArguments);
147   mySelectButton2 = new QPushButton(myGroupArguments);
148   mySelectButton2->setIcon(iconSelect);
149   myLineEdit2 = new QLineEdit(myGroupArguments);
150   myLineEdit2->setReadOnly(true);
151
152   myTextLabel3 = new QLabel(myGroupArguments);
153   mySelectButton3 = new QPushButton(myGroupArguments);
154   mySelectButton3->setIcon(iconSelect);
155   myLineEdit3 = new QLineEdit(myGroupArguments);
156   myLineEdit3->setReadOnly(true);
157
158   myCheckBoxNewGroup = new QCheckBox(tr("CONSTRUCT_NEW_GROUP_NODES"), myGroupArguments);
159
160   aGroupArgumentsLayout->addWidget(myTextLabel1,    0, 0);
161   aGroupArgumentsLayout->addWidget(mySelectButton1, 0, 1);
162   aGroupArgumentsLayout->addWidget(myLineEdit1,     0, 2);
163   aGroupArgumentsLayout->addWidget(myTextLabel2,    1, 0);
164   aGroupArgumentsLayout->addWidget(mySelectButton2, 1, 1);
165   aGroupArgumentsLayout->addWidget(myLineEdit2,     1, 2);
166   aGroupArgumentsLayout->addWidget(myTextLabel3,    2, 0);
167   aGroupArgumentsLayout->addWidget(mySelectButton3, 2, 1);
168   aGroupArgumentsLayout->addWidget(myLineEdit3,     2, 2);
169   aGroupArgumentsLayout->addWidget(myCheckBoxNewGroup, 3, 0);
170   aGroupArgumentsLayout->setRowStretch(4, 1);
171   
172   // Buttons
173   QGroupBox* aGroupButtons = new QGroupBox(this);
174   QHBoxLayout* aGroupButtonsLayout = new QHBoxLayout(aGroupButtons);
175   aGroupButtonsLayout->setSpacing(SPACING);
176   aGroupButtonsLayout->setMargin(MARGIN);
177
178   myButtonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGroupButtons);
179   myButtonOk->setAutoDefault(true);
180   myButtonOk->setDefault(true);
181   myButtonApply = new QPushButton(tr("SMESH_BUT_APPLY"), aGroupButtons);
182   myButtonApply->setAutoDefault(true);
183   myButtonClose = new QPushButton(tr("SMESH_BUT_CLOSE"), aGroupButtons);
184   myButtonClose->setAutoDefault(true);
185   myButtonHelp = new QPushButton(tr("SMESH_BUT_HELP"), aGroupButtons);
186   myButtonHelp->setAutoDefault(true);
187
188   aGroupButtonsLayout->addWidget(myButtonOk);
189   aGroupButtonsLayout->addSpacing(10);
190   aGroupButtonsLayout->addWidget(myButtonApply);
191   aGroupButtonsLayout->addSpacing(10);
192   aGroupButtonsLayout->addStretch();
193   aGroupButtonsLayout->addWidget(myButtonClose);
194   aGroupButtonsLayout->addWidget(myButtonHelp);
195
196   // Add mode selector, arguments and buttons to the main layout
197   aMainLayout->addWidget(aConstructorsBox);
198   aMainLayout->addWidget(myGroupArguments);
199   aMainLayout->addWidget(aGroupButtons);
200   
201   // Initialize the dialog
202   Init();
203
204   // Help file name
205   myHelpFileName = "double_nodes_page.html";
206
207   // Signals and slots connections
208   connect(myGroupConstructors, SIGNAL(buttonClicked(int)), SLOT(onConstructorsClicked(int)));
209      
210   connect(mySelectButton1, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
211   connect(mySelectButton2, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
212   connect(mySelectButton3, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
213
214   connect(myButtonOk,     SIGNAL(clicked()), this, SLOT(onOk()));
215   connect(myButtonClose,  SIGNAL(clicked()), this, SLOT(onClose()));
216   connect(myButtonApply,  SIGNAL(clicked()), this, SLOT(onApply()));
217   connect(myButtonHelp,   SIGNAL(clicked()), this, SLOT(onHelp()));
218   
219   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionChanged()));
220
221   connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
222   connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(onClose()));
223 }
224
225 /*!
226   \brief Destructor
227 */
228 SMESHGUI_DuplicateNodesDlg::~SMESHGUI_DuplicateNodesDlg()
229 {
230 }
231
232 /*!
233   \brief Destructor
234 */
235 void SMESHGUI_DuplicateNodesDlg::Init()
236 {
237   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
238   myCheckBoxNewGroup->setChecked(true);
239
240   // Set initial parameters
241   myBusy = false;
242   myCurrentLineEdit = myLineEdit1;
243
244   myGroups1.clear();
245   myGroups2.clear();
246   myGroups3.clear();
247   
248   // Set selection mode
249   mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP));
250   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
251     aViewWindow->SetSelectionMode(ActorSelection);
252   
253   // Set construction mode
254   int operationMode = myGroupConstructors->checkedId();
255   if (operationMode < 0) {
256     // The dialog has been just displayed
257     operationMode = 0;
258     myGroupConstructors->button(0)->setChecked(true);
259   }
260   onConstructorsClicked(operationMode);
261 }
262
263 /*!
264   \brief SLOT called to change the dialog operation mode.
265   \param constructorId id of the radio button in mode selector button group
266 */
267 void SMESHGUI_DuplicateNodesDlg::onConstructorsClicked (int constructorId)
268 {
269   // Clear all fields
270   myLineEdit1->clear();
271   myLineEdit2->clear();
272   myLineEdit3->clear();
273
274   myGroups1.clear();
275   myGroups2.clear();
276   myGroups3.clear();
277
278   // Set the first field as current
279   myCurrentLineEdit = myLineEdit1;
280   myCurrentLineEdit->setFocus();
281
282   switch (constructorId) {
283   case 0:
284     {
285       // Set text to the group of arguments and to the first two labels
286       myGroupArguments->setTitle(tr("DUPLICATION_WITHOUT_ELEMS"));
287       myTextLabel1->setText(tr("GROUP_NODES_TO_DUPLICATE"));
288       myTextLabel2->setText(tr("GROUP_NODES_TO_REPLACE"));
289
290       // Set checkbox title
291       myCheckBoxNewGroup->setText(tr("CONSTRUCT_NEW_GROUP_NODES"));
292       
293       // Hide the third field
294       myTextLabel3->hide();
295       mySelectButton3->hide();
296       myLineEdit3->hide();
297       
298       break;
299     }
300   case 1:
301     {
302       // Set text to the group of arguments and to all the labels
303       myGroupArguments->setTitle(tr("DUPLICATION_WITH_ELEMS"));
304       myTextLabel1->setText(tr("GROUP_ELEMS_TO_DUPLICATE"));
305       myTextLabel2->setText(tr("GROUP_NODES_NOT_DUPLICATE"));
306       myTextLabel3->setText(tr("GROUP_ELEMS_TO_REPLACE"));
307       
308       // Set checkbox title
309       myCheckBoxNewGroup->setText(tr("CONSTRUCT_NEW_GROUP_ELEMENTS"));
310
311       // Show the third field
312       myTextLabel3->show();
313       mySelectButton3->show();
314       myLineEdit3->show();
315
316       break;
317     }
318   }
319   
320   // Process selection
321   onSelectionChanged();
322 }
323
324 /*!
325   \brief SLOT called to apply changes.
326 */
327 bool SMESHGUI_DuplicateNodesDlg::onApply()
328 {
329   if ( mySMESHGUI->isActiveStudyLocked() || !isValid() )
330     return false;
331
332   BusyLocker lock( myBusy );
333  
334   bool toCreateGroup = myCheckBoxNewGroup->isChecked();
335   int operationMode = myGroupConstructors->checkedId();
336   
337   // Apply changes
338   bool result = false;
339   SUIT_OverrideCursor aWaitCursor;
340
341   try {
342     SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh();
343     SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
344
345     if ( operationMode == 0 ) {
346       SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
347       g1->length( myGroups1.count() );
348       for ( int i = 0; i < myGroups1.count(); i++ )
349         g1[i] = myGroups1[i];
350       SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
351       g2->length( myGroups2.count() );
352       for ( int i = 0; i < myGroups2.count(); i++ )
353         g2[i] = myGroups2[i];
354
355       if ( toCreateGroup ) {
356         SMESH::SMESH_GroupBase_var aNewGroup = 
357           aMeshEditor->DoubleNodeGroupsNew( g1.in(), g2.in() );
358         result = !CORBA::is_nil( aNewGroup );
359       }
360       else {
361         result = aMeshEditor->DoubleNodeGroups( g1.in(), g2.in() );
362       }
363     }
364     else {
365       SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
366       g1->length( myGroups1.count() );
367       for ( int i = 0; i < myGroups1.count(); i++ )
368         g1[i] = myGroups1[i];
369       SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
370       g2->length( myGroups2.count() );
371       for ( int i = 0; i < myGroups2.count(); i++ )
372         g2[i] = myGroups2[i];
373       SMESH::ListOfGroups_var g3 = new SMESH::ListOfGroups();
374       g3->length( myGroups3.count() );
375
376       for ( int i = 0; i < myGroups3.count(); i++ )
377         g3[i] = myGroups3[i];
378       if ( toCreateGroup ) {
379         SMESH::SMESH_GroupBase_ptr aNewGroup = 
380           aMeshEditor->DoubleNodeElemGroupsNew( g1.in(), g2.in(), g3.in() );
381         result = !CORBA::is_nil( aNewGroup );
382       }
383       else {
384         result = aMeshEditor->DoubleNodeElemGroups( g1.in(), g2.in(), g3.in() );
385       }
386     }
387   }
388   catch (const SALOME::SALOME_Exception& S_ex) {
389     SalomeApp_Tools::QtCatchCorbaException(S_ex);
390   }
391   catch ( const std::exception& exc ) {
392     INFOS( "Follow exception was cought:\n\t" << exc.what() );
393   } 
394   catch (...){
395     INFOS( "Unknown exception was cought !!!" );
396   }
397
398   if (!result) {
399     SUIT_MessageBox::warning(this,
400                              tr("SMESH_WRN_WARNING"),
401                              tr("SMESH_OPERATION_FAILED"));
402     return false;
403   }
404
405   // Update GUI
406   mySelectionMgr->clearSelected();
407   SMESH::UpdateView();
408   SMESHGUI::Modified();
409   mySMESHGUI->updateObjBrowser(true);
410
411   // Reinitialize the dialog
412   Init();
413   
414   return true;
415 }
416
417 /*!
418   \brief SLOT called to apply changes and close the dialog.
419 */
420 void SMESHGUI_DuplicateNodesDlg::onOk()
421 {
422   if (onApply())
423     onClose();
424 }
425
426 /*!
427   \brief SLOT called to close the dialog.
428 */
429 void SMESHGUI_DuplicateNodesDlg::onClose()
430 {
431   disconnect(mySelectionMgr, 0, this, 0);
432   disconnect(mySMESHGUI, 0, this, 0);
433   mySMESHGUI->ResetState();
434   mySelectionMgr->clearFilters();
435   reject();
436 }
437
438 /*!
439   \brief  SLOT called when selection changed.
440 */
441 void SMESHGUI_DuplicateNodesDlg::onSelectionChanged()
442 {
443   if ( myBusy || !isEnabled() ) return;
444   
445   int operationMode = myGroupConstructors->checkedId();
446
447   SALOME_ListIO aList;
448   mySelectionMgr->selectedObjects( aList );
449   //int aNbSel = aList.Extent();
450
451   QList<SMESH::SMESH_GroupBase_var> aGroups;
452
453   SALOME_ListIteratorOfListIO anIter ( aList );
454   bool ok = true;
455   for ( ; anIter.More() && ok; anIter.Next()) {
456     SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>( anIter.Value() );
457     // check group is selected
458     ok = !CORBA::is_nil( aGroup );
459     // check groups of the same mesh are selected
460     if ( ok ) {
461       SMESH::SMESH_Mesh_var aMesh1;
462       if ( !aGroups.isEmpty() ) aMesh1 = aGroups[0]->GetMesh();
463       SMESH::SMESH_Mesh_var aMesh2 = aGroup->GetMesh();
464       ok = CORBA::is_nil( aMesh1 ) || aMesh1->_is_equivalent( aMesh2 );
465     }
466     // check group of proper type is selected
467     if ( ok ) {
468       SMESH::ElementType aGroupType = aGroup->GetType();
469       if ( operationMode == 0 ) {
470         ok = ( myCurrentLineEdit == myLineEdit1 && aGroupType == SMESH::NODE ) ||
471              ( myCurrentLineEdit == myLineEdit2 && aGroupType != SMESH::NODE );
472       }
473       else {
474         ok = ( myCurrentLineEdit == myLineEdit1 && ( aGroupType == SMESH::EDGE ||
475                                                      aGroupType == SMESH::FACE ) ) ||
476              ( myCurrentLineEdit == myLineEdit2 && aGroupType == SMESH::NODE )     ||
477              ( myCurrentLineEdit == myLineEdit3 && aGroupType != SMESH::NODE );
478       }
479     }
480     if ( ok ) aGroups << aGroup;
481   }
482
483   // Clear current field
484   myCurrentLineEdit->clear();
485
486   if ( ok && !aGroups.isEmpty() ) {
487     if      ( myCurrentLineEdit == myLineEdit1 ) myGroups1 = aGroups;
488     else if ( myCurrentLineEdit == myLineEdit2 ) myGroups2 = aGroups;
489     else if ( myCurrentLineEdit == myLineEdit3 ) myGroups3 = aGroups;
490     myCurrentLineEdit->setText( aGroups.count() == 1 ? aGroups[0]->GetName() : 
491                                 QObject::tr( "SMESH_OBJECTS_SELECTED" ).arg( aGroups.count() ) );
492   }
493   else {
494     if      ( myCurrentLineEdit == myLineEdit1 ) myGroups1.clear();
495     else if ( myCurrentLineEdit == myLineEdit2 ) myGroups2.clear();
496     else if ( myCurrentLineEdit == myLineEdit3 ) myGroups3.clear();
497     myCurrentLineEdit->clear();
498   }
499
500   // Enable/disable "Apply and Close" and "Apply" buttons
501   bool isDataValid = isValid();
502   myButtonOk->setEnabled( isDataValid );
503   myButtonApply->setEnabled( isDataValid );
504 }
505
506 /*!
507   \brief  SLOT called when selection button clicked.
508 */
509 void SMESHGUI_DuplicateNodesDlg::onEditCurrentArgument()
510 {
511   QPushButton* send = (QPushButton*)sender();
512   
513   // Set current field for edition
514   if (send == mySelectButton1) {
515     myCurrentLineEdit = myLineEdit1;
516   } 
517   else if (send == mySelectButton2) {
518     myCurrentLineEdit = myLineEdit2;
519   }
520   else if (send == mySelectButton3) {
521     myCurrentLineEdit = myLineEdit3;
522   }
523   
524   myCurrentLineEdit->setFocus();
525   onSelectionChanged();
526 }
527
528 /*!
529   \brief Check if the input data is valid.
530   \return \c true id the data is valid
531 */
532 bool SMESHGUI_DuplicateNodesDlg::isValid()
533 {
534   return myGroupConstructors->checkedId() == 1 ?
535     ( !myGroups1.isEmpty() && !myGroups3.isEmpty()  ) :
536     ( !myGroups1.isEmpty() );
537 }
538
539
540 /*!
541   \brief SLOT called when dialog shoud be deativated.
542 */
543 void SMESHGUI_DuplicateNodesDlg::onDeactivate()
544 {
545   if (isEnabled()) {
546     mySelectionMgr->clearFilters();
547     setEnabled(false);
548     mySMESHGUI->ResetState();
549     mySMESHGUI->SetActiveDialogBox(0);
550   }
551 }
552
553 /*!
554   \brief Receive dialog enter events.
555   Activates the dialog when the mouse cursor enters.
556   Reimplemented from QWidget class.
557 */
558 void SMESHGUI_DuplicateNodesDlg::enterEvent (QEvent*)
559 {
560   if ( !isEnabled() ) {
561     mySMESHGUI->EmitSignalDeactivateDialog();
562     setEnabled(true);
563     mySMESHGUI->SetActiveDialogBox((QDialog*)this);
564     
565     // Set selection mode
566     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
567       aViewWindow->SetSelectionMode(ActorSelection);
568     mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
569   }
570 }
571
572 /*!
573   \brief Receive close events.
574   Reimplemented from QWidget class.
575 */
576 void SMESHGUI_DuplicateNodesDlg::closeEvent (QCloseEvent*)
577 {
578   onClose();
579 }
580
581 /*!
582   \brief Receive key press events.
583   Reimplemented from QWidget class.
584 */
585 void SMESHGUI_DuplicateNodesDlg::keyPressEvent( QKeyEvent* e )
586 {
587   QDialog::keyPressEvent( e );
588   if ( e->isAccepted() )
589     return;
590
591   if ( e->key() == Qt::Key_F1 ) {
592     e->accept();
593     onHelp();
594   }
595 }
596
597 /*!
598   \brief Show the dialog help page.
599 */
600 void SMESHGUI_DuplicateNodesDlg::onHelp()
601 {
602   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
603   if (app) 
604     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
605   else {
606     QString platform;
607 #ifdef WIN32
608     platform = "winapplication";
609 #else
610     platform = "application";
611 #endif
612     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
613                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
614                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
615                                                                  platform)).
616                              arg(myHelpFileName));
617   }
618 }