From c8dfd88621483e28b2cc7a6fef299e2a8acad3a5 Mon Sep 17 00:00:00 2001 From: asozinov Date: Sun, 21 May 2023 22:13:48 +0100 Subject: [PATCH] bos #35165 [CEA] Clear the mesh when an hypothesis is added to an algorithm - Call Update after add hypothesis - Fix problem, when after change hypothesis mesh in VTKViewer not clears automatically --- src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx | 19 +++++++++++++------ src/SMESHGUI/SMESHGUI_HypothesesUtils.h | 2 ++ src/SMESHGUI/SMESHGUI_MeshOp.cxx | 15 +++++++++++---- src/SMESHGUI/SMESHGUI_MeshOp.h | 2 +- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 1cece8d09..f738a949a 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -645,6 +645,7 @@ namespace SMESH try { CORBA::String_var error; res = aMesh->AddHypothesis(aShapeObject, aHyp, error.out()); + UpdateViewer(aMesh); if (res > SMESH::HYP_OK) { wc.suspend(); processHypothesisStatus(res, aHyp, true, error.in() ); @@ -676,6 +677,7 @@ namespace SMESH { CORBA::String_var error; res = aMesh->AddHypothesis( aShapeObject, aHyp, error.out() ); + UpdateViewer(aMesh); if (res > SMESH::HYP_OK) { wc.suspend(); processHypothesisStatus( res, aHyp, true, error.in() ); @@ -764,12 +766,7 @@ namespace SMESH processHypothesisStatus(res, anHyp, false); wc.resume(); } - if ( _PTR(SObject) meshSO = SMESH::FindSObject(aMesh) ) - { - if ( SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() )) - if( actor->GetVisibility() ) - actor->Update(); - } + UpdateViewer(aMesh); } } catch(const SALOME::SALOME_Exception& S_ex) { wc.suspend(); @@ -778,6 +775,16 @@ namespace SMESH } } return res < SMESH::HYP_UNKNOWN_FATAL; + } + + void UpdateViewer(SMESH::SMESH_Mesh_ptr theMesh) + { + if (_PTR(SObject) meshSO = SMESH::FindSObject(theMesh)) + { + if (SMESH_Actor* actor = SMESH::FindActorByEntry(meshSO->GetID().c_str())) + if (actor->GetVisibility()) + actor->Update(); + } } SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp) diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.h b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h index 351dc9a66..d112ae3f1 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.h +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h @@ -115,6 +115,8 @@ namespace SMESH bool RemoveHypothesisOrAlgorithmOnMesh( _PTR(SObject), SMESH::SMESH_Hypothesis_ptr ); + SMESHGUI_EXPORT void UpdateViewer(SMESH::SMESH_Mesh_ptr); + typedef std::vector<_PTR(SObject)> SObjectList; SMESHGUI_EXPORT SObjectList GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr ); diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 96552b530..21e947443 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -158,7 +158,7 @@ bool SMESHGUI_MeshOp::onApply() if (( myToCreate && !myIsMesh ) || myIsInvalidSubMesh ) aResult = createSubMesh( aMess, anEntryList ); else if ( !myToCreate ) - aResult = editMeshOrSubMesh( aMess ); + aResult = editMeshOrSubMesh( aMess, anEntryList ); if ( aResult ) { SMESHGUI::Modified(); @@ -2577,13 +2577,14 @@ int SMESHGUI_MeshOp::find( const SMESH::SMESH_Hypothesis_var& theHyp, //================================================================================ /*! * \brief Edits mesh or sub-mesh - * \param theMess - Output parameter intended for returning error message - * \retval bool - TRUE if mesh is edited successfully, FALSE otherwise + * \param theMess - Output parameter intended for returning error message + * \param theEntryList - List of entries of published objects + * \retval bool - TRUE if mesh is edited successfully, FALSE otherwise * * Assigns new name hypotheses and algorithms to the mesh or sub-mesh */ //================================================================================ -bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess ) +bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess, QStringList& theEntryList) { theMess = ""; @@ -2628,6 +2629,12 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess ) if ( !isMesh && !aSubMeshVar->_is_nil() ) aMesh = aSubMeshVar->GetFather(); + _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh.in()); + if (aMeshSO) { + SMESH::SetName(aMeshSO, myDlg->objectText(SMESHGUI_MeshDlg::Obj)); + theEntryList.append(aMeshSO->GetID().c_str()); + } + // Assign new algorithms and hypotheses for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ ) { diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.h b/src/SMESHGUI/SMESHGUI_MeshOp.h index 4a8cb11a4..0235fb497 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.h +++ b/src/SMESHGUI/SMESHGUI_MeshOp.h @@ -120,7 +120,7 @@ private: bool createMesh( QString&, QStringList& ); bool createSubMesh( QString&, QStringList& ); - bool editMeshOrSubMesh( QString& ); + bool editMeshOrSubMesh( QString&, QStringList& ); void createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr mesh, GEOM::GEOM_Object_ptr mainShape ); bool checkSubMeshConcurrency( SMESH::SMESH_Mesh_ptr mesh, -- 2.39.2