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