Salome HOME
bos #35165 [CEA] Clear the mesh when an hypothesis is added to an algorithm CR35165 13/head
authorasozinov <alexey.sozinov@opencascade.com>
Sun, 21 May 2023 21:13:48 +0000 (22:13 +0100)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 31 May 2023 07:30:37 +0000 (09:30 +0200)
- Call Update after add hypothesis
- Fix problem, when after change hypothesis mesh in VTKViewer not clears automatically

src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx
src/SMESHGUI/SMESHGUI_HypothesesUtils.h
src/SMESHGUI/SMESHGUI_MeshOp.cxx
src/SMESHGUI/SMESHGUI_MeshOp.h

index 1cece8d09658ab02f3879a3e8102aa6a064453bf..f738a949a2f6ed834ffdadfab3f094d4e8642ea0 100644 (file)
@@ -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)
index 351dc9a66b198b1ae6e7797c58c3cbb2c2c956b0..d112ae3f114603ffd555d5ecaed143d7fd3c8f50 100644 (file)
@@ -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 );
index 96552b53077fd1689362e19dccf3552d9b1cb4a9..21e94744375d8fa4e7b5d267c1e7b952187f2fdb 100644 (file)
@@ -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++ )
   {
index 4a8cb11a4fdebfbae83bd6e677ebc3dd2c11c20f..0235fb497a652f48354f317566f2dc393d078a00 100644 (file)
@@ -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,