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