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 // myMeshOldDisplayMode = myMeshActor->GetRepresentation();
383 // myMeshActor->SetRepresentation( VTK_WIREFRAME );
384 myMeshActor->SetPointRepresentation(true);
385 SMESH::RepaintCurrentView();
390 //================================================================================
392 * \brief Stops operation
394 //================================================================================
396 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
399 mySimulation->SetVisibility(false);
401 // myMeshActor->SetRepresentation( myMeshOldDisplayMode );
402 myMeshActor->SetPointRepresentation(false);
403 SMESH::RepaintCurrentView();
406 selectionMgr()->removeFilter( myFilter );
407 SMESHGUI_SelectionOp::stopOperation();
410 //================================================================================
412 * \brief perform it's intention action: move or create a node
414 //================================================================================
416 bool SMESHGUI_MakeNodeAtPointOp::onApply()
418 if( isStudyLocked() )
421 if ( !myMeshActor ) {
422 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
423 tr("INVALID_MESH") );
429 if ( !isValid( msg ) ) { // node id is invalid
431 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
437 QStringList aParameters;
438 aParameters << myDlg->myX->text();
439 aParameters << myDlg->myY->text();
440 aParameters << myDlg->myZ->text();
443 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
444 if (aMesh->_is_nil()) {
445 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
446 tr("SMESHG_NO_MESH") );
449 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
450 if (aMeshEditor->_is_nil())
453 aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
456 int anId = myDlg->myId->text().toInt( &ok );
457 if( !ok || anId < 1 )
458 anId = aMeshEditor->FindNodeClosestTo(myDlg->myX->GetValue(),
459 myDlg->myY->GetValue(),
460 myDlg->myZ->GetValue());
462 int aResult = aMeshEditor->MoveNode(anId,
463 myDlg->myX->GetValue(),
464 myDlg->myY->GetValue(),
465 myDlg->myZ->GetValue() );
469 myDlg->myCurrentX->SetValue(0);
470 myDlg->myCurrentY->SetValue(0);
471 myDlg->myCurrentZ->SetValue(0);
472 myDlg->myDX->SetValue(0);
473 myDlg->myDY->SetValue(0);
474 myDlg->myDZ->SetValue(0);
475 myDlg->myId->setText("");
478 selectionMgr()->setSelectedObjects(aList,false);
479 aList.Append(myMeshActor->getIO());
480 selectionMgr()->setSelectedObjects(aList,false);
482 SMESHGUI::Modified();
485 catch (const SALOME::SALOME_Exception& S_ex) {
486 SalomeApp_Tools::QtCatchCorbaException(S_ex);
494 //================================================================================
496 * \brief Check selected node id validity
498 //================================================================================
500 bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
504 !myDlg->myAutoSearchChkBox->isChecked() )
507 int id = myDlg->myId->text().toInt();
509 if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
510 ok = aMesh->FindNode( id );
512 msg += tr("INVALID_ID") + "\n";
515 ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok;
516 ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok;
517 ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok;
522 //================================================================================
524 * \brief SLOT called when selection changed
526 //================================================================================
528 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
530 if ( !myDlg->isVisible() || !myDlg->isEnabled() )
534 selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
535 if (aList.Extent() != 1)
537 Handle(SALOME_InteractiveObject) anIO = aList.First();
538 SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
540 if (!aMeshActor) { // coord by geom
541 if ( myDlg->myCoordBtn->isChecked() ) {
542 GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
543 if ( !geom->_is_nil() ) {
544 TopoDS_Vertex aShape;
545 if ( GEOMBase::GetShape(geom, aShape) &&
546 aShape.ShapeType() == TopAbs_VERTEX ) {
547 gp_Pnt P = BRep_Tool::Pnt(aShape);
549 myDlg->myX->SetValue(P.X());
550 myDlg->myY->SetValue(P.Y());
551 myDlg->myZ->SetValue(P.Z());
561 myMeshActor = aMeshActor;
564 int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
566 if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
567 if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
569 if ( myDlg->myCoordBtn->isChecked() ) { // set coord
570 myDlg->myX->SetValue(aNode->X());
571 myDlg->myY->SetValue(aNode->Y());
572 myDlg->myZ->SetValue(aNode->Z());
576 else if ( myDlg->myIdBtn->isChecked() &&
577 myDlg->myIdBtn->isEnabled() ) { // set node to move
578 myDlg->myId->setText(aString);
583 if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) {
584 double x = aCurrentNode->X();
585 double y = aCurrentNode->Y();
586 double z = aCurrentNode->Z();
587 double dx = myDlg->myX->GetValue() - x;
588 double dy = myDlg->myY->GetValue() - y;
589 double dz = myDlg->myZ->GetValue() - z;
590 myDlg->myCurrentX->SetValue(x);
591 myDlg->myCurrentY->SetValue(y);
592 myDlg->myCurrentZ->SetValue(z);
593 myDlg->myDX->SetValue(dx);
594 myDlg->myDY->SetValue(dy);
595 myDlg->myDZ->SetValue(dz);
604 //================================================================================
606 * \brief update preview
608 //================================================================================
610 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
616 SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
618 bool moveShown = false;
621 const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
622 const bool preview = myDlg->myPreviewChkBox->isChecked();
625 myDlg->myCurrentX->SetValue(0);
626 myDlg->myCurrentY->SetValue(0);
627 myDlg->myCurrentZ->SetValue(0);
628 myDlg->myDX->SetValue(0);
629 myDlg->myDY->SetValue(0);
630 myDlg->myDZ->SetValue(0);
631 myDlg->myId->setText("");
634 if ( autoSearch || isValid( msg ) )
637 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
638 if (!aMesh->_is_nil()) {
639 SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
640 if (!aPreviewer->_is_nil())
642 SUIT_OverrideCursor aWaitCursor;
646 anId = aPreviewer->FindNodeClosestTo(myDlg->myX->GetValue(),
647 myDlg->myY->GetValue(),
648 myDlg->myZ->GetValue());
650 anId = myDlg->myId->text().toInt();
652 // find id and/or just compute preview
653 aPreviewer->MoveNode(anId,
654 myDlg->myX->GetValue(),
655 myDlg->myY->GetValue(),
656 myDlg->myZ->GetValue());
657 if ( autoSearch ) { // set found id
660 idTxt = idTxt.arg( anId );
663 myDlg->myId->setText( idTxt );
666 SMESH::double_array* aXYZ = aMesh->GetNodeXYZ( anId );
667 if( aXYZ && aXYZ->length() >= 3 )
669 double x = aXYZ->operator[](0);
670 double y = aXYZ->operator[](1);
671 double z = aXYZ->operator[](2);
672 double dx = myDlg->myX->GetValue() - x;
673 double dy = myDlg->myY->GetValue() - y;
674 double dz = myDlg->myZ->GetValue() - z;
675 myDlg->myCurrentX->SetValue(x);
676 myDlg->myCurrentY->SetValue(y);
677 myDlg->myCurrentZ->SetValue(z);
678 myDlg->myDX->SetValue(dx);
679 myDlg->myDY->SetValue(dy);
680 myDlg->myDZ->SetValue(dz);
683 if ( preview ) { // fill preview data
684 aMeshPreviewStruct = aPreviewer->GetPreviewData();
685 moveShown = ( anId > 0 );
696 aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
698 aMeshPreviewStruct->nodesXYZ.length(1);
699 aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
700 aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
701 aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
703 aMeshPreviewStruct->elementTypes.length(1);
704 aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
705 aMeshPreviewStruct->elementTypes[0].isPoly = false;
706 aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
708 aMeshPreviewStruct->elementConnectivities.length(1);
709 aMeshPreviewStruct->elementConnectivities[0] = 0;
713 if ( aMeshPreviewStruct.operator->() )
715 mySimulation->SetData(aMeshPreviewStruct._retn());
719 mySimulation->SetVisibility(false);
725 //================================================================================
727 * \brief SLOT called when the node id is manually changed
729 //================================================================================
731 void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText )
735 if( SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh() )
737 Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO();
739 aList.Append( anIO );
740 selectionMgr()->setSelectedObjects( aList, false );
742 if( const SMDS_MeshNode* aNode = aMesh->FindNode( theText.toInt() ) )
744 TColStd_MapOfInteger aListInd;
745 aListInd.Add( aNode->GetID() );
746 selector()->AddOrRemoveIndex( anIO, aListInd, false );
747 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() ) )
748 aViewWindow->highlight( anIO, true, true );
754 //================================================================================
756 * \brief Activate Node selection
758 //================================================================================
760 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
762 selectionMgr()->clearFilters();
763 SMESH::SetPointRepresentation(false);
764 selectionMgr()->installFilter( myFilter );
765 setSelectionMode( NodeSelection );
768 //================================================================================
772 //================================================================================
774 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
776 if ( myDlg ) delete myDlg;
777 if ( mySimulation ) delete mySimulation;
778 if ( myFilter ) delete myFilter;
781 //================================================================================
783 * \brief Gets dialog of this operation
784 * \retval LightApp_Dialog* - pointer to dialog of this operation
786 //================================================================================
788 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const