Salome HOME
0020577: EDF 1164 SMESH: Bad dump of concatenate with create common groups
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_NodesDlg.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_NodesDlg.cxx
24 //  Author : Nicolas REJNERI
25 //  Module : SMESH
26 //  $Header$
27 //
28 #include "SMESHGUI_NodesDlg.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
36 #include "SMESH_Actor.h"
37 #include "SMESH_ActorUtils.h"
38 #include "SMESH_ObjectDef.h"
39
40 #include "SMDS_Mesh.hxx"
41 #include "SMDS_MeshNode.hxx"
42
43 #include "SUIT_Session.h"
44 #include "SUIT_OverrideCursor.h"
45 #include "SUIT_ViewWindow.h"
46 #include "SUIT_ViewManager.h"
47 #include "SUIT_MessageBox.h"
48 #include "SUIT_Desktop.h"
49
50 #include "SalomeApp_Study.h"
51 #include "LightApp_Application.h"
52 #include "LightApp_SelectionMgr.h"
53
54 #include "SVTK_Selector.h"
55 #include "SVTK_ViewWindow.h"
56 #include "VTKViewer_Algorithm.h"
57 #include "VTKViewer_CellLocationsArray.h"
58
59 #include "SALOME_Actor.h"
60 #include "SALOME_ListIO.hxx"
61
62 #include "utilities.h"
63
64 // VTK Includes
65 #include <vtkCell.h>
66 #include <vtkIdList.h>
67 #include <vtkCellArray.h>
68 #include <vtkUnsignedCharArray.h>
69 #include <vtkUnstructuredGrid.h>
70 #include <vtkDataSetMapper.h>
71 #include <vtkActorCollection.h>
72 #include <vtkRenderer.h>
73 #include <vtkProperty.h>
74
75 // QT Includes
76 #include <qbuttongroup.h>
77 #include <qframe.h>
78 #include <qgroupbox.h>
79 #include <qlabel.h>
80 #include <qlineedit.h>
81 #include <qpushbutton.h>
82 #include <qradiobutton.h>
83 #include <qlayout.h>
84 #include <qvariant.h>
85 #include <qtooltip.h>
86 #include <qwhatsthis.h>
87 #include <qimage.h>
88 #include <qpixmap.h>
89 #include <qvalidator.h>
90 #include <qevent.h>
91
92 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
93
94 using namespace std;
95
96
97 namespace SMESH {
98
99   void AddNode (SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z)
100   {
101     SUIT_OverrideCursor wc;
102     try {
103       _PTR(SObject) aSobj = SMESH::FindSObject(theMesh);
104       SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
105       aMeshEditor->AddNode(x,y,z);
106       _PTR(Study) aStudy = GetActiveStudyDocument();
107       CORBA::Long anId = aStudy->StudyId();
108       if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, aSobj->GetID().c_str())) {
109         aVisualObj->Update(true);
110       }
111     } catch (SALOME::SALOME_Exception& exc) {
112       INFOS("Follow exception was cought:\n\t" << exc.details.text);
113     } catch (const std::exception& exc) {
114       INFOS("Follow exception was cought:\n\t" << exc.what());
115     } catch (...) {
116       INFOS("Unknown exception was cought !!!");
117     }
118   }
119
120   class TNodeSimulation {
121     SVTK_ViewWindow* myViewWindow;
122
123     SALOME_Actor *myPreviewActor;
124     vtkDataSetMapper* myMapper;
125     vtkPoints* myPoints;
126
127   public:
128     TNodeSimulation(SVTK_ViewWindow* theViewWindow):
129       myViewWindow(theViewWindow)
130     {
131       vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
132
133       // Create points
134       myPoints = vtkPoints::New();
135       myPoints->SetNumberOfPoints(1);
136       myPoints->SetPoint(0,0.0,0.0,0.0);
137
138       // Create cells
139       vtkIdList *anIdList = vtkIdList::New();
140       anIdList->SetNumberOfIds(1);
141
142       vtkCellArray *aCells = vtkCellArray::New();
143       aCells->Allocate(2, 0);
144
145       vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
146       aCellTypesArray->SetNumberOfComponents(1);
147       aCellTypesArray->Allocate(1);
148
149       anIdList->SetId(0, 0);
150       aCells->InsertNextCell(anIdList);
151       aCellTypesArray->InsertNextValue(VTK_VERTEX);
152
153       VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
154       aCellLocationsArray->SetNumberOfComponents(1);
155       aCellLocationsArray->SetNumberOfTuples(1);
156
157       aCells->InitTraversal();
158       vtkIdType npts = 0;
159       aCellLocationsArray->SetValue(0, aCells->GetTraversalLocation(npts));
160
161       aGrid->SetCells(aCellTypesArray, aCellLocationsArray, aCells);
162
163       aGrid->SetPoints(myPoints);
164       aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aCells);
165       aCellLocationsArray->Delete();
166       aCellTypesArray->Delete();
167       aCells->Delete();
168       anIdList->Delete();
169
170       // Create and display actor
171       myMapper = vtkDataSetMapper::New();
172       myMapper->SetInput(aGrid);
173       aGrid->Delete();
174
175       myPreviewActor = SALOME_Actor::New();
176       myPreviewActor->SetInfinitive(true);
177       myPreviewActor->VisibilityOff();
178       myPreviewActor->PickableOff();
179       myPreviewActor->SetMapper(myMapper);
180
181       vtkProperty* aProp = vtkProperty::New();
182       aProp->SetRepresentationToPoints();
183
184       vtkFloatingPointType anRGB[3];
185       GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
186       aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
187
188       vtkFloatingPointType aPointSize = GetFloat( "SMESH:node_size", 3 );
189       aProp->SetPointSize( aPointSize );
190
191       myPreviewActor->SetProperty( aProp );
192       aProp->Delete();
193
194       myViewWindow->AddActor(myPreviewActor);
195     }
196
197     void SetPosition (float x, float y, float z)
198     {
199       myPoints->SetPoint(0,x,y,z);
200       myPoints->Modified();
201       SetVisibility(true);
202     }
203
204     void SetVisibility (bool theVisibility)
205     {
206       myPreviewActor->SetVisibility(theVisibility);
207       RepaintCurrentView();
208     }
209
210     ~TNodeSimulation()
211     {
212       myViewWindow->RemoveActor(myPreviewActor);
213       myPreviewActor->Delete();
214
215       myMapper->RemoveAllInputs();
216       myMapper->Delete();
217
218       myPoints->Delete();
219     }
220   };
221 }
222
223 //=================================================================================
224 // class    : SMESHGUI_NodesDlg()
225 // purpose  :
226 //=================================================================================
227 SMESHGUI_NodesDlg::SMESHGUI_NodesDlg (SMESHGUI* theModule,
228                                       const char* name,
229                                       bool modal,
230                                       WFlags fl): 
231   QDialog(SMESH::GetDesktop(theModule), 
232           name, 
233           modal, 
234           WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
235   mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
236   mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
237   mySMESHGUI(theModule)
238 {
239   mySimulation = new SMESH::TNodeSimulation(SMESH::GetViewWindow( mySMESHGUI ));
240
241   QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_NODE")));
242   if (!name)
243     setName("SMESHGUI_NodesDlg");
244   resize(303, 185);
245   setCaption(tr("MESH_NODE_TITLE"));
246   setSizeGripEnabled(TRUE);
247   SMESHGUI_NodesDlgLayout = new QGridLayout(this);
248   SMESHGUI_NodesDlgLayout->setSpacing(6);
249   SMESHGUI_NodesDlgLayout->setMargin(11);
250
251   /***************************************************************/
252   GroupButtons = new QGroupBox(this, "GroupButtons");
253   GroupButtons->setGeometry(QRect(10, 10, 281, 48));
254   GroupButtons->setTitle(tr("" ));
255   GroupButtons->setColumnLayout(0, Qt::Vertical);
256   GroupButtons->layout()->setSpacing(0);
257   GroupButtons->layout()->setMargin(0);
258   GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
259   GroupButtonsLayout->setAlignment(Qt::AlignTop);
260   GroupButtonsLayout->setSpacing(6);
261   GroupButtonsLayout->setMargin(11);
262   buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
263   buttonHelp->setText(tr("SMESH_BUT_HELP" ));
264   buttonHelp->setAutoDefault(TRUE);
265   GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
266   buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
267   buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
268   buttonCancel->setAutoDefault(TRUE);
269   GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
270   buttonApply = new QPushButton(GroupButtons, "buttonApply");
271   buttonApply->setText(tr("SMESH_BUT_APPLY" ));
272   buttonApply->setAutoDefault(TRUE);
273   GroupButtonsLayout->addWidget(buttonApply, 0, 1);
274   QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
275   GroupButtonsLayout->addItem(spacer_9, 0, 2);
276   buttonOk = new QPushButton(GroupButtons, "buttonOk");
277   buttonOk->setText(tr("SMESH_BUT_APPLY_AND_CLOSE" ));
278   buttonOk->setAutoDefault(TRUE);
279   buttonOk->setDefault(TRUE);
280   GroupButtonsLayout->addWidget(buttonOk, 0, 0);
281   SMESHGUI_NodesDlgLayout->addWidget(GroupButtons, 2, 0);
282
283   /***************************************************************/
284   GroupConstructors = new QButtonGroup(this, "GroupConstructors");
285   GroupConstructors->setTitle(tr("MESH_NODE" ));
286   GroupConstructors->setExclusive(TRUE);
287   GroupConstructors->setColumnLayout(0, Qt::Vertical);
288   GroupConstructors->layout()->setSpacing(0);
289   GroupConstructors->layout()->setMargin(0);
290   GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
291   GroupConstructorsLayout->setAlignment(Qt::AlignTop);
292   GroupConstructorsLayout->setSpacing(6);
293   GroupConstructorsLayout->setMargin(11);
294   Constructor1 = new QRadioButton(GroupConstructors, "Constructor1");
295   Constructor1->setText(tr("" ));
296   Constructor1->setPixmap(image0);
297   Constructor1->setChecked(TRUE);
298   GroupConstructorsLayout->addWidget(Constructor1, 0, 0);
299   QSpacerItem* spacer_2 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
300   GroupConstructorsLayout->addItem(spacer_2, 0, 1);
301   SMESHGUI_NodesDlgLayout->addWidget(GroupConstructors, 0, 0);
302
303   /***************************************************************/
304   GroupCoordinates = new QGroupBox(this, "GroupCoordinates");
305   GroupCoordinates->setTitle(tr("SMESH_COORDINATES" ));
306   GroupCoordinates->setColumnLayout(0, Qt::Vertical);
307   GroupCoordinates->layout()->setSpacing(0);
308   GroupCoordinates->layout()->setMargin(0);
309   GroupCoordinatesLayout = new QGridLayout(GroupCoordinates->layout());
310   GroupCoordinatesLayout->setAlignment(Qt::AlignTop);
311   GroupCoordinatesLayout->setSpacing(6);
312   GroupCoordinatesLayout->setMargin(11);
313
314   TextLabel_X = new QLabel(GroupCoordinates, "TextLabel_X");
315   TextLabel_X->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
316   TextLabel_X->setText(tr("SMESH_X" ));
317   GroupCoordinatesLayout->addWidget(TextLabel_X, 0, 0);
318
319   TextLabel_Y = new QLabel(GroupCoordinates, "TextLabel_Y");
320   //TextLabel_Y->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
321   TextLabel_Y->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
322   TextLabel_Y->setText(tr("SMESH_Y" ));
323   GroupCoordinatesLayout->addWidget(TextLabel_Y, 0, 2);
324
325   TextLabel_Z = new QLabel(GroupCoordinates, "TextLabel_Z");
326   //TextLabel_Z->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
327   TextLabel_Z->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
328   TextLabel_Z->setText(tr("SMESH_Z" ));
329   GroupCoordinatesLayout->addWidget(TextLabel_Z, 0, 4);
330
331   SpinBox_X = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_X");
332   GroupCoordinatesLayout->addWidget(SpinBox_X, 0, 1);
333
334   SpinBox_Y = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_Y");
335   GroupCoordinatesLayout->addWidget(SpinBox_Y, 0, 3);
336
337   SpinBox_Z = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_Z");
338   GroupCoordinatesLayout->addWidget(SpinBox_Z, 0, 5);
339
340   SMESHGUI_NodesDlgLayout->addWidget(GroupCoordinates, 1, 0);
341
342   myHelpFileName = "adding_nodes_and_elements_page.html#adding_nodes_anchor";
343
344   /* Initialisation and display */
345   Init();
346 }
347
348 //=======================================================================
349 // function : ~SMESHGUI_NodesDlg()
350 // purpose  : Destructor
351 //=======================================================================
352 SMESHGUI_NodesDlg::~SMESHGUI_NodesDlg()
353 {
354   delete mySimulation;
355 }
356
357 //=================================================================================
358 // function : Init()
359 // purpose  :
360 //=================================================================================
361 void SMESHGUI_NodesDlg::Init ()
362 {
363   /* Get setting of step value from file configuration */
364   double step;
365   // QString St = SUIT_CONFIG->getSetting("xxxxxxxxxxxxx");  TODO
366   // step = St.toDouble();                                    TODO
367   step = 25.0;
368
369   /* min, max, step and decimals for spin boxes */
370   SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
371   SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
372   SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
373   SpinBox_X->SetValue(0.0);
374   SpinBox_Y->SetValue(0.0);
375   SpinBox_Z->SetValue(0.0);
376
377   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
378
379   /* signals and slots connections */
380   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
381   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
382   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
383   connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
384
385   connect(SpinBox_X, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double)));
386   connect(SpinBox_Y, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double)));
387   connect(SpinBox_Z, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double)));
388
389   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
390   connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
391   /* to close dialog if study frame change */
392   connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel()));
393
394   this->show();
395
396   // set selection mode
397   SMESH::SetPointRepresentation(true);
398   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
399     aViewWindow->SetSelectionMode(NodeSelection);
400
401   SelectionIntoArgument();
402 }
403
404 //=================================================================================
405 // function : ValueChangedInSpinBox()
406 // purpose  :
407 //=================================================================================
408 void SMESHGUI_NodesDlg::ValueChangedInSpinBox (double newValue)
409 {
410   if (!myMesh->_is_nil()) {
411     double vx = SpinBox_X->GetValue();
412     double vy = SpinBox_Y->GetValue();
413     double vz = SpinBox_Z->GetValue();
414
415     mySimulation->SetPosition(vx,vy,vz);
416   }
417 }
418
419 //=================================================================================
420 // function : ClickOnOk()
421 // purpose  :
422 //=================================================================================
423 void SMESHGUI_NodesDlg::ClickOnOk()
424 {
425   if (ClickOnApply())
426     ClickOnCancel();
427 }
428
429 //=================================================================================
430 // function : ClickOnApply()
431 // purpose  :
432 //=================================================================================
433 bool SMESHGUI_NodesDlg::ClickOnApply()
434 {
435   if (mySMESHGUI->isActiveStudyLocked())
436     return false;
437
438   if (myMesh->_is_nil()) {
439     SUIT_MessageBox::warn1(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
440                            tr("MESH_IS_NOT_SELECTED"), tr("SMESH_BUT_OK"));
441     return false;
442   }
443
444   /* Recup args and call method */
445   double x = SpinBox_X->GetValue();
446   double y = SpinBox_Y->GetValue();
447   double z = SpinBox_Z->GetValue();
448   mySimulation->SetVisibility(false);
449   SMESH::AddNode(myMesh,x,y,z);
450   SMESH::SetPointRepresentation(true);
451
452   // select myMesh
453   SALOME_ListIO aList;
454   mySelectionMgr->selectedObjects(aList);
455   if (aList.Extent() != 1) {
456     if (SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView()) {
457       VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
458       vtkActorCollection *aCollection = aCopy.GetActors();
459       aCollection->InitTraversal();
460       while (vtkActor *anAct = aCollection->GetNextActor()) {
461         if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
462           if (anActor->hasIO()) {
463             if (SMESH_MeshObj *aMeshObj = dynamic_cast<SMESH_MeshObj*>(anActor->GetObject().get())) {
464               if (myMesh->_is_equivalent(aMeshObj->GetMeshServer())) {
465                 aList.Clear();
466                 aList.Append(anActor->getIO());
467                 mySelectionMgr->setSelectedObjects(aList, false);
468                 break;
469               }
470             }
471           }
472         }
473       }
474     }
475   }
476   return true;
477 }
478
479 //=================================================================================
480 // function : ClickOnCancel()
481 // purpose  :
482 //=================================================================================
483 void SMESHGUI_NodesDlg::ClickOnCancel()
484 {
485   disconnect(mySelectionMgr, 0, this, 0);
486   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
487     aViewWindow->SetSelectionMode(ActorSelection);
488
489   mySimulation->SetVisibility(false);
490   SMESH::SetPointRepresentation(false);
491   mySMESHGUI->ResetState();
492
493   reject();
494 }
495
496 //=================================================================================
497 // function : ClickOnHelp()
498 // purpose  :
499 //=================================================================================
500 void SMESHGUI_NodesDlg::ClickOnHelp()
501 {
502   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
503   if (app) 
504     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
505   else {
506                 QString platform;
507 #ifdef WIN32
508                 platform = "winapplication";
509 #else
510                 platform = "application";
511 #endif
512     SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
513                            QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
514                            arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
515                            QObject::tr("BUT_OK"));
516   }
517 }
518
519 //=================================================================================
520 // function : SelectionIntoArgument()
521 // purpose  : Called when selection as changed or other case
522 //=================================================================================
523 void SMESHGUI_NodesDlg::SelectionIntoArgument()
524 {
525   if (!GroupConstructors->isEnabled())
526     return;
527
528   mySimulation->SetVisibility(false);
529   SMESH::SetPointRepresentation(true);
530
531   const SALOME_ListIO& aList = mySelector->StoredIObjects();
532   if (aList.Extent() == 1) {
533     Handle(SALOME_InteractiveObject) anIO = aList.First();
534     if (anIO->hasEntry()) {
535       myMesh = SMESH::GetMeshByIO(anIO);
536       if (myMesh->_is_nil()) return;
537       QString aText;
538       if (SMESH::GetNameOfSelectedNodes(mySelector,anIO,aText) == 1) {
539         if (SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())) {
540           if (SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()) {
541             if (const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
542               SpinBox_X->SetValue(aNode->X());
543               SpinBox_Y->SetValue(aNode->Y());
544               SpinBox_Z->SetValue(aNode->Z());
545             }
546           }
547         }
548       }
549       mySimulation->SetPosition(SpinBox_X->GetValue(),
550                                 SpinBox_Y->GetValue(),
551                                 SpinBox_Z->GetValue());
552     }
553   }
554 }
555
556 //=================================================================================
557 // function : closeEvent()
558 // purpose  :
559 //=================================================================================
560 void SMESHGUI_NodesDlg::closeEvent (QCloseEvent*)
561 {
562   this->ClickOnCancel(); /* same than click on cancel button */
563 }
564
565 //=================================================================================
566 // function : hideEvent()
567 // purpose  : caused by ESC key
568 //=================================================================================
569 void SMESHGUI_NodesDlg::hideEvent (QHideEvent*)
570 {
571   if (!isMinimized())
572     ClickOnCancel();
573 }
574
575 //=================================================================================
576 // function : enterEvent()
577 // purpose  : to reactivate this dialog box when mouse enter onto the window
578 //=================================================================================
579 void SMESHGUI_NodesDlg::enterEvent(QEvent*)
580 {
581   if (!GroupConstructors->isEnabled())
582     ActivateThisDialog();
583 }
584
585 //=================================================================================
586 // function : DeactivateActiveDialog()
587 // purpose  : public slot to deactivate if active
588 //=================================================================================
589 void SMESHGUI_NodesDlg::DeactivateActiveDialog()
590 {
591   if (GroupConstructors->isEnabled()) {
592     GroupConstructors->setEnabled(false);
593     GroupCoordinates->setEnabled(false);
594     GroupButtons->setEnabled(false);
595     mySimulation->SetVisibility(false);
596     mySMESHGUI->ResetState();
597     mySMESHGUI->SetActiveDialogBox(0);
598   }
599 }
600
601 //=================================================================================
602 // function : ActivateThisDialog()
603 // purpose  :
604 //=================================================================================
605 void SMESHGUI_NodesDlg::ActivateThisDialog()
606 {
607   mySMESHGUI->EmitSignalDeactivateDialog();
608   GroupConstructors->setEnabled(true);
609   GroupCoordinates->setEnabled(true);
610   GroupButtons->setEnabled(true);
611
612   SMESH::SetPointRepresentation(true);
613   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
614     aViewWindow->SetSelectionMode(NodeSelection);
615
616   SelectionIntoArgument();
617 }
618
619 //=================================================================================
620 // function : keyPressEvent()
621 // purpose  :
622 //=================================================================================
623 void SMESHGUI_NodesDlg::keyPressEvent( QKeyEvent* e )
624 {
625   QDialog::keyPressEvent( e );
626   if ( e->isAccepted() )
627     return;
628
629   if ( e->key() == Key_F1 )
630     {
631       e->accept();
632       ClickOnHelp();
633     }
634 }