1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SMESHGUI_MakeNodeAtPointDlg.cxx
24 // Author : Edward AGAPOV, Open CASCADE S.A.S.
27 #include "SMESHGUI_MakeNodeAtPointDlg.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"
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>
42 // SALOME GEOM includes
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>
57 #include <TColStd_MapOfInteger.hxx>
58 #include <TopoDS_Vertex.hxx>
59 #include <BRep_Tool.hxx>
64 #include <QGridLayout>
65 #include <QHBoxLayout>
66 #include <QVBoxLayout>
68 #include <QPushButton>
70 #include <QRadioButton>
72 #include <QButtonGroup>
75 #include <vtkProperty.h>
78 #include <SALOMEconfig.h>
79 #include CORBA_SERVER_HEADER(SMESH_Mesh)
80 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
86 * \brief Dialog to publish a sub-shape of the mesh main shape
87 * by selecting mesh elements
89 SMESHGUI_MakeNodeAtPointDlg::SMESHGUI_MakeNodeAtPointDlg()
90 : SMESHGUI_Dialog( 0, false, true )
92 setWindowTitle(tr("CAPTION"));
94 QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
95 aDlgLay->setMargin(0);
96 aDlgLay->setSpacing(SPACING);
98 QWidget* aMainFrame = createMainFrame (mainFrame());
100 aDlgLay->addWidget(aMainFrame);
102 aDlgLay->setStretchFactor(aMainFrame, 1);
105 //=======================================================================
106 // function : createMainFrame()
107 // purpose : Create frame containing dialog's input fields
108 //=======================================================================
109 QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent)
111 QWidget* aFrame = new QWidget(theParent);
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")));
119 QGroupBox* aPixGrp = new QGroupBox(tr("MOVE_NODE"), aFrame);
120 QButtonGroup* aBtnGrp = new QButtonGroup(this);
121 QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp);
122 aPixGrpLayout->setMargin(MARGIN);
123 aPixGrpLayout->setSpacing(SPACING);
125 QRadioButton* aRBut = new QRadioButton(aPixGrp);
126 aRBut->setIcon(iconMoveNode);
127 aRBut->setChecked(true);
128 aPixGrpLayout->addWidget(aRBut);
129 aBtnGrp->addButton(aRBut, 0);
133 QGroupBox* aCoordGrp = new QGroupBox(tr("DESTINATION"), aFrame);
134 QHBoxLayout* aCoordGrpLayout = new QHBoxLayout(aCoordGrp);
135 aCoordGrpLayout->setMargin(MARGIN);
136 aCoordGrpLayout->setSpacing(SPACING);
138 myCoordBtn = new QPushButton(aCoordGrp);
139 myCoordBtn->setIcon(iconSelect);
140 myCoordBtn->setCheckable(true);
142 QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp);
143 myX = new SMESHGUI_SpinBox(aCoordGrp);
145 QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp);
146 myY = new SMESHGUI_SpinBox(aCoordGrp);
148 QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp);
149 myZ = new SMESHGUI_SpinBox(aCoordGrp);
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");
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);
165 myNodeToMoveGrp = new QGroupBox(tr("NODE_2MOVE"), aFrame);
167 QLabel* idLabel = new QLabel(tr("NODE_2MOVE_ID"), myNodeToMoveGrp);
168 myIdBtn = new QPushButton(myNodeToMoveGrp);
169 myIdBtn->setIcon(iconSelect);
170 myIdBtn->setCheckable(true);
171 myId = new QLineEdit(myNodeToMoveGrp);
172 myId->setValidator(new SMESHGUI_IdValidator(this, 1));
174 QWidget* aCoordWidget = new QWidget(myNodeToMoveGrp);
176 QLabel* aCurrentXLabel = new QLabel(tr("SMESH_X"), aCoordWidget);
177 myCurrentX = new SMESHGUI_SpinBox(aCoordWidget);
178 myCurrentX->setButtonSymbols(QAbstractSpinBox::NoButtons);
179 myCurrentX->setReadOnly(true);
181 QLabel* aCurrentYLabel = new QLabel(tr("SMESH_Y"), aCoordWidget);
182 myCurrentY = new SMESHGUI_SpinBox(aCoordWidget);
183 myCurrentY->setButtonSymbols(QAbstractSpinBox::NoButtons);
184 myCurrentY->setReadOnly(true);
186 QLabel* aCurrentZLabel = new QLabel(tr("SMESH_Z"), aCoordWidget);
187 myCurrentZ = new SMESHGUI_SpinBox(aCoordWidget);
188 myCurrentZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
189 myCurrentZ->setReadOnly(true);
191 QLabel* aDXLabel = new QLabel(tr("SMESH_DX"), aCoordWidget);
192 myDX = new SMESHGUI_SpinBox(aCoordWidget);
193 myDX->setButtonSymbols(QAbstractSpinBox::NoButtons);
194 myDX->setReadOnly(true);
196 QLabel* aDYLabel = new QLabel(tr("SMESH_DY"), aCoordWidget);
197 myDY = new SMESHGUI_SpinBox(aCoordWidget);
198 myDY->setButtonSymbols(QAbstractSpinBox::NoButtons);
199 myDY->setReadOnly(true);
201 QLabel* aDZLabel = new QLabel(tr("SMESH_DZ"), aCoordWidget);
202 myDZ = new SMESHGUI_SpinBox(aCoordWidget);
203 myDZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
204 myDZ->setReadOnly(true);
206 myCurrentX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
207 myCurrentY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
208 myCurrentZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
209 myDX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
210 myDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
211 myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
213 QGridLayout* aCoordLayout = new QGridLayout(aCoordWidget);
214 aCoordLayout->setMargin(0);
215 aCoordLayout->setSpacing(SPACING);
216 aCoordLayout->addWidget(aCurrentXLabel, 0, 0);
217 aCoordLayout->addWidget(myCurrentX, 0, 1);
218 aCoordLayout->addWidget(aCurrentYLabel, 0, 2);
219 aCoordLayout->addWidget(myCurrentY, 0, 3);
220 aCoordLayout->addWidget(aCurrentZLabel, 0, 4);
221 aCoordLayout->addWidget(myCurrentZ, 0, 5);
222 aCoordLayout->addWidget(aDXLabel, 1, 0);
223 aCoordLayout->addWidget(myDX, 1, 1);
224 aCoordLayout->addWidget(aDYLabel, 1, 2);
225 aCoordLayout->addWidget(myDY, 1, 3);
226 aCoordLayout->addWidget(aDZLabel, 1, 4);
227 aCoordLayout->addWidget(myDZ, 1, 5);
229 myAutoSearchChkBox = new QCheckBox( tr("AUTO_SEARCH"), myNodeToMoveGrp);
230 myPreviewChkBox = new QCheckBox( tr("PREVIEW"), myNodeToMoveGrp);
232 QGridLayout* myNodeToMoveGrpLayout = new QGridLayout(myNodeToMoveGrp);
233 myNodeToMoveGrpLayout->setSpacing(SPACING);
234 myNodeToMoveGrpLayout->setMargin(MARGIN);
236 myNodeToMoveGrpLayout->addWidget( idLabel, 0, 0 );
237 myNodeToMoveGrpLayout->addWidget( myIdBtn, 0, 1 );
238 myNodeToMoveGrpLayout->addWidget( myId, 0, 2 );
239 myNodeToMoveGrpLayout->addWidget( aCoordWidget, 1, 0, 1, 3 );
240 myNodeToMoveGrpLayout->addWidget( myAutoSearchChkBox, 2, 0, 1, 3 );
241 myNodeToMoveGrpLayout->addWidget( myPreviewChkBox, 3, 0, 1, 3 );
243 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
244 aLay->addWidget(aPixGrp);
245 aLay->addWidget(aCoordGrp);
246 aLay->addWidget(myNodeToMoveGrp);
248 connect(myCoordBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
249 connect(myIdBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
250 connect(myAutoSearchChkBox, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
252 myIdBtn->setChecked(true);
253 myAutoSearchChkBox->setChecked(true);
258 //================================================================================
260 * \brief SLOT called when any button is toggled
261 * \param bool - on or off
263 //================================================================================
265 void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on)
267 const QObject* aSender = sender();
269 if ( aSender == myCoordBtn ) // button to set coord by node selection
271 if ( myIdBtn->isEnabled() )
272 myIdBtn->setChecked( !on );
274 else if ( aSender == myIdBtn ) // button to select a node to move
276 myCoordBtn->setChecked( !on );
279 if ( aSender == myAutoSearchChkBox ) // automatic node search
282 myCurrentX->SetValue(0);
283 myCurrentY->SetValue(0);
284 myCurrentZ->SetValue(0);
289 myId->setReadOnly ( true );
290 myIdBtn->setChecked( false );
291 myIdBtn->setEnabled( false );
292 myCoordBtn->setChecked( true );
295 myId->setReadOnly ( false );
296 myIdBtn->setEnabled( true );
301 //================================================================================
305 //================================================================================
307 SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp()
310 myDlg = new SMESHGUI_MakeNodeAtPointDlg;
312 myHelpFileName = "mesh_through_point_page.html";
314 // connect signals and slots
315 connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
316 connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
317 connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
318 connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
319 connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
320 connect(myDlg->myAutoSearchChkBox,SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
323 //=======================================================================
324 // function : startOperation()
325 // purpose : Init dialog fields, connect signals and slots, show dialog
326 //=======================================================================
327 void SMESHGUI_MakeNodeAtPointOp::startOperation()
332 // init simulation with a current View
333 if ( mySimulation ) delete mySimulation;
334 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
335 vtkProperty* aProp = vtkProperty::New();
336 aProp->SetRepresentationToWireframe();
337 aProp->SetColor(250, 0, 250);
338 aProp->SetPointSize(5);
339 aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
340 mySimulation->GetActor()->SetProperty(aProp);
343 // SalomeApp_TypeFilter depends on a current study
344 if ( myFilter ) delete myFilter;
345 QList<SUIT_SelectionFilter*> filters;
346 filters.append( new SalomeApp_TypeFilter((SalomeApp_Study*)study(), "SMESH" ));
347 TColStd_MapOfInteger vertexType;
348 vertexType.Add( TopAbs_VERTEX );
349 filters.append( new SMESH_NumberFilter("GEOM", TopAbs_VERTEX, 1, vertexType ));
350 myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
353 SMESHGUI_SelectionOp::startOperation(); // this method should be called only after filter creation
354 //activateSelection(); // set filters // called inside of previous statement
356 myDlg->myX->SetValue(0);
357 myDlg->myY->SetValue(0);
358 myDlg->myZ->SetValue(0);
359 myDlg->myCurrentX->SetValue(0);
360 myDlg->myCurrentY->SetValue(0);
361 myDlg->myCurrentZ->SetValue(0);
362 myDlg->myDX->SetValue(0);
363 myDlg->myDY->SetValue(0);
364 myDlg->myDZ->SetValue(0);
365 myDlg->myId->setText("");
368 onSelectionDone(); // init myMeshActor
371 // myMeshOldDisplayMode = myMeshActor->GetRepresentation();
372 // myMeshActor->SetRepresentation( VTK_WIREFRAME );
373 myMeshActor->SetPointRepresentation(true);
374 SMESH::RepaintCurrentView();
379 //================================================================================
381 * \brief Stops operation
383 //================================================================================
385 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
388 mySimulation->SetVisibility(false);
390 // myMeshActor->SetRepresentation( myMeshOldDisplayMode );
391 myMeshActor->SetPointRepresentation(false);
392 SMESH::RepaintCurrentView();
395 selectionMgr()->removeFilter( myFilter );
396 SMESHGUI_SelectionOp::stopOperation();
399 //================================================================================
401 * \brief perform it's intention action: move or create a node
403 //================================================================================
405 bool SMESHGUI_MakeNodeAtPointOp::onApply()
407 if( isStudyLocked() )
410 if ( !myMeshActor ) {
411 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
412 tr("INVALID_MESH") );
418 if ( !isValid( msg ) ) { // node id is invalid
420 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
428 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
429 if (aMesh->_is_nil()) {
430 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
431 tr("SMESHG_NO_MESH") );
434 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
435 if (aMeshEditor->_is_nil())
439 int anId = myDlg->myId->text().toInt( &ok );
440 if( !ok || anId < 1 )
441 anId = aMeshEditor->FindNodeClosestTo(myDlg->myX->GetValue(),
442 myDlg->myY->GetValue(),
443 myDlg->myZ->GetValue());
445 int aResult = aMeshEditor->MoveNode(anId,
446 myDlg->myX->GetValue(),
447 myDlg->myY->GetValue(),
448 myDlg->myZ->GetValue() );
452 QStringList aParameters;
453 aParameters << myDlg->myX->text();
454 aParameters << myDlg->myY->text();
455 aParameters << myDlg->myZ->text();
456 aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
458 myDlg->myCurrentX->SetValue(0);
459 myDlg->myCurrentY->SetValue(0);
460 myDlg->myCurrentZ->SetValue(0);
461 myDlg->myDX->SetValue(0);
462 myDlg->myDY->SetValue(0);
463 myDlg->myDZ->SetValue(0);
464 myDlg->myId->setText("");
467 selectionMgr()->setSelectedObjects(aList,false);
468 aList.Append(myMeshActor->getIO());
469 selectionMgr()->setSelectedObjects(aList,false);
471 SMESHGUI::Modified();
474 catch (const SALOME::SALOME_Exception& S_ex) {
475 SalomeApp_Tools::QtCatchCorbaException(S_ex);
483 //================================================================================
485 * \brief Check selected node id validity
487 //================================================================================
489 bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
493 !myDlg->myAutoSearchChkBox->isChecked() )
496 int id = myDlg->myId->text().toInt();
498 if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
499 ok = aMesh->FindNode( id );
501 msg += tr("INVALID_ID") + "\n";
504 ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok;
505 ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok;
506 ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok;
511 //================================================================================
513 * \brief SLOT called when selection changed
515 //================================================================================
517 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
519 if ( !myDlg->isVisible() || !myDlg->isEnabled() )
523 selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
524 if (aList.Extent() != 1)
526 Handle(SALOME_InteractiveObject) anIO = aList.First();
527 SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
529 if (!aMeshActor) { // coord by geom
530 if ( myDlg->myCoordBtn->isChecked() ) {
531 GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
532 if ( !geom->_is_nil() ) {
533 TopoDS_Vertex aShape;
534 if ( GEOMBase::GetShape(geom, aShape) &&
535 aShape.ShapeType() == TopAbs_VERTEX ) {
536 gp_Pnt P = BRep_Tool::Pnt(aShape);
538 myDlg->myX->SetValue(P.X());
539 myDlg->myY->SetValue(P.Y());
540 myDlg->myZ->SetValue(P.Z());
550 myMeshActor = aMeshActor;
553 int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
555 if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
556 if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
558 if ( myDlg->myCoordBtn->isChecked() ) { // set coord
559 myDlg->myX->SetValue(aNode->X());
560 myDlg->myY->SetValue(aNode->Y());
561 myDlg->myZ->SetValue(aNode->Z());
565 else if ( myDlg->myIdBtn->isChecked() &&
566 myDlg->myIdBtn->isEnabled() ) { // set node to move
567 myDlg->myId->setText(aString);
572 if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) {
573 double x = aCurrentNode->X();
574 double y = aCurrentNode->Y();
575 double z = aCurrentNode->Z();
576 double dx = myDlg->myX->GetValue() - x;
577 double dy = myDlg->myY->GetValue() - y;
578 double dz = myDlg->myZ->GetValue() - z;
579 myDlg->myCurrentX->SetValue(x);
580 myDlg->myCurrentY->SetValue(y);
581 myDlg->myCurrentZ->SetValue(z);
582 myDlg->myDX->SetValue(dx);
583 myDlg->myDY->SetValue(dy);
584 myDlg->myDZ->SetValue(dz);
593 //================================================================================
595 * \brief update preview
597 //================================================================================
599 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
605 SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
607 bool moveShown = false;
610 const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
611 const bool preview = myDlg->myPreviewChkBox->isChecked();
614 myDlg->myCurrentX->SetValue(0);
615 myDlg->myCurrentY->SetValue(0);
616 myDlg->myCurrentZ->SetValue(0);
617 myDlg->myDX->SetValue(0);
618 myDlg->myDY->SetValue(0);
619 myDlg->myDZ->SetValue(0);
620 myDlg->myId->setText("");
623 if ( autoSearch || isValid( msg ) )
626 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
627 if (!aMesh->_is_nil()) {
628 SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
629 if (!aPreviewer->_is_nil())
631 SUIT_OverrideCursor aWaitCursor;
635 anId = aPreviewer->FindNodeClosestTo(myDlg->myX->GetValue(),
636 myDlg->myY->GetValue(),
637 myDlg->myZ->GetValue());
639 anId = myDlg->myId->text().toInt();
641 // find id and/or just compute preview
642 aPreviewer->MoveNode(anId,
643 myDlg->myX->GetValue(),
644 myDlg->myY->GetValue(),
645 myDlg->myZ->GetValue());
646 if ( autoSearch ) { // set found id
649 idTxt = idTxt.arg( anId );
652 myDlg->myId->setText( idTxt );
655 SMESH::double_array* aXYZ = aMesh->GetNodeXYZ( anId );
656 if( aXYZ && aXYZ->length() >= 3 )
658 double x = aXYZ->operator[](0);
659 double y = aXYZ->operator[](1);
660 double z = aXYZ->operator[](2);
661 double dx = myDlg->myX->GetValue() - x;
662 double dy = myDlg->myY->GetValue() - y;
663 double dz = myDlg->myZ->GetValue() - z;
664 myDlg->myCurrentX->SetValue(x);
665 myDlg->myCurrentY->SetValue(y);
666 myDlg->myCurrentZ->SetValue(z);
667 myDlg->myDX->SetValue(dx);
668 myDlg->myDY->SetValue(dy);
669 myDlg->myDZ->SetValue(dz);
672 if ( preview ) { // fill preview data
673 aMeshPreviewStruct = aPreviewer->GetPreviewData();
674 moveShown = ( anId > 0 );
685 aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
687 aMeshPreviewStruct->nodesXYZ.length(1);
688 aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
689 aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
690 aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
692 aMeshPreviewStruct->elementTypes.length(1);
693 aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
694 aMeshPreviewStruct->elementTypes[0].isPoly = false;
695 aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
697 aMeshPreviewStruct->elementConnectivities.length(1);
698 aMeshPreviewStruct->elementConnectivities[0] = 0;
702 if ( aMeshPreviewStruct.operator->() )
704 mySimulation->SetData(aMeshPreviewStruct._retn());
708 mySimulation->SetVisibility(false);
714 //================================================================================
716 * \brief Activate Node selection
718 //================================================================================
720 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
722 selectionMgr()->clearFilters();
723 SMESH::SetPointRepresentation(false);
724 selectionMgr()->installFilter( myFilter );
725 setSelectionMode( NodeSelection );
728 //================================================================================
732 //================================================================================
734 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
736 if ( myDlg ) delete myDlg;
737 if ( mySimulation ) delete mySimulation;
738 if ( myFilter ) delete myFilter;
741 //================================================================================
743 * \brief Gets dialog of this operation
744 * \retval LightApp_Dialog* - pointer to dialog of this operation
746 //================================================================================
748 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const