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