Salome HOME
PyQt4/PyQt5 support.
[modules/smesh.git] / src / Tools / Verima / Base / tableGroupeRatios.py
1 from qtsalome import QSqlQuery
2 from tableDeBase import TableDeBase
3
4 class TableGroupeRatios (TableDeBase):
5       def __init__(self):
6           TableDeBase.__init__(self,"GroupesRatios")
7           self.setField(('Maillage','Version','Groupe','RatioMax','RatioMin','Quartile1','Mediane','Quartile3','Moyenne'))
8           self.setTypeField(('int','int','str','float','float','float','float','float','float'),('idMaillage','idVersion','Groupe'))
9
10       def createSqlTable(self):
11           query=QSqlQuery()
12
13           texteQuery ="create table GroupesRatios(idMaillage int, idVersion int,  Groupe varchar(40),"
14           texteQuery+="RatioMax float, RatioMin float, "
15           texteQuery+="Q1 float,"
16           texteQuery+="Mediane float,"
17           texteQuery+="Q3 float,"
18           texteQuery+="Moyenne float,"
19           texteQuery+="foreign key (idMaillage) references Maillages(id)," 
20           texteQuery+="foreign key (idVersion) references Versions(id)," 
21           texteQuery+="foreign key (Groupe) references GroupesRef(nomGroupe)," 
22           texteQuery+="primary key (idMaillage,idVersion,Groupe));"
23           print "Creation de TableGroupeRatios : " , query.exec_(texteQuery)
24
25       def getVal(self,idMaillage, idVersion, Groupe, Entite):
26           query=QSqlQuery()
27           texteQuery ='select '+ str(Entite) + ' from GroupesRatios where idMaillage='+str(idMaillage)
28           texteQuery+=' and  idVersion='+str(idVersion)
29           texteQuery+=" and Groupe='" + str(Groupe) +"';"
30           query.exec_(texteQuery)
31           nb=0
32           val=0                          # Valeur si l enregistrement n existe pas
33           while (query.next()) :
34               val=query.value(0).toFloat()[0]
35               nb=nb+1
36           if nb > 1 : print "Double valeur de Reference dans la table des mailles"
37           return val
38