~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to gui/Pages/MatisseNetworkView.py

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-01 17:43:32 UTC
  • mto: (6.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20111101174332-tl4vk45no0x3emc3
Tags: upstream-2.1.0
ImportĀ upstreamĀ versionĀ 2.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: iso-8859-1 -*-
2
 
#
3
 
#-------------------------------------------------------------------------------
4
 
#
5
 
#     This file is part of the Code_Saturne User Interface, element of the
6
 
#     Code_Saturne CFD tool.
7
 
#
8
 
#     Copyright (C) 1998-2009 EDF S.A., France
9
 
#
10
 
#     contact: saturne-support@edf.fr
11
 
#
12
 
#     The Code_Saturne User Interface is free software; you can redistribute it
13
 
#     and/or modify it under the terms of the GNU General Public License
14
 
#     as published by the Free Software Foundation; either version 2 of
15
 
#     the License, or (at your option) any later version.
16
 
#
17
 
#     The Code_Saturne User Interface is distributed in the hope that it will be
18
 
#     useful, but WITHOUT ANY WARRANTY; without even the implied warranty
19
 
#     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 
#     GNU General Public License for more details.
21
 
#
22
 
#     You should have received a copy of the GNU General Public License
23
 
#     along with the Code_Saturne Kernel; if not, write to the
24
 
#     Free Software Foundation, Inc.,
25
 
#     51 Franklin St, Fifth Floor,
26
 
#     Boston, MA  02110-1301  USA
27
 
#
28
 
#-------------------------------------------------------------------------------
29
 
 
30
 
"""
31
 
This module contains the following classes and function:
32
 
- MatisseNetworkView
33
 
"""
34
 
 
35
 
#-------------------------------------------------------------------------------
36
 
# Standard modules
37
 
#-------------------------------------------------------------------------------
38
 
 
39
 
import logging
40
 
 
41
 
#-------------------------------------------------------------------------------
42
 
# Third-party modules
43
 
#-------------------------------------------------------------------------------
44
 
 
45
 
from PyQt4.QtCore import *
46
 
from PyQt4.QtGui  import *
47
 
 
48
 
#-------------------------------------------------------------------------------
49
 
# Application modules import
50
 
#-------------------------------------------------------------------------------
51
 
 
52
 
from Base.Toolbox import GuiParam
53
 
from MatisseNetworkForm import Ui_MatisseNetworkForm
54
 
import Base.QtPage as QtPage
55
 
import Pages.MatisseTypeModel as MatisseType
56
 
import Pages.MatisseGeomModel as MatisseGeom
57
 
from Pages.MatisseNetworkModel import MatisseNetworkModel
58
 
 
59
 
#-------------------------------------------------------------------------------
60
 
# log config
61
 
#-------------------------------------------------------------------------------
62
 
 
63
 
logging.basicConfig()
64
 
log = logging.getLogger("MatisseNetworkView")
65
 
log.setLevel(GuiParam.DEBUG)
66
 
 
67
 
#-------------------------------------------------------------------------------
68
 
# Main class
69
 
#-------------------------------------------------------------------------------
70
 
 
71
 
class MatisseNetworkView(QWidget, Ui_MatisseNetworkForm):
72
 
    """
73
 
    """
74
 
 
75
 
    def __init__(self, parent, case):
76
 
        """
77
 
        Constructor
78
 
        """
79
 
        QWidget.__init__(self, parent)
80
 
 
81
 
        Ui_MatisseNetworkForm.__init__(self)
82
 
        self.setupUi(self)
83
 
 
84
 
        self.case = case
85
 
 
86
 
        self.model = MatisseNetworkModel(self.case)
87
 
 
88
 
        model_geom = MatisseGeom.MatisseGeomModel(self.case)
89
 
##         self.lineStep = model_geom.getMatisseGeomDoubleVar('ptrres')
90
 
##         self.rowStep = model_geom.getMatisseGeomDoubleVar('plgres')
91
 
        self.heightStep = model_geom.getMatisseGeomDoubleVar('epchel')
92
 
##         self.lineMax = model_geom.getMatisseGeomDoubleVar('nptran')
93
 
##         self.rowMax = model_geom.getMatisseGeomDoubleVar('nplgrs')
94
 
##         self.heightMax = model_geom.getMatisseGeomDoubleVar('nchest')
95
 
 
96
 
        model_mat_type = MatisseType.MatisseTypeModel(self.case)
97
 
        self.alveoStat = model_mat_type.node_alveo['status']
98
 
 
99
 
 
100
 
        # Create the Page layout.
101
 
        self.widgetLine.initWidget(self.case, "network_line")
102
 
        self.widgetRow.initWidget(self.case, "network_row")
103
 
        # Connections
104
 
        self.connect(self.lineEdit_hreso1,
105
 
                     SIGNAL("textChanged(const QString &)"),
106
 
                     self.getMatisseNetworkVar_hreso1)
107
 
 
108
 
        self.connect(self.lineEdit_hreso2,
109
 
                     SIGNAL("textChanged(const QString &)"),
110
 
                     self.getMatisseNetworkVar_hreso2)
111
 
 
112
 
        self.connect(self.lineEdit_hplen,
113
 
                     SIGNAL("textChanged(const QString &)"),
114
 
                     self.getMatisseNetworkVar_hplen)
115
 
 
116
 
        # Validators
117
 
        validator_hreso1 = QtPage.DoubleValidator(
118
 
            self.lineEdit_hreso1, "validator_hreso1")
119
 
 
120
 
        validator_hreso2 = QtPage.DoubleValidator(
121
 
            self.lineEdit_hreso2, "validator_hreso2")
122
 
 
123
 
        validator_hplen = QtPage.DoubleValidator(
124
 
            self.lineEdit_hplen, "validator_hplen")
125
 
 
126
 
        self.lineEdit_hreso1.setValidator(validator_hreso1)
127
 
        self.lineEdit_hreso2.setValidator(validator_hreso2)
128
 
        self.lineEdit_hplen.setValidator(validator_hplen)
129
 
 
130
 
        # initialize
131
 
 
132
 
        invStat = 'on'
133
 
        if self.alveoStat == 'on' :
134
 
            invStat = 'off'
135
 
 
136
 
        self.nbcellreso1 = self.model.getMatisseNetworkDoubleVar('nbcellreso1')
137
 
        self.nbcellreso2 = self.model.getMatisseNetworkDoubleVar('nbcellreso2')
138
 
        self.nbcellplen  = self.model.getMatisseNetworkDoubleVar('nbcellplen')
139
 
 
140
 
        self.lineEdit_hreso1.setText(QString(str(self.nbcellreso1)))
141
 
        self.lineEdit_hreso2.setText(QString(str(self.nbcellreso2)))
142
 
        self.lineEdit_hplen.setText(QString(str(self.nbcellplen)))
143
 
 
144
 
        self.hreso1 = self.heightStep * self.nbcellreso1
145
 
        self.hreso2 = self.heightStep * self.nbcellreso2
146
 
        self.hplen  = self.heightStep * self.nbcellplen
147
 
 
148
 
        self.model.setMatisseNetworkVar('hreso1', self.hreso1)
149
 
        self.model.setMatisseNetworkVar('hreso2', self.hreso2)
150
 
        self.model.setMatisseNetworkVar('hplen',  self.hplen)
151
 
 
152
 
        self.lineEdit2_1.setText(QString(str(self.hreso1)))
153
 
        self.lineEdit2_2.setText(QString(str(self.hreso2)))
154
 
        self.lineEdit2_3.setText(QString(str(self.hplen)))
155
 
 
156
 
 
157
 
        if invStat == "off":
158
 
            self.lineEdit_hreso1.setDisabled(True)
159
 
 
160
 
        if self.alveoStat == "off":
161
 
            self.lineEdit_hreso2.setDisabled(True)
162
 
            self.lineEdit_hplen.setDisabled(True)
163
 
 
164
 
 
165
 
        self.lineEdit2_1.setDisabled(True)
166
 
        self.lineEdit2_2.setDisabled(True)
167
 
        self.lineEdit2_3.setDisabled(True)
168
 
 
169
 
 
170
 
    def getMatisseNetworkVar_hreso1(self):
171
 
        """
172
 
        Input thermiclic load variable.
173
 
        """
174
 
        self.nbcellreso1, ok = self.lineEdit_hreso1.text().toFloat()
175
 
        self.model.setMatisseNetworkVar('nbcellreso1', self.nbcellreso1)
176
 
        val = float(self.nbcellreso1) * self.heightStep
177
 
        self.model.setMatisseNetworkVar('hreso1', val)
178
 
 
179
 
 
180
 
    def getMatisseNetworkVar_hreso2(self):
181
 
        """
182
 
        Input thermiclic load variable.
183
 
        """
184
 
        self.nbcellreso2, ok = self.lineEdit_hreso2.text().toFloat()
185
 
        self.model.setMatisseNetworkVar('nbcellreso2', self.nbcellreso2)
186
 
        val = float(self.nbcellreso2) * self.heightStep
187
 
        self.model.setMatisseNetworkVar('hreso2', val)
188
 
 
189
 
 
190
 
    def getMatisseNetworkVar_hplen(self):
191
 
        """
192
 
        Input thermiclic load variable.
193
 
        """
194
 
        self.nbcellplen, ok = self.lineEdit_hplen.text().toFloat()
195
 
        self.model.setMatisseNetworkVar('nbcellplen', self.nbcellplen)
196
 
        val = float(self.nbcellplen) * self.heightStep
197
 
        self.model.setMatisseNetworkVar('hplen', val)
198
 
 
199
 
 
200
 
    def tr(self, text):
201
 
        """
202
 
        Translation
203
 
        """
204
 
        return text
205
 
 
206
 
 
207
 
#-------------------------------------------------------------------------------
208
 
# Testing part
209
 
#-------------------------------------------------------------------------------
210
 
 
211
 
 
212
 
if __name__ == "__main__":
213
 
    pass
214
 
 
215
 
 
216
 
#-------------------------------------------------------------------------------
217
 
# End
218
 
#-------------------------------------------------------------------------------
 
 
b'\\ No newline at end of file'