Salome HOME
Copyright update 2021
[modules/smesh.git] / src / Tools / Verima / Base / tableGroupeTailles.py
1 # Copyright (C) 2014-2021  EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from qtsalome import QSqlQuery
21 from Base.tableDeBase import TableDeBase
22
23 class TableGroupeTailles (TableDeBase):
24       def __init__(self):
25           TableDeBase.__init__(self,"GroupeTailles")
26           self.setField(('Maillage','Version','Groupe','TailleMax','TailleMin','Quartile1','Mediane','Quartile3','Moyenne'))
27           self.setTypeField(('int','int','str','float','float','float','float','float','float'),('idMaillage','idVersion'))
28
29       def createSqlTable(self):
30           query=QSqlQuery()
31
32           texteQuery ="create table GroupeTailles(idMaillage int, idVersion int, "
33           texteQuery+="Groupe varchar(40),TailleMax float, TailleMin float, "
34           texteQuery+="Q1 float, "
35           texteQuery+="Mediane float, "
36           texteQuery+="Q3 float, "
37           texteQuery+="Moyenne float, "
38           texteQuery+="foreign key (idMaillage) references Maillages(id)," 
39           texteQuery+="foreign key (idVersion) references Versions(id)," 
40           texteQuery+="foreign key (Groupe) references GroupesRef(nomGroupe),"
41           texteQuery+="primary key (idMaillage,idVersion,Groupe));"
42
43           print("Creation de TableGroupeTailles : " , query.exec_(texteQuery))
44
45       def getVal(self,idMaillage, idVersion, Groupe,  Entite):
46           query=QSqlQuery()
47           texteQuery ='select '+ str(Entite) + ' from GroupeTailles where idMaillage='+str(idMaillage)
48           texteQuery+=' and  idVersion='+str(idVersion)
49           texteQuery+=" and Groupe='" + str(Groupe) +"';"
50           query.exec_(texteQuery)
51           nb=0
52           val=0                          # Valeur si l enregistrement n existe pas
53           while (query.next()) :
54               val=query.value(0).toFloat()[0]
55               nb=nb+1
56           if nb > 1 : print("Double valeur de Reference dans la table des tailles")
57           return val
58