X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_HypothesesUtils.cxx;h=96f59ae8af1c8c99463bb220e114fb358b7a0377;hp=619ec75dc4b0c21cdb29596d78387a2a94e15e1f;hb=9d28d73b09e96b23cf9937afa17474f98508df18;hpb=c38c10811a065cf5b13e8807ed71864d92ca7d80 diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 619ec75dc..96f59ae8a 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -142,9 +142,10 @@ namespace SMESH{ QString HypsXml = HypsXmlList[ i ]; // Find full path to the resource XML file - QString xmlFile = HypsXml + ".xml"; - xmlFile = resMgr->path("resources", "SMESH", xmlFile); - + QString xmlFile = resMgr->path("resources", "SMESH", HypsXml + ".xml"); + if ( xmlFile.isEmpty() ) // try PLUGIN resources + xmlFile = resMgr->path("resources", HypsXml, HypsXml + ".xml"); + QFile file (xmlFile); if (file.exists() && file.open(IO_ReadOnly)) { file.close(); @@ -192,7 +193,9 @@ namespace SMESH{ } - QStringList GetAvailableHypotheses(const bool isAlgo) + QStringList GetAvailableHypotheses( const bool isAlgo, + const int theDim, + const bool isAux ) { QStringList aHypList; @@ -200,20 +203,14 @@ namespace SMESH{ InitAvailableHypotheses(); // fill list of hypotheses/algorithms + THypothesisDataMap* pMap = isAlgo ? &myAlgorithmsMap : &myHypothesesMap; THypothesisDataMap::iterator anIter; - if (isAlgo) { - anIter = myAlgorithmsMap.begin(); - for (; anIter != myAlgorithmsMap.end(); anIter++) { - aHypList.append(((*anIter).first).c_str()); - } - } - else { - anIter = myHypothesesMap.begin(); - for (; anIter != myHypothesesMap.end(); anIter++) { - aHypList.append(((*anIter).first).c_str()); - } + for ( anIter = pMap->begin(); anIter != pMap->end(); anIter++ ) + { + HypothesisData* aData = (*anIter).second; + if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux ) + aHypList.append(((*anIter).first).c_str()); } - return aHypList; } @@ -253,9 +250,8 @@ namespace SMESH{ // 2. Get names of plugin libraries HypothesisData* aHypData = GetHypothesisData(aHypType); - if (!aHypData) { - return aCreator; - } + if (!aHypData) + return aCreator; QString aClientLibName = aHypData->ClientLibName; QString aServerLibName = aHypData->ServerLibName; @@ -421,55 +417,38 @@ namespace SMESH{ int res = SMESH::HYP_UNKNOWN_FATAL; SUIT_OverrideCursor wc; - if (IObject->hasReference()) { - try { - _PTR(Study) aStudy = GetActiveStudyDocument(); - SMESH_Hypothesis_var anHyp = IObjectToInterface(IObject); - _PTR(SObject) aHypSObj = aStudy->FindObjectID(IObject->getReference()); - if (aHypSObj) { - _PTR(SObject) MorSM = SMESH::GetMeshOrSubmesh(aHypSObj); - if (MorSM) { - GEOM::GEOM_Object_var aShape = SMESH::GetShapeOnMeshOrSubMesh(MorSM); - if (!aShape->_is_nil()){ - SMESH::SMESH_Mesh_var aMesh = - 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) { - _PTR(SObject) meshSO = SMESH::FindSObject(aMesh); - if (meshSO) - SMESH::ModifiedMesh(meshSO, false); - } - if (res > SMESH::HYP_OK) { - wc.suspend(); - processHypothesisStatus(res, anHyp, false); - wc.resume(); - } - } - } - } + try { + _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 ) ) + { + 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( int 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; } } - else if (IObject->hasEntry()) { - if(MYDEBUG) MESSAGE("IObject entry " << IObject->getEntry()); + catch(const SALOME::SALOME_Exception& S_ex) + { + wc.suspend(); + SalomeApp_Tools::QtCatchCorbaException(S_ex); + res = SMESH::HYP_UNKNOWN_FATAL; } return res < SMESH::HYP_UNKNOWN_FATAL; } bool RemoveHypothesisOrAlgorithmOnMesh (_PTR(SObject) MorSM, - SMESH::SMESH_Hypothesis_ptr anHyp) + SMESH::SMESH_Hypothesis_ptr anHyp) { SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeIOR_var anIOR; @@ -478,9 +457,9 @@ namespace SMESH{ if (MorSM) { try { - GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM); - if (!aShapeObject->_is_nil()) { - SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM); + if (!aShapeObject->_is_nil()) { + SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); if (!aSubMesh->_is_nil()) @@ -524,7 +503,7 @@ namespace SMESH{ if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<GetFather(); if (aFather) { _PTR(SObject) SOfatherFather = aFather->GetFather();