From: vsr Date: Wed, 23 Apr 2008 11:11:39 +0000 (+0000) Subject: Fix of IPAL19621 (Qt4 porting: regress of automatic assign a set of hypotheses). X-Git-Tag: V5_0_0~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d8bff2b915d6aa6802e28f1770c00f2cbcedeabd;p=modules%2Fsmesh.git Fix of IPAL19621 (Qt4 porting: regress of automatic assign a set of hypotheses). --- diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 35b8a567d..3a0bc9ffa 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -77,22 +77,20 @@ static int MYDEBUG = 0; namespace SMESH { - typedef QMap THypothesisDataMap; + typedef QMap THypothesisDataMap; THypothesisDataMap myHypothesesMap; THypothesisDataMap myAlgorithmsMap; - typedef QMap THypCreatorMap; + typedef QMap THypCreatorMap; THypCreatorMap myHypCreatorMap; - std::list myListOfHypothesesSets; - //QList 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)) { @@ -141,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; @@ -173,10 +170,14 @@ namespace SMESH bool ok = reader.parse(source); file.close(); if (ok) { - myHypothesesMap.unite( QMap( aXmlHandler->myHypothesesMap ) ); - myAlgorithmsMap.unite( QMap( aXmlHandler->myAlgorithmsMap ) ); - 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(), @@ -217,19 +218,20 @@ namespace SMESH InitAvailableHypotheses(); bool checkGeometry = !isNeedGeometry; // 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.value(); - if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux) - if (checkGeometry){ - if (aData->IsNeedGeometry == isNeedGeometry) - aHypList.append(anIter.key().c_str()); - } - else - aHypList.append(anIter.key().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; } @@ -241,29 +243,29 @@ namespace SMESH // Init list of available hypotheses, if needed InitAvailableHypotheses(); - std::list::iterator hypoSet = myListOfHypothesesSets.begin(); - //QList::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) { - std::list::iterator hypoSet = myListOfHypothesesSets.begin(); - //QList::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; } @@ -274,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.value(); + 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.value(); + else if (myAlgorithmsMap.find(aHypType) != myAlgorithmsMap.end()) { + aHypData = myAlgorithmsMap[aHypType]; } return aHypData; } @@ -326,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 @@ -347,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 @@ -377,7 +375,7 @@ namespace SMESH } else { // map hypothesis creator to a hypothesis name - myHypCreatorMap[aHypType.toLatin1().data()] = aCreator; + myHypCreatorMap[aHypType] = aCreator; } } } diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx index 3bc04fdfa..cf87f29ef 100644 --- a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx @@ -159,11 +159,11 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&, if (qName == "algorithm") { - myAlgorithmsMap[aHypAlType.toLatin1().data()] = aHypData; + myAlgorithmsMap[aHypAlType] = aHypData; } else { - myHypothesesMap[aHypAlType.toLatin1().data()] = aHypData; + myHypothesesMap[aHypAlType] = aHypData; } } } @@ -175,7 +175,7 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&, if (atts.value("name") != "") { HypothesesSet* aHypoSet = new HypothesesSet ( atts.value("name") ); - myListOfHypothesesSets.push_back( aHypoSet ); + myListOfHypothesesSets.append( aHypoSet ); for ( int isHypo = 0; isHypo < 2; ++isHypo ) { diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.h b/src/SMESHGUI/SMESHGUI_XmlHandler.h index f3582ed29..25b2cf393 100644 --- a/src/SMESHGUI/SMESHGUI_XmlHandler.h +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.h @@ -30,11 +30,8 @@ // Qt includes #include - -// STL includes -#include -#include -#include +#include +#include class HypothesisData; class HypothesesSet; @@ -56,10 +53,10 @@ public: bool fatalError( const QXmlParseException& ); public: - std::map myHypothesesMap; - std::map myAlgorithmsMap; + QMap myHypothesesMap; + QMap myAlgorithmsMap; - std::list myListOfHypothesesSets; + QList myListOfHypothesesSets; private: QString myErrorProt;