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