Salome HOME
Debug
[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_Notebook.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, DBL_DIGITS_DISPLAY);
152   myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
153   myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
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   : SMESHGUI_Helper( getSMESHGUI() )
272 {
273   mySimulation = 0;
274   myDlg = new SMESHGUI_MakeNodeAtPointDlg;
275   myFilter = 0;
276   myHelpFileName = "mesh_through_point_page.html";
277
278   // connect signals and slots
279   connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
280   connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
281   connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
282   connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
283   connect(myDlg->myPreviewChkBox,   SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
284   connect(myDlg->myAutoSearchChkBox,SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
285   connect(myDlg->myMoveRBtn,        SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
286   connect(myDlg->myCreateRBtn,      SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
287 }
288
289 //=======================================================================
290 // function : startOperation()
291 // purpose  : Init dialog fields, connect signals and slots, show dialog
292 //=======================================================================
293 void SMESHGUI_MakeNodeAtPointOp::startOperation()
294 {
295   myNoPreview = false;
296   myMeshActor = 0;
297
298   // init simulation with a current View
299   if ( mySimulation ) delete mySimulation;
300   mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
301   vtkProperty* aProp = vtkProperty::New();
302   aProp->SetRepresentationToWireframe();
303   aProp->SetColor(250, 0, 250);
304   aProp->SetPointSize(5);
305   aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
306   mySimulation->GetActor()->SetProperty(aProp);
307   aProp->Delete();
308
309   // SalomeApp_TypeFilter depends on a current study
310   if ( myFilter ) delete myFilter;
311   QList<SUIT_SelectionFilter*> filters;
312   filters.append( new SalomeApp_TypeFilter((SalomeApp_Study*)study(), "SMESH" ));
313   TColStd_MapOfInteger vertexType;
314   vertexType.Add( TopAbs_VERTEX );
315   filters.append( new SMESH_NumberFilter("GEOM", TopAbs_VERTEX, 1, vertexType ));
316   myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
317
318   // IPAL19360
319   SMESHGUI_SelectionOp::startOperation(); // this method should be called only after filter creation
320   //activateSelection(); // set filters   // called inside of previous statement
321
322   myDlg->myX->SetValue(0);
323   myDlg->myY->SetValue(0);
324   myDlg->myZ->SetValue(0);
325   myDlg->myId->setText("");
326   myDlg->show();
327
328   onSelectionDone(); // init myMeshActor
329
330   if ( myMeshActor ) {
331 //     myMeshOldDisplayMode = myMeshActor->GetRepresentation();
332 //     myMeshActor->SetRepresentation( VTK_WIREFRAME );
333     myMeshActor->SetPointRepresentation(true);
334     SMESH::RepaintCurrentView();
335     redisplayPreview();
336   }
337 }
338
339 //================================================================================
340 /*!
341  * \brief Stops operation
342  */
343 //================================================================================
344
345 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
346 {
347   myNoPreview = true;
348   mySimulation->SetVisibility(false);
349   if ( myMeshActor ) {
350 //     myMeshActor->SetRepresentation( myMeshOldDisplayMode );
351     myMeshActor->SetPointRepresentation(false);
352     SMESH::RepaintCurrentView();
353     myMeshActor = 0;
354   }
355   selectionMgr()->removeFilter( myFilter );
356   SMESHGUI_SelectionOp::stopOperation();
357 }
358
359 //================================================================================
360 /*!
361  * \brief perform it's intention action: move or create a node
362  */
363 //================================================================================
364
365 bool SMESHGUI_MakeNodeAtPointOp::onApply()
366 {
367   if( isStudyLocked() )
368     return false;
369
370   if ( !myMeshActor ) {
371     SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
372                               tr("INVALID_MESH") );
373     dlg()->show();
374     return false;
375   }
376
377   QString msg;
378   if ( !isValid( msg ) ) { // node id is invalid
379     if( !msg.isEmpty() )
380       SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), msg );
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       getNotebook()->setParameters( aMesh, 3, myDlg->myX, myDlg->myY, myDlg->myZ );
415
416       myDlg->myId->setText("");
417
418       SALOME_ListIO aList;
419       selectionMgr()->setSelectedObjects(aList,false);
420       aList.Append(myMeshActor->getIO());
421       selectionMgr()->setSelectedObjects(aList,false);
422       SMESH::UpdateView();
423     }
424   }
425   catch (const SALOME::SALOME_Exception& S_ex) {
426     SalomeApp_Tools::QtCatchCorbaException(S_ex);
427   }
428   catch (...) {
429   }
430
431   return true;
432 }
433
434 //================================================================================
435 /*!
436  * \brief Check selected node id validity
437  */
438 //================================================================================
439
440 bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
441 {
442   if( !checkParameters( !myNoPreview, 3, myDlg->myX, myDlg->myY, myDlg->myZ ) )
443     return false;
444
445   bool ok = true;
446   if ( myMeshActor &&
447        myDlg->myMoveRBtn->isChecked() &&
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   return ok;
459 }
460
461 //================================================================================
462 /*!
463  * \brief SLOT called when selection changed
464  */
465 //================================================================================
466
467 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
468 {
469   if ( !myDlg->isVisible() || !myDlg->isEnabled() )
470     return;
471   try {
472     SALOME_ListIO aList;
473     selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
474     if (aList.Extent() != 1)
475       return;
476     Handle(SALOME_InteractiveObject) anIO = aList.First();
477     SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
478
479     if (!aMeshActor) { // coord by geom
480       if ( myDlg->myCoordBtn->isChecked() ) {
481         GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
482         if ( !geom->_is_nil() ) {
483           TopoDS_Vertex aShape;
484           if ( GEOMBase::GetShape(geom, aShape) &&
485                aShape.ShapeType() == TopAbs_VERTEX ) {
486             gp_Pnt P = BRep_Tool::Pnt(aShape);
487             myNoPreview = true;
488             myDlg->myX->SetValue(P.X());
489             myDlg->myY->SetValue(P.Y());
490             myDlg->myZ->SetValue(P.Z());
491             myNoPreview = false;
492             redisplayPreview();
493           }
494         }
495         return;
496       }
497     }
498
499     if ( !myMeshActor )
500       myMeshActor = aMeshActor;
501
502     QString aString;
503     int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
504     if (nbElems == 1) {
505       if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
506         if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
507           myNoPreview = true;
508           if ( myDlg->myCoordBtn->isChecked() ) { // set coord
509             myDlg->myX->SetValue(aNode->X());
510             myDlg->myY->SetValue(aNode->Y());
511             myDlg->myZ->SetValue(aNode->Z());
512             myNoPreview = false;
513             redisplayPreview();
514           }
515           else if ( myDlg->myIdBtn->isChecked() &&
516                     myDlg->myIdBtn->isEnabled() ) { // set node to move
517             myDlg->myId->setText(aString);
518             myNoPreview = false;
519             redisplayPreview();
520           }
521         }
522       }
523     }
524   } catch (...) {
525   }
526 }
527
528 //================================================================================
529 /*!
530  * \brief update preview
531  */
532 //================================================================================
533
534 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
535 {
536   if ( myNoPreview )
537     return;
538   myNoPreview = true;
539
540   SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
541
542   bool moveShown = false;
543   if ( myDlg->myMoveRBtn->isChecked() && // Move method
544        myMeshActor)
545   {
546     const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
547     const bool preview    = myDlg->myPreviewChkBox->isChecked();
548     if ( autoSearch )
549       myDlg->myId->setText("");
550     QString msg;
551     if ( preview && ( autoSearch || isValid( msg ) ))
552     {
553       try {
554         SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
555         if (!aMesh->_is_nil()) {
556           SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
557           if (!aPreviewer->_is_nil())
558           {
559             SUIT_OverrideCursor aWaitCursor;
560
561             // find id and/or just compute preview
562             int anId = aPreviewer->MoveClosestNodeToPoint(myDlg->myX->GetValue(),
563                                                           myDlg->myY->GetValue(),
564                                                           myDlg->myZ->GetValue(),
565                                                           myDlg->myId->text().toInt());
566             if ( autoSearch ) { // set found id
567               QString idTxt("%1");
568               if ( anId > 0 )
569                 idTxt = idTxt.arg( anId );
570               else
571                 idTxt = "";
572               myDlg->myId->setText( idTxt );
573             }
574             if ( preview ) { // fill preview data
575               aMeshPreviewStruct = aPreviewer->GetPreviewData();
576               moveShown = ( anId > 0 );
577             }
578           }
579         }
580       }catch (...) {
581       }
582     }
583   }
584
585   if ( !moveShown )
586   {
587     aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
588
589     aMeshPreviewStruct->nodesXYZ.length(1);
590     aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
591     aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
592     aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
593
594     aMeshPreviewStruct->elementTypes.length(1);
595     aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
596     aMeshPreviewStruct->elementTypes[0].isPoly = false;
597     aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
598
599     aMeshPreviewStruct->elementConnectivities.length(1);
600     aMeshPreviewStruct->elementConnectivities[0] = 0;
601   }
602
603   // display data
604   if ( aMeshPreviewStruct.operator->() )
605   {
606     mySimulation->SetData(aMeshPreviewStruct._retn());
607   }
608   else
609 {
610     mySimulation->SetVisibility(false);
611   }
612
613   myNoPreview = false;
614 }
615
616 //================================================================================
617 /*!
618  * \brief Activate Node selection
619  */
620 //================================================================================
621
622 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
623 {
624   selectionMgr()->clearFilters();
625   SMESH::SetPointRepresentation(false);
626   selectionMgr()->installFilter( myFilter );
627   setSelectionMode( NodeSelection );
628 }
629
630 //================================================================================
631 /*!
632  * \brief Destructor
633 */
634 //================================================================================
635
636 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
637 {
638   if ( myDlg )        delete myDlg;
639   if ( mySimulation ) delete mySimulation;
640   if ( myFilter )     delete myFilter;
641 }
642
643 //================================================================================
644 /*!
645  * \brief Gets dialog of this operation
646  * \retval LightApp_Dialog* - pointer to dialog of this operation
647  */
648 //================================================================================
649
650 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const
651 {
652   return myDlg;
653 }
654