Salome HOME
Revert "Synchronize adm files"
[modules/homard.git] / src / HOMARDGUI / HOMARDGUI_Utils.cxx
index d76efeeba063310c89293fe934c766471a686c36..fdc6eda1cb19ea99e6a1122af14a2f8ede91f492 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2011-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2011-2014  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -43,7 +43,9 @@
 #include <qstring.h>
 #include <qstringlist.h>
 #include <sys/stat.h>
+#ifndef WIN32
 #include <dirent.h>
+#endif
 
 SALOME_ListIO HOMARD_UTILS::mySelected;
 
@@ -56,7 +58,6 @@ SALOME_ListIO HOMARD_UTILS::mySelected;
     return theStudy->studyDS();
 }
 
-
 //================================================================
 // Function : GetActiveStudy
 // Returne un pointeur sur l'etude active
@@ -116,11 +117,10 @@ const SALOME_ListIO& HOMARD_UTILS::selectedIO()
       if( aSelectionMgr )
       {
              aSelectionMgr->selectedObjects( mySelected );
-              for (SALOME_ListIteratorOfListIO it (mySelected); it.More(); it.Next())
-                SCRUTE(it.Value()->getEntry());
+        for (SALOME_ListIteratorOfListIO it (mySelected); it.More(); it.Next())
+        SCRUTE(it.Value()->getEntry());
       };
       return mySelected;
-
 }
 
 //================================================================
@@ -135,7 +135,7 @@ int HOMARD_UTILS::IObjectCount()
       {
              aSelectionMgr->selectedObjects( mySelected );
              SCRUTE(mySelected.Extent());
-              return mySelected.Extent();
+        return mySelected.Extent();
       }
       return 0;
 }
@@ -161,20 +161,7 @@ Handle(SALOME_InteractiveObject) HOMARD_UTILS::lastIObject()
 }
 
 //================================================================
-// Function : isXmgrace
-// Retourne vrai si le fichier associe est de type ASCII
-//================================================================
-bool HOMARD_UTILS::isXmgrace(_PTR(SObject) MonObj)
-{
-   _PTR(GenericAttribute) anAttr;
-   if (!MonObj->FindAttribute(anAttr, "AttributeComment")) return false;
-   _PTR(AttributeComment) aFileComment (anAttr);
-   std::string Type = aFileComment->Value();
-   if (QString(Type.c_str()) == QString("HomardOuputQual")) return true;
-   return false;
-}
-//================================================================
-// Retourne vrai si l objet est du type voulu
+// Retourne vrai si l'objet est du type voulu
 // . Dans le cas d'un cas, d'une hypothese, d'une zone, on se contente
 // d'une comparaison simple entre le type stocke et TypeObject.
 // . Pour l'iteration, le type stocke en attribut est sous la forme
