X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_HypothesesUtils.cxx;h=68d15b79bd3878fac173c80b4c26e617156fa742;hp=8f4d0e782ba511a70ec32df4e04a723ab096fede;hb=bf36cccf8ecd8f2d43c10106ec053d89a495d99a;hpb=8616118fe1c2fef49d88367eaa0dba3aebdcf1ab diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 8f4d0e782..68d15b79b 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -66,14 +66,7 @@ namespace SMESH{ typedef map THypCreatorMap; THypCreatorMap myHypCreatorMap; - void addMap(const THypothesisDataMap& theMap, - THypothesisDataMap& toMap) - { - THypothesisDataMap::const_iterator it; - for (it = theMap.begin(); it != theMap.end(); it++) - toMap.insert(*it); - } - + list myListOfHypothesesSets; void processHypothesisStatus(const int theHypStatus, SMESH::SMESH_Hypothesis_ptr theHyp, @@ -160,8 +153,12 @@ namespace SMESH{ bool ok = reader.parse(source); file.close(); if (ok) { - addMap(aXmlHandler->myHypothesesMap, myHypothesesMap); - addMap(aXmlHandler->myAlgorithmsMap, myAlgorithmsMap); + myHypothesesMap.insert( aXmlHandler->myHypothesesMap.begin(), + aXmlHandler->myHypothesesMap.end() ); + myAlgorithmsMap.insert( aXmlHandler->myAlgorithmsMap.begin(), + aXmlHandler->myAlgorithmsMap.end() ); + myListOfHypothesesSets.splice( myListOfHypothesesSets.begin(), + aXmlHandler->myListOfHypothesesSets ); } else { SUIT_MessageBox::error1(SMESHGUI::desktop(), @@ -193,7 +190,9 @@ namespace SMESH{ } - QStringList GetAvailableHypotheses(const bool isAlgo) + QStringList GetAvailableHypotheses( const bool isAlgo, + const int theDim, + const bool isAux ) { QStringList aHypList; @@ -201,23 +200,48 @@ 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()); - } + 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()); } - else { - anIter = myHypothesesMap.begin(); - for (; anIter != myHypothesesMap.end(); anIter++) { - aHypList.append(((*anIter).first).c_str()); + return aHypList; + } + + + QStringList GetHypothesesSets() + { + QStringList aSetNameList; + + // Init list of available hypotheses, if needed + InitAvailableHypotheses(); + + list::iterator hypoSet = myListOfHypothesesSets.begin(); + for ( ; hypoSet != myListOfHypothesesSets.end(); ++hypoSet ) + { + HypothesesSet* aSet = *hypoSet; + if ( aSet && aSet->AlgoList.count() ) { + aSetNameList.append( aSet->HypoSetName ); } } - return aHypList; + return aSetNameList; } + HypothesesSet* GetHypothesesSet(const QString theSetName) + { + list::iterator hypoSet = myListOfHypothesesSets.begin(); + for ( ; hypoSet != myListOfHypothesesSets.end(); ++hypoSet ) + { + HypothesesSet* aSet = *hypoSet; + if ( aSet && aSet->HypoSetName == theSetName ) + return aSet; + } + return 0; + } HypothesisData* GetHypothesisData (const char* aHypType) { @@ -254,9 +278,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; @@ -424,63 +447,27 @@ namespace SMESH{ try { _PTR(Study) aStudy = GetActiveStudyDocument(); - SMESH_Hypothesis_var anHyp = IObjectToInterface(IObject); - if (IObject->hasReference()) + _PTR(SObject) aHypObj = aStudy->FindObjectID( IObject->getEntry() ); + if( aHypObj ) { - if(MYDEBUG) MESSAGE("HAS REFERENCE " << IObject->getEntry()); - _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(); - } - } - } - } + _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 ); } - } - else if (IObject->hasEntry()) - { - if(MYDEBUG) MESSAGE("IObject entry HAS ENTRY " << IObject->getEntry()); - SObjectList meshList = GetMeshesUsingAlgoOrHypothesis(anHyp); - for ( int i = 0; i < meshList.size(); ++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.suspend(); - processHypothesisStatus( res, anHyp, false ); - wc.resume(); - } - } - } } } - catch(const SALOME::SALOME_Exception& S_ex) { + catch(const SALOME::SALOME_Exception& S_ex) + { wc.suspend(); SalomeApp_Tools::QtCatchCorbaException(S_ex); res = SMESH::HYP_UNKNOWN_FATAL; @@ -544,7 +531,7 @@ namespace SMESH{ if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<GetFather(); if (aFather) { _PTR(SObject) SOfatherFather = aFather->GetFather(); @@ -562,4 +549,33 @@ namespace SMESH{ if (MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed"); return listSOmesh; } + +#define CASE2MESSAGE(enum) case SMESH::enum: msg = QObject::tr( #enum ); break; + QString GetMessageOnAlgoStateErrors(const algo_error_array& errors) + { + QString resMsg = QObject::tr("SMESH_WRN_MISSING_PARAMETERS") + ":\n"; + for ( int i = 0; i < errors.length(); ++i ) { + const SMESH::AlgoStateError & error = errors[ i ]; + QString msg; + switch( error.name ) { + CASE2MESSAGE( MISSING_ALGO ); + CASE2MESSAGE( MISSING_HYPO ); + CASE2MESSAGE( NOT_CONFORM_MESH ); + default: continue; + } + // apply args to message: + // %1 - algo name + if ( error.algoName.in() != 0 ) + msg = msg.arg( error.algoName.in() ); + // %2 - dimention + msg = msg.arg( error.algoDim ); + // %3 - global/local + msg = msg.arg( QObject::tr( error.isGlobalAlgo ? "GLOBAL_ALGO" : "LOCAL_ALGO" )); + + if ( i ) resMsg += ";\n"; + resMsg += msg; + } + return resMsg; + } + }