1 // Copyright (C) 2007-2012 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 <SVTK_ViewWindow.h>
51 #include <SalomeApp_Tools.h>
52 #include <SalomeApp_TypeFilter.h>
53 #include <SUIT_ResourceMgr.h>
54 #include <SUIT_OverrideCursor.h>
55 #include <SUIT_MessageBox.h>
58 #include <TColStd_MapOfInteger.hxx>
59 #include <TopoDS_Vertex.hxx>
60 #include <BRep_Tool.hxx>
65 #include <QGridLayout>
66 #include <QHBoxLayout>
67 #include <QVBoxLayout>
69 #include <QPushButton>
71 #include <QRadioButton>
73 #include <QButtonGroup>
76 #include <vtkProperty.h>
79 #include <SALOMEconfig.h>
80 #include CORBA_SERVER_HEADER(SMESH_Mesh)
81 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
87 * \brief Dialog to publish a sub-shape of the mesh main shape
88 * by selecting mesh elements
90 SMESHGUI_MakeNodeAtPointDlg::SMESHGUI_MakeNodeAtPointDlg()
91 : SMESHGUI_Dialog( 0, false, true )
93 setWindowTitle(tr("CAPTION"));
95 QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
96 aDlgLay->setMargin(0);
97 aDlgLay->setSpacing(SPACING);
99 QWidget* aMainFrame = createMainFrame (mainFrame());
101 aDlgLay->addWidget(aMainFrame);
103 aDlgLay->setStretchFactor(aMainFrame, 1);
106 //=======================================================================
107 // function : createMainFrame()
108 // purpose : Create frame containing dialog's input fields
109 //=======================================================================
110 QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent)
112 QWidget* aFrame = new QWidget(theParent);
114 SUIT_ResourceMgr* rm = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
115 QPixmap iconMoveNode (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE")));
116 QPixmap iconSelect (rm->loadPixmap("SMESH", tr("ICON_SELECT")));
120 QGroupBox* aPixGrp = new QGroupBox(tr("MOVE_NODE"), aFrame);
121 QButtonGroup* aBtnGrp = new QButtonGroup(this);
122 QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp);
123 aPixGrpLayout->setMargin(MARGIN);
124 aPixGrpLayout->setSpacing(SPACING);
126 QRadioButton* aRBut = new QRadioButton(aPixGrp);
127 aRBut->setIcon(iconMoveNode);
128 aRBut->setChecked(true);
129 aPixGrpLayout->addWidget(aRBut);
130 aBtnGrp->addButton(aRBut, 0);
134 QGroupBox* aCoordGrp = new QGroupBox(tr("DESTINATION"), aFrame);
135 QHBoxLayout* aCoordGrpLayout = new QHBoxLayout(aCoordGrp);
136 aCoordGrpLayout->setMargin(MARGIN);
137 aCoordGrpLayout->setSpacing(SPACING);
139 myCoordBtn = new QPushButton(aCoordGrp);
140 myCoordBtn->setIcon(iconSelect);
141 myCoordBtn->setCheckable(true);
143 QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp);
144 myX = new SMESHGUI_SpinBox(aCoordGrp);
146 QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp);
147 myY = new SMESHGUI_SpinBox(aCoordGrp);
149 QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp);
150 myZ = new SMESHGUI_SpinBox(aCoordGrp);
152 myX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
153 myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
154 myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
156 aCoordGrpLayout->addWidget(myCoordBtn);
157 aCoordGrpLayout->addWidget(aXLabel);
158 aCoordGrpLayout->addWidget(myX);
159 aCoordGrpLayout->addWidget(aYLabel);
160 aCoordGrpLayout->addWidget(myY);
161 aCoordGrpLayout->addWidget(aZLabel);
162 aCoordGrpLayout->addWidget(myZ);
163 aCoordGrpLayout->setStretchFactor(myX, 1);
164 aCoordGrpLayout->setStretchFactor(myY, 1);
165 aCoordGrpLayout->setStretchFactor(myZ, 1);
169 myNodeToMoveGrp = new QGroupBox(tr("NODE_2MOVE"), aFrame);
171 QLabel* idLabel = new QLabel(tr("NODE_2MOVE_ID"), myNodeToMoveGrp);
172 myIdBtn = new QPushButton(myNodeToMoveGrp);
173 myIdBtn->setIcon(iconSelect);
174 myIdBtn->setCheckable(true);
175 myId = new QLineEdit(myNodeToMoveGrp);
176 myId->setValidator(new SMESHGUI_IdValidator(this, 1));
178 QWidget* aCoordWidget = new QWidget(myNodeToMoveGrp);
180 QLabel* aCurrentXLabel = new QLabel(tr("SMESH_X"), aCoordWidget);
181 myCurrentX = new SMESHGUI_SpinBox(aCoordWidget);
182 myCurrentX->setButtonSymbols(QAbstractSpinBox::NoButtons);
183 myCurrentX->setReadOnly(true);
185 QLabel* aCurrentYLabel = new QLabel(tr("SMESH_Y"), aCoordWidget);
186 myCurrentY = new SMESHGUI_SpinBox(aCoordWidget);
187 myCurrentY->setButtonSymbols(QAbstractSpinBox::NoButtons);
188 myCurrentY->setReadOnly(true);
190 QLabel* aCurrentZLabel = new QLabel(tr("SMESH_Z"), aCoordWidget);
191 myCurrentZ = new SMESHGUI_SpinBox(aCoordWidget);
192 myCurrentZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
193 myCurrentZ->setReadOnly(true);
195 QLabel* aDXLabel = new QLabel(tr("SMESH_DX"), aCoordWidget);
196 myDX = new SMESHGUI_SpinBox(aCoordWidget);
197 myDX->setButtonSymbols(QAbstractSpinBox::NoButtons);
198 myDX->setReadOnly(true);
200 QLabel* aDYLabel = new QLabel(tr("SMESH_DY"), aCoordWidget);
201 myDY = new SMESHGUI_SpinBox(aCoordWidget);
202 myDY->setButtonSymbols(QAbstractSpinBox::NoButtons);
203 myDY->setReadOnly(true);
205 QLabel* aDZLabel = new QLabel(tr("SMESH_DZ"), aCoordWidget);
206 myDZ = new SMESHGUI_SpinBox(aCoordWidget);
207 myDZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
208 myDZ->setReadOnly(true);
210 myCurrentX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
211 myCurrentY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
212 myCurrentZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
213 myDX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
214 myDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
215 myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
217 QGridLayout* aCoordLayout = new QGridLayout(aCoordWidget);
218 aCoordLayout->setMargin(0);
219 aCoordLayout->setSpacing(SPACING);
220 aCoordLayout->addWidget(aCurrentXLabel, 0, 0);
221 aCoordLayout->addWidget(myCurrentX, 0, 1);
222 aCoordLayout->addWidget(aCurrentYLabel, 0, 2);
223 aCoordLayout->addWidget(myCurrentY, 0, 3);
224 aCoordLayout->addWidget(aCurrentZLabel, 0, 4);
225 aCoordLayout->addWidget(myCurrentZ, 0, 5);
226 aCoordLayout->addWidget(aDXLabel, 1, 0);
227 aCoordLayout->addWidget(myDX, 1, 1);
228 aCoordLayout->addWidget(aDYLabel, 1, 2);
229 aCoordLayout->addWidget(myDY, 1, 3);
230 aCoordLayout->addWidget(aDZLabel, 1, 4);
231 aCoordLayout->addWidget(myDZ, 1, 5);
232 aCoordLayout->setColumnStretch(1, 1);
233 aCoordLayout->setColumnStretch(3, 1);
234 aCoordLayout->setColumnStretch(5, 1);
236 myAutoSearchChkBox = new QCheckBox( tr("AUTO_SEARCH"), myNodeToMoveGrp);
237 myPreviewChkBox = new QCheckBox( tr("PREVIEW"), myNodeToMoveGrp);
239 QGridLayout* myNodeToMoveGrpLayout = new QGridLayout(myNodeToMoveGrp);
240 myNodeToMoveGrpLayout->setSpacing(SPACING);
241 myNodeToMoveGrpLayout->setMargin(MARGIN);
243 myNodeToMoveGrpLayout->addWidget( idLabel, 0, 0 );
244 myNodeToMoveGrpLayout->addWidget( myIdBtn, 0, 1 );
245 myNodeToMoveGrpLayout->addWidget( myId, 0, 2 );
246 myNodeToMoveGrpLayout->addWidget( aCoordWidget, 1, 0, 1, 3 );
247 myNodeToMoveGrpLayout->addWidget( myAutoSearchChkBox, 2, 0, 1, 3 );
248 myNodeToMoveGrpLayout->addWidget( myPreviewChkBox, 3, 0, 1, 3 );
250 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
251 aLay->addWidget(aPixGrp);
252 aLay->addWidget(aCoordGrp);
253 aLay->addWidget(myNodeToMoveGrp);
255 connect(myCoordBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
256 connect(myIdBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
257 connect(myAutoSearchChkBox, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
259 myIdBtn->setChecked(true);
260 myAutoSearchChkBox->setChecked(true);
265 //================================================================================
267 * \brief SLOT called when any button is toggled
268 * \param bool - on or off
270 //================================================================================
272 void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on)
274 const QObject* aSender = sender();
276 if ( aSender == myCoordBtn ) // button to set coord by node selection
278 if ( myIdBtn->isEnabled() )
279 myIdBtn->setChecked( !on );
281 else if ( aSender == myIdBtn ) // button to select a node to move
283 myCoordBtn->setChecked( !on );
286 if ( aSender == myAutoSearchChkBox ) // automatic node search
289 myCurrentX->SetValue(0);
290 myCurrentY->SetValue(0);
291 myCurrentZ->SetValue(0);
296 myId->setReadOnly ( true );
297 myIdBtn->setChecked( false );
298 myIdBtn->setEnabled( false );
299 myCoordBtn->setChecked( true );
302 myId->setReadOnly ( false );
303 myIdBtn->setEnabled( true );
308 //================================================================================
312 //================================================================================
314 SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp()
317 myDlg = new SMESHGUI_MakeNodeAtPointDlg;
319 myHelpFileName = "mesh_through_point_page.html";
321 // connect signals and slots
322 connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
323 connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
324 connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
325 connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
326 connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
327 connect(myDlg->myAutoSearchChkBox,SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
329 // IPAL22913: TC6.5.0: selected in "Move node" dialog box node is not highlighted
330 // note: this slot seems to be lost together with removed obsolete SMESHGUI_MoveNodesDlg class
331 connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(onTextChange(const QString&)));
334 //=======================================================================
335 // function : startOperation()
336 // purpose : Init dialog fields, connect signals and slots, show dialog
337 //=======================================================================
338 void SMESHGUI_MakeNodeAtPointOp::startOperation()
343 // init simulation with a current View
344 if ( mySimulation ) delete mySimulation;
345 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
346 vtkProperty* aProp = vtkProperty::New();
347 aProp->SetRepresentationToWireframe();
348 aProp->SetColor(250, 0, 250);
349 aProp->SetPointSize(5);
350 aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
351 mySimulation->GetActor()->SetProperty(aProp);
354 // SalomeApp_TypeFilter depends on a current study
355 if ( myFilter ) delete myFilter;
356 QList<SUIT_SelectionFilter*> filters;
357 filters.append( new SalomeApp_TypeFilter((SalomeApp_Study*)study(), "SMESH" ));
358 TColStd_MapOfInteger vertexType;
359 vertexType.Add( TopAbs_VERTEX );
360 filters.append( new SMESH_NumberFilter("GEOM", TopAbs_VERTEX, 1, vertexType ));
361 myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
364 SMESHGUI_SelectionOp::startOperation(); // this method should be called only after filter creation
365 //activateSelection(); // set filters // called inside of previous statement
367 myDlg->myX->SetValue(0);
368 myDlg->myY->SetValue(0);
369 myDlg->myZ->SetValue(0);
370 myDlg->myCurrentX->SetValue(0);
371 myDlg->myCurrentY->SetValue(0);
372 myDlg->myCurrentZ->SetValue(0);
373 myDlg->myDX->SetValue(0);
374 myDlg->myDY->SetValue(0);
375 myDlg->myDZ->SetValue(0);
376 myDlg->myId->setText("");
379 onSelectionDone(); // init myMeshActor
382 // myMeshActor->SetRepresentation( VTK_WIREFRAME );
383 myMeshActor->SetPointRepresentation(true);
384 SMESH::RepaintCurrentView();
389 //================================================================================
391 * \brief Stops operation
393 //================================================================================
395 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
398 mySimulation->SetVisibility(false);
400 myMeshActor->SetPointRepresentation(false);
401 SMESH::RepaintCurrentView();
404 selectionMgr()->removeFilter( myFilter );
405 SMESHGUI_SelectionOp::stopOperation();
408 //================================================================================
410 * \brief perform it's intention action: move or create a node
412 //================================================================================
414 bool SMESHGUI_MakeNodeAtPointOp::onApply()
416 if( isStudyLocked() )
419 if ( !myMeshActor ) {
420 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
421 tr("INVALID_MESH") );
427 if ( !isValid( msg ) ) { // node id is invalid
429 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
435 QStringList aParameters;
436 aParameters << myDlg->myX->text();
437 aParameters << myDlg->myY->text();
438 aParameters << myDlg->myZ->text();
441 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
442 if (aMesh->_is_nil()) {
443 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
444 tr("SMESHG_NO_MESH") );
447 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
448 if (aMeshEditor->_is_nil())
451 aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
454 int anId = myDlg->myId->text().toInt( &ok );
455 if( !ok || anId < 1 )
456 anId = aMeshEditor->FindNodeClosestTo(myDlg->myX->GetValue(),
457 myDlg->myY->GetValue(),
458 myDlg->myZ->GetValue());
460 int aResult = aMeshEditor->MoveNode(anId,
461 myDlg->myX->GetValue(),
462 myDlg->myY->GetValue(),
463 myDlg->myZ->GetValue() );
467 myDlg->myCurrentX->SetValue(0);
468 myDlg->myCurrentY->SetValue(0);
469 myDlg->myCurrentZ->SetValue(0);
470 myDlg->myDX->SetValue(0);
471 myDlg->myDY->SetValue(0);
472 myDlg->myDZ->SetValue(0);
473 myDlg->myId->setText("");
476 selectionMgr()->setSelectedObjects(aList,false);
477 aList.Append(myMeshActor->getIO());
478 selectionMgr()->setSelectedObjects(aList,false);
480 SMESHGUI::Modified();
483 catch (const SALOME::SALOME_Exception& S_ex) {
484 SalomeApp_Tools::QtCatchCorbaException(S_ex);
492 //================================================================================
494 * \brief Check selected node id validity
496 //================================================================================
498 bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
502 !myDlg->myAutoSearchChkBox->isChecked() )
505 int id = myDlg->myId->text().toInt();
507 if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
508 ok = aMesh->FindNode( id );
510 msg += tr("INVALID_ID") + "\n";
513 ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok;
514 ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok;
515 ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok;
520 //================================================================================
522 * \brief SLOT called when selection changed
524 //================================================================================
526 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
528 if ( !myDlg->isVisible() || !myDlg->isEnabled() )
532 selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
533 if (aList.Extent() != 1)
535 Handle(SALOME_InteractiveObject) anIO = aList.First();
536 SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
538 if (!aMeshActor) { // coord by geom
539 if ( myDlg->myCoordBtn->isChecked() ) {
540 GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
541 if ( !geom->_is_nil() ) {
542 TopoDS_Vertex aShape;
543 if ( GEOMBase::GetShape(geom, aShape) &&
544 aShape.ShapeType() == TopAbs_VERTEX ) {
545 gp_Pnt P = BRep_Tool::Pnt(aShape);
547 myDlg->myX->SetValue(P.X());
548 myDlg->myY->SetValue(P.Y());
549 myDlg->myZ->SetValue(P.Z());
559 myMeshActor = aMeshActor;
562 int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
564 if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
565 if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
567 if ( myDlg->myCoordBtn->isChecked() ) { // set coord
568 myDlg->myX->SetValue(aNode->X());
569 myDlg->myY->SetValue(aNode->Y());
570 myDlg->myZ->SetValue(aNode->Z());
574 else if ( myDlg->myIdBtn->isChecked() &&
575 myDlg->myIdBtn->isEnabled() ) { // set node to move
576 myDlg->myId->setText(aString);
581 if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) {
582 double x = aCurrentNode->X();
583 double y = aCurrentNode->Y();
584 double z = aCurrentNode->Z();
585 double dx = myDlg->myX->GetValue() - x;
586 double dy = myDlg->myY->GetValue() - y;
587 double dz = myDlg->myZ->GetValue() - z;
588 myDlg->myCurrentX->SetValue(x);
589 myDlg->myCurrentY->SetValue(y);
590 myDlg->myCurrentZ->SetValue(z);
591 myDlg->myDX->SetValue(dx);
592 myDlg->myDY->SetValue(dy);
593 myDlg->myDZ->SetValue(dz);
602 //================================================================================
604 * \brief update preview
606 //================================================================================
608 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
614 SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
616 bool moveShown = false;
619 const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
620 const bool preview = myDlg->myPreviewChkBox->isChecked();
623 myDlg->myCurrentX->SetValue(0);
624 myDlg->myCurrentY->SetValue(0);
625 myDlg->myCurrentZ->SetValue(0);
626 myDlg->myDX->SetValue(0);
627 myDlg->myDY->SetValue(0);
628 myDlg->myDZ->SetValue(0);
629 myDlg->myId->setText("");
632 if ( autoSearch || isValid( msg ) )
635 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
636 if (!aMesh->_is_nil()) {
637 SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
638 if (!aPreviewer->_is_nil())
640 SUIT_OverrideCursor aWaitCursor;
644 anId = aPreviewer->FindNodeClosestTo(myDlg->myX->GetValue(),
645 myDlg->myY->GetValue(),
646 myDlg->myZ->GetValue());
648 anId = myDlg->myId->text().toInt();
650 // find id and/or just compute preview
651 aPreviewer->MoveNode(anId,
652 myDlg->myX->GetValue(),
653 myDlg->myY->GetValue(),
654 myDlg->myZ->GetValue());
655 if ( autoSearch ) { // set found id
658 idTxt = idTxt.arg( anId );
661 myDlg->myId->setText( idTxt );
664 SMESH::double_array* aXYZ = aMesh->GetNodeXYZ( anId );
665 if( aXYZ && aXYZ->length() >= 3 )
667 double x = aXYZ->operator[](0);
668 double y = aXYZ->operator[](1);
669 double z = aXYZ->operator[](2);
670 double dx = myDlg->myX->GetValue() - x;
671 double dy = myDlg->myY->GetValue() - y;
672 double dz = myDlg->myZ->GetValue() - z;
673 myDlg->myCurrentX->SetValue(x);
674 myDlg->myCurrentY->SetValue(y);
675 myDlg->myCurrentZ->SetValue(z);
676 myDlg->myDX->SetValue(dx);
677 myDlg->myDY->SetValue(dy);
678 myDlg->myDZ->SetValue(dz);
681 if ( preview ) { // fill preview data
682 aMeshPreviewStruct = aPreviewer->GetPreviewData();
683 moveShown = ( anId > 0 );
694 aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
696 aMeshPreviewStruct->nodesXYZ.length(1);
697 aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
698 aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
699 aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
701 aMeshPreviewStruct->elementTypes.length(1);
702 aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
703 aMeshPreviewStruct->elementTypes[0].isPoly = false;
704 aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
706 aMeshPreviewStruct->elementConnectivities.length(1);
707 aMeshPreviewStruct->elementConnectivities[0] = 0;
711 if ( aMeshPreviewStruct.operator->() )
713 mySimulation->SetData(aMeshPreviewStruct._retn());
717 mySimulation->SetVisibility(false);
723 //================================================================================
725 * \brief SLOT called when the node id is manually changed
727 //================================================================================
729 void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText )
733 if( SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh() )
735 Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO();
737 aList.Append( anIO );
738 selectionMgr()->setSelectedObjects( aList, false );
740 if( const SMDS_MeshNode* aNode = aMesh->FindNode( theText.toInt() ) )
742 TColStd_MapOfInteger aListInd;
743 aListInd.Add( aNode->GetID() );
744 selector()->AddOrRemoveIndex( anIO, aListInd, false );
745 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() ) )
746 aViewWindow->highlight( anIO, true, true );
752 //================================================================================
754 * \brief Activate Node selection
756 //================================================================================
758 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
760 selectionMgr()->clearFilters();
761 SMESH::SetPointRepresentation(false);
762 selectionMgr()->installFilter( myFilter );
763 setSelectionMode( NodeSelection );
766 //================================================================================
770 //================================================================================
772 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
774 if ( myDlg ) delete myDlg;
775 if ( mySimulation ) delete mySimulation;
776 if ( myFilter ) delete myFilter;
779 //================================================================================
781 * \brief Gets dialog of this operation
782 * \retval LightApp_Dialog* - pointer to dialog of this operation
784 //================================================================================
786 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const