Salome HOME
IPAL21489 Filter by Scalars... does not show visible elements for some presentations.
[modules/visu.git] / src / VISU_I / VISU_ResultUtils.cc
index 8caa8bf8296027284d9235a87ced3f7de8f72c3b..b117cc9c91f661efa52f4a0c35dae98d6a43bb75 100644 (file)
@@ -1,6 +1,6 @@
-//  VISU OBJECT : interactive object for VISU entities implementation
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
 //  This library is free software; you can redistribute it and/or
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+//  VISU OBJECT : interactive object for VISU entities implementation
 //  File   : VISU_ResultUtils.cc
 //  Author : Alexey PETROV
 //  Module : VISU
-
+//
 #include "VISU_ResultUtils.hh"
 
 #include "SUIT_Session.h"
-#include "SALOME_Event.hxx"
+#include "SALOME_Event.h"
 #include "SalomeApp_Study.h"
 #include "SalomeApp_Application.h"
 
 #include "VISU_Convertor.hxx"
 #include "VISU_ConvertorUtils.hxx"
 
-#include <qfileinfo.h>
-#include <qfile.h>
-#include <qdir.h>
+#include <QFileInfo>
+#include <QFile>
+#include <QDir>
 
 #include <boost/thread/recursive_mutex.hpp>
 #include <boost/thread/thread.hpp>
@@ -48,6 +48,8 @@ static int MYTIMEDEBUG = 0;
 static int MYTIMEDEBUG = 0;
 #endif
 
+using namespace std;
+
 namespace VISU
 {
   //----------------------------------------------------------------------------
@@ -107,9 +109,10 @@ namespace VISU
   {
     TLock aLock(myMutex);
     SUIT_Session* aSession = SUIT_Session::session();
-    QPtrList<SUIT_Application> anApplications = aSession->applications();
-    QPtrListIterator<SUIT_Application> anIter (anApplications);
-    while (SUIT_Application* aSApp = anIter.current()) {
+    QList<SUIT_Application*> anApplications = aSession->applications();
+    QListIterator<SUIT_Application*> anIter (anApplications);
+    while (anIter.hasNext()) {
+      SUIT_Application* aSApp = anIter.next();
       if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
        if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())) {
          if (_PTR(Study) aCStudy = aStudy->studyDS()) {
@@ -122,7 +125,6 @@ namespace VISU
          }
        }
       }
-      ++anIter;
     }
   }
 
@@ -140,7 +142,7 @@ namespace VISU
     QString aResult;
     if (anIter == aMap.end()) {
       aMap[theName] = 0;
-      aResult = theName;
+      aResult = theName.c_str();
     } else {
       aResult = GenerateName(theName,++aMap[theName]);
     }
@@ -190,8 +192,8 @@ namespace VISU
       aName = QString("%1, -").arg(theName.c_str());
     else
       aName = QString("%1, %2").arg(theName.c_str()).arg(theUnits.c_str());
-    aName = aName.simplifyWhiteSpace();
-    return aName.latin1();
+    aName = aName.simplified();
+    return aName;
   }
 
 
@@ -263,7 +265,7 @@ namespace VISU
                         NO_IOR,
                         aMeshName,
                         NO_PERFSITENT_REF,
-                        aComment.latin1(),
+                        aComment.toLatin1().data(),
                         true);
     
       aComment = QString("myComment=FAMILIES;myMeshName=%1").arg(aMeshName.c_str());
@@ -274,7 +276,7 @@ namespace VISU
                         NO_IOR,
                         "Families",
                         NO_PERFSITENT_REF,
-                        aComment.latin1(),
+                        aComment.toLatin1().data(),
                         true);
 
       if(theIsBuildGroups){
@@ -348,7 +350,7 @@ namespace VISU
                           NO_IOR,
                           anEntityName.c_str(),
                           NO_PERFSITENT_REF,
-                          aComment.latin1(), 
+                          aComment.toLatin1().data(), 
                           true);
       }
     }
