]> SALOME platform Git repositories - tools/eficas.git/blob - Aster/Cata/Utilitai/courbes.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Aster / Cata / Utilitai / courbes.py
1 #@ MODIF courbes Utilitai  DATE 14/09/2004   AUTEUR MCOURTOI M.COURTOIS 
2 # -*- coding: iso-8859-1 -*-
3 #            CONFIGURATION MANAGEMENT OF EDF VERSION
4 # ======================================================================
5 # COPYRIGHT (C) 1991 - 2004  EDF R&D                  WWW.CODE-ASTER.ORG
6 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY  
7 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY  
8 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR     
9 # (AT YOUR OPTION) ANY LATER VERSION.                                                  
10 #                                                                       
11 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT   
12 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF            
13 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU      
14 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.                              
15 #                                                                       
16 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE     
17 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,         
18 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.        
19 # ======================================================================
20
21 #==================================================
22 # fonction "COURBES"
23 # usage : permet de tracer des courbes en interactif
24 # avec XMGRACE ou dans un fichier postscript
25 #==================================================
26
27 import Stanley
28 from Stanley import xmgrace
29 from Stanley import as_courbes
30
31 def COURBES(listcourb,titre=' ',soustitre=' ',legx=' ',legy=' ',bornex=None,borney=None,fichier=None):
32
33 # ARGUMENTS 
34
35 # listcourb : tuple de courbes, chaque courbe etant definie soit par 
36 #             (TABLE1, NOM_PARA_X, TABLE2, NOM_PARA_Y, LEGENDE)
37 # soit par :
38 #             (FONCTION,LEGENDE)
39 # titre et sous_titre : facultatifs, titre et sous-tritre du graphique
40 # legx, legy          : facultatifs, legendes des axes
41 # bornex, borney      : facultatifs, bornes sur les axes
42 # fichier             : facultatif : sortie au format postscript si present
43 #
44 # exemples  d'appel :
45 #--------------------
46 # courb1=(SYYPRT,'ABSC_CURV',SYYPRT,'SIYY','PRT')
47 # courb2=(SYYMLC10,'ABSC_CURV',SYYMLC10,'SIYY','MLC10')
48 # courb3=(SYYML100,'ABSC_CURV',SYYML100,'SIYY','MLC100')
49 # listcourb=(courb1,courb2,courb3)
50 # COURBES(listcourb,titre='Plaque trouee',legx='Abcisses curvilignes',legy='Contraintes (MPa)',bornex=(0,100),borney=(500,1000))
51 # fonc1=(F1,'F_PRT')
52 # fonc2=(F2,'F_MLC10')
53 # fonc3=(F3,'F_MLC100')
54 # listfonc=(fonc1,fonc2,fonc3)
55 # COURBES(listfonc,titre='Fonctions')
56 # postscript
57 # COURBES(listfonc,titre='Plaque trouee',fichier='./fort.24')
58 #--------------------------------------------------------------
59
60 # initialisation du trace de  courbes
61
62   if (fichier!=None):
63      graphe=xmgrace.Xmgr(10,' -hardcopy -nosafe')
64      print "Nombre de courbes  ",len(listcourb)," sur le fichier :",fichier
65
66   else:
67      graphe=xmgrace.Xmgr(10,' -noask')
68      print "Nombre de courbes  ",len(listcourb)
69
70   graphe.Nouveau_graphe()
71
72 # dimensionnement des axes 
73   if bornex != None : 
74      xmin=list(bornex)[0]
75      xmax=list(bornex)[1]
76      ctest1 = as_courbes.Courbe()
77      ctest1.x=[xmin,xmax]
78      ctest1.y=[0.0,0.0]
79      graphe.Courbe(ctest1)
80
81   if borney != None : 
82      ymin=list(borney)[0]
83      ymax=list(borney)[1]
84      ctest2 = as_courbes.Courbe()
85      ctest2.x=[0.0,0.0]
86      ctest2.y=[ymin,ymax]
87      graphe.Courbe(ctest2)
88
89   if titre != None :
90      if soustitre != None :
91         graphe.Titre(titre,soustitre)
92      else :
93         graphe.Titre(titre,' ')
94      
95   if legx != None :
96      graphe.Axe_x(legx)
97      
98   if legy != None :
99      graphe.Axe_y(legy)
100
101   k = 0
102        
103   for courbi in listcourb:
104      sigi = as_courbes.Courbe()
105      
106      try :
107         # cas d une table
108         sigi.Lire_x(courbi[0],courbi[1])
109         sigi.Lire_y(courbi[2],courbi[3])
110         legende=courbi[4]
111      except :
112         # cas d une fonction
113         sigi.x,sigi.y=courbi[0].Valeurs()
114         legende=courbi[1]
115
116      graphe.Courbe(sigi,legende)
117      graphe.Send('WITH G'+repr(graphe.gr_act))
118      graphe.Send('S' + str(k) + ' SYMBOL ' + str(k+2))
119      graphe.Send('S' + str(k) + ' SYMBOL SIZE 0.5')
120      graphe.Send('S' + str(k) + ' SYMBOL COLOR '+str(k+2))
121      graphe.Send('S' + str(k) + ' LINE COLOR '+str(k+2))
122      k = k + 1
123      graphe.Send('REDRAW')
124   
125   if (fichier!=None):
126      graphe.Sortie_EPS(fichier)
127      graphe.Fermer()
128   else:
129      graphe.Attendre()
130
131   k=0
132
133 #===========================================
134
135