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