Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MoveNodesDlg.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_MoveNodesDlg.cxx
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
26 // SMESH includes
27 //
28 #include "SMESHGUI_MoveNodesDlg.h"
29
30 #include "SMESHGUI.h"
31 #include "SMESHGUI_SpinBox.h"
32 #include "SMESHGUI_IdValidator.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36
37 #include <SMESH_Actor.h>
38 #include <SMDS_Mesh.hxx>
39
40 // SALOME GUI includes
41 #include <LightApp_SelectionMgr.h>
42 #include <LightApp_Application.h>
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Desktop.h>
45 #include <SUIT_Session.h>
46 #include <SUIT_MessageBox.h>
47
48 #include <SVTK_ViewModel.h>
49 #include <SVTK_ViewWindow.h>
50 #include <SALOME_ListIO.hxx>
51
52 #include <VTKViewer_CellLocationsArray.h>
53
54 // OCCT includes
55 #include <TColStd_MapOfInteger.hxx>
56
57 // VTK includes
58 #include <vtkIdList.h>
59 #include <vtkCellArray.h>
60 #include <vtkUnsignedCharArray.h>
61 #include <vtkUnstructuredGrid.h>
62 #include <vtkDataSetMapper.h>
63 #include <vtkProperty.h>
64
65 // Qt includes
66 #include <QGroupBox>
67 #include <QLabel>
68 #include <QLineEdit>
69 #include <QPushButton>
70 #include <QRadioButton>
71 #include <QHBoxLayout>
72 #include <QVBoxLayout>
73 #include <QKeyEvent>
74 #include <QButtonGroup>
75
76 // IDL includes
77 #include <SALOMEconfig.h>
78 #include CORBA_SERVER_HEADER(SMESH_Mesh)
79 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
80
81 #define SPACING 6
82 #define MARGIN  11
83
84 //=================================================================================
85 // name    : SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg
86 // Purpose :
87 //=================================================================================
88 SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg(SMESHGUI* theModule):
89   QDialog(SMESH::GetDesktop(theModule)),
90   mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
91   mySMESHGUI(theModule)
92 {
93   myPreviewActor = 0;
94   myBusy = false;
95
96   setModal(false);
97   setWindowTitle(tr("CAPTION"));
98
99   QVBoxLayout* aDlgLay = new QVBoxLayout(this);
100   aDlgLay->setSpacing(SPACING);
101   aDlgLay->setMargin(MARGIN);
102
103   QWidget* aMainFrame = createMainFrame  (this);
104   QWidget* aBtnFrame  = createButtonFrame(this);
105
106   aDlgLay->addWidget(aMainFrame);
107   aDlgLay->addWidget(aBtnFrame);
108
109   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
110
111   myHelpFileName = "moving_nodes_page.html";
112
113   Init();
114 }
115
116 //=======================================================================
117 // name    : SMESHGUI_MoveNodesDlg::createButtonFrame
118 // Purpose : Create frame containing buttons
119 //=======================================================================
120 QWidget* SMESHGUI_MoveNodesDlg::createButtonFrame (QWidget* theParent)
121 {
122   QFrame* aFrame = new QFrame(theParent);
123   aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
124
125   myOkBtn     = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
126   myApplyBtn  = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
127   myCloseBtn  = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
128   myHelpBtn   = new QPushButton(tr("SMESH_BUT_HELP"),  aFrame);
129
130   QHBoxLayout* aLay = new QHBoxLayout(aFrame);
131   aLay->setSpacing(SPACING);
132   aLay->setMargin(MARGIN);
133
134   aLay->addWidget(myOkBtn);
135   aLay->addSpacing(10);
136   aLay->addWidget(myApplyBtn);
137   aLay->addSpacing(10);
138   aLay->addStretch();
139   aLay->addWidget(myCloseBtn);
140   aLay->addWidget(myHelpBtn);
141
142   connect(myOkBtn,    SIGNAL(clicked()), SLOT(onOk()));
143   connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
144   connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
145   connect(myHelpBtn,  SIGNAL(clicked()), SLOT(onHelp()));
146
147   return aFrame;
148 }
149
150 //=======================================================================
151 // name    : SMESHGUI_MoveNodesDlg::createMainFrame
152 // Purpose : Create frame containing dialog's input fields
153 //=======================================================================
154 QWidget* SMESHGUI_MoveNodesDlg::createMainFrame (QWidget* theParent)
155 {
156   QWidget* aFrame = new QWidget(theParent);
157
158   QPixmap iconMoveNode (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE")));
159   QPixmap iconSelect   (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
160
161   //------------------------------------------------------------
162   QGroupBox* aPixGrp = new QGroupBox(tr("MESH_NODE"), aFrame);
163   QButtonGroup* aBtnGrp = new QButtonGroup(this);
164   QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp);
165   aPixGrpLayout->setSpacing(SPACING);
166   aPixGrpLayout->setMargin(MARGIN);
167
168   QRadioButton* aRBut = new QRadioButton(aPixGrp);
169   aRBut->setIcon(iconMoveNode);
170   aRBut->setChecked(true);
171
172   aPixGrpLayout->addWidget(aRBut);
173   aBtnGrp->addButton(aRBut, 0);
174
175   //------------------------------------------------------------
176   QGroupBox* anIdGrp = new QGroupBox(tr("SMESH_MOVE"), aFrame);
177   QHBoxLayout* anIdGrpLayout = new QHBoxLayout(anIdGrp);
178   anIdGrpLayout->setSpacing(SPACING);
179   anIdGrpLayout->setMargin(MARGIN);
180
181   QLabel* idLabl = new QLabel(tr("NODE_ID"), anIdGrp);
182   QPushButton* idBtn = new QPushButton(anIdGrp);
183   idBtn->setIcon(iconSelect);
184   myId = new QLineEdit(anIdGrp);
185   myId->setValidator(new SMESHGUI_IdValidator(this, 1));
186
187   anIdGrpLayout->addWidget(idLabl);
188   anIdGrpLayout->addWidget(idBtn);
189   anIdGrpLayout->addWidget(myId);
190
191   //------------------------------------------------------------
192   QGroupBox* aCoordGrp = new QGroupBox(tr("SMESH_COORDINATES"), aFrame);
193   QHBoxLayout* aCoordGrpLayout = new QHBoxLayout(aCoordGrp);
194   aCoordGrpLayout->setSpacing(SPACING);
195   aCoordGrpLayout->setMargin(MARGIN);
196
197   QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp);
198   myX = new SMESHGUI_SpinBox(aCoordGrp);
199
200   QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp);
201   myY = new SMESHGUI_SpinBox(aCoordGrp);
202
203   QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp);
204   myZ = new SMESHGUI_SpinBox(aCoordGrp);
205
206   aCoordGrpLayout->addWidget(aXLabel);
207   aCoordGrpLayout->addWidget(myX);
208   aCoordGrpLayout->addWidget(aYLabel);
209   aCoordGrpLayout->addWidget(myY);
210   aCoordGrpLayout->addWidget(aZLabel);
211   aCoordGrpLayout->addWidget(myZ);
212
213   //------------------------------------------------------------
214   myX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 25.0, "length_precision");
215   myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 25.0, "length_precision");
216   myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 25.0, "length_precision");
217
218   //------------------------------------------------------------
219   QVBoxLayout* aLay = new QVBoxLayout(aFrame);
220   aLay->setMargin(0);
221   aLay->setMargin(SPACING);
222   aLay->addWidget(aPixGrp);
223   aLay->addWidget(anIdGrp);
224   aLay->addWidget(aCoordGrp);
225
226   //------------------------------------------------------------
227   // connect signale and slots
228   connect(myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
229   connect(myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
230   connect(myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
231   connect(myId, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
232
233   return aFrame;
234 }
235
236 //=======================================================================
237 // name    : SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg
238 // Purpose :
239 //=======================================================================
240 SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg()
241 {
242   erasePreview();
243 }
244
245 //=======================================================================
246 // name    : SMESHGUI_MoveNodesDlg::Init
247 // Purpose : Init dialog fields
248 //=======================================================================
249 void SMESHGUI_MoveNodesDlg::Init()
250 {
251   myPreviewActor = 0;
252   myMeshActor = 0;
253   myBusy = false;
254
255   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
256
257   // selection and SMESHGUI
258   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
259   connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
260   connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
261
262   reset();
263   setEnabled(true);
264
265   // set selection mode
266   SMESH::SetPointRepresentation(true);
267   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
268     aViewWindow->SetSelectionMode(NodeSelection);
269
270   onSelectionDone();
271 }
272
273 //=======================================================================
274 // name    : SMESHGUI_MoveNodesDlg::isValid
275 // Purpose : Verify validity of entry information
276 //=======================================================================
277 bool SMESHGUI_MoveNodesDlg::isValid (const bool theMess)
278 {
279   if (myId->text().isEmpty()) {
280     if (theMess)
281       SUIT_MessageBox::information(this, tr("SMESH_WARNING"),
282                                    tr("NODE_ID_IS_NOT_DEFINED"));
283     return false;
284   }
285
286   QString msg;
287   bool ok = true;
288   ok = myX->isValid( msg, theMess ) && ok;
289   ok = myY->isValid( msg, theMess ) && ok;
290   ok = myZ->isValid( msg, theMess ) && ok;
291   if( !ok ) {
292     if( theMess ) {
293       QString str( tr( "SMESH_INCORRECT_INPUT" ) );
294       if ( !msg.isEmpty() )
295         str += "\n" + msg;
296       SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
297     }
298     return false;
299   }
300
301   return true;
302 }
303
304 //=======================================================================
305 // name    : SMESHGUI_MoveNodesDlg::reset
306 // Purpose : Reset the dialog state
307 //=======================================================================
308 void SMESHGUI_MoveNodesDlg::reset()
309 {
310   myId->clear();
311   myX->SetValue(0);
312   myY->SetValue(0);
313   myZ->SetValue(0);
314   redisplayPreview();
315   updateButtons();
316 }
317
318 //=======================================================================
319 // name    : SMESHGUI_MoveNodesDlg::onApply
320 // Purpose : SLOT called when "Apply" button pressed.
321 //=======================================================================
322 bool SMESHGUI_MoveNodesDlg::onApply()
323 {
324   if (mySMESHGUI->isActiveStudyLocked())
325     return false;
326
327   if (!isValid(true))
328     return false;
329
330   SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
331   if (aMesh->_is_nil()) {
332     SUIT_MessageBox::information(this, tr("SMESH_ERROR"),
333                                  tr("SMESHG_NO_MESH"));
334     return false;
335   }
336
337   SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
338   if (aMeshEditor->_is_nil())
339     return false;
340
341   int anId = myId->text().toInt();
342   bool aResult = false;
343   try {
344     aResult = aMeshEditor->MoveNode(anId, myX->GetValue(), myY->GetValue(), myZ->GetValue());
345
346     QStringList aParameters;
347     aParameters << myX->text();
348     aParameters << myY->text();
349     aParameters << myZ->text();
350     aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
351   } catch (...) {
352   }
353
354   if (aResult) {
355     SALOME_ListIO aList;
356     aList.Append(myMeshActor->getIO());
357     mySelectionMgr->setSelectedObjects(aList,false);
358     SMESH::UpdateView();
359     reset();
360   }
361
362   return aResult;
363 }
364
365 //=======================================================================
366 // name    : SMESHGUI_MoveNodesDlg::onOk
367 // Purpose : SLOT called when "Ok" button pressed.
368 //=======================================================================
369 void SMESHGUI_MoveNodesDlg::onOk()
370 {
371   if (onApply())
372     onClose();
373 }
374
375 //=======================================================================
376 // name    : SMESHGUI_MoveNodesDlg::onClose
377 // Purpose : SLOT called when "Close" button pressed. Close dialog
378 //=======================================================================
379 void SMESHGUI_MoveNodesDlg::onClose()
380 {
381   //mySelectionMgr->clearSelected();
382   SMESH::SetPointRepresentation(false);
383   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
384     aViewWindow->SetSelectionMode(ActorSelection);
385   disconnect(mySelectionMgr, 0, this, 0);
386   disconnect(mySMESHGUI, 0, this, 0);
387   erasePreview();
388   mySMESHGUI->ResetState();
389   reject();
390 }
391
392 //=================================================================================
393 // function : onHelp()
394 // purpose  :
395 //=================================================================================
396 void SMESHGUI_MoveNodesDlg::onHelp()
397 {
398   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
399   if (app) 
400     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
401   else {
402                 QString platform;
403 #ifdef WIN32
404                 platform = "winapplication";
405 #else
406                 platform = "application";
407 #endif
408     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
409                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
410                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
411                                                                  platform)).
412                              arg(myHelpFileName));
413   }
414 }
415
416 //=======================================================================
417 // name    : SMESHGUI_MoveNodesDlg::onTextChange
418 // Purpose :
419 //=======================================================================
420 void SMESHGUI_MoveNodesDlg::onTextChange (const QString& theNewText)
421 {
422   if (myBusy) return;
423
424   myOkBtn->setEnabled(false);
425   myApplyBtn->setEnabled(false);
426   erasePreview();
427
428   // select entered node
429   if(myMeshActor){
430     if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()){
431       myBusy = true;
432       Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO();
433       SALOME_ListIO aList;
434       aList.Append(anIO);
435       mySelectionMgr->setSelectedObjects(aList,false);
436       myBusy = false;
437
438       if(const SMDS_MeshElement *anElem = aMesh->FindElement(theNewText.toInt())) {
439         TColStd_MapOfInteger aListInd;
440         aListInd.Add(anElem->GetID());
441         mySelector->AddOrRemoveIndex(anIO,aListInd, false);
442         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
443           aViewWindow->highlight(anIO,true,true);
444         
445         onSelectionDone();
446       }
447     }
448   }
449 }
450
451 //=======================================================================
452 // name    : SMESHGUI_MoveNodesDlg::onSelectionDone
453 // Purpose : SLOT called when selection changed
454 //=======================================================================
455 void SMESHGUI_MoveNodesDlg::onSelectionDone()
456 {
457   if (myBusy) return;
458   myMeshActor = 0;
459
460   SALOME_ListIO aList;
461   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
462
463   if (aList.Extent() == 1) {
464     Handle(SALOME_InteractiveObject) anIO = aList.First();
465     myMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
466     if(myMeshActor){
467       QString aText;
468       if (SMESH::GetNameOfSelectedNodes(mySelector,anIO,aText) == 1) {
469         if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) {
470           if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
471             myBusy = true;
472             myId->setText(aText);
473             myX->SetValue(aNode->X());
474             myY->SetValue(aNode->Y());
475             myZ->SetValue(aNode->Z());
476             myBusy = false;
477             erasePreview(); // avoid overlapping of a selection and a preview
478             updateButtons();
479             return;
480           }
481         }
482       }
483     }
484   }
485
486   reset();
487 }
488
489 //=======================================================================
490 // name    : SMESHGUI_MoveNodesDlg::onDeactivate
491 // Purpose : SLOT called when dialog must be deativated
492 //=======================================================================
493 void SMESHGUI_MoveNodesDlg::onDeactivate()
494 {
495   setEnabled(false);
496   erasePreview();
497 }
498
499 //=======================================================================
500 // name    : SMESHGUI_MoveNodesDlg::enterEvent
501 // Purpose : Event filter
502 //=======================================================================
503 void SMESHGUI_MoveNodesDlg::enterEvent (QEvent*)
504 {
505   if (!isEnabled()) {
506     mySMESHGUI->EmitSignalDeactivateDialog();
507
508     // set selection mode
509     SMESH::SetPointRepresentation(true);
510     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
511       aViewWindow->SetSelectionMode(NodeSelection);
512
513     redisplayPreview();
514
515     setEnabled(true);
516   }
517 }
518
519 //=======================================================================
520 // name    : SMESHGUI_MoveNodesDlg::closeEvent
521 // Purpose :
522 //=======================================================================
523 void SMESHGUI_MoveNodesDlg::closeEvent (QCloseEvent*)
524 {
525   onClose();
526   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
527     aViewWindow->Repaint();
528 }
529
530 //=======================================================================
531 // name    : SMESHGUI_MoveNodesDlg::hideEvent
532 // Purpose : may be caused by ESC key
533 //=======================================================================
534 void SMESHGUI_MoveNodesDlg::hideEvent (QHideEvent*)
535 {
536   if (!isMinimized())
537     onClose();
538 }
539
540 //=======================================================================
541 // name    : SMESHGUI_MoveNodesDlg::updateButtons
542 // Purpose : Update buttons state
543 //=======================================================================
544 void SMESHGUI_MoveNodesDlg::updateButtons()
545 {
546   bool isEnabled = isValid(false);
547   myOkBtn->setEnabled(isEnabled);
548   myApplyBtn->setEnabled(isEnabled);
549 }
550
551 //=======================================================================
552 // name    : SMESHGUI_MoveNodesDlg::erasePreview
553 // Purpose : Erase preview
554 //=======================================================================
555 void  SMESHGUI_MoveNodesDlg::erasePreview()
556 {
557   if (myPreviewActor == 0)
558     return;
559
560   SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
561   if (aViewWindow)
562     aViewWindow->RemoveActor(myPreviewActor);
563   myPreviewActor->Delete();
564   myPreviewActor = 0;
565   if (aViewWindow)
566     aViewWindow->Repaint();
567 }
568
569 //=======================================================================
570 // name    : SMESHGUI_MoveNodesDlg::redisplayPreview
571 // Purpose : Redisplay preview
572 //=======================================================================
573 void SMESHGUI_MoveNodesDlg::redisplayPreview()
574 {
575   if (myBusy)
576     return;
577
578   if (myPreviewActor != 0)
579     erasePreview();
580
581   if (!isValid(false))
582     return;
583
584   vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
585
586   vtkPoints* aPoints = vtkPoints::New();
587   aPoints->SetNumberOfPoints(1);
588   aPoints->SetPoint(0, myX->GetValue(), myY->GetValue(), myZ->GetValue());
589
590   // Create cells
591
592   vtkIdList *anIdList = vtkIdList::New();
593   anIdList->SetNumberOfIds(1);
594
595   vtkCellArray *aCells = vtkCellArray::New();
596   aCells->Allocate(2, 0);
597
598   vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
599   aCellTypesArray->SetNumberOfComponents(1);
600   aCellTypesArray->Allocate(1);
601
602   anIdList->SetId(0, 0);
603   aCells->InsertNextCell(anIdList);
604   aCellTypesArray->InsertNextValue(VTK_VERTEX);
605   anIdList->Delete();
606
607   VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
608   aCellLocationsArray->SetNumberOfComponents(1);
609   aCellLocationsArray->SetNumberOfTuples(1);
610
611   aCells->InitTraversal();
612   vtkIdType npts;
613   aCellLocationsArray->SetValue(0, aCells->GetTraversalLocation(npts));
614
615   aGrid->SetPoints(aPoints);
616   aPoints->Delete();
617
618   aGrid->SetCells(aCellTypesArray,aCellLocationsArray,aCells);
619   aCellLocationsArray->Delete();
620   aCellTypesArray->Delete();
621   aCells->Delete();
622
623   // Create and display actor
624   vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
625   aMapper->SetInput(aGrid);
626   aGrid->Delete();
627
628   myPreviewActor = SALOME_Actor::New();
629   myPreviewActor->PickableOff();
630   myPreviewActor->SetMapper(aMapper);
631   aMapper->Delete();
632
633   vtkProperty* aProp = vtkProperty::New();
634   aProp->SetRepresentationToWireframe();
635   aProp->SetColor(250, 0, 250);
636   aProp->SetPointSize(5);
637   myPreviewActor->SetProperty(aProp);
638   aProp->Delete();
639
640   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
641     {
642       aViewWindow->AddActor(myPreviewActor);
643       aViewWindow->Repaint();
644     }
645 }
646
647 //=================================================================================
648 // function : keyPressEvent()
649 // purpose  :
650 //=================================================================================
651 void SMESHGUI_MoveNodesDlg::keyPressEvent( QKeyEvent* e )
652 {
653   QDialog::keyPressEvent( e );
654   if ( e->isAccepted() )
655     return;
656
657   if ( e->key() == Qt::Key_F1 ) {
658     e->accept();
659     onHelp();
660   }
661 }