Salome HOME
3c262d28a59e4e9e46878eb2173be7d9b2534002
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MakeNodeAtPointDlg.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 // File   : SMESHGUI_MakeNodeAtPointDlg.cxx
23 // Author : Edward AGAPOV, Open CASCADE S.A.S.
24 // SMESH includes
25 //
26 #include "SMESHGUI_MakeNodeAtPointDlg.h"
27
28 #include "SMESHGUI.h"
29 #include "SMESHGUI_IdValidator.h"
30 #include "SMESHGUI_MeshUtils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_SpinBox.h"
33 #include "SMESHGUI_MeshEditPreview.h"
34
35 #include <SMDS_Mesh.hxx>
36 #include <SMESH_Actor.h>
37 #include <SMESH_ActorUtils.h>
38 #include <SMESH_NumberFilter.hxx>
39 #include <SMESH_LogicalFilter.hxx>
40
41 // SALOME GEOM includes
42 #include <GEOMBase.h>
43
44 // SALOME GUI includes
45 #include <LightApp_SelectionMgr.h>
46 #include <SALOME_ListIO.hxx>
47 #include <SUIT_Desktop.h>
48 #include <SVTK_ViewModel.h>
49 #include <SalomeApp_Tools.h>
50 #include <SalomeApp_TypeFilter.h>
51 #include <SUIT_ResourceMgr.h>
52 #include <SUIT_OverrideCursor.h>
53 #include <SUIT_MessageBox.h>
54
55 // OCCT includes
56 #include <TColStd_MapOfInteger.hxx>
57 #include <TopoDS_Vertex.hxx>
58 #include <BRep_Tool.hxx>
59 #include <gp_Pnt.hxx>
60
61 // Qt includes
62 #include <QGroupBox>
63 #include <QGridLayout>
64 #include <QHBoxLayout>
65 #include <QVBoxLayout>
66 #include <QLineEdit>
67 #include <QPushButton>
68 #include <QLabel>
69 #include <QRadioButton>
70 #include <QCheckBox>
71 #include <QButtonGroup>
72
73 // VTK includes
74 #include <vtkProperty.h>
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  * \brief Dialog to publish a sub-shape of the mesh main shape
86  *        by selecting mesh elements
87  */
88 SMESHGUI_MakeNodeAtPointDlg::SMESHGUI_MakeNodeAtPointDlg()
89   : SMESHGUI_Dialog( 0, false, true )
90 {
91   setWindowTitle(tr("CAPTION"));
92
93   QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
94   aDlgLay->setMargin(MARGIN);;
95   aDlgLay->setSpacing(SPACING);
96
97   QWidget* aMainFrame = createMainFrame  (mainFrame());
98
99   aDlgLay->addWidget(aMainFrame);
100
101   aDlgLay->setStretchFactor(aMainFrame, 1);
102 }
103
104 //=======================================================================
105 // function : createMainFrame()
106 // purpose  : Create frame containing dialog's input fields
107 //=======================================================================
108 QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent)
109 {
110   QWidget* aFrame = new QWidget(theParent);
111
112   SUIT_ResourceMgr* rm = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
113   QPixmap iconMoveNode (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE")));
114   QPixmap iconSelect   (rm->loadPixmap("SMESH", tr("ICON_SELECT")));
115
116   // constructor
117
118   QGroupBox* aPixGrp = new QGroupBox(tr("MESH_PASS_THROUGH_POINT"), aFrame);
119   QButtonGroup* aBtnGrp = new QButtonGroup(this);
120   QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp);
121   aPixGrpLayout->setMargin(MARGIN);
122   aPixGrpLayout->setSpacing(SPACING);
123
124   QRadioButton* aRBut = new QRadioButton(aPixGrp);
125   aRBut->setIcon(iconMoveNode);
126   aRBut->setChecked(true);
127   aPixGrpLayout->addWidget(aRBut);
128   aBtnGrp->addButton(aRBut, 0);
129
130   // coordinates
131
132   QGroupBox* aCoordGrp = new QGroupBox(tr("SMESH_COORDINATES"), aFrame);
133   QHBoxLayout* aCoordGrpLayout = new QHBoxLayout(aCoordGrp);
134   aCoordGrpLayout->setMargin(MARGIN);
135   aCoordGrpLayout->setSpacing(SPACING);
136
137   myCoordBtn = new QPushButton(aCoordGrp);
138   myCoordBtn->setIcon(iconSelect);
139   myCoordBtn->setCheckable(true);
140
141   QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp);
142   myX = new SMESHGUI_SpinBox(aCoordGrp);
143
144   QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp);
145   myY = new SMESHGUI_SpinBox(aCoordGrp);
146
147   QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp);
148   myZ = new SMESHGUI_SpinBox(aCoordGrp);
149
150   myX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
151   myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
152   myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
153
154   aCoordGrpLayout->addWidget(myCoordBtn);
155   aCoordGrpLayout->addWidget(aXLabel);
156   aCoordGrpLayout->addWidget(myX);
157   aCoordGrpLayout->addWidget(aYLabel);
158   aCoordGrpLayout->addWidget(myY);
159   aCoordGrpLayout->addWidget(aZLabel);
160   aCoordGrpLayout->addWidget(myZ);
161
162   // Method selection
163
164   QGroupBox* aMethodGrp = new QGroupBox(tr("METHOD"), aFrame);
165   QHBoxLayout* aMethodGrpLayout = new QHBoxLayout(aMethodGrp);
166   aMethodGrpLayout->setMargin(MARGIN);
167   aMethodGrpLayout->setSpacing(SPACING);
168
169   myMoveRBtn = new QRadioButton(tr("MOVE_EXISTING_METHOD"), aMethodGrp);
170   myCreateRBtn = new QRadioButton(tr("CREATE_NEW_METHOD"), aMethodGrp);
171
172   aMethodGrpLayout->addWidget(myMoveRBtn);
173   aMethodGrpLayout->addWidget(myCreateRBtn);
174
175   // node ID
176
177   myNodeToMoveGrp = new QGroupBox(tr("NODE_2MOVE"), aFrame);
178
179   QLabel* idLabel = new QLabel(tr("NODE_2MOVE_ID"), myNodeToMoveGrp);
180   myIdBtn = new QPushButton(myNodeToMoveGrp);
181   myIdBtn->setIcon(iconSelect);
182   myIdBtn->setCheckable(true);
183   myId = new QLineEdit(myNodeToMoveGrp);
184   myId->setValidator(new SMESHGUI_IdValidator(this, 1));
185   myAutoSearchChkBox = new QCheckBox( tr("AUTO_SEARCH"), myNodeToMoveGrp);
186   myPreviewChkBox = new QCheckBox( tr("PREVIEW"), myNodeToMoveGrp);
187
188   QGridLayout* myNodeToMoveGrpLayout = new QGridLayout(myNodeToMoveGrp);
189   myNodeToMoveGrpLayout->setSpacing(SPACING);
190   myNodeToMoveGrpLayout->setMargin(MARGIN);
191
192   myNodeToMoveGrpLayout->addWidget( idLabel, 0, 0 );
193   myNodeToMoveGrpLayout->addWidget( myIdBtn, 0, 1 );
194   myNodeToMoveGrpLayout->addWidget( myId,    0, 2 );
195   myNodeToMoveGrpLayout->addWidget( myAutoSearchChkBox, 1, 0, 1, 3 );
196   myNodeToMoveGrpLayout->addWidget( myPreviewChkBox,    2, 0, 1, 3 );
197
198   QVBoxLayout* aLay = new QVBoxLayout(aFrame);
199   aLay->addWidget(aPixGrp);
200   aLay->addWidget(aCoordGrp);
201   aLay->addWidget(aMethodGrp);
202   aLay->addWidget(myNodeToMoveGrp);
203
204   connect(myCoordBtn,         SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
205   connect(myMoveRBtn,         SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
206   connect(myCreateRBtn,       SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
207   connect(myIdBtn,            SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
208   connect(myAutoSearchChkBox, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
209
210   myMoveRBtn->setChecked(true);
211   myIdBtn->setChecked(true);
212   myAutoSearchChkBox->setChecked(true);
213
214   return aFrame;
215 }
216
217 //================================================================================
218 /*!
219  * \brief SLOT called when any button is toggled
220   * \param bool - on or off
221  */
222 //================================================================================
223
224 void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on)
225 {
226   const QObject* aSender = sender();
227   if ( on ) {
228     if ( aSender == myCoordBtn ) // button to set coord by node selection
229     {
230       if ( myIdBtn->isEnabled() )
231         myIdBtn->setChecked( !on );
232     }
233     else if ( aSender == myIdBtn ) // button to select a node to move
234     {
235       myCoordBtn->setChecked( !on );
236     }
237     else if ( aSender == myMoveRBtn ) // move node method
238     {
239       myNodeToMoveGrp->setEnabled( true );
240     }
241     else if ( aSender == myCreateRBtn ) // create node method
242     {
243       myNodeToMoveGrp->setEnabled( false );
244       myCoordBtn->setChecked( true ); 
245     }
246   }      
247   if ( aSender == myAutoSearchChkBox ) // automatic node search
248   {
249     if ( on ) {
250       myId->setText("");
251       myId->setReadOnly ( true );
252       myIdBtn->setChecked( false );
253       myIdBtn->setEnabled( false );
254       myCoordBtn->setChecked( true );
255     }
256     else {
257       myId->setReadOnly ( false );
258       myIdBtn->setEnabled( true );
259     }
260   }
261 }
262
263 //================================================================================
264 /*!
265  * \brief Constructor
266 */
267 //================================================================================
268
269 SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp()
270   : SMESHGUI_Helper( getSMESHGUI() )
271 {
272   mySimulation = 0;
273   myDlg = new SMESHGUI_MakeNodeAtPointDlg;
274   myFilter = 0;
275   myHelpFileName = "mesh_through_point_page.html";
276
277   // connect signals and slots
278   connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
279   connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
280   connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
281   connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
282   connect(myDlg->myPreviewChkBox,   SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
283   connect(myDlg->myAutoSearchChkBox,SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
284   connect(myDlg->myMoveRBtn,        SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
285   connect(myDlg->myCreateRBtn,      SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
286 }
287
288 //=======================================================================
289 // function : startOperation()
290 // purpose  : Init dialog fields, connect signals and slots, show dialog
291 //=======================================================================
292 void SMESHGUI_MakeNodeAtPointOp::startOperation()
293 {
294   myNoPreview = false;
295   myMeshActor = 0;
296
297   // init simulation with a current View
298   if ( mySimulation ) delete mySimulation;
299   mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
300   vtkProperty* aProp = vtkProperty::New();
301   aProp->SetRepresentationToWireframe();
302   aProp->SetColor(250, 0, 250);
303   aProp->SetPointSize(5);
304   aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
305   mySimulation->GetActor()->SetProperty(aProp);
306   aProp->Delete();
307
308   // SalomeApp_TypeFilter depends on a current study
309   if ( myFilter ) delete myFilter;
310   QList<SUIT_SelectionFilter*> filters;
311   filters.append( new SalomeApp_TypeFilter((SalomeApp_Study*)study(), "SMESH" ));
312   TColStd_MapOfInteger vertexType;
313   vertexType.Add( TopAbs_VERTEX );
314   filters.append( new SMESH_NumberFilter("GEOM", TopAbs_VERTEX, 1, vertexType ));
315   myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
316
317   // IPAL19360
318   SMESHGUI_SelectionOp::startOperation(); // this method should be called only after filter creation
319   //activateSelection(); // set filters   // called inside of previous statement
320
321   myDlg->myX->SetValue(0);
322   myDlg->myY->SetValue(0);
323   myDlg->myZ->SetValue(0);
324   myDlg->myId->setText("");
325   myDlg->show();
326
327   onSelectionDone(); // init myMeshActor
328
329   if ( myMeshActor ) {
330 //     myMeshOldDisplayMode = myMeshActor->GetRepresentation();
331 //     myMeshActor->SetRepresentation( VTK_WIREFRAME );
332     myMeshActor->SetPointRepresentation(true);
333     SMESH::RepaintCurrentView();
334     redisplayPreview();
335   }
336 }
337
338 //================================================================================
339 /*!
340  * \brief Stops operation
341  */
342 //================================================================================
343
344 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
345 {
346   myNoPreview = true;
347   mySimulation->SetVisibility(false);
348   if ( myMeshActor ) {
349 //     myMeshActor->SetRepresentation( myMeshOldDisplayMode );
350     myMeshActor->SetPointRepresentation(false);
351     SMESH::RepaintCurrentView();
352     myMeshActor = 0;
353   }
354   selectionMgr()->removeFilter( myFilter );
355   SMESHGUI_SelectionOp::stopOperation();
356 }
357
358 //================================================================================
359 /*!
360  * \brief perform it's intention action: move or create a node
361  */
362 //================================================================================
363
364 bool SMESHGUI_MakeNodeAtPointOp::onApply()
365 {
366   if( isStudyLocked() )
367     return false;
368
369   if ( !myMeshActor ) {
370     SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
371                               tr("INVALID_MESH") );
372     dlg()->show();
373     return false;
374   }
375
376   QString msg;
377   if ( !isValid( msg ) ) { // node id is invalid
378     if( !msg.isEmpty() )
379       SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), msg );
380     dlg()->show();
381     return false;
382   }
383
384
385   try {
386     SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
387     if (aMesh->_is_nil()) {
388       SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
389                                    tr("SMESHG_NO_MESH") );
390       return true;
391     }
392     SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
393     if (aMeshEditor->_is_nil())
394       return true;
395
396     int aResult = 0;
397     if ( myDlg->myCreateRBtn->isChecked() )
398     {
399       aResult = aMeshEditor->AddNode(myDlg->myX->GetValue(),
400                                      myDlg->myY->GetValue(),
401                                      myDlg->myZ->GetValue());
402     }
403     else
404     {
405       int anId = myDlg->myId->text().toInt();
406       aResult = aMeshEditor->MoveClosestNodeToPoint(myDlg->myX->GetValue(),
407                                                     myDlg->myY->GetValue(),
408                                                     myDlg->myZ->GetValue(),
409                                                     anId);
410     }
411     if (aResult)
412     {
413       QStringList aParameters;
414       aParameters << myDlg->myX->text();
415       aParameters << myDlg->myY->text();
416       aParameters << myDlg->myZ->text();
417       //asl: aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
418
419       myDlg->myId->setText("");
420
421       SALOME_ListIO aList;
422       selectionMgr()->setSelectedObjects(aList,false);
423       aList.Append(myMeshActor->getIO());
424       selectionMgr()->setSelectedObjects(aList,false);
425       SMESH::UpdateView();
426     }
427   }
428   catch (const SALOME::SALOME_Exception& S_ex) {
429     SalomeApp_Tools::QtCatchCorbaException(S_ex);
430   }
431   catch (...) {
432   }
433
434   return true;
435 }
436
437 //================================================================================
438 /*!
439  * \brief Check selected node id validity
440  */
441 //================================================================================
442
443 bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
444 {
445   if( !checkParameters( !myNoPreview, 3, myDlg->myX, myDlg->myY, myDlg->myZ ) )
446     return false;
447
448   bool ok = true;
449   if ( myMeshActor &&
450        myDlg->myMoveRBtn->isChecked() &&
451        !myDlg->myAutoSearchChkBox->isChecked() )
452   {
453     ok = false;
454     int id = myDlg->myId->text().toInt();
455     if ( id > 0 )
456       if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
457         ok = aMesh->FindNode( id );
458     if( !ok )
459       msg += tr("INVALID_ID") + "\n";
460   }
461   return ok;
462 }
463
464 //================================================================================
465 /*!
466  * \brief SLOT called when selection changed
467  */
468 //================================================================================
469
470 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
471 {
472   if ( !myDlg->isVisible() || !myDlg->isEnabled() )
473     return;
474   try {
475     SALOME_ListIO aList;
476     selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
477     if (aList.Extent() != 1)
478       return;
479     Handle(SALOME_InteractiveObject) anIO = aList.First();
480     SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
481
482     if (!aMeshActor) { // coord by geom
483       if ( myDlg->myCoordBtn->isChecked() ) {
484         GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
485         if ( !geom->_is_nil() ) {
486           TopoDS_Vertex aShape;
487           if ( GEOMBase::GetShape(geom, aShape) &&
488                aShape.ShapeType() == TopAbs_VERTEX ) {
489             gp_Pnt P = BRep_Tool::Pnt(aShape);
490             myNoPreview = true;
491             myDlg->myX->SetValue(P.X());
492             myDlg->myY->SetValue(P.Y());
493             myDlg->myZ->SetValue(P.Z());
494             myNoPreview = false;
495             redisplayPreview();
496           }
497         }
498         return;
499       }
500     }
501
502     if ( !myMeshActor )
503       myMeshActor = aMeshActor;
504
505     QString aString;
506     int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
507     if (nbElems == 1) {
508       if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
509         if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
510           myNoPreview = true;
511           if ( myDlg->myCoordBtn->isChecked() ) { // set coord
512             myDlg->myX->SetValue(aNode->X());
513             myDlg->myY->SetValue(aNode->Y());
514             myDlg->myZ->SetValue(aNode->Z());
515             myNoPreview = false;
516             redisplayPreview();
517           }
518           else if ( myDlg->myIdBtn->isChecked() &&
519                     myDlg->myIdBtn->isEnabled() ) { // set node to move
520             myDlg->myId->setText(aString);
521             myNoPreview = false;
522             redisplayPreview();
523           }
524         }
525       }
526     }
527   } catch (...) {
528   }
529 }
530
531 //================================================================================
532 /*!
533  * \brief update preview
534  */
535 //================================================================================
536
537 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
538 {
539   if ( myNoPreview )
540     return;
541   myNoPreview = true;
542
543   SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
544
545   bool moveShown = false;
546   if ( myDlg->myMoveRBtn->isChecked() && // Move method
547        myMeshActor)
548   {
549     const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
550     const bool preview    = myDlg->myPreviewChkBox->isChecked();
551     if ( autoSearch )
552       myDlg->myId->setText("");
553     QString msg;
554     if ( preview && ( autoSearch || isValid( msg ) ))
555     {
556       try {
557         SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
558         if (!aMesh->_is_nil()) {
559           SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
560           if (!aPreviewer->_is_nil())
561           {
562             SUIT_OverrideCursor aWaitCursor;
563
564             // find id and/or just compute preview
565             int anId = aPreviewer->MoveClosestNodeToPoint(myDlg->myX->GetValue(),
566                                                           myDlg->myY->GetValue(),
567                                                           myDlg->myZ->GetValue(),
568                                                           myDlg->myId->text().toInt());
569             if ( autoSearch ) { // set found id
570               QString idTxt("%1");
571               if ( anId > 0 )
572                 idTxt = idTxt.arg( anId );
573               else
574                 idTxt = "";
575               myDlg->myId->setText( idTxt );
576             }
577             if ( preview ) { // fill preview data
578               aMeshPreviewStruct = aPreviewer->GetPreviewData();
579               moveShown = ( anId > 0 );
580             }
581           }
582         }
583       }catch (...) {
584       }
585     }
586   }
587
588   if ( !moveShown )
589   {
590     aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
591
592     aMeshPreviewStruct->nodesXYZ.length(1);
593     aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
594     aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
595     aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
596
597     aMeshPreviewStruct->elementTypes.length(1);
598     aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
599     aMeshPreviewStruct->elementTypes[0].isPoly = false;
600     aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
601
602     aMeshPreviewStruct->elementConnectivities.length(1);
603     aMeshPreviewStruct->elementConnectivities[0] = 0;
604   }
605
606   // display data
607   if ( aMeshPreviewStruct.operator->() )
608   {
609     mySimulation->SetData(aMeshPreviewStruct._retn());
610   }
611   else
612 {
613     mySimulation->SetVisibility(false);
614   }
615
616   myNoPreview = false;
617 }
618
619 //================================================================================
620 /*!
621  * \brief Activate Node selection
622  */
623 //================================================================================
624
625 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
626 {
627   selectionMgr()->clearFilters();
628   SMESH::SetPointRepresentation(false);
629   selectionMgr()->installFilter( myFilter );
630   setSelectionMode( NodeSelection );
631 }
632
633 //================================================================================
634 /*!
635  * \brief Destructor
636 */
637 //================================================================================
638
639 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
640 {
641   if ( myDlg )        delete myDlg;
642   if ( mySimulation ) delete mySimulation;
643   if ( myFilter )     delete myFilter;
644 }
645
646 //================================================================================
647 /*!
648  * \brief Gets dialog of this operation
649  * \retval LightApp_Dialog* - pointer to dialog of this operation
650  */
651 //================================================================================
652
653 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const
654 {
655   return myDlg;
656 }
657