From: eap Date: Thu, 21 Jul 2005 05:57:32 +0000 (+0000) Subject: PAL9524 - unassign a hypothesis when Edit/Delete called for it X-Git-Tag: T2_2_5a~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=452107403b08236b473084e8b560e7ed6acd8d30;p=modules%2Fsmesh.git PAL9524 - unassign a hypothesis when Edit/Delete called for it --- diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 34c82ee21..798cb8d19 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -767,7 +767,7 @@ namespace{ if(!obj->_is_nil()){ SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject()); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject()); - + QString objType = CheckTypeObject(IObject); if ( !aGroup->_is_nil() ) { // DELETE GROUP SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh(); aMesh->RemoveGroup( aGroup ); @@ -776,6 +776,10 @@ namespace{ SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); aMesh->RemoveSubMesh( aSubMesh ); } + else if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS + SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject); + aStudyBuilder->RemoveObjectWithChildren( obj ); + } else {// default action: remove SObject from the study // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy); diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 5d47d4c19..351c60f6b 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -410,11 +410,12 @@ namespace SMESH{ { int res = SMESH::HYP_UNKNOWN_FATAL; QAD_WaitCursor wc; - - if (IObject->hasReference()) { - try { - SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); - SMESH_Hypothesis_var anHyp = IObjectToInterface(IObject); + + try { + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + SMESH_Hypothesis_var anHyp = IObjectToInterface(IObject); + if (IObject->hasReference()) + { SALOMEDS::SObject_var aHypSObj = aStudy->FindObjectID(IObject->getReference()); if (!aHypSObj->_is_nil()) { SALOMEDS::SObject_var MorSM = SMESH::GetMeshOrSubmesh(aHypSObj); @@ -425,10 +426,10 @@ namespace SMESH{ SMESH::SObjectToInterface(MorSM); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); - + if (!aSubMesh->_is_nil()) aMesh = aSubMesh->GetFather(); - + if (!aMesh->_is_nil()) { res = aMesh->RemoveHypothesis(aShape, anHyp); if ( res < SMESH::HYP_UNKNOWN_FATAL ) { @@ -446,18 +447,35 @@ namespace SMESH{ } } } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); - res = SMESH::HYP_UNKNOWN_FATAL; + else if (IObject->hasEntry()) + { + if(MYDEBUG) MESSAGE("IObject entry " << IObject->getEntry()); + SALOMEDS::Study::ListOfSObject_var meshList = GetMeshesUsingAlgoOrHypothesis(anHyp); + for ( int i = 0; i < meshList->length(); ++i ) { + SMESH::SMESH_Mesh_var aMesh = + SMESH::SObjectToInterface( meshList[ i ]); + GEOM::GEOM_Object_var aShape = SMESH::GetShapeOnMeshOrSubMesh( meshList[ i ]); + if ( ! aMesh->_is_nil() && !aShape->_is_nil() ) { + res = aMesh->RemoveHypothesis(aShape, anHyp); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) + SMESH::ModifiedMesh( meshList[ i ], false); + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, anHyp, false ); + wc.start(); + } + } + } } - } - else if (IObject->hasEntry()) { - if(MYDEBUG) MESSAGE("IObject entry " << IObject->getEntry()); + } + catch( const SALOME::SALOME_Exception& S_ex ) { + wc.stop(); + QtCatchCorbaException( S_ex ); + res = SMESH::HYP_UNKNOWN_FATAL; } return res < SMESH::HYP_UNKNOWN_FATAL; } - + bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM, SMESH::SMESH_Hypothesis_ptr anHyp) {