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);
162 aCoordGrpLayout->setStretchFactor(myX, 1);
163 aCoordGrpLayout->setStretchFactor(myY, 1);
164 aCoordGrpLayout->setStretchFactor(myZ, 1);
168 myNodeToMoveGrp = new QGroupBox(tr("NODE_2MOVE"), aFrame);
170 QLabel* idLabel = new QLabel(tr("NODE_2MOVE_ID"), myNodeToMoveGrp);
171 myIdBtn = new QPushButton(myNodeToMoveGrp);
172 myIdBtn->setIcon(iconSelect);
173 myIdBtn->setCheckable(true);
174 myId = new QLineEdit(myNodeToMoveGrp);
175 myId->setValidator(new SMESHGUI_IdValidator(this, 1));
177 QWidget* aCoordWidget = new QWidget(myNodeToMoveGrp);
179 QLabel* aCurrentXLabel = new QLabel(tr("SMESH_X"), aCoordWidget);
180 myCurrentX = new SMESHGUI_SpinBox(aCoordWidget);
181 myCurrentX->setButtonSymbols(QAbstractSpinBox::NoButtons);
182 myCurrentX->setReadOnly(true);
184 QLabel* aCurrentYLabel = new QLabel(tr("SMESH_Y"), aCoordWidget);
185 myCurrentY = new SMESHGUI_SpinBox(aCoordWidget);
186 myCurrentY->setButtonSymbols(QAbstractSpinBox::NoButtons);
187 myCurrentY->setReadOnly(true);
189 QLabel* aCurrentZLabel = new QLabel(tr("SMESH_Z"), aCoordWidget);
190 myCurrentZ = new SMESHGUI_SpinBox(aCoordWidget);
191 myCurrentZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
192 myCurrentZ->setReadOnly(true);
194 QLabel* aDXLabel = new QLabel(tr("SMESH_DX"), aCoordWidget);
195 myDX = new SMESHGUI_SpinBox(aCoordWidget);
196 myDX->setButtonSymbols(QAbstractSpinBox::NoButtons);
197 myDX->setReadOnly(true);
199 QLabel* aDYLabel = new QLabel(tr("SMESH_DY"), aCoordWidget);
200 myDY = new SMESHGUI_SpinBox(aCoordWidget);
201 myDY->setButtonSymbols(QAbstractSpinBox::NoButtons);
202 myDY->setReadOnly(true);
204 QLabel* aDZLabel = new QLabel(tr("SMESH_DZ"), aCoordWidget);
205 myDZ = new SMESHGUI_SpinBox(aCoordWidget);
206 myDZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
207 myDZ->setReadOnly(true);
209 myCurrentX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
210 myCurrentY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
211 myCurrentZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
212 myDX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
213 myDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
214 myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
216 QGridLayout* aCoordLayout = new QGridLayout(aCoordWidget);
217 aCoordLayout->setMargin(0);
218 aCoordLayout->setSpacing(SPACING);
219 aCoordLayout->addWidget(aCurrentXLabel, 0, 0);
220 aCoordLayout->addWidget(myCurrentX, 0, 1);
221 aCoordLayout->addWidget(aCurrentYLabel, 0, 2);
222 aCoordLayout->addWidget(myCurrentY, 0, 3);
223 aCoordLayout->addWidget(aCurrentZLabel, 0, 4);
224 aCoordLayout->addWidget(myCurrentZ, 0, 5);
225 aCoordLayout->addWidget(aDXLabel, 1, 0);
226 aCoordLayout->addWidget(myDX, 1, 1);
227 aCoordLayout->addWidget(aDYLabel, 1, 2);
228 aCoordLayout->addWidget(myDY, 1, 3);
229 aCoordLayout->addWidget(aDZLabel, 1, 4);
230 aCoordLayout->addWidget(myDZ, 1, 5);
231 aCoordLayout->setColumnStretch(1, 1);
232 aCoordLayout->setColumnStretch(3, 1);
233 aCoordLayout->setColumnStretch(5, 1);
235 myAutoSearchChkBox = new QCheckBox( tr("AUTO_SEARCH"), myNodeToMoveGrp);
236 myPreviewChkBox = new QCheckBox( tr("PREVIEW"), myNodeToMoveGrp);
238 QGridLayout* myNodeToMoveGrpLayout = new QGridLayout(myNodeToMoveGrp);
239 myNodeToMoveGrpLayout->setSpacing(SPACING);
240 myNodeToMoveGrpLayout->setMargin(MARGIN);
242 myNodeToMoveGrpLayout->addWidget( idLabel, 0, 0 );
243 myNodeToMoveGrpLayout->addWidget( myIdBtn, 0, 1 );
244 myNodeToMoveGrpLayout->addWidget( myId, 0, 2 );
245 myNodeToMoveGrpLayout->addWidget( aCoordWidget, 1, 0, 1, 3 );
246 myNodeToMoveGrpLayout->addWidget( myAutoSearchChkBox, 2, 0, 1, 3 );
247 myNodeToMoveGrpLayout->addWidget( myPreviewChkBox, 3, 0, 1, 3 );
249 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
250 aLay->addWidget(aPixGrp);
251 aLay->addWidget(aCoordGrp);
252 aLay->addWidget(myNodeToMoveGrp);
254 connect(myCoordBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
255 connect(myIdBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
256 connect(myAutoSearchChkBox, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
258 myIdBtn->setChecked(true);
259 myAutoSearchChkBox->setChecked(true);
264 //================================================================================
266 * \brief SLOT called when any button is toggled
267 * \param bool - on or off
269 //================================================================================
271 void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on)
273 const QObject* aSender = sender();
275 if ( aSender == myCoordBtn ) // button to set coord by node selection
277 if ( myIdBtn->isEnabled() )
278 myIdBtn->setChecked( !on );
280 else if ( aSender == myIdBtn ) // button to select a node to move
282 myCoordBtn->setChecked( !on );
285 if ( aSender == myAutoSearchChkBox ) // automatic node search
288 myCurrentX->SetValue(0);
289 myCurrentY->SetValue(0);
290 myCurrentZ->SetValue(0);
295 myId->setReadOnly ( true );
296 myIdBtn->setChecked( false );
297 myIdBtn->setEnabled( false );
298 myCoordBtn->setChecked( true );
301 myId->setReadOnly ( false );
302 myIdBtn->setEnabled( true );
307 //================================================================================
311 //================================================================================
313 SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp()
316 myDlg = new SMESHGUI_MakeNodeAtPointDlg;
318 myHelpFileName = "mesh_through_point_page.html";
320 // connect signals and slots
321 connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
322 connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
323 connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
324 connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
325 connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
326 connect(myDlg->myAutoSearchChkBox,SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
329 //=======================================================================
330 // function : startOperation()
331 // purpose : Init dialog fields, connect signals and slots, show dialog
332 //=======================================================================
333 void SMESHGUI_MakeNodeAtPointOp::startOperation()
338 // init simulation with a current View
339 if ( mySimulation ) delete mySimulation;
340 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
341 vtkProperty* aProp = vtkProperty::New();
342 aProp->SetRepresentationToWireframe();
343 aProp->SetColor(250, 0, 250);
344 aProp->SetPointSize(5);
345 aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
346 mySimulation->GetActor()->SetProperty(aProp);
349 // SalomeApp_TypeFilter depends on a current study
350 if ( myFilter ) delete myFilter;
351 QList<SUIT_SelectionFilter*> filters;
352 filters.append( new SalomeApp_TypeFilter((SalomeApp_Study*)study(), "SMESH" ));
353 TColStd_MapOfInteger vertexType;
354 vertexType.Add( TopAbs_VERTEX );
355 filters.append( new SMESH_NumberFilter("GEOM", TopAbs_VERTEX, 1, vertexType ));
356 myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
359 SMESHGUI_SelectionOp::startOperation(); // this method should be called only after filter creation
360 //activateSelection(); // set filters // called inside of previous statement
362 myDlg->myX->SetValue(0);
363 myDlg->myY->SetValue(0);
364 myDlg->myZ->SetValue(0);
365 myDlg->myCurrentX->SetValue(0);
366 myDlg->myCurrentY->SetValue(0);
367 myDlg->myCurrentZ->SetValue(0);
368 myDlg->myDX->SetValue(0);
369 myDlg->myDY->SetValue(0);
370 myDlg->myDZ->SetValue(0);
371 myDlg->myId->setText("");
374 onSelectionDone(); // init myMeshActor
377 // myMeshOldDisplayMode = myMeshActor->GetRepresentation();
378 // myMeshActor->SetRepresentation( VTK_WIREFRAME );
379 myMeshActor->SetPointRepresentation(true);
380 SMESH::RepaintCurrentView();
385 //================================================================================
387 * \brief Stops operation
389 //================================================================================
391 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
394 mySimulation->SetVisibility(false);
396 // myMeshActor->SetRepresentation( myMeshOldDisplayMode );
397 myMeshActor->SetPointRepresentation(false);
398 SMESH::RepaintCurrentView();
401 selectionMgr()->removeFilter( myFilter );
402 SMESHGUI_SelectionOp::stopOperation();
405 //================================================================================
407 * \brief perform it's intention action: move or create a node
409 //================================================================================
411 bool SMESHGUI_MakeNodeAtPointOp::onApply()
413 if( isStudyLocked() )
416 if ( !myMeshActor ) {
417 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
418 tr("INVALID_MESH") );
424 if ( !isValid( msg ) ) { // node id is invalid
426 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
434 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
435 if (aMesh->_is_nil()) {
436 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
437 tr("SMESHG_NO_MESH") );
440 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
441 if (aMeshEditor->_is_nil())
445 int anId = myDlg->myId->text().toInt( &ok );
446 if( !ok || anId < 1 )
447 anId = aMeshEditor->FindNodeClosestTo(myDlg->myX->GetValue(),
448 myDlg->myY->GetValue(),
449 myDlg->myZ->GetValue());
451 int aResult = aMeshEditor->MoveNode(anId,
452 myDlg->myX->GetValue(),
453 myDlg->myY->GetValue(),
454 myDlg->myZ->GetValue() );
458 QStringList aParameters;
459 aParameters << myDlg->myX->text();
460 aParameters << myDlg->myY->text();
461 aParameters << myDlg->myZ->text();
462 aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
464 myDlg->myCurrentX->SetValue(0);
465 myDlg->myCurrentY->SetValue(0);
466 myDlg->myCurrentZ->SetValue(0);
467 myDlg->myDX->SetValue(0);
468 myDlg->myDY->SetValue(0);
469 myDlg->myDZ->SetValue(0);
470 myDlg->myId->setText("");
473 selectionMgr()->setSelectedObjects(aList,false);
474 aList.Append(myMeshActor->getIO());
475 selectionMgr()->setSelectedObjects(aList,false);
477 SMESHGUI::Modified();
480 catch (const SALOME::SALOME_Exception& S_ex) {
481 SalomeApp_Tools::QtCatchCorbaException(S_ex);
489 //================================================================================
491 * \brief Check selected node id validity
493 //================================================================================
495 bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
499 !myDlg->myAutoSearchChkBox->isChecked() )
502 int id = myDlg->myId->text().toInt();
504 if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
505 ok = aMesh->FindNode( id );
507 msg += tr("INVALID_ID") + "\n";
510 ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok;
511 ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok;
512 ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok;
517 //================================================================================
519 * \brief SLOT called when selection changed
521 //================================================================================
523 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
525 if ( !myDlg->isVisible() || !myDlg->isEnabled() )
529 selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
530 if (aList.Extent() != 1)
532 Handle(SALOME_InteractiveObject) anIO = aList.First();
533 SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
535 if (!aMeshActor) { // coord by geom
536 if ( myDlg->myCoordBtn->isChecked() ) {
537 GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
538 if ( !geom->_is_nil() ) {
539 TopoDS_Vertex aShape;
540 if ( GEOMBase::GetShape(geom, aShape) &&
541 aShape.ShapeType() == TopAbs_VERTEX ) {
542 gp_Pnt P = BRep_Tool::Pnt(aShape);
544 myDlg->myX->SetValue(P.X());
545 myDlg->myY->SetValue(P.Y());
546 myDlg->myZ->SetValue(P.Z());
556 myMeshActor = aMeshActor;
559 int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
561 if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
562 if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
564 if ( myDlg->myCoordBtn->isChecked() ) { // set coord
565 myDlg->myX->SetValue(aNode->X());
566 myDlg->myY->SetValue(aNode->Y());
567 myDlg->myZ->SetValue(aNode->Z());
571 else if ( myDlg->myIdBtn->isChecked() &&
572 myDlg->myIdBtn->isEnabled() ) { // set node to move
573 myDlg->myId->setText(aString);
578 if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) {
579 double x = aCurrentNode->X();
580 double y = aCurrentNode->Y();
581 double z = aCurrentNode->Z();
582 double dx = myDlg->myX->GetValue() - x;
583 double dy = myDlg->myY->GetValue() - y;
584 double dz = myDlg->myZ->GetValue() - z;
585 myDlg->myCurrentX->SetValue(x);
586 myDlg->myCurrentY->SetValue(y);
587 myDlg->myCurrentZ->SetValue(z);
588 myDlg->myDX->SetValue(dx);
589 myDlg->myDY->SetValue(dy);
590 myDlg->myDZ->SetValue(dz);
599 //================================================================================
601 * \brief update preview
603 //================================================================================
605 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
611 SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
613 bool moveShown = false;
616 const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
617 const bool preview = myDlg->myPreviewChkBox->isChecked();
620 myDlg->myCurrentX->SetValue(0);
621 myDlg->myCurrentY->SetValue(0);
622 myDlg->myCurrentZ->SetValue(0);
623 myDlg->myDX->SetValue(0);
624 myDlg->myDY->SetValue(0);
625 myDlg->myDZ->SetValue(0);
626 myDlg->myId->setText("");
629 if ( autoSearch || isValid( msg ) )
632 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
633 if (!aMesh->_is_nil()) {
634 SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
635 if (!aPreviewer->_is_nil())
637 SUIT_OverrideCursor aWaitCursor;
641 anId = aPreviewer->FindNodeClosestTo(myDlg->myX->GetValue(),
642 myDlg->myY->GetValue(),
643 myDlg->myZ->GetValue());
645 anId = myDlg->myId->text().toInt();
647 // find id and/or just compute preview
648 aPreviewer->MoveNode(anId,
649 myDlg->myX->GetValue(),
650 myDlg->myY->GetValue(),
651 myDlg->myZ->GetValue());
652 if ( autoSearch ) { // set found id
655 idTxt = idTxt.arg( anId );
658 myDlg->myId->setText( idTxt );
661 SMESH::double_array* aXYZ = aMesh->GetNodeXYZ( anId );
662 if( aXYZ && aXYZ->length() >= 3 )
664 double x = aXYZ->operator[](0);
665 double y = aXYZ->operator[](1);
666 double z = aXYZ->operator[](2);
667 double dx = myDlg->myX->GetValue() - x;
668 double dy = myDlg->myY->GetValue() - y;
669 double dz = myDlg->myZ->GetValue() - z;
670 myDlg->myCurrentX->SetValue(x);
671 myDlg->myCurrentY->SetValue(y);
672 myDlg->myCurrentZ->SetValue(z);
673 myDlg->myDX->SetValue(dx);
674 myDlg->myDY->SetValue(dy);
675 myDlg->myDZ->SetValue(dz);
678 if ( preview ) { // fill preview data
679 aMeshPreviewStruct = aPreviewer->GetPreviewData();
680 moveShown = ( anId > 0 );
691 aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
693 aMeshPreviewStruct->nodesXYZ.length(1);
694 aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
695 aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
696 aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
698 aMeshPreviewStruct->elementTypes.length(1);
699 aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
700 aMeshPreviewStruct->elementTypes[0].isPoly = false;
701 aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
703 aMeshPreviewStruct->elementConnectivities.length(1);
704 aMeshPreviewStruct->elementConnectivities[0] = 0;
708 if ( aMeshPreviewStruct.operator->() )
710 mySimulation->SetData(aMeshPreviewStruct._retn());
714 mySimulation->SetVisibility(false);
720 //================================================================================
722 * \brief Activate Node selection
724 //================================================================================
726 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
728 selectionMgr()->clearFilters();
729 SMESH::SetPointRepresentation(false);
730 selectionMgr()->installFilter( myFilter );
731 setSelectionMode( NodeSelection );
734 //================================================================================
738 //================================================================================
740 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
742 if ( myDlg ) delete myDlg;
743 if ( mySimulation ) delete mySimulation;
744 if ( myFilter ) delete myFilter;
747 //================================================================================
749 * \brief Gets dialog of this operation
750 * \retval LightApp_Dialog* - pointer to dialog of this operation
752 //================================================================================
754 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const