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