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