~ubuntu-branches/ubuntu/saucy/pyacidobasic/saucy

« back to all changes in this revision

Viewing changes to .pc/debian-changes-0.1-3/becherlistwidget.py

  • Committer: Bazaar Package Importer
  • Author(s): Georges Khaznadar
  • Date: 2010-08-15 19:34:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100815193400-ywmgp5v7hv0dhexm
Tags: 0.1-6
* fixed the versionless GPL reference
* upgraded Standards-Version to 3.9.1
* first release to Debian. Closes: #593135

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#-*- coding: utf-8 -*-
 
2
 
 
3
 
 
4
licence="""
 
5
    file becherlistwidget.py: part of the package pyacidobasic version %s:
 
6
 
 
7
    Copyright (C) 2010 Georges Khaznadar <georgesk@ofset.org>
 
8
 
 
9
    This program is free software: you can redistribute it and/or modify
 
10
    it under the terms of the GNU General Public License as published by
 
11
    the Free Software Foundation, either version 3 of the License, or
 
12
    (at your option) any later version.
 
13
 
 
14
    This program is distributed in the hope that it will be useful,
 
15
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
    GNU General Public License for more details.
 
18
 
 
19
    You should have received a copy of the GNU General Public License
 
20
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
"""
 
22
 
 
23
from PyQt4.QtCore import *
 
24
from PyQt4.QtGui import *
 
25
from prelevement import concentrationVolumePrelevement
 
26
 
 
27
class BecherListWidget(QListWidget):
 
28
    def __init__(self,parent):
 
29
        QListWidget.__init__(self,parent)
 
30
        self.contenu=[]
 
31
 
 
32
    def renseigneParametres(self,ab):
 
33
        """
 
34
        Renseigne les paramètres manquants pour l'acide/base ajouté
 
35
        """
 
36
        ab.c, ab.v=concentrationVolumePrelevement(ab.nom)
 
37
 
 
38
    def vide(self):
 
39
        """
 
40
        Supprime les contenus de la liste
 
41
        """
 
42
        for r in range(self.count()):
 
43
            it=self.takeItem(0)
 
44
            del it
 
45
        self.contenu=[]
 
46
 
 
47
    def findMainWindow(self):
 
48
        """
 
49
        trouve la fenêtre principale
 
50
        """
 
51
        for t in QApplication.topLevelWidgets():
 
52
            if len(t.windowTitle())>0:
 
53
                return t
 
54
        return None
 
55
        
 
56
    def dropEvent(self, event):
 
57
        QListWidget.dropEvent(self, event)
 
58
        for r in range (self.count()):
 
59
            nom=self.item(r).text()
 
60
            for ab in self.listeAcidesBases:
 
61
                trouve=False
 
62
                if ab.nom.toUtf8()==nom.toUtf8():
 
63
                    newAb=ab.copie()
 
64
                    trouve=True
 
65
                    break
 
66
            if trouve:
 
67
                self.renseigneParametres(newAb)
 
68
                self.contenu.append(newAb)
 
69
                it=self.takeItem(r)
 
70
                del it
 
71
                self.insertItem(r,self.nouveauTexte(newAb))
 
72
        # on envoie un signal pour dire qu'il faut tracer les courbes
 
73
        QApplication.postEvent(self.findMainWindow(), QEvent(QEvent.User))
 
74
 
 
75
    def nouveauTexte(self,ab):
 
76
        """
 
77
        Le nouveau texte à afficher concernent l'acide/base
 
78
        @param ab : l'acide/base à considérer
 
79
        """
 
80
        return "%s %s mol/L, %s mL" %(ab.nom,ab.c,ab.v)
 
81
 
 
82
    def chargeNette(self,pH):
 
83
        """
 
84
        Renvoie la charge électrique des produits mis dans le bécher
 
85
        en fonction du pH, compte non tenu des ions H+ et de ce qui vient
 
86
        de la burette. UNité du résultat : Faraday
 
87
        @param pH, le pH
 
88
        """
 
89
        charge=0.0
 
90
        for ab in self.contenu:
 
91
            charge+=ab.chargeNette(pH)
 
92
        return charge
 
93
 
 
94
    def chargeEau(self,pH):
 
95
        """
 
96
        renvoie la charge électrique porté par les protons et les ions
 
97
        hydroxyde, en fonction du pH
 
98
        @param pH le pH
 
99
        """
 
100
        v=0.0
 
101
        for ab in self.contenu:
 
102
            v+=ab.v
 
103
        return (10**(-pH)-10**(pH-14))*v*1e-3
 
104
 
 
105
    def charge(self, pH):
 
106
        """
 
107
        Renvoie la charge électrique totale, en fonction du pH
 
108
        @param pH le pH
 
109
        """
 
110
        return self.chargeNette(pH) + self.chargeEau(pH)