From: Renaud Barate Date: Wed, 11 Jan 2012 13:22:23 +0000 (+0000) Subject: Fix bug when displaying OpenTURNS distributions (sometimes the displayed distribution... X-Git-Tag: LOGILAB~248 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=79516300be6bfa2689e8894ce6370db14446a5d0;p=tools%2Feficas.git Fix bug when displaying OpenTURNS distributions (sometimes the displayed distribution was not the right one) --- diff --git a/InterfaceQT4/compooper.py b/InterfaceQT4/compooper.py index 7993545a..f2527f6a 100644 --- a/InterfaceQT4/compooper.py +++ b/InterfaceQT4/compooper.py @@ -1,10 +1,8 @@ -# -*- coding: utf-8 -*- -import traceback -import string -from PyQt4 import * -from PyQt4.QtGui import * -from PyQt4.QtCore import * - +# -*- coding: iso-8859-1 -*- +import os +import tempfile +from PyQt4.QtGui import QMessageBox, QAction +from PyQt4.QtCore import Qt, SIGNAL from Editeur import Objecttreeitem import browser @@ -45,39 +43,31 @@ class Node(browser.JDCNode, typeNode.PopUpMenuNode): def viewPng(self) : from monPixmap import MonLabelPixmap - fichier=self.appliEficas.getName() - try : - os.remove(fichier) - except : - pass - #try: - if 1: - import generator + import generator + try: g = generator.plugins[self.appliEficas.format_fichier]() g.gener(self.item.object, format='beautifie') stdGener = g.getGenerateur() - if len(g.dictMCLois) != 1: - QMessageBox.warning( - None, - self.appliEficas.trUtf8("Erreur interne"), - self.appliEficas.trUtf8("La PDF de la loi ne peut pas etre affichee."), - self.appliEficas.trUtf8("&Annuler")) - return loi = g.dictMCLois.keys()[0] nomLoi = loi.get_name() - script = stdGener.GraphiquePDF(loi, fichier) + (fd, fichier) = tempfile.mkstemp(prefix = "openturns_graph_", suffix = ".png") + os.close(fd) + chemin = os.path.dirname(fichier) + base = os.path.splitext(os.path.basename(fichier))[0] + script = stdGener.GraphiquePDF(loi, chemin, base) #print script d = {} exec script in d widgetPng=MonLabelPixmap(self.appliEficas,fichier,nomLoi) + os.remove(fichier) widgetPng.show() - #except: - else: + except: QMessageBox.warning( - None, - self.appliEficas.trUtf8("Erreur interne"), - self.appliEficas.trUtf8("La PDF de la loi ne peut pas etre affichee."), - self.appliEficas.trUtf8("&Annuler")) + self.appliEficas, + self.appliEficas.tr("Erreur interne"), + self.appliEficas.tr("La PDF de la loi ne peut pas ĂȘtre affichĂ©e."), + self.appliEficas.tr("&Annuler")) + raise class EtapeTreeItem(Objecttreeitem.ObjectTreeItem): """ La classe EtapeTreeItem est un adaptateur des objets ETAPE du noyau diff --git a/InterfaceQT4/qtEficas.py b/InterfaceQT4/qtEficas.py index b024ac46..72562810 100644 --- a/InterfaceQT4/qtEficas.py +++ b/InterfaceQT4/qtEficas.py @@ -449,11 +449,6 @@ class Appli(Ui_Eficas,QMainWindow): def NewInclude(self): self.viewmanager.newIncludeEditor() - def getName(self): - self.indice=self.indice+1 - texte="tempo"+str(self.indice) - return texte - def cleanPath(self): for pathCode in ('Aster','Carmel3D','Cuve2dg','Openturns_Study','Openturns_Wrapper','MAP'): try: diff --git a/generator/OpenturnsSTD.py b/generator/OpenturnsSTD.py index 56187753..f6b88b50 100644 --- a/generator/OpenturnsSTD.py +++ b/generator/OpenturnsSTD.py @@ -1318,14 +1318,14 @@ class STDGenerateur : - def GraphiquePDF (self, loi, fichier): + def GraphiquePDF (self, loi, chemin, fichier): ''' Produit une image PNG representant la PDF de la loi ''' txt = headerSTD % self.OpenTURNS_path txt += "dist = %s\n" % apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) ) txt += "graph = dist.drawPDF()\n" - txt += "graph.draw( '%s' )\n" % fichier + txt += "graph.draw( '%s', '%s' , 640, 480, GraphImplementation.PNG)\n" % (chemin, fichier) txt += footerSTD return txt