00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "SMESHGUI_MakeNodeAtPointDlg.h"
00028
00029 #include "SMESHGUI.h"
00030 #include "SMESHGUI_IdValidator.h"
00031 #include "SMESHGUI_MeshUtils.h"
00032 #include "SMESHGUI_VTKUtils.h"
00033 #include "SMESHGUI_SpinBox.h"
00034 #include "SMESHGUI_MeshEditPreview.h"
00035
00036 #include <SMDS_Mesh.hxx>
00037 #include <SMESH_Actor.h>
00038 #include <SMESH_ActorUtils.h>
00039 #include <SMESH_NumberFilter.hxx>
00040 #include <SMESH_LogicalFilter.hxx>
00041
00042
00043 #include <GEOMBase.h>
00044
00045
00046 #include <LightApp_SelectionMgr.h>
00047 #include <SALOME_ListIO.hxx>
00048 #include <SUIT_Desktop.h>
00049 #include <SVTK_ViewModel.h>
00050 #include <SalomeApp_Tools.h>
00051 #include <SalomeApp_TypeFilter.h>
00052 #include <SUIT_ResourceMgr.h>
00053 #include <SUIT_OverrideCursor.h>
00054 #include <SUIT_MessageBox.h>
00055
00056
00057 #include <TColStd_MapOfInteger.hxx>
00058 #include <TopoDS_Vertex.hxx>
00059 #include <BRep_Tool.hxx>
00060 #include <gp_Pnt.hxx>
00061
00062
00063 #include <QGroupBox>
00064 #include <QGridLayout>
00065 #include <QHBoxLayout>
00066 #include <QVBoxLayout>
00067 #include <QLineEdit>
00068 #include <QPushButton>
00069 #include <QLabel>
00070 #include <QRadioButton>
00071 #include <QCheckBox>
00072 #include <QButtonGroup>
00073
00074
00075 #include <vtkProperty.h>
00076
00077
00078 #include <SALOMEconfig.h>
00079 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00080 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
00081
00082 #define SPACING 6
00083 #define MARGIN 11
00084
00089 SMESHGUI_MakeNodeAtPointDlg::SMESHGUI_MakeNodeAtPointDlg()
00090 : SMESHGUI_Dialog( 0, false, true )
00091 {
00092 setWindowTitle(tr("CAPTION"));
00093
00094 QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
00095 aDlgLay->setMargin(0);
00096 aDlgLay->setSpacing(SPACING);
00097
00098 QWidget* aMainFrame = createMainFrame (mainFrame());
00099
00100 aDlgLay->addWidget(aMainFrame);
00101
00102 aDlgLay->setStretchFactor(aMainFrame, 1);
00103 }
00104
00105
00106
00107
00108
00109 QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent)
00110 {
00111 QWidget* aFrame = new QWidget(theParent);
00112
00113 SUIT_ResourceMgr* rm = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
00114 QPixmap iconMoveNode (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE")));
00115 QPixmap iconSelect (rm->loadPixmap("SMESH", tr("ICON_SELECT")));
00116
00117
00118
00119 QGroupBox* aPixGrp = new QGroupBox(tr("MOVE_NODE"), aFrame);
00120 QButtonGroup* aBtnGrp = new QButtonGroup(this);
00121 QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp);
00122 aPixGrpLayout->setMargin(MARGIN);
00123 aPixGrpLayout->setSpacing(SPACING);
00124
00125 QRadioButton* aRBut = new QRadioButton(aPixGrp);
00126 aRBut->setIcon(iconMoveNode);
00127 aRBut->setChecked(true);
00128 aPixGrpLayout->addWidget(aRBut);
00129 aBtnGrp->addButton(aRBut, 0);
00130
00131
00132
00133 QGroupBox* aCoordGrp = new QGroupBox(tr("DESTINATION"), aFrame);
00134 QHBoxLayout* aCoordGrpLayout = new QHBoxLayout(aCoordGrp);
00135 aCoordGrpLayout->setMargin(MARGIN);
00136 aCoordGrpLayout->setSpacing(SPACING);
00137
00138 myCoordBtn = new QPushButton(aCoordGrp);
00139 myCoordBtn->setIcon(iconSelect);
00140 myCoordBtn->setCheckable(true);
00141
00142 QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp);
00143 myX = new SMESHGUI_SpinBox(aCoordGrp);
00144
00145 QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp);
00146 myY = new SMESHGUI_SpinBox(aCoordGrp);
00147
00148 QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp);
00149 myZ = new SMESHGUI_SpinBox(aCoordGrp);
00150
00151 myX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00152 myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00153 myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00154
00155 aCoordGrpLayout->addWidget(myCoordBtn);
00156 aCoordGrpLayout->addWidget(aXLabel);
00157 aCoordGrpLayout->addWidget(myX);
00158 aCoordGrpLayout->addWidget(aYLabel);
00159 aCoordGrpLayout->addWidget(myY);
00160 aCoordGrpLayout->addWidget(aZLabel);
00161 aCoordGrpLayout->addWidget(myZ);
00162 aCoordGrpLayout->setStretchFactor(myX, 1);
00163 aCoordGrpLayout->setStretchFactor(myY, 1);
00164 aCoordGrpLayout->setStretchFactor(myZ, 1);
00165
00166
00167
00168 myNodeToMoveGrp = new QGroupBox(tr("NODE_2MOVE"), aFrame);
00169
00170 QLabel* idLabel = new QLabel(tr("NODE_2MOVE_ID"), myNodeToMoveGrp);
00171 myIdBtn = new QPushButton(myNodeToMoveGrp);
00172 myIdBtn->setIcon(iconSelect);
00173 myIdBtn->setCheckable(true);
00174 myId = new QLineEdit(myNodeToMoveGrp);
00175 myId->setValidator(new SMESHGUI_IdValidator(this, 1));
00176
00177 QWidget* aCoordWidget = new QWidget(myNodeToMoveGrp);
00178
00179 QLabel* aCurrentXLabel = new QLabel(tr("SMESH_X"), aCoordWidget);
00180 myCurrentX = new SMESHGUI_SpinBox(aCoordWidget);
00181 myCurrentX->setButtonSymbols(QAbstractSpinBox::NoButtons);
00182 myCurrentX->setReadOnly(true);
00183
00184 QLabel* aCurrentYLabel = new QLabel(tr("SMESH_Y"), aCoordWidget);
00185 myCurrentY = new SMESHGUI_SpinBox(aCoordWidget);
00186 myCurrentY->setButtonSymbols(QAbstractSpinBox::NoButtons);
00187 myCurrentY->setReadOnly(true);
00188
00189 QLabel* aCurrentZLabel = new QLabel(tr("SMESH_Z"), aCoordWidget);
00190 myCurrentZ = new SMESHGUI_SpinBox(aCoordWidget);
00191 myCurrentZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
00192 myCurrentZ->setReadOnly(true);
00193
00194 QLabel* aDXLabel = new QLabel(tr("SMESH_DX"), aCoordWidget);
00195 myDX = new SMESHGUI_SpinBox(aCoordWidget);
00196 myDX->setButtonSymbols(QAbstractSpinBox::NoButtons);
00197 myDX->setReadOnly(true);
00198
00199 QLabel* aDYLabel = new QLabel(tr("SMESH_DY"), aCoordWidget);
00200 myDY = new SMESHGUI_SpinBox(aCoordWidget);
00201 myDY->setButtonSymbols(QAbstractSpinBox::NoButtons);
00202 myDY->setReadOnly(true);
00203
00204 QLabel* aDZLabel = new QLabel(tr("SMESH_DZ"), aCoordWidget);
00205 myDZ = new SMESHGUI_SpinBox(aCoordWidget);
00206 myDZ->setButtonSymbols(QAbstractSpinBox::NoButtons);
00207 myDZ->setReadOnly(true);
00208
00209 myCurrentX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00210 myCurrentY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00211 myCurrentZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00212 myDX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00213 myDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00214 myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
00215
00216 QGridLayout* aCoordLayout = new QGridLayout(aCoordWidget);
00217 aCoordLayout->setMargin(0);
00218 aCoordLayout->setSpacing(SPACING);
00219 aCoordLayout->addWidget(aCurrentXLabel, 0, 0);
00220 aCoordLayout->addWidget(myCurrentX, 0, 1);
00221 aCoordLayout->addWidget(aCurrentYLabel, 0, 2);
00222 aCoordLayout->addWidget(myCurrentY, 0, 3);
00223 aCoordLayout->addWidget(aCurrentZLabel, 0, 4);
00224 aCoordLayout->addWidget(myCurrentZ, 0, 5);
00225 aCoordLayout->addWidget(aDXLabel, 1, 0);
00226 aCoordLayout->addWidget(myDX, 1, 1);
00227 aCoordLayout->addWidget(aDYLabel, 1, 2);
00228 aCoordLayout->addWidget(myDY, 1, 3);
00229 aCoordLayout->addWidget(aDZLabel, 1, 4);
00230 aCoordLayout->addWidget(myDZ, 1, 5);
00231 aCoordLayout->setColumnStretch(1, 1);
00232 aCoordLayout->setColumnStretch(3, 1);
00233 aCoordLayout->setColumnStretch(5, 1);
00234
00235 myAutoSearchChkBox = new QCheckBox( tr("AUTO_SEARCH"), myNodeToMoveGrp);
00236 myPreviewChkBox = new QCheckBox( tr("PREVIEW"), myNodeToMoveGrp);
00237
00238 QGridLayout* myNodeToMoveGrpLayout = new QGridLayout(myNodeToMoveGrp);
00239 myNodeToMoveGrpLayout->setSpacing(SPACING);
00240 myNodeToMoveGrpLayout->setMargin(MARGIN);
00241
00242 myNodeToMoveGrpLayout->addWidget( idLabel, 0, 0 );
00243 myNodeToMoveGrpLayout->addWidget( myIdBtn, 0, 1 );
00244 myNodeToMoveGrpLayout->addWidget( myId, 0, 2 );
00245 myNodeToMoveGrpLayout->addWidget( aCoordWidget, 1, 0, 1, 3 );
00246 myNodeToMoveGrpLayout->addWidget( myAutoSearchChkBox, 2, 0, 1, 3 );
00247 myNodeToMoveGrpLayout->addWidget( myPreviewChkBox, 3, 0, 1, 3 );
00248
00249 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
00250 aLay->addWidget(aPixGrp);
00251 aLay->addWidget(aCoordGrp);
00252 aLay->addWidget(myNodeToMoveGrp);
00253
00254 connect(myCoordBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
00255 connect(myIdBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
00256 connect(myAutoSearchChkBox, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool)));
00257
00258 myIdBtn->setChecked(true);
00259 myAutoSearchChkBox->setChecked(true);
00260
00261 return aFrame;
00262 }
00263
00264
00269
00270
00271 void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on)
00272 {
00273 const QObject* aSender = sender();
00274 if ( on ) {
00275 if ( aSender == myCoordBtn )
00276 {
00277 if ( myIdBtn->isEnabled() )
00278 myIdBtn->setChecked( !on );
00279 }
00280 else if ( aSender == myIdBtn )
00281 {
00282 myCoordBtn->setChecked( !on );
00283 }
00284 }
00285 if ( aSender == myAutoSearchChkBox )
00286 {
00287 if ( on ) {
00288 myCurrentX->SetValue(0);
00289 myCurrentY->SetValue(0);
00290 myCurrentZ->SetValue(0);
00291 myDX->SetValue(0);
00292 myDY->SetValue(0);
00293 myDZ->SetValue(0);
00294 myId->setText("");
00295 myId->setReadOnly ( true );
00296 myIdBtn->setChecked( false );
00297 myIdBtn->setEnabled( false );
00298 myCoordBtn->setChecked( true );
00299 }
00300 else {
00301 myId->setReadOnly ( false );
00302 myIdBtn->setEnabled( true );
00303 }
00304 }
00305 }
00306
00307
00311
00312
00313 SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp()
00314 {
00315 mySimulation = 0;
00316 myDlg = new SMESHGUI_MakeNodeAtPointDlg;
00317 myFilter = 0;
00318 myHelpFileName = "mesh_through_point_page.html";
00319
00320
00321 connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
00322 connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
00323 connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
00324 connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
00325 connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
00326 connect(myDlg->myAutoSearchChkBox,SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
00327 }
00328
00329
00330
00331
00332
00333 void SMESHGUI_MakeNodeAtPointOp::startOperation()
00334 {
00335 myNoPreview = false;
00336 myMeshActor = 0;
00337
00338
00339 if ( mySimulation ) delete mySimulation;
00340 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
00341 vtkProperty* aProp = vtkProperty::New();
00342 aProp->SetRepresentationToWireframe();
00343 aProp->SetColor(250, 0, 250);
00344 aProp->SetPointSize(5);
00345 aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
00346 mySimulation->GetActor()->SetProperty(aProp);
00347 aProp->Delete();
00348
00349
00350 if ( myFilter ) delete myFilter;
00351 QList<SUIT_SelectionFilter*> filters;
00352 filters.append( new SalomeApp_TypeFilter((SalomeApp_Study*)study(), "SMESH" ));
00353 TColStd_MapOfInteger vertexType;
00354 vertexType.Add( TopAbs_VERTEX );
00355 filters.append( new SMESH_NumberFilter("GEOM", TopAbs_VERTEX, 1, vertexType ));
00356 myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
00357
00358
00359 SMESHGUI_SelectionOp::startOperation();
00360
00361
00362 myDlg->myX->SetValue(0);
00363 myDlg->myY->SetValue(0);
00364 myDlg->myZ->SetValue(0);
00365 myDlg->myCurrentX->SetValue(0);
00366 myDlg->myCurrentY->SetValue(0);
00367 myDlg->myCurrentZ->SetValue(0);
00368 myDlg->myDX->SetValue(0);
00369 myDlg->myDY->SetValue(0);
00370 myDlg->myDZ->SetValue(0);
00371 myDlg->myId->setText("");
00372 myDlg->show();
00373
00374 onSelectionDone();
00375
00376 if ( myMeshActor ) {
00377
00378
00379 myMeshActor->SetPointRepresentation(true);
00380 SMESH::RepaintCurrentView();
00381 redisplayPreview();
00382 }
00383 }
00384
00385
00389
00390
00391 void SMESHGUI_MakeNodeAtPointOp::stopOperation()
00392 {
00393 myNoPreview = true;
00394 mySimulation->SetVisibility(false);
00395 if ( myMeshActor ) {
00396
00397 myMeshActor->SetPointRepresentation(false);
00398 SMESH::RepaintCurrentView();
00399 myMeshActor = 0;
00400 }
00401 selectionMgr()->removeFilter( myFilter );
00402 SMESHGUI_SelectionOp::stopOperation();
00403 }
00404
00405
00409
00410
00411 bool SMESHGUI_MakeNodeAtPointOp::onApply()
00412 {
00413 if( isStudyLocked() )
00414 return false;
00415
00416 if ( !myMeshActor ) {
00417 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
00418 tr("INVALID_MESH") );
00419 dlg()->show();
00420 return false;
00421 }
00422
00423 QString msg;
00424 if ( !isValid( msg ) ) {
00425 if( !msg.isEmpty() )
00426 SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
00427 tr("INVALID_ID") );
00428 dlg()->show();
00429 return false;
00430 }
00431
00432
00433 try {
00434 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
00435 if (aMesh->_is_nil()) {
00436 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
00437 tr("SMESHG_NO_MESH") );
00438 return true;
00439 }
00440 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
00441 if (aMeshEditor->_is_nil())
00442 return true;
00443
00444 bool ok;
00445 int anId = myDlg->myId->text().toInt( &ok );
00446 if( !ok || anId < 1 )
00447 anId = aMeshEditor->FindNodeClosestTo(myDlg->myX->GetValue(),
00448 myDlg->myY->GetValue(),
00449 myDlg->myZ->GetValue());
00450
00451 int aResult = aMeshEditor->MoveNode(anId,
00452 myDlg->myX->GetValue(),
00453 myDlg->myY->GetValue(),
00454 myDlg->myZ->GetValue() );
00455
00456 if (aResult)
00457 {
00458 QStringList aParameters;
00459 aParameters << myDlg->myX->text();
00460 aParameters << myDlg->myY->text();
00461 aParameters << myDlg->myZ->text();
00462 aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
00463
00464 myDlg->myCurrentX->SetValue(0);
00465 myDlg->myCurrentY->SetValue(0);
00466 myDlg->myCurrentZ->SetValue(0);
00467 myDlg->myDX->SetValue(0);
00468 myDlg->myDY->SetValue(0);
00469 myDlg->myDZ->SetValue(0);
00470 myDlg->myId->setText("");
00471
00472 SALOME_ListIO aList;
00473 selectionMgr()->setSelectedObjects(aList,false);
00474 aList.Append(myMeshActor->getIO());
00475 selectionMgr()->setSelectedObjects(aList,false);
00476 SMESH::UpdateView();
00477 SMESHGUI::Modified();
00478 }
00479 }
00480 catch (const SALOME::SALOME_Exception& S_ex) {
00481 SalomeApp_Tools::QtCatchCorbaException(S_ex);
00482 }
00483 catch (...) {
00484 }
00485
00486 return true;
00487 }
00488
00489
00493
00494
00495 bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
00496 {
00497 bool ok = true;
00498 if ( myMeshActor &&
00499 !myDlg->myAutoSearchChkBox->isChecked() )
00500 {
00501 ok = false;
00502 int id = myDlg->myId->text().toInt();
00503 if ( id > 0 )
00504 if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
00505 ok = aMesh->FindNode( id );
00506 if( !ok )
00507 msg += tr("INVALID_ID") + "\n";
00508 }
00509
00510 ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok;
00511 ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok;
00512 ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok;
00513
00514 return ok;
00515 }
00516
00517
00521
00522
00523 void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
00524 {
00525 if ( !myDlg->isVisible() || !myDlg->isEnabled() )
00526 return;
00527 try {
00528 SALOME_ListIO aList;
00529 selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
00530 if (aList.Extent() != 1)
00531 return;
00532 Handle(SALOME_InteractiveObject) anIO = aList.First();
00533 SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
00534
00535 if (!aMeshActor) {
00536 if ( myDlg->myCoordBtn->isChecked() ) {
00537 GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
00538 if ( !geom->_is_nil() ) {
00539 TopoDS_Vertex aShape;
00540 if ( GEOMBase::GetShape(geom, aShape) &&
00541 aShape.ShapeType() == TopAbs_VERTEX ) {
00542 gp_Pnt P = BRep_Tool::Pnt(aShape);
00543 myNoPreview = true;
00544 myDlg->myX->SetValue(P.X());
00545 myDlg->myY->SetValue(P.Y());
00546 myDlg->myZ->SetValue(P.Z());
00547 myNoPreview = false;
00548 redisplayPreview();
00549 }
00550 }
00551 return;
00552 }
00553 }
00554
00555 if ( !myMeshActor )
00556 myMeshActor = aMeshActor;
00557
00558 QString aString;
00559 int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
00560 if (nbElems == 1) {
00561 if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
00562 if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
00563 myNoPreview = true;
00564 if ( myDlg->myCoordBtn->isChecked() ) {
00565 myDlg->myX->SetValue(aNode->X());
00566 myDlg->myY->SetValue(aNode->Y());
00567 myDlg->myZ->SetValue(aNode->Z());
00568 myNoPreview = false;
00569 redisplayPreview();
00570 }
00571 else if ( myDlg->myIdBtn->isChecked() &&
00572 myDlg->myIdBtn->isEnabled() ) {
00573 myDlg->myId->setText(aString);
00574 myNoPreview = false;
00575 redisplayPreview();
00576 }
00577
00578 if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) {
00579 double x = aCurrentNode->X();
00580 double y = aCurrentNode->Y();
00581 double z = aCurrentNode->Z();
00582 double dx = myDlg->myX->GetValue() - x;
00583 double dy = myDlg->myY->GetValue() - y;
00584 double dz = myDlg->myZ->GetValue() - z;
00585 myDlg->myCurrentX->SetValue(x);
00586 myDlg->myCurrentY->SetValue(y);
00587 myDlg->myCurrentZ->SetValue(z);
00588 myDlg->myDX->SetValue(dx);
00589 myDlg->myDY->SetValue(dy);
00590 myDlg->myDZ->SetValue(dz);
00591 }
00592 }
00593 }
00594 }
00595 } catch (...) {
00596 }
00597 }
00598
00599
00603
00604
00605 void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
00606 {
00607 if ( myNoPreview )
00608 return;
00609 myNoPreview = true;
00610
00611 SMESH::MeshPreviewStruct_var aMeshPreviewStruct;
00612
00613 bool moveShown = false;
00614 if ( myMeshActor)
00615 {
00616 const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked();
00617 const bool preview = myDlg->myPreviewChkBox->isChecked();
00618 if ( autoSearch )
00619 {
00620 myDlg->myCurrentX->SetValue(0);
00621 myDlg->myCurrentY->SetValue(0);
00622 myDlg->myCurrentZ->SetValue(0);
00623 myDlg->myDX->SetValue(0);
00624 myDlg->myDY->SetValue(0);
00625 myDlg->myDZ->SetValue(0);
00626 myDlg->myId->setText("");
00627 }
00628 QString msg;
00629 if ( autoSearch || isValid( msg ) )
00630 {
00631 try {
00632 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());
00633 if (!aMesh->_is_nil()) {
00634 SMESH::SMESH_MeshEditor_var aPreviewer = aMesh->GetMeshEditPreviewer();
00635 if (!aPreviewer->_is_nil())
00636 {
00637 SUIT_OverrideCursor aWaitCursor;
00638
00639 int anId = 0;
00640 if ( autoSearch )
00641 anId = aPreviewer->FindNodeClosestTo(myDlg->myX->GetValue(),
00642 myDlg->myY->GetValue(),
00643 myDlg->myZ->GetValue());
00644 else
00645 anId = myDlg->myId->text().toInt();
00646
00647
00648 aPreviewer->MoveNode(anId,
00649 myDlg->myX->GetValue(),
00650 myDlg->myY->GetValue(),
00651 myDlg->myZ->GetValue());
00652 if ( autoSearch ) {
00653 QString idTxt("%1");
00654 if ( anId > 0 )
00655 idTxt = idTxt.arg( anId );
00656 else
00657 idTxt = "";
00658 myDlg->myId->setText( idTxt );
00659 }
00660
00661 SMESH::double_array* aXYZ = aMesh->GetNodeXYZ( anId );
00662 if( aXYZ && aXYZ->length() >= 3 )
00663 {
00664 double x = aXYZ->operator[](0);
00665 double y = aXYZ->operator[](1);
00666 double z = aXYZ->operator[](2);
00667 double dx = myDlg->myX->GetValue() - x;
00668 double dy = myDlg->myY->GetValue() - y;
00669 double dz = myDlg->myZ->GetValue() - z;
00670 myDlg->myCurrentX->SetValue(x);
00671 myDlg->myCurrentY->SetValue(y);
00672 myDlg->myCurrentZ->SetValue(z);
00673 myDlg->myDX->SetValue(dx);
00674 myDlg->myDY->SetValue(dy);
00675 myDlg->myDZ->SetValue(dz);
00676 }
00677
00678 if ( preview ) {
00679 aMeshPreviewStruct = aPreviewer->GetPreviewData();
00680 moveShown = ( anId > 0 );
00681 }
00682 }
00683 }
00684 }catch (...) {
00685 }
00686 }
00687 }
00688
00689 if ( !moveShown )
00690 {
00691 aMeshPreviewStruct = new SMESH::MeshPreviewStruct();
00692
00693 aMeshPreviewStruct->nodesXYZ.length(1);
00694 aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue();
00695 aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue();
00696 aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue();
00697
00698 aMeshPreviewStruct->elementTypes.length(1);
00699 aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE;
00700 aMeshPreviewStruct->elementTypes[0].isPoly = false;
00701 aMeshPreviewStruct->elementTypes[0].nbNodesInElement = 1;
00702
00703 aMeshPreviewStruct->elementConnectivities.length(1);
00704 aMeshPreviewStruct->elementConnectivities[0] = 0;
00705 }
00706
00707
00708 if ( aMeshPreviewStruct.operator->() )
00709 {
00710 mySimulation->SetData(aMeshPreviewStruct._retn());
00711 }
00712 else
00713 {
00714 mySimulation->SetVisibility(false);
00715 }
00716
00717 myNoPreview = false;
00718 }
00719
00720
00724
00725
00726 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
00727 {
00728 selectionMgr()->clearFilters();
00729 SMESH::SetPointRepresentation(false);
00730 selectionMgr()->installFilter( myFilter );
00731 setSelectionMode( NodeSelection );
00732 }
00733
00734
00738
00739
00740 SMESHGUI_MakeNodeAtPointOp::~SMESHGUI_MakeNodeAtPointOp()
00741 {
00742 if ( myDlg ) delete myDlg;
00743 if ( mySimulation ) delete mySimulation;
00744 if ( myFilter ) delete myFilter;
00745 }
00746
00747
00752
00753
00754 LightApp_Dialog* SMESHGUI_MakeNodeAtPointOp::dlg() const
00755 {
00756 return myDlg;
00757 }
00758