1 // Copyright (C) 2007-2013 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 myUpdateBtn = new QPushButton(tr("UPDATE_DESTINATION"), myNodeToMoveGrp);
179 myUpdateBtn->setAutoDefault(true);
181 QWidget* aCoordWidget = new QWidget(myNodeToMoveGrp);
183 QLabel* aCurrentXLabel = new QLabel(tr("SMESH_X"), aCoordWidget);
184 myCurrentX = new SMESHGUI_SpinBox(aCoordWidget);
185 myCurrentX->setButtonSymbols(QAbstractSpinBox::NoButtons);
186 myCurrentX->setReadOnly(true);
188 QLabel* aCurrentYLabel = new QLabel(tr("SMESH_Y"), aCoordWidget);
189 myCurrentY = new SMESHGUI_SpinBox(aCoordWidget);
190 myCurrentY->setButtonSymbols(QAbstractSpinBox::NoButtons);
191 myCurrentY->setReadOnly(true);
193 QLabel* aCurrentZLabel = new QLabel(tr("SMESH_Z"), aCoordWidget);
194 myCurrentZ = new SMESHGUI_SpinBox(aCoordWidget);
195 myCurrentZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
196 myCurrentZ->setReadOnly(true);
198 QLabel* aDXLabel = new QLabel(tr("SMESH_DX"), aCoordWidget);
199 myDX = new SMESHGUI_SpinBox(aCoordWidget);
200 myDX->setButtonSymbols(QAbstractSpinBox::NoButtons);
201 myDX->setReadOnly(true);
203 QLabel* aDYLabel = new QLabel(tr("SMESH_DY"), aCoordWidget);
204 myDY = new SMESHGUI_SpinBox(aCoordWidget);
205 myDY->setButtonSymbols(QAbstractSpinBox::NoButtons);
206 myDY->setReadOnly(true);
208 QLabel* aDZLabel = new QLabel(tr("SMESH_DZ"), aCoordWidget);
209 myDZ = new SMESHGUI_SpinBox(aCoordWidget);
210 myDZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
211 myDZ->setReadOnly(true);
213 myCurrentX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
214 myCurrentY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
215 myCurrentZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
216 myDX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
217 myDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
218 myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
220 QGridLayout* aCoordLayout = new QGridLayout(aCoordWidget);
221 aCoordLayout->setMargin(0);
222 aCoordLayout->setSpacing(SPACING);
223 aCoordLayout->addWidget(aCurrentXLabel, 0, 0);
224 aCoordLayout->addWidget(myCurrentX, 0, 1);
225 aCoordLayout->addWidget(aCurrentYLabel, 0, 2);
226 aCoordLayout->addWidget(myCurrentY, 0, 3);
227 aCoordLayout->addWidget(aCurrentZLabel, 0, 4);
228 aCoordLayout->addWidget(myCurrentZ, 0, 5);
229 aCoordLayout->addWidget(aDXLabel, 1, 0);
230 aCoordLayout->addWidget(myDX, 1, 1);
231 aCoordLayout->addWidget(aDYLabel, 1, 2);
232 aCoordLayout->addWidget(myDY, 1, 3);
233 aCoordLayout->addWidget(aDZLabel, 1, 4);
234 aCoordLayout->addWidget(myDZ, 1, 5);
235 aCoordLayout->setColumnStretch(1, 1);
236 aCoordLayout->setColumnStretch(3, 1);
237 aCoordLayout->setColumnStretch(5, 1);
239 myAutoSearchChkBox = new QCheckBox( tr("AUTO_SEARCH"), myNodeToMoveGrp);
240 myPreviewChkBox = new QCheckBox( tr("PREVIEW"), myNodeToMoveGrp);
242 QGridLayout* myNodeToMoveGrpLayout = new QGridLayout(myNodeToMoveGrp);
243 myNodeToMoveGrpLayout->setSpacing(SPACING);
244 myNodeToMoveGrpLayout->setMargin(MARGIN);
246 myNodeToMoveGrpLayout->addWidget( idLabel, 0, 0 );
247 myNodeToMoveGrpLayout->addWidget( myIdBtn, 0, 1 );
248 myNodeToMoveGrpLayout->addWidget( myId, 0, 2 );
249 myNodeToMoveGrpLayout->addWidget( myUpdateBtn, 0, 3 );
250 myNodeToMoveGrpLayout->addWidget( aCoordWidget, 1, 0, 1, 4 );
251 myNodeToMoveGrpLayout->addWidget( myAutoSearchChkBox, 2, 0, 1, 4 );
252 myNodeToMoveGrpLayout->addWidget( myPreviewChkBox, 3, 0, 1, 4 );
254 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
255 aLay->addWidget(aPixGrp);
256 aLay->addWidget(aCoordGrp);
257 aLay->addWidget(myNodeToMoveGrp);
259 connect(myCoordBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
260 connect(myIdBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
261 connect(myAutoSearchChkBox, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
263 myIdBtn->setChecked(true);
264 myAutoSearchChkBox->setChecked(true);
269 //================================================================================
271 * \brief SLOT called when any button is toggled
272 * \param bool - on or off
274 //================================================================================
276 void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on)
278 const QObject* aSender = sender();
280 if ( aSender == myCoordBtn ) // button to set coord by node selection
282 if ( myIdBtn->isEnabled() )
283 myIdBtn->setChecked( !on );
285 else if ( aSender == myIdBtn ) // button to select a node to move
287 myCoordBtn->setChecked( !on );
290 if ( aSender == myAutoSearchChkBox ) // automatic node search
293 myCurrentX->SetValue(0);
294 myCurrentY->SetValue(0);
295 myCurrentZ->SetValue(0);
300 myId->setReadOnly ( true );
301 myIdBtn->setChecked( false );
302 myIdBtn->setEnabled( false );
303 myCoordBtn->setChecked( true );
304 myUpdateBtn->setEnabled( false );
307 myId->setReadOnly ( false );
308 myIdBtn->setEnabled( true );
309 myUpdateBtn->setEnabled( true );
314 //================================================================================
318 //================================================================================
320 SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp()
323 myDlg = new SMESHGUI_MakeNodeAtPointDlg;
325 myHelpFileName = "mesh_through_point_page.html";
328 myUpdateDestination = false;
330 // connect signals and slots
331 connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
332 connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
333 connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
334 connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
335 connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
336 connect(myDlg->myAutoSearchChkBox,SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
338 // IPAL22913: TC6.5.0: selected in "Move node" dialog box node is not highlighted
339 // note: this slot seems to be lost together with removed obsolete SMESHGUI_MoveNodesDlg class
340 connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(onTextChange(const QString&)));
341 connect(myDlg->myUpdateBtn, SIGNAL (clicked()), this, SLOT(onUpdateDestination()));
344 void SMESHGUI_MakeNodeAtPointOp::onUpdateDestination()
346 myUpdateDestination = true;
348 myUpdateDestination = false;
351 //=======================================================================
352 // function : startOperation()
353 // purpose : Init dialog fields, connect signals and slots, show dialog
354 //=======================================================================
355 void SMESHGUI_MakeNodeAtPointOp::startOperation()
360 // init simulation with a current View
361 if ( mySimulation ) delete mySimulation;
362 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
363 vtkProperty* aProp = vtkProperty::New();
364 aProp->SetRepresentationToWireframe();
365 aProp->SetColor(250, 0, 250);
366 aProp->SetPointSize(5);
367 aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
368 mySimulation->GetActor()->SetProperty(aProp);
371 // SalomeApp_TypeFilter depends on a current study
372 if ( myFilter ) delete myFilter;
373 QList<SUIT_SelectionFilter*> filters;
374 filters.append( new SalomeApp_TypeFilter((SalomeApp_Study*)study(), "SMESH" ));
375 TColStd_MapOfInteger vertexType;
376 vertexType.Add( TopAbs_VERTEX );
377 filters.append( new SMESH_NumberFilter("GEOM", TopAbs_VERTEX, 1, vertexType ));
378 myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
381 SMESHGUI_SelectionOp::startOperation(); // this method should be called only after filter creation
382 //activateSelection(); // set filters // called inside of previous statement
384 myDlg->myX->SetValue(0);
385 myDlg->myY->SetValue(0);
386 myDlg->myZ->SetValue(0);
387 myDlg->myCurrentX->SetValue(0);
388 myDlg->myCurrentY->SetValue(0);
389 myDlg->myCurrentZ->SetValue(0);
390 myDlg->myDX->SetValue(0);
391 myDlg->myDY->SetValue(0);
392 myDlg->myDZ->SetValue(0);
393 myDlg->myId->setText("");
396 onSelectionDone(); // init myMeshActor
399 // myMeshActor->SetRepresentation( VTK_WIREFRAME );
400 myMeshActor->SetPointRepresentation(true);
401 SMESH::RepaintCurrentView();
406 //================================================================================
408 * \brief Stops operation
410 //================================================================================
412 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
415 mySimulation->SetVisibility(false);
417 myMeshActor->SetPointRepresentation(false);
418 SMESH::RepaintCurrentView();
421 selectionMgr()->removeFilter( myFilter );
422 SMESHGUI_SelectionOp::stopOperation();
425 //================================================================================
427 * \brief perform it's intention action: move or create a node
429 //================================================================================
431 bool SMESHGUI_MakeNodeAtPointOp::onApply()
433 if( isStudyLocked() )
436 if ( !myMeshActor ) {
437 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
438 tr("INVALID_MESH") );
444 if ( !isValid( msg ) ) { // node id is invalid
446 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
452 QStringList aParameters;
453 aParameters << myDlg->myX->text();
454 aParameters << myDlg->myY->text();
455 aParameters << myDlg->myZ->text();
458 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
459 if (aMesh->_is_nil()) {
460 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
461 tr("SMESHG_NO_MESH") );
464 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
465 if (aMeshEditor->_is_nil())
468 aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
471 int anId = myDlg->myId->text().toInt( &ok );
472 if( !ok || anId < 1 )
473 anId = aMeshEditor->FindNodeClosestTo(myDlg->myX->GetValue(),
474 myDlg->myY->GetValue(),
475 myDlg->myZ->GetValue());
477 int aResult = aMeshEditor->MoveNode(anId,
478 myDlg->myX->GetValue(),
479 myDlg->myY->GetValue(),
480 myDlg->myZ->GetValue() );
484 myDlg->myCurrentX->SetValue(0);
485 myDlg->myCurrentY->SetValue(0);
486 myDlg->myCurrentZ->SetValue(0);
487 myDlg->myDX->SetValue(0);
488 myDlg->myDY->SetValue(0);
489 myDlg->myDZ->SetValue(0);
490 myDlg->myId->setText("");
493 selectionMgr()->setSelectedObjects(aList,false);
494 aList.Append(myMeshActor->getIO());
495 selectionMgr()->setSelectedObjects(aList,false);
497 SMESHGUI::Modified();
500 catch (const SALOME::SALOME_Exception& S_ex) {
501 SalomeApp_Tools::QtCatchCorbaException(S_ex);
509 //================================================================================
511 * \brief Check selected node id validity
513 //================================================================================
515 bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
519 !myDlg->myAutoSearchChkBox->isChecked() )
522 int id = myDlg->myId->text().toInt();
524 if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
525 ok = aMesh->FindNode( id );
527 msg += tr("INVALID_ID") + "\n";
530 ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok;
531 ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok;
532 ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok;
537 //================================================================================
539 * \brief SLOT called when selection changed
541 //================================================================================
543 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
545 if ( !myDlg->isVisible() || !myDlg->isEnabled() )
549 selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
550 if (aList.Extent() != 1)
552 Handle(SALOME_InteractiveObject) anIO = aList.First();
553 SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
555 if (!aMeshActor) { // coord by geom
556 if ( myDlg->myCoordBtn->isChecked() ) {
557 GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
558 if ( !geom->_is_nil() ) {
559 TopoDS_Vertex aShape;
560 if ( GEOMBase::GetShape(geom, aShape) &&
561 aShape.ShapeType() == TopAbs_VERTEX ) {
562 gp_Pnt P = BRep_Tool::Pnt(aShape);
564 myDlg->myX->SetValue(P.X());
565 myDlg->myY->SetValue(P.Y());
566 myDlg->myZ->SetValue(P.Z());
576 myMeshActor = aMeshActor;
579 int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
581 if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
582 if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
584 if ( myDlg->myCoordBtn->isChecked() ) { // set coord
585 myDlg->myX->SetValue(aNode->X());
586 myDlg->myY->SetValue(aNode->Y());
587 myDlg->myZ->SetValue(aNode->Z());
591 else if ( myDlg->myIdBtn->isChecked() &&
592 myDlg->myIdBtn->isEnabled() ) { // set node to move
593 myDlg->myId->setText(aString);
598 if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) {
599 double x = aCurrentNode->X();
600 double y = aCurrentNode->Y();
601 double z = aCurrentNode->Z();
602 double dx = myDlg->myX->GetValue() - x;
603 double dy = myDlg->myY->GetValue() - y;
604 double dz = myDlg->myZ->GetValue() - z;
605 myDlg->myCurrentX->SetValue(x);
606 myDlg->myCurrentY->SetValue(y);
607 myDlg->myCurrentZ->SetValue(z);
608 myDlg->myDX->SetValue(dx);
609 myDlg->myDY->SetValue(dy);
610 myDlg->myDZ->SetValue(dz);
619 //================================================================================
621 * \brief update preview
623 //================================================================================
625 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
631 SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
633 bool moveShown = false;
636 const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
637 const bool preview = myDlg->myPreviewChkBox->isChecked();
640 myDlg->myCurrentX->SetValue(0);
641 myDlg->myCurrentY->SetValue(0);
642 myDlg->myCurrentZ->SetValue(0);
643 myDlg->myDX->SetValue(0);
644 myDlg->myDY->SetValue(0);
645 myDlg->myDZ->SetValue(0);
646 myDlg->myId->setText("");
649 if ( autoSearch || isValid( msg ) )
652 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
653 if (!aMesh->_is_nil()) {
654 SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
655 if (!aPreviewer->_is_nil())
657 SUIT_OverrideCursor aWaitCursor;
661 anId = aPreviewer->FindNodeClosestTo(myDlg->myX->GetValue(),
662 myDlg->myY->GetValue(),
663 myDlg->myZ->GetValue());
665 anId = myDlg->myId->text().toInt();
667 // find id and/or just compute preview
668 aPreviewer->MoveNode(anId,
669 myDlg->myX->GetValue(),
670 myDlg->myY->GetValue(),
671 myDlg->myZ->GetValue());
672 if ( autoSearch ) { // set found id
675 idTxt = idTxt.arg( anId );
678 myDlg->myId->setText( idTxt );
681 SMESH::double_array* aXYZ = aMesh->GetNodeXYZ( anId );
682 if( aXYZ && aXYZ->length() >= 3 )
684 double x = aXYZ->operator[](0);
685 double y = aXYZ->operator[](1);
686 double z = aXYZ->operator[](2);
688 if ( myUpdateDestination ) {
689 myDlg->myX->SetValue(x);
690 myDlg->myY->SetValue(y);
691 myDlg->myZ->SetValue(z);
694 double dx = myDlg->myX->GetValue() - x;
695 double dy = myDlg->myY->GetValue() - y;
696 double dz = myDlg->myZ->GetValue() - z;
697 myDlg->myCurrentX->SetValue(x);
698 myDlg->myCurrentY->SetValue(y);
699 myDlg->myCurrentZ->SetValue(z);
700 myDlg->myDX->SetValue(dx);
701 myDlg->myDY->SetValue(dy);
702 myDlg->myDZ->SetValue(dz);
705 if ( preview ) { // fill preview data
706 aMeshPreviewStruct = aPreviewer->GetPreviewData();
707 moveShown = ( anId > 0 );
718 aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
720 aMeshPreviewStruct->nodesXYZ.length(1);
721 aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
722 aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
723 aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
725 aMeshPreviewStruct->elementTypes.length(1);
726 aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
727 aMeshPreviewStruct->elementTypes[0].isPoly = false;
728 aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
730 aMeshPreviewStruct->elementConnectivities.length(1);
731 aMeshPreviewStruct->elementConnectivities[0] = 0;
735 if ( aMeshPreviewStruct.operator->() )
737 mySimulation->SetData(aMeshPreviewStruct._retn());
741 mySimulation->SetVisibility(false);
747 //================================================================================
749 * \brief SLOT called when the node id is manually changed
751 //================================================================================
753 void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText )
757 if( SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh() )
759 Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO();
761 aList.Append( anIO );
762 selectionMgr()->setSelectedObjects( aList, false );
764 if( const SMDS_MeshNode* aNode = aMesh->FindNode( theText.toInt() ) )
766 TColStd_MapOfInteger aListInd;
767 aListInd.Add( aNode->GetID() );
768 selector()->AddOrRemoveIndex( anIO, aListInd, false );
769 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() ) )
770 aViewWindow->highlight( anIO, true, true );
776 //================================================================================
778 * \brief Activate Node selection
780 //================================================================================
782 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
784 selectionMgr()->clearFilters();
785 SMESH::SetPointRepresentation(false);
786 selectionMgr()->installFilter( myFilter );
787 setSelectionMode( NodeSelection );
790 //================================================================================
794 //================================================================================
796 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
798 if ( myDlg ) delete myDlg;
799 if ( mySimulation ) delete mySimulation;
800 if ( myFilter ) delete myFilter;
803 //================================================================================
805 * \brief Gets dialog of this operation
806 * \retval LightApp_Dialog* - pointer to dialog of this operation
808 //================================================================================
810 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const