Salome HOME
Dump Python Extension - Debug
[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   QString msg;
375   if ( !isValid( msg ) ) { // node id is invalid
376     if( !msg.isEmpty() )
377       SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
378                                 tr("INVALID_ID") );
379     dlg()->show();
380     return false;
381   }
382
383
384   try {
385     SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
386     if (aMesh->_is_nil()) {
387       SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
388                                    tr("SMESHG_NO_MESH") );
389       return true;
390     }
391     SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
392     if (aMeshEditor->_is_nil())
393       return true;
394
395     int aResult = 0;
396     if ( myDlg->myCreateRBtn->isDown() )
397     {
398       aResult = aMeshEditor->AddNode(myDlg->myX->GetValue(),
399                                      myDlg->myY->GetValue(),
400                                      myDlg->myZ->GetValue());
401     }
402     else
403     {
404       int anId = myDlg->myId->text().toInt();
405       aResult = aMeshEditor->MoveClosestNodeToPoint(myDlg->myX->GetValue(),
406                                                     myDlg->myY->GetValue(),
407                                                     myDlg->myZ->GetValue(),
408                                                     anId);
409     }
410     if (aResult)
411     {
412       QStringList aParameters;
413       aParameters << myDlg->myX->text();
414       aParameters << myDlg->myY->text();
415       aParameters << myDlg->myZ->text();
416       aMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
417
418       myDlg->myId->setText("");
419
420       SALOME_ListIO aList;
421       selectionMgr()->setSelectedObjects(aList,false);
422       aList.Append(myMeshActor->getIO());
423       selectionMgr()->setSelectedObjects(aList,false);
424       SMESH::UpdateView();
425     }
426   }
427   catch (const SALOME::SALOME_Exception& S_ex) {
428     SalomeApp_Tools::QtCatchCorbaException(S_ex);
429   }
430   catch (...) {
431   }
432
433   return true;
434 }
435
436 //================================================================================
437 /*!
438  * \brief Check selected node id validity
439  */
440 //================================================================================
441
442 bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
443 {
444   bool ok = true;
445   if ( myMeshActor &&
446        myDlg->myMoveRBtn->isDown() &&
447        !myDlg->myAutoSearchChkBox->isChecked() )
448   {
449     ok = false;
450     int id = myDlg->myId->text().toInt();
451     if ( id > 0 )
452       if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
453         ok = aMesh->FindNode( id );
454     if( !ok )
455       msg += tr("INVALID_ID") + "\n";
456   }
457
458   ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok;
459   ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok;
460   ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok;
461
462   return ok;
463 }
464
465 //================================================================================
466 /*!
467  * \brief SLOT called when selection changed
468  */
469 //================================================================================
470
471 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
472 {
473   if ( !myDlg->isVisible() || !myDlg->isEnabled() )
474     return;
475   try {
476     SALOME_ListIO aList;
477     selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
478     if (aList.Extent() != 1)
479       return;
480     Handle(SALOME_InteractiveObject) anIO = aList.First();
481     SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
482
483     if (!aMeshActor) { // coord by geom
484       if ( myDlg->myCoordBtn->isDown() ) {
485         GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
486         if ( !geom->_is_nil() ) {
487           TopoDS_Vertex aShape;
488           if ( GEOMBase::GetShape(geom, aShape) &&
489                aShape.ShapeType() == TopAbs_VERTEX ) {
490             gp_Pnt P = BRep_Tool::Pnt(aShape);
491             myNoPreview = true;
492             myDlg->myX->SetValue(P.X());
493             myDlg->myY->SetValue(P.Y());
494             myDlg->myZ->SetValue(P.Z());
495             myNoPreview = false;
496             redisplayPreview();
497           }
498         }
499         return;
500       }
501     }
502
503     if ( !myMeshActor )
504       myMeshActor = aMeshActor;
505
506     QString aString;
507     int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
508     if (nbElems == 1) {
509       if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
510         if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
511           myNoPreview = true;
512           if ( myDlg->myCoordBtn->isDown() ) { // set coord
513             myDlg->myX->SetValue(aNode->X());
514             myDlg->myY->SetValue(aNode->Y());
515             myDlg->myZ->SetValue(aNode->Z());
516             myNoPreview = false;
517             redisplayPreview();
518           }
519           else if ( myDlg->myIdBtn->isDown() &&
520                     myDlg->myIdBtn->isEnabled() ) { // set node to move
521             myDlg->myId->setText(aString);
522             myNoPreview = false;
523             redisplayPreview();
524           }
525         }
526       }
527     }
528   } catch (...) {
529   }
530 }
531
532 //================================================================================
533 /*!
534  * \brief update preview
535  */
536 //================================================================================
537
538 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
539 {
540   if ( myNoPreview )
541     return;
542   myNoPreview = true;
543
544   SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
545
546   bool moveShown = false;
547   if ( myDlg->myMoveRBtn->isDown() && // Move method
548        myMeshActor)
549   {
550     const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
551     const bool preview    = myDlg->myPreviewChkBox->isChecked();
552     if ( autoSearch )
553       myDlg->myId->setText("");
554     QString msg;
555     if ( preview && ( autoSearch || isValid( msg ) ))
556     {
557       try {
558         SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
559         if (!aMesh->_is_nil()) {
560           SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
561           if (!aPreviewer->_is_nil())
562           {
563             SUIT_OverrideCursor aWaitCursor;
564
565             // find id and/or just compute preview
566             int anId = aPreviewer->MoveClosestNodeToPoint(myDlg->myX->GetValue(),
567                                                           myDlg->myY->GetValue(),
568                                                           myDlg->myZ->GetValue(),
569                                                           myDlg->myId->text().toInt());
570             if ( autoSearch ) { // set found id
571               QString idTxt("%1");
572               if ( anId > 0 )
573                 idTxt = idTxt.arg( anId );
574               else
575                 idTxt = "";
576               myDlg->myId->setText( idTxt );
577             }
578             if ( preview ) { // fill preview data
579               aMeshPreviewStruct = aPreviewer->GetPreviewData();
580               moveShown = ( anId > 0 );
581             }
582           }
583         }
584       }catch (...) {
585       }
586     }
587   }
588
589   if ( !moveShown )
590   {
591     aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
592
593     aMeshPreviewStruct->nodesXYZ.length(1);
594     aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
595     aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
596     aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
597
598     aMeshPreviewStruct->elementTypes.length(1);
599     aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
600     aMeshPreviewStruct->elementTypes[0].isPoly = false;
601     aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
602
603     aMeshPreviewStruct->elementConnectivities.length(1);
604     aMeshPreviewStruct->elementConnectivities[0] = 0;
605   }
606
607   // display data
608   if ( aMeshPreviewStruct.operator->() )
609   {
610     mySimulation->SetData(aMeshPreviewStruct._retn());
611   }
612   else
613 {
614     mySimulation->SetVisibility(false);
615   }
616
617   myNoPreview = false;
618 }
619
620 //================================================================================
621 /*!
622  * \brief Activate Node selection
623  */
624 //================================================================================
625
626 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
627 {
628   selectionMgr()->clearFilters();
629   SMESH::SetPointRepresentation(false);
630   selectionMgr()->installFilter( myFilter );
631   setSelectionMode( NodeSelection );
632 }
633
634 //================================================================================
635 /*!
636  * \brief Destructor
637 */
638 //================================================================================
639
640 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
641 {
642   if ( myDlg )        delete myDlg;
643   if ( mySimulation ) delete mySimulation;
644   if ( myFilter )     delete myFilter;
645 }
646
647 //================================================================================
648 /*!
649  * \brief Gets dialog of this operation
650  * \retval LightApp_Dialog* - pointer to dialog of this operation
651  */
652 //================================================================================
653
654 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const
655 {
656   return myDlg;
657 }
658