@@ -410,7 +412,7 @@ namespace VISU
                             NO_IOR,
                             aFamilyName,
                             NO_PERFSITENT_REF,
-                            aComment.latin1(),
+                            aComment.toLatin1().data(),
                             true);
        }
       }
@@ -425,7 +427,7 @@ namespace VISU
                         NO_IOR,
                         "Groups",
                         NO_PERFSITENT_REF,
-                        aComment.latin1(),
+                        aComment.toLatin1().data(),
                         false);
 
        TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
@@ -440,7 +442,7 @@ namespace VISU
                             NO_IOR,
                             aGroupName,
                             NO_PERFSITENT_REF,
-                            aComment.latin1(),
+                            aComment.toLatin1().data(),
                             true);
          const TFamilySet& aFamilySet = aGroup->myFamilySet;
          TFamilySet::const_iterator aFamilyIter = aFamilySet.begin();
@@ -511,7 +513,7 @@ namespace VISU
          {
            aComment = "";
            aComment.append("myComment=FIELDS;");
-           aComment.append("myMeshName=");aComment.append(aMeshName);
+           aComment.append("myMeshName=");aComment.append(aMeshName.c_str());
 
            CreateAttributes(theStudy,
                             aMesh->myFieldsEntry,
@@ -519,7 +521,7 @@ namespace VISU
                             NO_IOR,
                             "Fields",
                             NO_PERFSITENT_REF,
-                            aComment.latin1(),
+                            aComment.toLatin1().data(),
                             false);
 
            anIsFieldsEntryUpdated = true;
@@ -540,9 +542,9 @@ namespace VISU
                                             aMesh->myFieldsEntry,
                                             NO_ICON,
                                             NO_IOR,
-                                            aFieldNameWithUnit.latin1(),
+                                            aFieldNameWithUnit.toLatin1().data(),
                                             NO_PERFSITENT_REF,
-                                            aComment.latin1(),
+                                            aComment.toLatin1().data(),
                                             true);
 
          CreateReference(theStudy,
@@ -570,7 +572,7 @@ namespace VISU
                                                    NO_IOR,
                                                    aTimeStampId,
                                                    NO_PERFSITENT_REF,
-                                                   aComment.latin1(),
+                                                   aComment.toLatin1().data(),
                                                    true);
          }
        }
@@ -634,11 +636,11 @@ namespace VISU
   RemoveFile(const std::string& theFileName,
             bool theRemoveEmptyDir)
   {
-    QFileInfo aFileInfo(theFileName);
-    QFile(aFileInfo.absFilePath()).remove();
+    QFileInfo aFileInfo(theFileName.c_str());
+    QFile(aFileInfo.absoluteFilePath()).remove();
     
     if(theRemoveEmptyDir)
-      QDir().rmdir(aFileInfo.dirPath(TRUE));
+      QDir().rmdir(aFileInfo.absolutePath());
 
     return aFileInfo.exists();
   }
@@ -649,18 +651,18 @@ namespace VISU
   CopyFile(const std::string& theSourceFileName,
           const std::string& theTargetFileName)
   {
-    QFileInfo aSourceFileInfo(theSourceFileName);
-    QFileInfo aTargetFileInfo(theTargetFileName);
-    if(aSourceFileInfo.absFilePath() == aTargetFileInfo.absFilePath())
+    QFileInfo aSourceFileInfo(theSourceFileName.c_str());
+    QFileInfo aTargetFileInfo(theTargetFileName.c_str());
+    if(aSourceFileInfo.absoluteFilePath() == aTargetFileInfo.absoluteFilePath())
       return true;
 
     QString aCommand;
     aCommand.sprintf("%s %s %s",
                     COPY_COMMAND,
-                    aSourceFileInfo.filePath().latin1(),
-                    aTargetFileInfo.filePath().latin1());
+                    aSourceFileInfo.filePath().toLatin1().data(),
+                    aTargetFileInfo.filePath().toLatin1().data());
 
-    return system(aCommand.latin1()) == 0;
+    return system(aCommand.toLatin1().data()) == 0;
   }