]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Fix of IPAL19621 (Qt4 porting: regress of automatic assign a set of hypotheses).
authorvsr <vsr@opencascade.com>
Wed, 23 Apr 2008 11:11:39 +0000 (11:11 +0000)
committervsr <vsr@opencascade.com>
Wed, 23 Apr 2008 11:11:39 +0000 (11:11 +0000)
src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx
src/SMESHGUI/SMESHGUI_XmlHandler.cxx
src/SMESHGUI/SMESHGUI_XmlHandler.h

index 35b8a567d54e9e93932a3b92eb82fbc2a8e6ac14..3a0bc9ffa3bf9b780ffe49d4fe6fdaf093589d59 100644 (file)
@@ -77,22 +77,20 @@ static int MYDEBUG = 0;
 
 namespace SMESH
 {
-  typedef QMap<std::string,HypothesisData*> THypothesisDataMap;
+  typedef QMap<QString,HypothesisData*> THypothesisDataMap;
   THypothesisDataMap myHypothesesMap;
   THypothesisDataMap myAlgorithmsMap;
 
-  typedef QMap<std::string,SMESHGUI_GenericHypothesisCreator*> THypCreatorMap;
+  typedef QMap<QString,SMESHGUI_GenericHypothesisCreator*> THypCreatorMap;
   THypCreatorMap myHypCreatorMap;
 
-  std::list<HypothesesSet*> myListOfHypothesesSets;
-  //QList<HypothesesSet*> myListOfHypothesesSets;
+  QList<HypothesesSet*> 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<std::string,HypothesisData*>( aXmlHandler->myHypothesesMap ) );
-            myAlgorithmsMap.unite( QMap<std::string,HypothesisData*>( aXmlHandler->myAlgorithmsMap ) );
-            myListOfHypothesesSets.splice( myListOfHypothesesSets.begin(),
-                                           aXmlHandler->myListOfHypothesesSets );
+           myHypothesesMap.unite( aXmlHandler->myHypothesesMap );
+            myAlgorithmsMap.unite( aXmlHandler->myAlgorithmsMap );
+           QList<HypothesesSet*>::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<HypothesesSet*>::iterator hypoSet = myListOfHypothesesSets.begin();
-    //QList<HypothesesSet*>::iterator hypoSet = myListOfHypothesesSets.begin();
-    for ( ; hypoSet != myListOfHypothesesSets.end(); ++hypoSet )
-      {
-       HypothesesSet* aSet = *hypoSet;
-       if ( aSet && aSet->AlgoList.count() ) {
-         aSetNameList.append( aSet->HypoSetName );
-       }
+    QList<HypothesesSet*>::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<HypothesesSet*>::iterator hypoSet = myListOfHypothesesSets.begin();
-    //QList<HypothesesSet*>::iterator hypoSet = myListOfHypothesesSets.begin();
-    for ( ; hypoSet != myListOfHypothesesSets.end(); ++hypoSet )
-      {
-       HypothesesSet* aSet = *hypoSet;
-       if ( aSet && aSet->HypoSetName == theSetName )
-         return aSet;
-      }
+    QList<HypothesesSet*>::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;
            }
          }
        }
index 3bc04fdfaa38233e985d39b3c6b6658fed4abf1b..cf87f29ef58dc3662ab2c95ff007c1dc46e76a9c 100644 (file)
@@ -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 )
       {
index f3582ed29a31a2bd06185890475dbe16c111427e..25b2cf393f109dff83c294adbfc758dfd1ae42af 100644 (file)
 
 // Qt includes
 #include <QXmlDefaultHandler>
-
-// STL includes
-#include <string>
-#include <map>
-#include <list>
+#include <QMap>
+#include <QList>
 
 class HypothesisData;
 class HypothesesSet;
@@ -56,10 +53,10 @@ public:
   bool     fatalError( const QXmlParseException& );
 
 public:
-  std::map<std::string, HypothesisData*> myHypothesesMap;
-  std::map<std::string, HypothesisData*> myAlgorithmsMap;
+  QMap<QString, HypothesisData*>         myHypothesesMap;
+  QMap<QString, HypothesisData*>         myAlgorithmsMap;
 
-  std::list<HypothesesSet*>              myListOfHypothesesSets;
+  QList<HypothesesSet*>                  myListOfHypothesesSets;
 
 private:
   QString                                myErrorProt;