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