Salome HOME
Update copyright information
[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->setDown(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->setDown( !on );
232     }
233     else if ( aSender == myIdBtn ) // button to select a node to move
234     {
235       myCoordBtn->setDown( !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->setDown( true ); 
245     }
246   }      
247   if ( aSender == myAutoSearchChkBox ) // automatic node search
248   {
249     if ( on ) {
250       myId->setText("");
251       myId->setReadOnly ( true );
252       myIdBtn->setDown( false );
253       myIdBtn->setEnabled( false );
254       myCoordBtn->setDown( 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 {
271   mySimulation = 0;
272   myDlg = new SMESHGUI_MakeNodeAtPointDlg;
273   myFilter = 0;
274   myHelpFileName = "mesh_through_point_page.html";
275
276   // connect signals and slots
277   connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
278   connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
279   connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
280   connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
281   connect(myDlg->myPreviewChkBox,   SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
282   connect(myDlg->myAutoSearchChkBox,SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
283   connect(myDlg->myMoveRBtn,        SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
284   connect(myDlg->myCreateRBtn,      SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
285 }
286
287 //=======================================================================
288 // function : startOperation()
289 // purpose  : Init dialog fields, connect signals and slots, show dialog
290 //=======================================================================
291 void SMESHGUI_MakeNodeAtPointOp::startOperation()
292 {
293   myNoPreview = false;
294   myMeshActor = 0;
295
296   // init simulation with a current View
297   if ( mySimulation ) delete mySimulation;
298   mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
299   vtkProperty* aProp = vtkProperty::New();
300   aProp->SetRepresentationToWireframe();
301   aProp->SetColor(250, 0, 250);
302   aProp->SetPointSize(5);
303   aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
304   mySimulation->GetActor()->SetProperty(aProp);
305   aProp->Delete();
306
307   // SalomeApp_TypeFilter depends on a current study
308   if ( myFilter ) delete myFilter;
309   QList<SUIT_SelectionFilter*> filters;
310   filters.append( new SalomeApp_TypeFilter((SalomeApp_Study*)study(), "SMESH" ));
311   TColStd_MapOfInteger vertexType;
312   vertexType.Add( TopAbs_VERTEX );
313   filters.append( new SMESH_NumberFilter("GEOM", TopAbs_VERTEX, 1, vertexType ));
314   myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
315
316   // IPAL19360
317   SMESHGUI_SelectionOp::startOperation(); // this method should be called only after filter creation
318   //activateSelection(); // set filters   // called inside of previous statement
319
320   myDlg->myX->SetValue(0);
321   myDlg->myY->SetValue(0);
322   myDlg->myZ->SetValue(0);
323   myDlg->myId->setText("");
324   myDlg->show();
325
326   onSelectionDone(); // init myMeshActor
327
328   if ( myMeshActor ) {
329 //     myMeshOldDisplayMode = myMeshActor->GetRepresentation();
330 //     myMeshActor->SetRepresentation( VTK_WIREFRAME );
331     myMeshActor->SetPointRepresentation(true);
332     SMESH::RepaintCurrentView();
333     redisplayPreview();
334   }
335 }
336
337 //================================================================================
338 /*!
339  * \brief Stops operation
340  */
341 //================================================================================
342
343 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
344 {
345   myNoPreview = true;
346   mySimulation->SetVisibility(false);
347   if ( myMeshActor ) {
348 //     myMeshActor->SetRepresentation( myMeshOldDisplayMode );
349     myMeshActor->SetPointRepresentation(false);
350     SMESH::RepaintCurrentView();
351     myMeshActor = 0;
352   }
353   selectionMgr()->removeFilter( myFilter );
354   SMESHGUI_SelectionOp::stopOperation();
355 }
356
357 //================================================================================
358 /*!
359  * \brief perform it's intention action: move or create a node
360  */
361 //================================================================================
362
363 bool SMESHGUI_MakeNodeAtPointOp::onApply()
364 {
365   if( isStudyLocked() )
366     return false;
367
368   if ( !myMeshActor ) {
369     SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
370                               tr("INVALID_MESH") );
371     dlg()->show();
372     return false;
373   }
374
375   if ( !isValid() ) { // node id is invalid
376     SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
377                               tr("INVALID_ID") );
378     dlg()->show();
379     return false;
380   }
381
382
383   try {
384     SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
385     if (aMesh->_is_nil()) {
386       SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
387                                    tr("SMESHG_NO_MESH") );
388       return true;
389     }
390     SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
391     if (aMeshEditor->_is_nil())
392       return true;
393
394     int aResult = 0;
395     if ( myDlg->myCreateRBtn->isDown() )
396     {
397       aResult = aMeshEditor->AddNode(myDlg->myX->GetValue(),
398                                      myDlg->myY->GetValue(),
399                                      myDlg->myZ->GetValue());
400     }
401     else
402     {
403       int anId = myDlg->myId->text().toInt();
404       aResult = aMeshEditor->MoveClosestNodeToPoint(myDlg->myX->GetValue(),
405                                                     myDlg->myY->GetValue(),
406                                                     myDlg->myZ->GetValue(),
407                                                     anId);
408     }
409     if (aResult)
410     {
411       myDlg->myId->setText("");
412
413       SALOME_ListIO aList;
414       selectionMgr()->setSelectedObjects(aList,false);
415       aList.Append(myMeshActor->getIO());
416       selectionMgr()->setSelectedObjects(aList,false);
417       SMESH::UpdateView();
418     }
419   }
420   catch (const SALOME::SALOME_Exception& S_ex) {
421     SalomeApp_Tools::QtCatchCorbaException(S_ex);
422   }
423   catch (...) {
424   }
425
426   return true;
427 }
428
429 //================================================================================
430 /*!
431  * \brief Check selected node id validity
432  */
433 //================================================================================
434
435 bool SMESHGUI_MakeNodeAtPointOp::isValid()
436 {
437   bool ok = true;
438
439   if ( myMeshActor &&
440        myDlg->myMoveRBtn->isDown() &&
441        !myDlg->myAutoSearchChkBox->isChecked() )
442   {
443     ok = false;
444     int id = myDlg->myId->text().toInt();
445     if ( id > 0 )
446       if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
447         ok = aMesh->FindNode( id );
448   }
449   return ok;
450 }
451
452 //================================================================================
453 /*!
454  * \brief SLOT called when selection changed
455  */
456 //================================================================================
457
458 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
459 {
460   if ( !myDlg->isVisible() || !myDlg->isEnabled() )
461     return;
462   try {
463     SALOME_ListIO aList;
464     selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
465     if (aList.Extent() != 1)
466       return;
467     Handle(SALOME_InteractiveObject) anIO = aList.First();
468     SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
469
470     if (!aMeshActor) { // coord by geom
471       if ( myDlg->myCoordBtn->isDown() ) {
472         GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
473         if ( !geom->_is_nil() ) {
474           TopoDS_Vertex aShape;
475           if ( GEOMBase::GetShape(geom, aShape) &&
476                aShape.ShapeType() == TopAbs_VERTEX ) {
477             gp_Pnt P = BRep_Tool::Pnt(aShape);
478             myNoPreview = true;
479             myDlg->myX->SetValue(P.X());
480             myDlg->myY->SetValue(P.Y());
481             myDlg->myZ->SetValue(P.Z());
482             myNoPreview = false;
483             redisplayPreview();
484           }
485         }
486         return;
487       }
488     }
489
490     if ( !myMeshActor )
491       myMeshActor = aMeshActor;
492
493     QString aString;
494     int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
495     if (nbElems == 1) {
496       if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
497         if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
498           myNoPreview = true;
499           if ( myDlg->myCoordBtn->isDown() ) { // set coord
500             myDlg->myX->SetValue(aNode->X());
501             myDlg->myY->SetValue(aNode->Y());
502             myDlg->myZ->SetValue(aNode->Z());
503             myNoPreview = false;
504             redisplayPreview();
505           }
506           else if ( myDlg->myIdBtn->isDown() &&
507                     myDlg->myIdBtn->isEnabled() ) { // set node to move
508             myDlg->myId->setText(aString);
509             myNoPreview = false;
510             redisplayPreview();
511           }
512         }
513       }
514     }
515   } catch (...) {
516   }
517 }
518
519 //================================================================================
520 /*!
521  * \brief update preview
522  */
523 //================================================================================
524
525 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
526 {
527   if ( myNoPreview )
528     return;
529   myNoPreview = true;
530
531   SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
532
533   bool moveShown = false;
534   if ( myDlg->myMoveRBtn->isDown() && // Move method
535        myMeshActor)
536   {
537     const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
538     const bool preview    = myDlg->myPreviewChkBox->isChecked();
539     if ( autoSearch )
540       myDlg->myId->setText("");
541     if ( preview && ( autoSearch || isValid() ))
542     {
543       try {
544         SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
545         if (!aMesh->_is_nil()) {
546           SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
547           if (!aPreviewer->_is_nil())
548           {
549             SUIT_OverrideCursor aWaitCursor;
550
551             // find id and/or just compute preview
552             int anId = aPreviewer->MoveClosestNodeToPoint(myDlg->myX->GetValue(),
553                                                           myDlg->myY->GetValue(),
554                                                           myDlg->myZ->GetValue(),
555                                                           myDlg->myId->text().toInt());
556             if ( autoSearch ) { // set found id
557               QString idTxt("%1");
558               if ( anId > 0 )
559                 idTxt = idTxt.arg( anId );
560               else
561                 idTxt = "";
562               myDlg->myId->setText( idTxt );
563             }
564             if ( preview ) { // fill preview data
565               aMeshPreviewStruct = aPreviewer->GetPreviewData();
566               moveShown = ( anId > 0 );
567             }
568           }
569         }
570       }catch (...) {
571       }
572     }
573   }
574
575   if ( !moveShown )
576   {
577     aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
578
579     aMeshPreviewStruct->nodesXYZ.length(1);
580     aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
581     aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
582     aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
583
584     aMeshPreviewStruct->elementTypes.length(1);
585     aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
586     aMeshPreviewStruct->elementTypes[0].isPoly = false;
587     aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
588
589     aMeshPreviewStruct->elementConnectivities.length(1);
590     aMeshPreviewStruct->elementConnectivities[0] = 0;
591   }
592
593   // display data
594   if ( aMeshPreviewStruct.operator->() )
595   {
596     mySimulation->SetData(aMeshPreviewStruct._retn());
597   }
598   else
599 {
600     mySimulation->SetVisibility(false);
601   }
602
603   myNoPreview = false;
604 }
605
606 //================================================================================
607 /*!
608  * \brief Activate Node selection
609  */
610 //================================================================================
611
612 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
613 {
614   selectionMgr()->clearFilters();
615   SMESH::SetPointRepresentation(false);
616   selectionMgr()->installFilter( myFilter );
617   setSelectionMode( NodeSelection );
618 }
619
620 //================================================================================
621 /*!
622  * \brief Destructor
623 */
624 //================================================================================
625
626 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
627 {
628   if ( myDlg )        delete myDlg;
629   if ( mySimulation ) delete mySimulation;
630   if ( myFilter )     delete myFilter;
631 }
632
633 //================================================================================
634 /*!
635  * \brief Gets dialog of this operation
636  * \retval LightApp_Dialog* - pointer to dialog of this operation
637  */
638 //================================================================================
639
640 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const
641 {
642   return myDlg;
643 }
644