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