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