]> SALOME platform Git repositories - tools/eficas.git/commitdiff
Salome HOME
*** empty log message ***
authorPascale Noyret <pascale.noyret@edf.fr>
Fri, 7 Jan 2011 08:57:40 +0000 (08:57 +0000)
committerPascale Noyret <pascale.noyret@edf.fr>
Fri, 7 Jan 2011 08:57:40 +0000 (08:57 +0000)
InterfaceQT4/editor.py
MAP/Templates/s_polymers_st_1/cata_s_polymers_st_1.xml
MAP/Templates/s_polymers_st_1/s_polymers_st_1_YACS_nodes.py
generator/generator_cuve2dg.py
generator/generator_map.py
generator/generator_openturns_study.py
generator/generator_openturns_wrapper.py

index 2c80c260afa063652d40f5ca6d6c2a6c50333125..6c5b7173131a1bb874f973b175199f3192d3faa7 100644 (file)
@@ -23,6 +23,9 @@ import traceback
 from PyQt4 import *
 from PyQt4.QtGui  import *
 from PyQt4.QtCore import *
+import time
+from datetime import date
+
 
 # Modules Eficas
 
@@ -540,52 +543,72 @@ class JDCEditor(QSplitter):
       if execution=="oui" :
          print "il faut faire le run dans Salome"
     
