Salome HOME
PAL13473 (Build repetitive mesh):
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.cxx
index bd4816adce8d5afda654d4c8e34556a1c24d5341..0e13c26e5196cfb172bb4452c2f612fececde5b1 100644 (file)
@@ -49,6 +49,7 @@
 #include "GeometryGUI.h"
 
 #include "SalomeApp_Tools.h"
+#include "SalomeApp_Application.h"
 #include "SALOMEDSClient_Study.hxx"
 #include "SALOMEDSClient_AttributeIOR.hxx"
 #include "SALOMEDSClient_AttributeName.hxx"
@@ -400,7 +401,7 @@ _PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
 //================================================================================
 void SMESHGUI_MeshOp::selectionDone()
 {
-  if ( !dlg()->isShown() )
+  if ( !dlg()->isShown() || !myDlg->isEnabled() )
     return;
 
   SMESHGUI_SelectionOp::selectionDone();
@@ -903,7 +904,9 @@ void SMESHGUI_MeshOp::createHypothesis (const int theDim,
       // with values used to mesh a subshape
       SMESH::SMESH_Hypothesis_var initParamHyp =
         getInitParamsHypothesis(theTypeName, aData->ServerLibName);
+      myDlg->setEnabled( false );
       aCreator->create(initParamHyp, myDlg);
+      myDlg->setEnabled( true );
     } else {
       SMESH::CreateHypothesis(theTypeName, aData->Label, false);
     }
@@ -946,8 +949,11 @@ void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
 
   char* aTypeName = aHyp->GetName();
   SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aTypeName );
-  if ( aCreator )
+  if ( aCreator ) {
+    myDlg->setEnabled( false );
     aCreator->edit( aHyp.in(), dlg() );
+    myDlg->setEnabled( true );
+  }
 }
 
 //================================================================================
@@ -1755,42 +1761,44 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
     {
       int aNewHypIndex = currentHyp( dim, hypType );
       int anOldHypIndex = -1;
+
+      // remove old hypotheses
       if ( myObjHyps[ dim ][ hypType ].count() > 0 )
+      {
         anOldHypIndex = find( myObjHyps[ dim ][ hypType ].first(),
                               myExistingHyps[ dim ][ hypType ] );
-      if ( aNewHypIndex != anOldHypIndex )
-      {
-        // remove old hypotheses
-        if ( anOldHypIndex >= 0 ) {
-          SMESH::RemoveHypothesisOrAlgorithmOnMesh(
-            pObj, myExistingHyps[ dim ][ hypType ][ anOldHypIndex ] );
+        if ( aNewHypIndex != anOldHypIndex || // different hyps
+             anOldHypIndex == -1 )            // hyps of different algos
+        {
+          SMESH::RemoveHypothesisOrAlgorithmOnMesh
+            ( pObj, myObjHyps[ dim ][ hypType ].first() );
           myObjHyps[ dim ][ hypType ].clear();
         }
+      }
 
-        // assign new hypotheses
-        if ( aNewHypIndex != -1 )
+      // assign new hypotheses
+      if ( aNewHypIndex != anOldHypIndex && aNewHypIndex != -1 )
+      {
+        SMESH::SMESH_Mesh_var aMeshVar =
+          SMESH::SMESH_Mesh::_narrow( _CAST(SObject,pObj)->GetObject() );
+        bool isMesh = !aMeshVar->_is_nil();
+        if ( isMesh )
         {
-          SMESH::SMESH_Mesh_var aMeshVar =
-              SMESH::SMESH_Mesh::_narrow( _CAST(SObject,pObj)->GetObject() );
-          bool isMesh = !aMeshVar->_is_nil();
-          if ( isMesh )
-          {
-            SMESH::AddHypothesisOnMesh(
-              aMeshVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ] );
-          }
-          else
-          {
-            SMESH::SMESH_subMesh_var aVar =
-              SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
-            if ( !aVar->_is_nil() )
-              SMESH::AddHypothesisOnSubMesh(
-                aVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ] );
-          }
+          SMESH::AddHypothesisOnMesh
+            (aMeshVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ] );
+        }
+        else
+        {
+          SMESH::SMESH_subMesh_var aVar =
+            SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
+          if ( !aVar->_is_nil() )
+            SMESH::AddHypothesisOnSubMesh
+              ( aVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ] );
         }
-        // reread all hypotheses of mesh if necessary
-        QStringList anExisting;
-        existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
       }
+      // reread all hypotheses of mesh if necessary
+      QStringList anExisting;
+      existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
     }
   }
 
@@ -1856,6 +1864,7 @@ void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
 void SMESHGUI_MeshOp::onPublishShapeByMeshDlg(SUIT_Operation* op)
 {
   if ( myShapeByMeshOp == op ) {
+    SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); //MZN: 24.11.2006  IPAL13980 - Object Browser update added
     myDlg->show();
     // Select a found geometry object
     GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();