Salome HOME
Merge from V5_1_4_BR (5_1_4rc2) 09/06/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     SMESHGUI::Modified();
360     reset();
361   }
362
363   return aResult;
364 }
365
366 //=======================================================================
367 // name    : SMESHGUI_MoveNodesDlg::onOk
368 // Purpose : SLOT called when "Ok" button pressed.
369 //=======================================================================
370 void SMESHGUI_MoveNodesDlg::onOk()
371 {
372   if (onApply())
373     onClose();
374 }
375
376 //=======================================================================
377 // name    : SMESHGUI_MoveNodesDlg::onClose
378 // Purpose : SLOT called when "Close" button pressed. Close dialog
379 //=======================================================================
380 void SMESHGUI_MoveNodesDlg::onClose()
381 {
382   //mySelectionMgr->clearSelected();
383   SMESH::SetPointRepresentation(false);
384   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
385     aViewWindow->SetSelectionMode(ActorSelection);
386   disconnect(mySelectionMgr, 0, this, 0);
387   disconnect(mySMESHGUI, 0, this, 0);
388   erasePreview();
389   mySMESHGUI->ResetState();
390   reject();
391 }
392
393 //=================================================================================
394 // function : onHelp()
395 // purpose  :
396 //=================================================================================
397 void SMESHGUI_MoveNodesDlg::onHelp()
398 {
399   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
400   if (app) 
401     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
402   else {
403                 QString platform;
404 #ifdef WIN32
405                 platform = "winapplication";
406 #else
407                 platform = "application";
408 #endif
409     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
410                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
411                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
412                                                                  platform)).
413                              arg(myHelpFileName));
414   }
415 }
416
417 //=======================================================================
418 // name    : SMESHGUI_MoveNodesDlg::onTextChange
419 // Purpose :
420 //=======================================================================
421 void SMESHGUI_MoveNodesDlg::onTextChange (const QString& theNewText)
422 {
423   if (myBusy) return;
424
425   myOkBtn->setEnabled(false);
426   myApplyBtn->setEnabled(false);
427   erasePreview();
428
429   // select entered node
430   if(myMeshActor){
431     if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()){
432       myBusy = true;
433       Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO();
434       SALOME_ListIO aList;
435       aList.Append(anIO);
436       mySelectionMgr->setSelectedObjects(aList,false);
437       myBusy = false;
438
439       if(const SMDS_MeshElement *anElem = aMesh->FindElement(theNewText.toInt())) {
440         TColStd_MapOfInteger aListInd;
441         aListInd.Add(anElem->GetID());
442         mySelector->AddOrRemoveIndex(anIO,aListInd, false);
443         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
444           aViewWindow->highlight(anIO,true,true);
445         
446         onSelectionDone();
447       }
448     }
449   }
450 }
451
452 //=======================================================================
453 // name    : SMESHGUI_MoveNodesDlg::onSelectionDone
454 // Purpose : SLOT called when selection changed
455 //=======================================================================
456 void SMESHGUI_MoveNodesDlg::onSelectionDone()
457 {
458   if (myBusy) return;
459   myMeshActor = 0;
460
461   SALOME_ListIO aList;
462   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
463
464   if (aList.Extent() == 1) {
465     Handle(SALOME_InteractiveObject) anIO = aList.First();
466     myMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
467     if(myMeshActor){
468       QString aText;
469       if (SMESH::GetNameOfSelectedNodes(mySelector,anIO,aText) == 1) {
470         if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) {
471           if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
472             myBusy = true;
473             myId->setText(aText);
474             myX->SetValue(aNode->X());
475             myY->SetValue(aNode->Y());
476             myZ->SetValue(aNode->Z());
477             myBusy = false;
478             erasePreview(); // avoid overlapping of a selection and a preview
479             updateButtons();
480             return;
481           }
482         }
483       }
484     }
485   }
486
487   reset();
488 }
489
490 //=======================================================================
491 // name    : SMESHGUI_MoveNodesDlg::onDeactivate
492 // Purpose : SLOT called when dialog must be deativated
493 //=======================================================================
494 void SMESHGUI_MoveNodesDlg::onDeactivate()
495 {
496   setEnabled(false);
497   erasePreview();
498 }
499
500 //=======================================================================
501 // name    : SMESHGUI_MoveNodesDlg::enterEvent
502 // Purpose : Event filter
503 //=======================================================================
504 void SMESHGUI_MoveNodesDlg::enterEvent (QEvent*)
505 {
506   if (!isEnabled()) {
507     mySMESHGUI->EmitSignalDeactivateDialog();
508
509     // set selection mode
510     SMESH::SetPointRepresentation(true);
511     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
512       aViewWindow->SetSelectionMode(NodeSelection);
513
514     redisplayPreview();
515
516     setEnabled(true);
517   }
518 }
519
520 //=======================================================================
521 // name    : SMESHGUI_MoveNodesDlg::closeEvent
522 // Purpose :
523 //=======================================================================
524 void SMESHGUI_MoveNodesDlg::closeEvent (QCloseEvent*)
525 {
526   onClose();
527   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
528     aViewWindow->Repaint();
529 }
530
531 //=======================================================================
532 // name    : SMESHGUI_MoveNodesDlg::hideEvent
533 // Purpose : may be caused by ESC key
534 //=======================================================================
535 void SMESHGUI_MoveNodesDlg::hideEvent (QHideEvent*)
536 {
537   if (!isMinimized())
538     onClose();
539 }
540
541 //=======================================================================
542 // name    : SMESHGUI_MoveNodesDlg::updateButtons
543 // Purpose : Update buttons state
544 //=======================================================================
545 void SMESHGUI_MoveNodesDlg::updateButtons()
546 {
547   bool isEnabled = isValid(false);
548   myOkBtn->setEnabled(isEnabled);
549   myApplyBtn->setEnabled(isEnabled);
550 }
551
552 //=======================================================================
553 // name    : SMESHGUI_MoveNodesDlg::erasePreview
554 // Purpose : Erase preview
555 //=======================================================================
556 void  SMESHGUI_MoveNodesDlg::erasePreview()
557 {
558   if (myPreviewActor == 0)
559     return;
560
561   SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
562   if (aViewWindow)
563     aViewWindow->RemoveActor(myPreviewActor);
564   myPreviewActor->Delete();
565   myPreviewActor = 0;
566   if (aViewWindow)
567     aViewWindow->Repaint();
568 }
569
570 //=======================================================================
571 // name    : SMESHGUI_MoveNodesDlg::redisplayPreview
572 // Purpose : Redisplay preview
573 //=======================================================================
574 void SMESHGUI_MoveNodesDlg::redisplayPreview()
575 {
576   if (myBusy)
577     return;
578
579   if (myPreviewActor != 0)
580     erasePreview();
581
582   if (!isValid(false))
583     return;
584
585   vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
586
587   vtkPoints* aPoints = vtkPoints::New();
588   aPoints->SetNumberOfPoints(1);
589   aPoints->SetPoint(0, myX->GetValue(), myY->GetValue(), myZ->GetValue());
590
591   // Create cells
592
593   vtkIdList *anIdList = vtkIdList::New();
594   anIdList->SetNumberOfIds(1);
595
596   vtkCellArray *aCells = vtkCellArray::New();
597   aCells->Allocate(2, 0);
598
599   vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
600   aCellTypesArray->SetNumberOfComponents(1);
601   aCellTypesArray->Allocate(1);
602
603   anIdList->SetId(0, 0);
604   aCells->InsertNextCell(anIdList);
605   aCellTypesArray->InsertNextValue(VTK_VERTEX);
606   anIdList->Delete();
607
608   VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
609   aCellLocationsArray->SetNumberOfComponents(1);
610   aCellLocationsArray->SetNumberOfTuples(1);
611
612   aCells->InitTraversal();
613   vtkIdType npts;
614   aCellLocationsArray->SetValue(0, aCells->GetTraversalLocation(npts));
615
616   aGrid->SetPoints(aPoints);
617   aPoints->Delete();
618
619   aGrid->SetCells(aCellTypesArray,aCellLocationsArray,aCells);
620   aCellLocationsArray->Delete();
621   aCellTypesArray->Delete();
622   aCells->Delete();
623
624   // Create and display actor
625   vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
626   aMapper->SetInput(aGrid);
627   aGrid->Delete();
628
629   myPreviewActor = SALOME_Actor::New();
630   myPreviewActor->PickableOff();
631   myPreviewActor->SetMapper(aMapper);
632   aMapper->Delete();
633
634   vtkProperty* aProp = vtkProperty::New();
635   aProp->SetRepresentationToWireframe();
636   aProp->SetColor(250, 0, 250);
637   aProp->SetPointSize(5);
638   myPreviewActor->SetProperty(aProp);
639   aProp->Delete();
640
641   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
642     {
643       aViewWindow->AddActor(myPreviewActor);
644       aViewWindow->Repaint();
645     }
646 }
647
648 //=================================================================================
649 // function : keyPressEvent()
650 // purpose  :
651 //=================================================================================
652 void SMESHGUI_MoveNodesDlg::keyPressEvent( QKeyEvent* e )
653 {
654   QDialog::keyPressEvent( e );
655   if ( e->isAccepted() )
656     return;
657
658   if ( e->key() == Qt::Key_F1 ) {
659     e->accept();
660     onHelp();
661   }
662 }