X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MakeNodeAtPointDlg.cxx;h=6b1b7c140536d60458a4a51493944ce053323d47;hb=refs%2Ftags%2FV9_7_0a2;hp=3b8ffef6514829c822f274c022c9d3f8eb0ea98a;hpb=5c19bc1e1684ec6a466423361949ed7b60556968;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx index 3b8ffef65..6b1b7c140 100644 --- a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -84,6 +84,11 @@ #define SPACING 6 #define MARGIN 11 +namespace +{ + enum { MANUAL_MODE = 0, SEARCH_MODE }; // how a node to move is specified +} + /*! * \brief Dialog to publish a sub-shape of the mesh main shape * by selecting mesh elements @@ -326,7 +331,8 @@ void SMESHGUI_MakeNodeAtPointDlg::ConstructorsClicked (int constructorId) myDestDX->hide(); myDestDY->hide(); myDestDZ->hide(); - if (myNodeToMoveGrp->isVisible()) {myNodeToMoveGrp->hide();} + if (myNodeToMoveGrp->isVisible()) myNodeToMoveGrp->hide(); + myDestBtn->setChecked( true ); break; } } @@ -349,21 +355,22 @@ SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp() mySMESHGUI = 0; myDlg = new SMESHGUI_MakeNodeAtPointDlg; myFilter = 0; - myHelpFileName = "mesh_through_point_page.html"; + myHelpFileName = "mesh_through_point.html"; myNoPreview = false; myUpdateDestination = false; myDestCoordChanged = true; // connect signals and slots - connect(myDlg->myDestinationX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); - connect(myDlg->myDestinationY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); - connect(myDlg->myDestinationZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); - connect(myDlg->myDestDX, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); - connect(myDlg->myDestDY, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); - connect(myDlg->myDestDZ, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); - connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview())); - connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),SLOT(redisplayPreview())); + connect(myDlg->myDestinationX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myDlg->myDestinationY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myDlg->myDestinationZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myDlg->myDestDX, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); + connect(myDlg->myDestDY, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); + connect(myDlg->myDestDZ, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); + connect(myDlg->myId, SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview())); + connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)), SLOT(redisplayPreview())); + connect(myDlg->myButtonGroup, SIGNAL (buttonClicked(int)), SLOT(redisplayPreview())); // IPAL22913: TC6.5.0: selected in "Move node" dialog box node is not highlighted // note: this slot seems to be lost together with removed obsolete SMESHGUI_MoveNodesDlg class @@ -435,18 +442,11 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation() myDlg->myDestDZ->setReadOnly(true); myDlg->myRButNodeToMove->setChecked(true); - myDlg->ConstructorsClicked(GetConstructorId()); + myDlg->ConstructorsClicked( GetConstructorId() ); myDlg->show(); onSelectionDone(); // init myMeshActor - - if ( myMeshActor ) { -// myMeshActor->SetRepresentation( VTK_WIREFRAME ); - myMeshActor->SetPointRepresentation(true); - SMESH::RepaintCurrentView(); - redisplayPreview(); - } } //================================================================================= @@ -474,12 +474,13 @@ void SMESHGUI_MakeNodeAtPointOp::stopOperation() mySimulation = 0; } if ( myMeshActor ) { - myMeshActor->SetPointRepresentation(false); - SMESH::RepaintCurrentView(); myMeshActor = 0; } + SMESH::SetPointRepresentation( false ); + SMESH::RepaintCurrentView(); + disconnect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this, SLOT(onOpenView())); - disconnect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView())); + disconnect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView())); selectionMgr()->removeFilter( myFilter ); SMESHGUI_SelectionOp::stopOperation(); } @@ -492,7 +493,7 @@ void SMESHGUI_MakeNodeAtPointOp::stopOperation() bool SMESHGUI_MakeNodeAtPointOp::onApply() { - if( isStudyLocked() ) + if( SMESHGUI::isStudyLocked() ) return false; if ( !myMeshActor ) { @@ -527,14 +528,14 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() if (aMeshEditor->_is_nil()) return true; - aMesh->SetParameters( aParameters.join(":").toLatin1().constData() ); + aMesh->SetParameters( aParameters.join(":").toUtf8().constData() ); bool ok; int anId = myDlg->myId->text().toInt( &ok ); if( !ok || anId < 1 ) - anId = aMeshEditor->FindNodeClosestTo(myDlg->myDestinationX->GetValue(), - myDlg->myDestinationY->GetValue(), - myDlg->myDestinationZ->GetValue()); + anId = FromSmIdType(aMeshEditor->FindNodeClosestTo(myDlg->myDestinationX->GetValue(), + myDlg->myDestinationY->GetValue(), + myDlg->myDestinationZ->GetValue())); int aResult = aMeshEditor->MoveNode(anId, myDlg->myDestinationX->GetValue(), @@ -604,6 +605,8 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() { if ( !myDlg->isVisible() || !myDlg->isEnabled() ) return; + + myNoPreview = true; try { SALOME_ListIO aList; selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type()); @@ -612,6 +615,10 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() Handle(SALOME_InteractiveObject) anIO = aList.First(); SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry()); + if (( myDlg->myIdBtn->isChecked() && myDlg->myIdBtn->isEnabled() ) || + ( !myDlg->myNodeToMoveGrp->isVisible() )) + myMeshActor = aMeshActor; + if (!aMeshActor) { // coord by geom if ( myDlg->myDestBtn->isChecked() ) { GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface(anIO); @@ -620,63 +627,56 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() if ( GEOMBase::GetShape(geom, aShape) && aShape.ShapeType() == TopAbs_VERTEX ) { gp_Pnt P = BRep_Tool::Pnt(aShape); - myNoPreview = true; myDlg->myDestinationX->SetValue(P.X()); myDlg->myDestinationY->SetValue(P.Y()); myDlg->myDestinationZ->SetValue(P.Z()); - myNoPreview = false; - redisplayPreview(); } } + myNoPreview = false; + redisplayPreview(); return; } } - if ( !myMeshActor ) - myMeshActor = aMeshActor; - QString aString; int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString); if (nbElems == 1) { if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) { if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) { - myNoPreview = true; if ( myDlg->myDestBtn->isChecked() ) { // set coord myDlg->myDestinationX->SetValue(aNode->X()); myDlg->myDestinationY->SetValue(aNode->Y()); myDlg->myDestinationZ->SetValue(aNode->Z()); - myNoPreview = false; - redisplayPreview(); } else if ( myDlg->myIdBtn->isChecked() && myDlg->myIdBtn->isEnabled() ) { // set node to move myDlg->myId->setText(aString); - myNoPreview = false; + myDlg->myCurrentX->SetValue( aNode->X() ); + myDlg->myCurrentY->SetValue( aNode->Y() ); + myDlg->myCurrentZ->SetValue( aNode->Z() ); redisplayPreview(); } - if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) { - double x = aCurrentNode->X(); - double y = aCurrentNode->Y(); - double z = aCurrentNode->Z(); - double dx = myDlg->myDestinationX->GetValue() - x; - double dy = myDlg->myDestinationY->GetValue() - y; - double dz = myDlg->myDestinationZ->GetValue() - z; - myDlg->myCurrentX->SetValue(x); - myDlg->myCurrentY->SetValue(y); - myDlg->myCurrentZ->SetValue(z); - myDlg->myDestDX->SetValue(dx); - myDlg->myDestDY->SetValue(dy); - myDlg->myDestDZ->SetValue(dz); - myDlg->myDestDX->setReadOnly(false); - myDlg->myDestDY->setReadOnly(false); - myDlg->myDestDZ->setReadOnly(false); - } + double x = myDlg->myCurrentX->GetValue(); + double y = myDlg->myCurrentY->GetValue(); + double z = myDlg->myCurrentZ->GetValue(); + double dx = myDlg->myDestinationX->GetValue() - x; + double dy = myDlg->myDestinationY->GetValue() - y; + double dz = myDlg->myDestinationZ->GetValue() - z; + myDlg->myDestDX->SetValue(dx); + myDlg->myDestDY->SetValue(dy); + myDlg->myDestDZ->SetValue(dz); + myDlg->myDestDX->setReadOnly(false); + myDlg->myDestDY->setReadOnly(false); + myDlg->myDestDZ->setReadOnly(false); } } } } catch (...) { } + + myNoPreview = false; + redisplayPreview(); } //================================================================================ @@ -691,12 +691,15 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() return; myNoPreview = true; + if ( !myMeshActor && GetConstructorId() == SEARCH_MODE ) + onSelectionDone(); + SMESH::MeshPreviewStruct_var aMeshPreviewStruct; bool moveShown = false; if ( myMeshActor) { - const bool isPreview = myDlg->myPreviewChkBox->isChecked(); + const bool isPreview = myDlg->myPreviewChkBox->isChecked(); const bool isMoveNode = myDlg->myRButMoveWithoutNode->isChecked(); QString msg; if ( isValid( msg ) ) @@ -725,22 +728,28 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() myDlg->myDestinationX->SetValue(x); myDlg->myDestinationY->SetValue(y); myDlg->myDestinationZ->SetValue(z); - } - if ( myDestCoordChanged ) { - dx = myDlg->myDestinationX->GetValue() - x; - dy = myDlg->myDestinationY->GetValue() - y; - dz = myDlg->myDestinationZ->GetValue() - z; myDlg->myDestDX->SetValue(dx); myDlg->myDestDY->SetValue(dy); myDlg->myDestDZ->SetValue(dz); } - else { - dx = myDlg->myDestDX->GetValue() + x; - dy = myDlg->myDestDY->GetValue() + y; - dz = myDlg->myDestDZ->GetValue() + z; - myDlg->myDestinationX->SetValue(dx); - myDlg->myDestinationY->SetValue(dy); - myDlg->myDestinationZ->SetValue(dz); + else + { + if ( myDestCoordChanged ) { + dx = myDlg->myDestinationX->GetValue() - x; + dy = myDlg->myDestinationY->GetValue() - y; + dz = myDlg->myDestinationZ->GetValue() - z; + myDlg->myDestDX->SetValue(dx); + myDlg->myDestDY->SetValue(dy); + myDlg->myDestDZ->SetValue(dz); + } + else { + dx = myDlg->myDestDX->GetValue() + x; + dy = myDlg->myDestDY->GetValue() + y; + dz = myDlg->myDestDZ->GetValue() + z; + myDlg->myDestinationX->SetValue(dx); + myDlg->myDestinationY->SetValue(dy); + myDlg->myDestinationZ->SetValue(dz); + } } myDlg->myCurrentX->SetValue(x); myDlg->myCurrentY->SetValue(y); @@ -761,9 +770,9 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() myDlg->myDestDZ->setReadOnly(true); } if ( isPreview && isMoveNode && anId == 0 ) - anId = aPreviewer->FindNodeClosestTo(myDlg->myDestinationX->GetValue(), - myDlg->myDestinationY->GetValue(), - myDlg->myDestinationZ->GetValue()); + anId = FromSmIdType(aPreviewer->FindNodeClosestTo(myDlg->myDestinationX->GetValue(), + myDlg->myDestinationY->GetValue(), + myDlg->myDestinationZ->GetValue())); // find id and/or just compute preview aPreviewer->MoveNode(anId, myDlg->myDestinationX->GetValue(), @@ -776,7 +785,8 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() } } } - }catch (...) { + } + catch (...) { } } } @@ -801,9 +811,9 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() if (!mySimulation) mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); // display data - if ( aMeshPreviewStruct.operator->() ) + if ( & aMeshPreviewStruct.in() ) { - mySimulation->SetData(aMeshPreviewStruct._retn()); + mySimulation->SetData( aMeshPreviewStruct.in() ); } else { @@ -859,8 +869,8 @@ void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText ) if( const SMDS_MeshNode* aNode = aMesh->FindNode( theText.toInt() ) ) { - TColStd_MapOfInteger aListInd; - aListInd.Add( aNode->GetID() ); + SVTK_TVtkIDsMap aListInd; + aListInd.Add( FromSmIdType(aNode->GetID()) ); selector()->AddOrRemoveIndex( anIO, aListInd, false ); if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() ) ) aViewWindow->highlight( anIO, true, true ); @@ -878,7 +888,7 @@ void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText ) void SMESHGUI_MakeNodeAtPointOp::activateSelection() { selectionMgr()->clearFilters(); - SMESH::SetPointRepresentation(false); + SMESH::SetPointRepresentation( true ); selectionMgr()->installFilter( myFilter ); setSelectionMode( NodeSelection ); }