Salome HOME
Don't drop the control mode when a mesh becomes empty
authoreap <eap@opencascade.com>
Mon, 21 Nov 2016 17:05:01 +0000 (20:05 +0300)
committereap <eap@opencascade.com>
Mon, 21 Nov 2016 17:05:01 +0000 (20:05 +0300)
+ Update mesh when unassign hypothesis

src/OBJECT/SMESH_Actor.cxx
src/SMESHGUI/SMESHGUI_Hypotheses.cxx
src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx

index 8ef0667e8e6aa47d861ce9304915039e4ffe9dbf..0c876a190bb5af1e370c97851154f28ebbc246a8 100644 (file)
@@ -817,7 +817,8 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
   if( !mgr )
     return;
 
-  myControlMode = eNone;
+  //myControlMode = eNone;
+  myControlMode = theMode;
   theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
 
   my0DActor->GetMapper()->SetScalarVisibility(false);
@@ -1003,7 +1004,7 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
     int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
     bool aShowOnlyScalarBarTitle = false;
     if(aNbCells) {
-      myControlMode = theMode;
+      //myControlMode = theMode;
       switch(myControlMode){
       case eFreeNodes:
       case eCoincidentNodes:
@@ -1097,7 +1098,7 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
   if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
     lookupTable->SetScale(VTK_SCALE_LOG10);
 
-  Update();
+  //Update();
 }
 
 int SMESH_ActorDef::GetNumberControlEntities()
@@ -1916,11 +1917,11 @@ void SMESH_ActorDef::SetPreSelected(bool thePreselect)
 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
 {
   if (myPickableActor->GetIsOpaque())
-    {
+  {
     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
     this->Render(ren);
     return 1;
-    }
+  }
   return 0;
 }
 
@@ -1928,11 +1929,11 @@ int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
 {
   if (!myPickableActor->GetIsOpaque())
-    {
+  {
     vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
     this->Render(ren);
     return 1;
-    }
+  }
   return 0;
 }
 
index 907d6ddc5f4fbdd00e8d83a86fdb010d03bc4c50..f313c8ce2cba016f685848be11629ca21aec2226 100644 (file)
@@ -319,9 +319,8 @@ void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
         _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
         SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
         SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() );
-        if( actor ) {
+        if( actor && actor->GetVisibility() )
           actor->Update();
-        }
       }
   }
   SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
index c1fc49bee78d6131bc95fe04ff1a9491d2ae4b1e..f6574cb5a967494be53b1573112b12dd3ebead07 100644 (file)
 #include "SMESHGUI_HypothesesUtils.h"
 
 #include "SMESHGUI.h"
+#include "SMESHGUI_GEOMGenUtils.h"
 #include "SMESHGUI_Hypotheses.h"
-#include "SMESHGUI_XmlHandler.h"
 #include "SMESHGUI_Utils.h"
-#include "SMESHGUI_GEOMGenUtils.h"
+#include "SMESHGUI_VTKUtils.h"
+#include "SMESHGUI_XmlHandler.h"
+
+#include "SMESH_Actor.h"
 
 // SALOME GUI includes
 #include <SUIT_Desktop.h>
@@ -701,29 +704,29 @@ namespace SMESH
       _PTR(Study) aStudy = GetActiveStudyDocument();
       _PTR(SObject) aHypObj = aStudy->FindObjectID( IObject->getEntry() );
       if( aHypObj )
+      {
+        _PTR(SObject) MorSM = SMESH::GetMeshOrSubmesh( aHypObj );
+        _PTR(SObject) aRealHypo;
+        if( aHypObj->ReferencedObject( aRealHypo ) )
         {
-          _PTR(SObject) MorSM = SMESH::GetMeshOrSubmesh( aHypObj );
-          _PTR(SObject) aRealHypo;
-          if( aHypObj->ReferencedObject( aRealHypo ) )
-            {
-              SMESH_Hypothesis_var hypo = SMESH_Hypothesis::_narrow( SObjectToObject( aRealHypo ) );
-              RemoveHypothesisOrAlgorithmOnMesh( MorSM, hypo );
-            }
-          else
-            {
-              SMESH_Hypothesis_var hypo = SMESH_Hypothesis::_narrow( SObjectToObject( aHypObj ) );
-              SObjectList meshList = GetMeshesUsingAlgoOrHypothesis( hypo );
-              for( size_t i = 0; i < meshList.size(); i++ )
-                RemoveHypothesisOrAlgorithmOnMesh( meshList[ i ], hypo );
-            }
+          SMESH_Hypothesis_var hypo = SMESH_Hypothesis::_narrow( SObjectToObject( aRealHypo ) );
+          RemoveHypothesisOrAlgorithmOnMesh( MorSM, hypo );
         }
+        else
+        {
+          SMESH_Hypothesis_var hypo = SMESH_Hypothesis::_narrow( SObjectToObject( aHypObj ) );
+          SObjectList meshList = GetMeshesUsingAlgoOrHypothesis( hypo );
+          for( size_t i = 0; i < meshList.size(); i++ )
+            RemoveHypothesisOrAlgorithmOnMesh( meshList[ i ], hypo );
+        }
+      }
     }
     catch(const SALOME::SALOME_Exception& S_ex)
-      {
-        wc.suspend();
-        SalomeApp_Tools::QtCatchCorbaException(S_ex);
-        res = SMESH::HYP_UNKNOWN_FATAL;
-      }
+    {
+      wc.suspend();
+      SalomeApp_Tools::QtCatchCorbaException(S_ex);
+      res = SMESH::HYP_UNKNOWN_FATAL;
+    }
     return res < SMESH::HYP_UNKNOWN_FATAL;
   }
 
@@ -745,26 +748,24 @@ namespace SMESH
         if (!aMesh->_is_nil()) {
           if (aMesh->HasShapeToMesh() && !aShapeObject->_is_nil()) {
             res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
-            if (res < SMESH::HYP_UNKNOWN_FATAL) {
-              _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
-              if (meshSO)
-                SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);
-            }
-
           }
           else if(!aMesh->HasShapeToMesh()){
             res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
-            if (res < SMESH::HYP_UNKNOWN_FATAL) {
-              _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
-              if (meshSO)
-                SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);
-            }
           }
           if (res > SMESH::HYP_OK) {
             wc.suspend();
             processHypothesisStatus(res, anHyp, false);
             wc.resume();
           }
+          if ( _PTR(SObject) meshSO = SMESH::FindSObject(aMesh) )
+          {
+            if ( res < SMESH::HYP_UNKNOWN_FATAL )
+              SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);
+
+            if ( SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() ))
+              if( actor->GetVisibility() )
+                actor->Update();
+          }
         }
       } catch(const SALOME::SALOME_Exception& S_ex) {
         wc.suspend();