-    #-----------------------------#
-    def saveRun(self):
-    #-----------------------------#
-        texte=self.run(execution="non")
-        path=self.CONFIGURATION.savedir
-        fn = QFileDialog.getSaveFileName( self,
+    
+    #-----------------------------------------------------#
+    def determineNomFichier(self,path,extension):
+    #-----------------------------------------------------#
+      if DictExtensions.has_key(self.appli.code) :
+         chaine1="JDC (*"+DictExtensions[self.appli.code]+");;"
+         extensions= self.trUtf8(chaine1+ "All Files (*)")
+      else :
+         extensions= self.trUtf8("JDC (*.comm);;" "All Files (*)")
+
+      if self.appli.code == "MAP" :
+         extensions = extensions + ";;Schema Yacs (*.xml);; Run (*.py);;"
+
+      fn = QFileDialog.getSaveFileName( self,
              self.trUtf8("sauvegarde"), path,
-             self.trUtf8("Run (*.py);;" "All Files (*)"),None,
+             extensions,None,
              QFileDialog.DontConfirmOverwrite)
-        if fn.isNull(): return 
-        ext = QFileInfo(fn).suffix()
-        if ext.isEmpty(): fn.append(".py")
-
-        if QFileInfo(fn).exists():
-                abort = QMessageBox.warning(self,
-                       self.trUtf8("Sauvegarde du Fichier"),
-                       self.trUtf8("Le fichier <b>%1</b> existe deja.").arg(fn),
-                       self.trUtf8("&Ecraser"),
-                       self.trUtf8("&Abandonner"))
-                if abort == 1 :  return
-
-        fn = unicode(QDir.convertSeparators(fn))
-        self.writeFile( fn, txt = texte)
+      print fn
+      if fn.isNull(): return (0, None)
+      ext = QFileInfo(fn).suffix()
+      if ext.isEmpty(): fn.append(extension)
+
+      if QFileInfo(fn).exists():
+           abort = QMessageBox.warning(self,
+                   self.trUtf8("Sauvegarde du Fichier"),
+                   self.trUtf8("Le fichier <b>%1</b> existe deja.").arg(fn),
+                   self.trUtf8("&Ecraser"),
+                   self.trUtf8("&Abandonner"))
+           if abort == 1 :  return (0, "")
+      return (1,fn)
+
+    def saveRun(self):
+    #-----------------#
+        texte=self.run(execution="non")
+        extension=".py"
+
+        if hasattr(self,'fichierRun'):
+           self.writeFile( self.fichierRun, txt = texte)
+           return
+
+        if self.fichier == None :
+           path=self.CONFIGURATION.savedir
+        else :
+          path=QFileInfo(self.fichier).absolutePath()+"/"+QFileInfo(self.fichier).baseName()+".py"
+        bOK, fn=self.determineNomFichier(path,extension)
+        if fn == "" : return
+        self.fichierRun = unicode(QDir.convertSeparators(fn))
+        self.writeFile( self.fichierRun, txt = texte)
     
     #-----------------------------#
     def saveYACS(self):
     #-----------------------------#
-        path=self.CONFIGURATION.savedir
-        fn = QFileDialog.getSaveFileName( self,
-             self.trUtf8("sauvegarde"), path,
-             self.trUtf8("Schema YACS (*.xml);;" "All Files (*)"),None,
-             QFileDialog.DontConfirmOverwrite)
-        if fn.isNull(): return 
-        ext = QFileInfo(fn).suffix()
-        if ext.isEmpty(): fn.append(".xml")
-
-        if QFileInfo(fn).exists():
-                abort = QMessageBox.warning(self,
-                       self.trUtf8("Sauvegarde du Fichier"),
-                       self.trUtf8("Le fichier <b>%1</b> existe deja.").arg(fn),
-                       self.trUtf8("&Ecraser"),
-                       self.trUtf8("&Abandonner"))
-                if abort == 1 :  return
-        fn = unicode(QDir.convertSeparators(fn))
-
-        texte=self.runYACS(execution="non",nomFichier=fn)
+        if hasattr(self,'fichierYACS'):
+           self.runYACS(execution="non",nomFichier=self.fichierYACS)
+           return
+
+        today = str(date.today())
+        today = today.replace('-', '')
+        today+="-"+time.strftime("%H%M%S", time.localtime())
+        path=self.CONFIGURATION.PATH_STUDY+"/"+self.CONFIGURATION.NAME_SCHEME+"_"+today+".xml"
+        extension=".xml"
+
+        bOK, fn=self.determineNomFichier(path,extension)
+        if fn == "" : return
+        self.runYACS(execution="non",nomFichier=self.fichierYACS)
+
       
     #-----------------------------------------#
     def cherche_Groupes(self):
@@ -607,88 +630,46 @@ class JDCEditor(QSplitter):
         if not self.modified and not saveas:
             return (0, None)      # do nothing if text wasn't changed
             
+        extension='.py'
+        if DictExtensions.has_key(self.appli.code) :
+           extension=DictExtensions[self.appli.code]
+        else :
+           extension='.comm'
+
         newName = None
+        fn = self.fichier
         if self.fichier is None or saveas:
           if path is None: 
              path=self.CONFIGURATION.savedir
-          selectedFilter = QString('')
-          if DictExtensions.has_key(self.appli.code) :
-               chaine1="JDC (*"+DictExtensions[self.appli.code]+");;"
-               extensions= self.trUtf8(chaine1+ "All Files (*)")
-          else :
-               extensions= self.trUtf8("JDC (*.comm);;" "All Files (*)")
-          fn = QFileDialog.getSaveFileName( self,
-               self.trUtf8("sauvegarde"), path,
-               extensions,None,
-               QFileDialog.DontConfirmOverwrite)
+          bOK, fn=self.determineNomFichier(path,extension)
           if fn.isNull(): return (0, None)
+
           ulfile = os.path.abspath(unicode(fn))
           self.appliEficas.CONFIGURATION.savedir=os.path.split(ulfile)[0]
-
-          ext = QFileInfo(fn).suffix()
-          if ext.isEmpty():
-             if DictExtensions.has_key(self.appli.code) :
-                fn.append(DictExtensions[self.appli.code])
-             else :
-                fn.append(".comm")
-
-          if QFileInfo(fn).exists():
-                abort = QMessageBox.warning(self,
-                       self.trUtf8("Sauvegarde du Fichier"),
-                       self.trUtf8("Le fichier <b>%1</b> existe deja.").arg(fn),
-                       self.trUtf8("&Ecraser"),
-                       self.trUtf8("&Abandonner"))
-                if abort == 1 :  return (0, None)
-
           fn = unicode(QDir.convertSeparators(fn))
           newName = fn
 
-        else:
-            fn = self.fichier
-        
-        if self.writeFile(fn):
-            self.fichier = fn
-            self.modified  = False                        
-            if self.fileInfo is None or saveas:
-                self.fileInfo = QFileInfo(self.fichier)
-                self.fileInfo.setCaching(0)
-            self.lastModified = self.fileInfo.lastModified()
-            if newName is not None:
-                self.appliEficas.addToRecentList(newName)
-                self.tree.racine.item.getObject().nom=os.path.basename(newName)
-                self.tree.racine.update_node_label()
-               
-            if self.jdc.isvalid() != 0 :
-               try : 
-                  fileXML = fn[:fn.rfind(".")] + '.xml'
-                  self.generator.writeOpenturnsXML( fileXML )
-               except :
-                  pass
+        if not (self.writeFile(fn)): return (0, None)
+        self.fichier = fn
+        self.modified  = False                        
+        if self.fileInfo is None or saveas:
+           self.fileInfo = QFileInfo(self.fichier)
+           self.fileInfo.setCaching(0)
+        self.lastModified = self.fileInfo.lastModified()
+        if newName is not None:
+           self.appliEficas.addToRecentList(newName)
+           self.tree.racine.item.getObject().nom=os.path.basename(newName)
+           self.tree.racine.update_node_label()
                
-               try : 
-                  fileSTD = fn[:fn.rfind(".")] + '.py'
-                  self.generator.writeOpenturnsSTD( fileSTD )
-               except :
-                  pass
-
-               try:
-                 self.generator.writeDefault(fn)
-               except:
-                 pass
-
-               try : 
-                  fileCuve2DG = fn[:fn.rfind(".")] + '.don'
-                  self.generator.writeCuve2DG(fileCuve2DG)
-               except :
-                  pass
+        if self.jdc.isvalid() != 0 :
+           try:
+              self.generator.writeDefault(fn)
+           except:
+              pass
 
-
-            if self.salome : 
+        if self.salome : 
                self.appliEficas.addJdcInSalome( self.fichier)
-
-            return (1, self.fichier)
-        else:
-            return (0, None)
+        return (1, self.fichier)
 #
     #---------------------------------#
     def saveFileAs(self, path = None):
index 373d97bb6406741b76eea07d4d68b466ebae39cf..2e1bbc4f17cf9d5ba6d4bf5531073f9488198176 100644 (file)
@@ -76,7 +76,7 @@ benhur_template="/local/noyret/EficasV1/MAP/templates/s_polymers_st_1/benhur_tem
       <script><code><![CDATA[import sys
 import os
 
-sys.path.append(os.path.join(os.getenv('EFICAS_ROOT'),'MAP/Templates/s_polymers_st_1'))
+#sys.path.append(os.path.join(os.getenv('EFICAS_ROOT'),'MAP/Templates/s_polymers_st_1'))
 from s_polymers_st_1_YACS_nodes import *
 
 lambda_x=component_fdvgrid(lambda_I, lambda_M, rve_size, file_inclusions, finesse)
@@ -154,18 +154,18 @@ component_gmsh_post(result_gmsh)
 ]]></code></script>
       <inport name="result_gmsh" type="string"/>
    </inline>
-   <control> <fromnode>pygmee_v2</fromnode> <tonode>fdvgrid</tonode> </control>
    <control> <fromnode>pygmee_v2</fromnode> <tonode>benhur</tonode> </control>
-   <control> <fromnode>init</fromnode> <tonode>pygmee_v2</tonode> </control>
-   <control> <fromnode>init</fromnode> <tonode>fdvgrid</tonode> </control>
-   <control> <fromnode>init</fromnode> <tonode>benhur</tonode> </control>
+   <control> <fromnode>pygmee_v2</fromnode> <tonode>fdvgrid</tonode> </control>
    <control> <fromnode>init</fromnode> <tonode>aster_s_polymers_st_1</tonode> </control>
+   <control> <fromnode>init</fromnode> <tonode>benhur</tonode> </control>
+   <control> <fromnode>init</fromnode> <tonode>fdvgrid</tonode> </control>
+   <control> <fromnode>init</fromnode> <tonode>pygmee_v2</tonode> </control>
    <control> <fromnode>benhur</fromnode> <tonode>aster_s_polymers_st_1</tonode> </control>
+   <control> <fromnode>env</fromnode> <tonode>aster_s_polymers_st_1</tonode> </control>
+   <control> <fromnode>env</fromnode> <tonode>benhur</tonode> </control>
+   <control> <fromnode>env</fromnode> <tonode>fdvgrid</tonode> </control>
    <control> <fromnode>env</fromnode> <tonode>pygmee_v2</tonode> </control>
    <control> <fromnode>env</fromnode> <tonode>init</tonode> </control>
-   <control> <fromnode>env</fromnode> <tonode>fdvgrid</tonode> </control>
-   <control> <fromnode>env</fromnode> <tonode>benhur</tonode> </control>
-   <control> <fromnode>env</fromnode> <tonode>aster_s_polymers_st_1</tonode> </control>
    <control> <fromnode>aster_s_polymers_st_1</fromnode> <tonode>gmsh_post</tonode> </control>
    <datalink control="false">
       <fromnode>pygmee_v2</fromnode> <fromport>result_inclusions</fromport>
@@ -201,23 +201,23 @@ component_gmsh_post(result_gmsh)
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>rve_size</fromport>
-      <tonode>pygmee_v2</tonode> <toport>rve_size</toport>
+      <tonode>aster_s_polymers_st_1</tonode> <toport>rve_size</toport>
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>rve_size</fromport>
-      <tonode>fdvgrid</tonode> <toport>rve_size</toport>
+      <tonode>pygmee_v2</tonode> <toport>rve_size</toport>
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>rve_size</fromport>
-      <tonode>benhur</tonode> <toport>rve_size</toport>
+      <tonode>fdvgrid</tonode> <toport>rve_size</toport>
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>rve_size</fromport>
-      <tonode>aster_s_polymers_st_1</tonode> <toport>rve_size</toport>
+      <tonode>benhur</tonode> <toport>rve_size</toport>
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>finesse</fromport>
-      <tonode>fdvgrid</tonode> <toport>finesse</toport>
+      <tonode>aster_s_polymers_st_1</tonode> <toport>finesse</toport>
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>finesse</fromport>
@@ -225,15 +225,15 @@ component_gmsh_post(result_gmsh)
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>finesse</fromport>
-      <tonode>aster_s_polymers_st_1</tonode> <toport>finesse</toport>
+      <tonode>fdvgrid</tonode> <toport>finesse</toport>
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>lambda_I</fromport>
-      <tonode>fdvgrid</tonode> <toport>lambda_I</toport>
+      <tonode>aster_s_polymers_st_1</tonode> <toport>lambda_I</toport>
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>lambda_I</fromport>
-      <tonode>aster_s_polymers_st_1</tonode> <toport>lambda_I</toport>
+      <tonode>fdvgrid</tonode> <toport>lambda_I</toport>
    </datalink>
    <datalink control="false">
       <fromnode>init</fromnode> <fromport>lambda_M</fromport>
@@ -253,15 +253,15 @@ component_gmsh_post(result_gmsh)
    </datalink>
    <datalink control="false">
       <fromnode>env</fromnode> <fromport>study_name</fromport>
-      <tonode>init</tonode> <toport>study_name</toport>
+      <tonode>fdvgrid</tonode> <toport>study_name</toport>
    </datalink>
    <datalink control="false">
       <fromnode>env</fromnode> <fromport>study_name</fromport>
-      <tonode>fdvgrid</tonode> <toport>study_name</toport>
+      <tonode>benhur</tonode> <toport>study_name</toport>
    </datalink>
    <datalink control="false">
       <fromnode>env</fromnode> <fromport>study_name</fromport>
-      <tonode>benhur</tonode> <toport>study_name</toport>
+      <tonode>init</tonode> <toport>study_name</toport>
    </datalink>
    <datalink control="false">
       <fromnode>env</fromnode> <fromport>study_name</fromport>
@@ -299,12 +299,12 @@ component_gmsh_post(result_gmsh)
       <tonode>benhur</tonode><toport>file_inclusions</toport>
       <value><string></string></value>
    </parameter>
-   <presentation name="pygmee_v2" x="583" y="470.25" width="158" height="279" expanded="1" expx="0" expy="0" expWidth="158" expHeight="279" shownState="0"/>
-   <presentation name="init" x="273" y="199.75" width="158" height="306" expanded="1" expx="0" expy="0" expWidth="158" expHeight="306" shownState="0"/>
-   <presentation name="fdvgrid" x="869" y="80.25" width="158" height="225" expanded="1" expx="0" expy="0" expWidth="158" expHeight="225" shownState="0"/>
+   <presentation name="aster_s_polymers_st_1" x="1132" y="271.75" width="158" height="252" expanded="1" expx="1132" expy="271.75" expWidth="158" expHeight="252" shownState="0"/>
    <presentation name="benhur" x="869" y="510.25" width="158" height="171" expanded="1" expx="0" expy="0" expWidth="158" expHeight="171" shownState="0"/>
-   <presentation name="env" x="9" y="301.25" width="158" height="117" expanded="1" expx="0" expy="0" expWidth="158" expHeight="117" shownState="0"/>
-   <presentation name="aster_s_polymers_st_1" x="1133" y="271.75" width="158" height="252" expanded="1" expx="0" expy="0" expWidth="158" expHeight="252" shownState="0"/>
+   <presentation name="fdvgrid" x="869" y="80.25" width="158" height="225" expanded="1" expx="0" expy="0" expWidth="158" expHeight="225" shownState="0"/>
    <presentation name="gmsh_post" x="1397.25" y="373.25" width="158" height="63" expanded="1" expx="0" expy="0" expWidth="158" expHeight="63" shownState="0"/>
+   <presentation name="env" x="9" y="301.25" width="158" height="117" expanded="1" expx="0" expy="0" expWidth="158" expHeight="117" shownState="0"/>
+   <presentation name="pygmee_v2" x="583" y="470.25" width="158" height="279" expanded="1" expx="0" expy="0" expWidth="158" expHeight="279" shownState="0"/>
+   <presentation name="init" x="273" y="199.75" width="158" height="306" expanded="1" expx="0" expy="0" expWidth="158" expHeight="306" shownState="0"/>
    <presentation name="__ROOT__" x="0" y="0" width="1559.25" height="753.25" expanded="1" expx="0" expy="0" expWidth="1559.25" expHeight="753.25" shownState="0"/>
 </proc>
index 82a7c10f4561d0e7ffb6eb7909c11c55badc23a6..e4230768384c3eaa302d7beb1f409eed3070b4d0 100644 (file)
@@ -123,7 +123,7 @@ class component_benhur(component_template) :
 
     def __call__(self, mesh_size, rve_size, inclusion_file, name_scheme, path_study):
     #------------------------------------------------------------------------------
-       return (self,result_mesh, self.result_log)
+       return (self.result_mesh, self.result_log)
 
 
 #----------------------------------------------------------
index f1bb0b262e0435d3118e7f4bec770adc76adc647..395a16d44120140c94dc6d67b0319188ce62e058 100644 (file)
@@ -606,7 +606,8 @@ class Cuve2dgGenerator(PythonGenerator):
        s=PythonGenerator.generMCSIMP(self,obj)
        return s
 
-   def writeCuve2DG(self, filename):
+   def writeDefault(self, fn):
+      filename = fn[:fn.rfind(".")] + '.don'
       print "je passe dans writeCuve2DG"
       self.genereTexteCuve()
       f = open( filename, 'wb')
index 0e72d01a3dc7047b07a04b402dea6993b75fde52..1a7bfbac18044e56db2695edf5bdf89eeda6e508 100644 (file)
@@ -83,7 +83,6 @@ class MapGenerator(PythonGenerator):
       return text
 
    def generRUN(self,obj,format='brut',config=None,):
-      print 'generRUN dans generator_map'
       self.initialise(config)
       text=PythonGenerator.gener(self,obj,format)
       for elt in self.listeCODE:
@@ -113,14 +112,8 @@ class MapGenerator(PythonGenerator):
                 fct=getattr(self.monSchema, codeYACS)
                 fct(self.proc,dico)
                 
-      today = str(date.today())
-      today = today.replace('-', '')
-      today+="-"+time.strftime("%H%M%S", time.localtime())
-
-      print "PATH_STUDY =", config.PATH_STUDY
-      nomFichier=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"_"+today+".xml"
+      print str(nomFichier)
       self.monSchema.write_yacs_proc(self.proc,str(nomFichier))
-      print "YACS xml output : ",nomFichier
 
    def generePythonMap(self,execution) :
       '''
index e743d6ec9e80b1b525287839941d5fffb22fda34..6f2312a13f56bc1bb256200352d6fe38203a2dbe 100644 (file)
@@ -125,7 +125,8 @@ class OpenturnsGenerator(PythonGenerator):
       else :
          self.texteSTD="Il y a un pb a la Creation du STD"
 
-   def writeOpenturnsSTD(self, filename):
+   def writeDefault(self, fn):
+      fileSTD = fn[:fn.rfind(".")] + '.py'
       f = open( str(filename), 'wb')
       f.write( self.texteSTD )
       f.close()
index 33923becd694dfbbcaca6f1b6247c667b10e2790..2dfd61ad0508caffb6c20a10b23b29e7213715a8 100644 (file)
@@ -129,13 +129,14 @@ class OpenturnsGenerator(PythonGenerator):
        print "dictMCVal", self.dictMCVal, "dictVariables", self.dictVariables
        MonBaseGenerateur=Generateur(self.appli,self.dictMCVal, [], {} ,self.dictVariables)
        MonGenerateur=MonBaseGenerateur.getXMLGenerateur()
-       #try :
-       if 1== 1 :
+       try :
+       #if 1== 1 :
           self.wrapperXML=MonGenerateur.CreeXML()
-       #except :
-       else :
+       except :
+       #else :
          self.wrapperXML=None
 
-   def writeOpenturnsXML(self, filename):
-      self.wrapperXML.writeFile( str(filename) )
+   def writeDefault(self, filename):
+      fileXML = fn[:fn.rfind(".")] + '.xml'
+      self.wrapperXML.writeFile( fileXML )