@@ -201,6 +188,7 @@ bool HOMARD_UTILS::isObject(_PTR(SObject) MonObj, QString TypeObject, int option
   if ( option == 0 )
   {
     int position = Type.lastIndexOf(TypeObject);
+//     MESSAGE("position = "<<position);
     if ( position == 0 ) { bOK = true ; }
   }
   else
@@ -210,71 +198,86 @@ bool HOMARD_UTILS::isObject(_PTR(SObject) MonObj, QString TypeObject, int option
   return bOK ;
 }
 //================================================================
-// Retourne vrai si l objet est une frontiere analytique
+// Retourne vrai si l'objet est une frontiere analytique
 //================================================================
 bool HOMARD_UTILS::isBoundaryAn(_PTR(SObject) MonObj)
 {
    return isObject( MonObj, QString("BoundaryAnHomard"), -1 ) ;
 }
 //================================================================
-// Retourne vrai si l objet est une frontiere discrete
+// Retourne vrai si l'objet est une frontiere discrete
 //================================================================
 bool HOMARD_UTILS::isBoundaryDi(_PTR(SObject) MonObj)
 {
    return isObject( MonObj, QString("BoundaryDiHomard"), -1 ) ;
 }
 //================================================================
-// Retourne vrai si l objet est une zone
+// Retourne vrai si l'objet est un cas
 //================================================================
-bool HOMARD_UTILS::isZone(_PTR(SObject) MonObj)
+bool HOMARD_UTILS::isCase(_PTR(SObject) MonObj)
 {
-   return isObject( MonObj, QString("ZoneHomard"), -1 ) ;
+   return isObject( MonObj, QString("CasHomard"), -1 ) ;
 }
 //================================================================
-// Retourne vrai si l objet est une Hypothese
+// Retourne vrai si l'objet est une Hypothese
 //================================================================
 bool HOMARD_UTILS::isHypo(_PTR(SObject) MonObj)
 {
    return isObject( MonObj, QString("HypoHomard"), -1 ) ;
 }
 //================================================================
-// Retourne vrai si l objet est une iteration
+// Retourne vrai si l'objet est une iteration
 //================================================================
 bool HOMARD_UTILS::isIter(_PTR(SObject) MonObj)
 {
    return isObject( MonObj, QString("IterationHomard"), 0 ) ;
 }
 //================================================================
-// Retourne vrai si l objet est un cas
+// Retourne vrai si l'objet est un schema YACS
 //================================================================
-bool HOMARD_UTILS::isCase(_PTR(SObject) MonObj)
+bool HOMARD_UTILS::isYACS(_PTR(SObject) MonObj)
 {
-   return isObject( MonObj, QString("CasHomard"), -1 ) ;
+   return isObject( MonObj, QString("YACSHomard"), -1 ) ;
 }
 //================================================================
-// Retourne vrai si l objet est un fichier de messages
+// Retourne vrai si l'objet est une zone
 //================================================================
-bool HOMARD_UTILS::isFilelog(_PTR(SObject) MonObj)
+bool HOMARD_UTILS::isZone(_PTR(SObject) MonObj)
 {
-   return isObject( MonObj, QString("log"), 0 ) ;
+   return isObject( MonObj, QString("ZoneHomard"), -1 ) ;
 }
 //================================================================
-// Retourne vrai si l objet est un fichier de bilan
+// Retourne vrai si l'objet est un fichier de type TypeFile
 //================================================================
-bool HOMARD_UTILS::isFileSummary(_PTR(SObject) MonObj)
+bool HOMARD_UTILS::isFileType(_PTR(SObject) MonObj, QString TypeFile)
 {
-   return isObject( MonObj, QString("Summary"), 0 ) ;
+   return isObject( MonObj, TypeFile, 0 ) ;
 }
 
 //=========================================================================================================
-void HOMARD_UTILS::PushOnHelp(QString monFichierAide, QString leContexte)
+void HOMARD_UTILS::PushOnHelp(QString monFichierAide, QString contexte, QString LanguageShort)
 {
   MESSAGE("Debut de PushOnHelp avec monFichierAide = "<< monFichierAide.toStdString().c_str());
   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
-  if (app) {
-    QString fichier = QString("fr/"+monFichierAide) ;
+  if (app)
+  {
     HOMARDGUI* aHomardGUI = dynamic_cast<HOMARDGUI*>( app->module( "Homard" ) );
-    app->onHelpContextModule(aHomardGUI ? app->moduleName(aHomardGUI->moduleName()) : QString(""), fichier, leContexte);
+    // Repertoire de reference de la documentation
+    QString rep = aHomardGUI ? app->moduleName(aHomardGUI->moduleName()) : QString("") ;
+    // WARNING/ATTENTION : si on savait recuperer la langue depuis les preferences, on ne ferait pas le passage par argument
+//     SUIT_ResourceMgr* resMgr = getApp()->resourceMgr();
+//     SUIT_ResourceMgr* resMgr = myModule->getApp()->resourceMgr();
+//     QString langue = resMgr->stringValue("language", "language", "en");
+//     QString langue = "fr" ;
+    MESSAGE(". LanguageShort " << LanguageShort.toStdString().c_str()) ;
+    // Complement du fichier
+    QString fichier = QString(LanguageShort+"/"+monFichierAide) ;
+    MESSAGE(". Appel de onHelpContextModule avec :");
+    MESSAGE("    rep      = "<< rep.toStdString().c_str());
+    MESSAGE("    fichier  = "<< fichier.toStdString().c_str());
+    MESSAGE("    contexte = "<< contexte.toStdString().c_str());
+
+    app->onHelpContextModule(rep, fichier, contexte);
   }
 }
 //=========================================================================================================