Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_NodesDlg.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_NodesDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #include "SMESHGUI_NodesDlg.h"
30
31 #include "SMESHGUI.h"
32 #include "SMESHGUI_SpinBox.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36
37 #include "SMESH_Actor.h"
38 #include "SMESH_ActorUtils.h"
39 #include "SMESH_ObjectDef.h"
40
41 #include "SMDS_Mesh.hxx"
42 #include "SMDS_MeshNode.hxx"
43
44 #include "SUIT_Session.h"
45 #include "SUIT_OverrideCursor.h"
46 #include "SUIT_ViewWindow.h"
47 #include "SUIT_ViewManager.h"
48 #include "SUIT_MessageBox.h"
49 #include "SUIT_Desktop.h"
50
51 #include "SalomeApp_Study.h"
52 #include "LightApp_Application.h"
53 #include "LightApp_SelectionMgr.h"
54
55 #include "SVTK_Selector.h"
56 #include "SVTK_ViewWindow.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_OK" ));
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       vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors();
458       aCollection->InitTraversal();
459       while (vtkActor *anAct = aCollection->GetNextActor()) {
460         if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
461           if (anActor->hasIO()) {
462             if (SMESH_MeshObj *aMeshObj = dynamic_cast<SMESH_MeshObj*>(anActor->GetObject().get())) {
463               if (myMesh->_is_equivalent(aMeshObj->GetMeshServer())) {
464                 aList.Clear();
465                 aList.Append(anActor->getIO());
466                 mySelectionMgr->setSelectedObjects(aList, false);
467                 break;
468               }
469             }
470           }
471         }
472       }
473     }
474   }
475   return true;
476 }
477
478 //=================================================================================
479 // function : ClickOnCancel()
480 // purpose  :
481 //=================================================================================
482 void SMESHGUI_NodesDlg::ClickOnCancel()
483 {
484   disconnect(mySelectionMgr, 0, this, 0);
485   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
486     aViewWindow->SetSelectionMode(ActorSelection);
487
488   mySimulation->SetVisibility(false);
489   SMESH::SetPointRepresentation(false);
490   mySMESHGUI->ResetState();
491
492   reject();
493 }
494
495 //=================================================================================
496 // function : ClickOnHelp()
497 // purpose  :
498 //=================================================================================
499 void SMESHGUI_NodesDlg::ClickOnHelp()
500 {
501   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
502   if (app) 
503     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
504   else {
505                 QString platform;
506 #ifdef WIN32
507                 platform = "winapplication";
508 #else
509                 platform = "application";
510 #endif
511     SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
512                            QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
513                            arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
514                            QObject::tr("BUT_OK"));
515   }
516 }
517
518 //=================================================================================
519 // function : SelectionIntoArgument()
520 // purpose  : Called when selection as changed or other case
521 //=================================================================================
522 void SMESHGUI_NodesDlg::SelectionIntoArgument()
523 {
524   if (!GroupConstructors->isEnabled())
525     return;
526
527   mySimulation->SetVisibility(false);
528   SMESH::SetPointRepresentation(true);
529
530   const SALOME_ListIO& aList = mySelector->StoredIObjects();
531   if (aList.Extent() == 1) {
532     Handle(SALOME_InteractiveObject) anIO = aList.First();
533     if (anIO->hasEntry()) {
534       myMesh = SMESH::GetMeshByIO(anIO);
535       if (myMesh->_is_nil()) return;
536       QString aText;
537       if (SMESH::GetNameOfSelectedNodes(mySelector,anIO,aText) == 1) {
538         if (SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())) {
539           if (SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()) {
540             if (const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
541               SpinBox_X->SetValue(aNode->X());
542               SpinBox_Y->SetValue(aNode->Y());
543               SpinBox_Z->SetValue(aNode->Z());
544             }
545           }
546         }
547       }
548       mySimulation->SetPosition(SpinBox_X->GetValue(),
549                                 SpinBox_Y->GetValue(),
550                                 SpinBox_Z->GetValue());
551     }
552   }
553 }
554
555 //=================================================================================
556 // function : closeEvent()
557 // purpose  :
558 //=================================================================================
559 void SMESHGUI_NodesDlg::closeEvent (QCloseEvent*)
560 {
561   this->ClickOnCancel(); /* same than click on cancel button */
562 }
563
564 //=================================================================================
565 // function : hideEvent()
566 // purpose  : caused by ESC key
567 //=================================================================================
568 void SMESHGUI_NodesDlg::hideEvent (QHideEvent*)
569 {
570   if (!isMinimized())
571     ClickOnCancel();
572 }
573
574 //=================================================================================
575 // function : enterEvent()
576 // purpose  : to reactivate this dialog box when mouse enter onto the window
577 //=================================================================================
578 void SMESHGUI_NodesDlg::enterEvent(QEvent*)
579 {
580   if (!GroupConstructors->isEnabled())
581     ActivateThisDialog();
582 }
583
584 //=================================================================================
585 // function : DeactivateActiveDialog()
586 // purpose  : public slot to deactivate if active
587 //=================================================================================
588 void SMESHGUI_NodesDlg::DeactivateActiveDialog()
589 {
590   if (GroupConstructors->isEnabled()) {
591     GroupConstructors->setEnabled(false);
592     GroupCoordinates->setEnabled(false);
593     GroupButtons->setEnabled(false);
594     mySimulation->SetVisibility(false);
595     mySMESHGUI->ResetState();
596     mySMESHGUI->SetActiveDialogBox(0);
597   }
598 }
599
600 //=================================================================================
601 // function : ActivateThisDialog()
602 // purpose  :
603 //=================================================================================
604 void SMESHGUI_NodesDlg::ActivateThisDialog()
605 {
606   mySMESHGUI->EmitSignalDeactivateDialog();
607   GroupConstructors->setEnabled(true);
608   GroupCoordinates->setEnabled(true);
609   GroupButtons->setEnabled(true);
610
611   SMESH::SetPointRepresentation(true);
612   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
613     aViewWindow->SetSelectionMode(NodeSelection);
614
615   SelectionIntoArgument();
616 }
617
618 //=================================================================================
619 // function : keyPressEvent()
620 // purpose  :
621 //=================================================================================
622 void SMESHGUI_NodesDlg::keyPressEvent( QKeyEvent* e )
623 {
624   QDialog::keyPressEvent( e );
625   if ( e->isAccepted() )
626     return;
627
628   if ( e->key() == Key_F1 )
629     {
630       e->accept();
631       ClickOnHelp();
632     }
633 }