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