X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_HypothesesUtils.cxx;h=0b9b9ea9dd5a8b4520f7551940c74ac894d69c25;hb=15c63b438579fe4bc31c0bf23a00582a95318dcb;hp=14a12754e98ff5d1327d84edd10dd189a6be3b6e;hpb=d303154d91eb916a55ac93a372cbdb918aa18d14;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 14a12754e..0b9b9ea9d 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -44,9 +44,12 @@ #include // STL includes -#include #include +// Qt includes +#include +//#include + // Other includes #ifdef WNT #include @@ -74,21 +77,20 @@ static int MYDEBUG = 0; namespace SMESH { - typedef std::map THypothesisDataMap; + typedef QMap THypothesisDataMap; THypothesisDataMap myHypothesesMap; THypothesisDataMap myAlgorithmsMap; - typedef std::map THypCreatorMap; + typedef QMap THypCreatorMap; THypCreatorMap myHypCreatorMap; - std::list myListOfHypothesesSets; + QList myListOfHypothesesSets; void processHypothesisStatus(const int theHypStatus, SMESH::SMESH_Hypothesis_ptr theHyp, const bool theIsAddition) { if (theHypStatus > SMESH::HYP_OK) { - // get Hyp name QString aHypName ("NULL Hypothesis"); if (!CORBA::is_nil(theHyp)) { @@ -137,13 +139,12 @@ namespace SMESH HypsXml.sprintf("%s", cenv); QStringList HypsXmlList = HypsXml.split(":", QString::SkipEmptyParts); - if (HypsXmlList.count() == 0) - { - SUIT_MessageBox::critical(SMESHGUI::desktop(), - QObject::tr("SMESH_WRN_WARNING"), - QObject::tr("MESHERS_FILE_NO_VARIABLE")); - return; - } + if (HypsXmlList.count() == 0) { + SUIT_MessageBox::critical(SMESHGUI::desktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("MESHERS_FILE_NO_VARIABLE")); + return; + } // loop on files in HypsXml QString aNoAccessFiles; @@ -169,12 +170,14 @@ namespace SMESH bool ok = reader.parse(source); file.close(); if (ok) { - myHypothesesMap.insert( aXmlHandler->myHypothesesMap.begin(), - aXmlHandler->myHypothesesMap.end() ); - myAlgorithmsMap.insert( aXmlHandler->myAlgorithmsMap.begin(), - aXmlHandler->myAlgorithmsMap.end() ); - myListOfHypothesesSets.splice( myListOfHypothesesSets.begin(), - aXmlHandler->myListOfHypothesesSets ); + myHypothesesMap.unite( aXmlHandler->myHypothesesMap ); + myAlgorithmsMap.unite( aXmlHandler->myAlgorithmsMap ); + QList::iterator it, pos = myListOfHypothesesSets.begin(); + for ( it = aXmlHandler->myListOfHypothesesSets.begin(); + it != aXmlHandler->myListOfHypothesesSets.end(); + ++it ) { + myListOfHypothesesSets.insert( pos, *it ); + } } else { SUIT_MessageBox::critical(SMESHGUI::desktop(), @@ -213,21 +216,22 @@ namespace SMESH // Init list of available hypotheses, if needed InitAvailableHypotheses(); - bool checkGeometry = !isNeedGeometry; + bool checkGeometry = ( !isNeedGeometry && isAlgo ); // fill list of hypotheses/algorithms - THypothesisDataMap* pMap = isAlgo ? &myAlgorithmsMap : &myHypothesesMap; + THypothesisDataMap& pMap = isAlgo ? myAlgorithmsMap : myHypothesesMap; THypothesisDataMap::iterator anIter; - for ( anIter = pMap->begin(); anIter != pMap->end(); anIter++ ) - { - HypothesisData* aData = (*anIter).second; - if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux) - if (checkGeometry){ - if (aData->IsNeedGeometry == isNeedGeometry) - aHypList.append(((*anIter).first).c_str()); - } - else - aHypList.append(((*anIter).first).c_str()); + for ( anIter = pMap.begin(); anIter != pMap.end(); anIter++ ) { + HypothesisData* aData = anIter.value(); + if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux) { + if (checkGeometry) { + if (aData->IsNeedGeometry == isNeedGeometry) + aHypList.append(anIter.key()); + } + else { + aHypList.append(anIter.key()); + } } + } return aHypList; } @@ -239,27 +243,29 @@ namespace SMESH // 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 ); - } + QList::iterator hypoSet; + for ( hypoSet = myListOfHypothesesSets.begin(); + hypoSet != myListOfHypothesesSets.end(); + ++hypoSet ) { + HypothesesSet* aSet = *hypoSet; + if ( aSet && aSet->AlgoList.count() ) { + aSetNameList.append( aSet->HypoSetName ); } - + } + 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; - } + QList::iterator hypoSet; + for ( hypoSet = myListOfHypothesesSets.begin(); + hypoSet != myListOfHypothesesSets.end(); + ++hypoSet ) { + HypothesesSet* aSet = *hypoSet; + if ( aSet && aSet->HypoSetName == theSetName ) + return aSet; + } return 0; } @@ -270,14 +276,11 @@ namespace SMESH // Init list of available hypotheses, if needed InitAvailableHypotheses(); - THypothesisDataMap::iterator type_data = myHypothesesMap.find(aHypType.toLatin1().data()); - if (type_data != myHypothesesMap.end()) { - aHypData = type_data->second; + if (myHypothesesMap.find(aHypType) != myHypothesesMap.end()) { + aHypData = myHypothesesMap[aHypType]; } - else { - type_data = myAlgorithmsMap.find(aHypType.toLatin1().data()); - if (type_data != myAlgorithmsMap.end()) - aHypData = type_data->second; + else if (myAlgorithmsMap.find(aHypType) != myAlgorithmsMap.end()) { + aHypData = myAlgorithmsMap[aHypType]; } return aHypData; } @@ -322,8 +325,8 @@ namespace SMESH SMESHGUI_GenericHypothesisCreator* aCreator = 0; // check, if creator for this hypothesis type already exists - if (myHypCreatorMap.find(aHypType.toLatin1().data()) != myHypCreatorMap.end()) { - aCreator = myHypCreatorMap[aHypType.toLatin1().data()]; + if (myHypCreatorMap.find(aHypType) != myHypCreatorMap.end()) { + aCreator = myHypCreatorMap[aHypType]; } else { // 1. Init list of available hypotheses, if needed @@ -343,15 +346,14 @@ namespace SMESH LibHandle libHandle = LoadLib( aClientLibName.toLatin1().data() ); if (!libHandle) { // report any error, if occured - if ( MYDEBUG ) - { + if ( MYDEBUG ) { #ifdef WIN32 - const char* anError = "Can't load client meshers plugin library"; + const char* anError = "Can't load client meshers plugin library"; #else - const char* anError = dlerror(); + const char* anError = dlerror(); #endif - MESSAGE(anError); - } + MESSAGE(anError); + } } else { // get method, returning hypothesis creator @@ -373,7 +375,7 @@ namespace SMESH } else { // map hypothesis creator to a hypothesis name - myHypCreatorMap[aHypType.toLatin1().data()] = aCreator; + myHypCreatorMap[aHypType] = aCreator; } } }