Fix of IPAL19621 (Qt4 porting: regress of automatic assign a set of hypotheses).

This commit is contained in:
vsr 2008-04-23 11:11:39 +00:00
parent b75d24976c
commit d8bff2b915
3 changed files with 66 additions and 71 deletions

View File

@ -77,22 +77,20 @@ static int MYDEBUG = 0;
namespace SMESH namespace SMESH
{ {
typedef QMap<std::string,HypothesisData*> THypothesisDataMap; typedef QMap<QString,HypothesisData*> THypothesisDataMap;
THypothesisDataMap myHypothesesMap; THypothesisDataMap myHypothesesMap;
THypothesisDataMap myAlgorithmsMap; THypothesisDataMap myAlgorithmsMap;
typedef QMap<std::string,SMESHGUI_GenericHypothesisCreator*> THypCreatorMap; typedef QMap<QString,SMESHGUI_GenericHypothesisCreator*> THypCreatorMap;
THypCreatorMap myHypCreatorMap; THypCreatorMap myHypCreatorMap;
std::list<HypothesesSet*> myListOfHypothesesSets; QList<HypothesesSet*> myListOfHypothesesSets;
//QList<HypothesesSet*> myListOfHypothesesSets;
void processHypothesisStatus(const int theHypStatus, void processHypothesisStatus(const int theHypStatus,
SMESH::SMESH_Hypothesis_ptr theHyp, SMESH::SMESH_Hypothesis_ptr theHyp,
const bool theIsAddition) const bool theIsAddition)
{ {
if (theHypStatus > SMESH::HYP_OK) { if (theHypStatus > SMESH::HYP_OK) {
// get Hyp name // get Hyp name
QString aHypName ("NULL Hypothesis"); QString aHypName ("NULL Hypothesis");
if (!CORBA::is_nil(theHyp)) { if (!CORBA::is_nil(theHyp)) {
@ -141,13 +139,12 @@ namespace SMESH
HypsXml.sprintf("%s", cenv); HypsXml.sprintf("%s", cenv);
QStringList HypsXmlList = HypsXml.split(":", QString::SkipEmptyParts); QStringList HypsXmlList = HypsXml.split(":", QString::SkipEmptyParts);
if (HypsXmlList.count() == 0) if (HypsXmlList.count() == 0) {
{ SUIT_MessageBox::critical(SMESHGUI::desktop(),
SUIT_MessageBox::critical(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_WRN_WARNING"), QObject::tr("MESHERS_FILE_NO_VARIABLE"));
QObject::tr("MESHERS_FILE_NO_VARIABLE")); return;
return; }
}
// loop on files in HypsXml // loop on files in HypsXml
QString aNoAccessFiles; QString aNoAccessFiles;
@ -173,10 +170,14 @@ namespace SMESH
bool ok = reader.parse(source); bool ok = reader.parse(source);
file.close(); file.close();
if (ok) { if (ok) {
myHypothesesMap.unite( QMap<std::string,HypothesisData*>( aXmlHandler->myHypothesesMap ) ); myHypothesesMap.unite( aXmlHandler->myHypothesesMap );
myAlgorithmsMap.unite( QMap<std::string,HypothesisData*>( aXmlHandler->myAlgorithmsMap ) ); myAlgorithmsMap.unite( aXmlHandler->myAlgorithmsMap );
myListOfHypothesesSets.splice( myListOfHypothesesSets.begin(), QList<HypothesesSet*>::iterator it, pos = myListOfHypothesesSets.begin();
aXmlHandler->myListOfHypothesesSets ); for ( it = aXmlHandler->myListOfHypothesesSets.begin();
it != aXmlHandler->myListOfHypothesesSets.end();
++it ) {
myListOfHypothesesSets.insert( pos, *it );
}
} }
else { else {
SUIT_MessageBox::critical(SMESHGUI::desktop(), SUIT_MessageBox::critical(SMESHGUI::desktop(),
@ -217,19 +218,20 @@ namespace SMESH
InitAvailableHypotheses(); InitAvailableHypotheses();
bool checkGeometry = !isNeedGeometry; bool checkGeometry = !isNeedGeometry;
// fill list of hypotheses/algorithms // fill list of hypotheses/algorithms
THypothesisDataMap* pMap = isAlgo ? &myAlgorithmsMap : &myHypothesesMap; THypothesisDataMap& pMap = isAlgo ? myAlgorithmsMap : myHypothesesMap;
THypothesisDataMap::iterator anIter; THypothesisDataMap::iterator anIter;
for ( anIter = pMap->begin(); anIter != pMap->end(); anIter++ ) for ( anIter = pMap.begin(); anIter != pMap.end(); anIter++ ) {
{ HypothesisData* aData = anIter.value();
HypothesisData* aData = anIter.value(); if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux) {
if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux) if (checkGeometry) {
if (checkGeometry){ if (aData->IsNeedGeometry == isNeedGeometry)
if (aData->IsNeedGeometry == isNeedGeometry) aHypList.append(anIter.key());
aHypList.append(anIter.key().c_str()); }
} else {
else aHypList.append(anIter.key());
aHypList.append(anIter.key().c_str()); }
} }
}
return aHypList; return aHypList;
} }
@ -241,29 +243,29 @@ namespace SMESH
// Init list of available hypotheses, if needed // Init list of available hypotheses, if needed
InitAvailableHypotheses(); InitAvailableHypotheses();
std::list<HypothesesSet*>::iterator hypoSet = myListOfHypothesesSets.begin(); QList<HypothesesSet*>::iterator hypoSet;
//QList<HypothesesSet*>::iterator hypoSet = myListOfHypothesesSets.begin(); for ( hypoSet = myListOfHypothesesSets.begin();
for ( ; hypoSet != myListOfHypothesesSets.end(); ++hypoSet ) hypoSet != myListOfHypothesesSets.end();
{ ++hypoSet ) {
HypothesesSet* aSet = *hypoSet; HypothesesSet* aSet = *hypoSet;
if ( aSet && aSet->AlgoList.count() ) { if ( aSet && aSet->AlgoList.count() ) {
aSetNameList.append( aSet->HypoSetName ); aSetNameList.append( aSet->HypoSetName );
}
} }
}
return aSetNameList; return aSetNameList;
} }
HypothesesSet* GetHypothesesSet(const QString& theSetName) HypothesesSet* GetHypothesesSet(const QString& theSetName)
{ {
std::list<HypothesesSet*>::iterator hypoSet = myListOfHypothesesSets.begin(); QList<HypothesesSet*>::iterator hypoSet;
//QList<HypothesesSet*>::iterator hypoSet = myListOfHypothesesSets.begin(); for ( hypoSet = myListOfHypothesesSets.begin();
for ( ; hypoSet != myListOfHypothesesSets.end(); ++hypoSet ) hypoSet != myListOfHypothesesSets.end();
{ ++hypoSet ) {
HypothesesSet* aSet = *hypoSet; HypothesesSet* aSet = *hypoSet;
if ( aSet && aSet->HypoSetName == theSetName ) if ( aSet && aSet->HypoSetName == theSetName )
return aSet; return aSet;
} }
return 0; return 0;
} }
@ -274,14 +276,11 @@ namespace SMESH
// Init list of available hypotheses, if needed // Init list of available hypotheses, if needed
InitAvailableHypotheses(); InitAvailableHypotheses();
THypothesisDataMap::iterator type_data = myHypothesesMap.find(aHypType.toLatin1().data()); if (myHypothesesMap.find(aHypType) != myHypothesesMap.end()) {
if (type_data != myHypothesesMap.end()) { aHypData = myHypothesesMap[aHypType];
aHypData = type_data.value();
} }
else { else if (myAlgorithmsMap.find(aHypType) != myAlgorithmsMap.end()) {
type_data = myAlgorithmsMap.find(aHypType.toLatin1().data()); aHypData = myAlgorithmsMap[aHypType];
if (type_data != myAlgorithmsMap.end())
aHypData = type_data.value();
} }
return aHypData; return aHypData;
} }
@ -326,8 +325,8 @@ namespace SMESH
SMESHGUI_GenericHypothesisCreator* aCreator = 0; SMESHGUI_GenericHypothesisCreator* aCreator = 0;
// check, if creator for this hypothesis type already exists // check, if creator for this hypothesis type already exists
if (myHypCreatorMap.find(aHypType.toLatin1().data()) != myHypCreatorMap.end()) { if (myHypCreatorMap.find(aHypType) != myHypCreatorMap.end()) {
aCreator = myHypCreatorMap[aHypType.toLatin1().data()]; aCreator = myHypCreatorMap[aHypType];
} }
else { else {
// 1. Init list of available hypotheses, if needed // 1. Init list of available hypotheses, if needed
@ -347,15 +346,14 @@ namespace SMESH
LibHandle libHandle = LoadLib( aClientLibName.toLatin1().data() ); LibHandle libHandle = LoadLib( aClientLibName.toLatin1().data() );
if (!libHandle) { if (!libHandle) {
// report any error, if occured // report any error, if occured
if ( MYDEBUG ) if ( MYDEBUG ) {
{
#ifdef WIN32 #ifdef WIN32
const char* anError = "Can't load client meshers plugin library"; const char* anError = "Can't load client meshers plugin library";
#else #else
const char* anError = dlerror(); const char* anError = dlerror();
#endif #endif
MESSAGE(anError); MESSAGE(anError);
} }
} }
else { else {
// get method, returning hypothesis creator // get method, returning hypothesis creator
@ -377,7 +375,7 @@ namespace SMESH
} }
else { else {
// map hypothesis creator to a hypothesis name // map hypothesis creator to a hypothesis name
myHypCreatorMap[aHypType.toLatin1().data()] = aCreator; myHypCreatorMap[aHypType] = aCreator;
} }
} }
} }

View File

@ -159,11 +159,11 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&,
if (qName == "algorithm") if (qName == "algorithm")
{ {
myAlgorithmsMap[aHypAlType.toLatin1().data()] = aHypData; myAlgorithmsMap[aHypAlType] = aHypData;
} }
else 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") != "") if (atts.value("name") != "")
{ {
HypothesesSet* aHypoSet = new HypothesesSet ( atts.value("name") ); HypothesesSet* aHypoSet = new HypothesesSet ( atts.value("name") );
myListOfHypothesesSets.push_back( aHypoSet ); myListOfHypothesesSets.append( aHypoSet );
for ( int isHypo = 0; isHypo < 2; ++isHypo ) for ( int isHypo = 0; isHypo < 2; ++isHypo )
{ {

View File

@ -30,11 +30,8 @@
// Qt includes // Qt includes
#include <QXmlDefaultHandler> #include <QXmlDefaultHandler>
#include <QMap>
// STL includes #include <QList>
#include <string>
#include <map>
#include <list>
class HypothesisData; class HypothesisData;
class HypothesesSet; class HypothesesSet;
@ -56,10 +53,10 @@ public:
bool fatalError( const QXmlParseException& ); bool fatalError( const QXmlParseException& );
public: public:
std::map<std::string, HypothesisData*> myHypothesesMap; QMap<QString, HypothesisData*> myHypothesesMap;
std::map<std::string, HypothesisData*> myAlgorithmsMap; QMap<QString, HypothesisData*> myAlgorithmsMap;
std::list<HypothesesSet*> myListOfHypothesesSets; QList<HypothesesSet*> myListOfHypothesesSets;
private: private:
QString myErrorProt; QString myErrorProt;