1
# -*- coding: iso-8859-1 -*-
3
#-------------------------------------------------------------------------------
5
# This file is part of the Code_Saturne User Interface, element of the
6
# Code_Saturne CFD tool.
8
# Copyright (C) 1998-2009 EDF S.A., France
10
# contact: saturne-support@edf.fr
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.
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.
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
28
#-------------------------------------------------------------------------------
31
This module contains the following classes and function:
35
#-------------------------------------------------------------------------------
37
#-------------------------------------------------------------------------------
41
#-------------------------------------------------------------------------------
43
#-------------------------------------------------------------------------------
45
from PyQt4.QtCore import *
46
from PyQt4.QtGui import *
48
#-------------------------------------------------------------------------------
49
# Application modules import
50
#-------------------------------------------------------------------------------
52
from Base.Toolbox import GuiParam
53
from MatisseHydrauForm import Ui_MatisseHydrauForm
54
import Base.QtPage as QtPage
55
import Pages.MatisseTypeModel as MatisseType
56
from MatisseHydrauModel import MatisseHydrauModel
58
#-------------------------------------------------------------------------------
60
#-------------------------------------------------------------------------------
63
log = logging.getLogger("MatisseHydrauView")
64
log.setLevel(GuiParam.DEBUG)
66
#-------------------------------------------------------------------------------
68
#-------------------------------------------------------------------------------
70
class StandardItemModelHydrau(QStandardItemModel):
72
def __init__(self, case):
75
QStandardItemModel.__init__(self)
78
self.model = MatisseHydrauModel(self.case)
79
self.model_mat_type = MatisseType.MatisseTypeModel(self.case)
81
self.setColumnCount(4)
112
# association between variables and tag
115
['icofor', self.icofor],
116
['iconlg', self.iconlg],
117
['debmas', self.debmas],
118
['pdccha', self.pdccha],
119
['pdcfch', self.pdcfch],
120
['dhchea', self.dhchea],
121
['sdchea', self.sdchea],
122
['pdcche', self.pdcche],
123
['pdccch', self.pdccch],
124
['dhches', self.dhches],
125
['sdches', self.sdches],
126
['pdcalg', self.pdcalg],
127
['pdcatv', self.pdcatv],
128
['argamt', self.argamt],
129
['pdcslg', self.pdcslg],
130
['pdcstv', self.pdcstv],
131
['argavl', self.argavl],
132
['amppdc', self.amppdc],
133
['dhalve', self.dhalve],
134
['dpvent', self.dpvent]]
137
self.texts['icofor'] = (1, self.tr("Forced hydraulic air circulation regime"))
138
self.texts['iconlg'] = (2, self.tr("Canister network in row (staggered arrangement otherwise)"))
139
self.texts['debmas'] = (3, self.tr("Forced circulation air flow"), "Kg/s")
140
self.texts['pdccha'] = (4, self.tr("Inlet chimney diffuser headloss"))
141
self.texts['pdcfch'] = (5, self.tr("Inlet chimney filter headloss"))
142
self.texts['dhchea'] = (6, self.tr("Inlet chimney hydraulic diameter"), "m")
143
self.texts['sdchea'] = (7, self.tr("Inlet chimney flow area"), "m<sup>2</sup>")
144
self.texts['pdcche'] = (8, self.tr("Outlet chimney diffuser headloss"))
145
self.texts['pdccch'] = (9, self.tr("Outlet chimney valve headloss"))
146
self.texts['dhches'] = (10, self.tr("Outlet chimney hydraulic diameter"), "m")
147
self.texts['sdches'] = (11, self.tr("Outlet chimney flow area"), "m<sup>2</sup>")
148
self.texts['pdcalg'] = (12, self.tr("Upstream inlet door longitudinal headloss"))
149
self.texts['pdcatv'] = (13, self.tr("Upstream inlet door transversal headloss"))
150
self.texts['argamt'] = (14, self.tr("Upstream register incline angle (degree)"), "<sup>o</sup>")
151
self.texts['pdcslg'] = (16, self.tr("Downstream outlet door longitudinal headloss"))
152
self.texts['pdcstv'] = (17, self.tr("Downstream outlet door transversal headloss"))
153
self.texts['argavl'] = (18, self.tr("Downstream register incline angle (degree)"), "<sup>o</sup>")
154
self.texts['amppdc'] = (20, self.tr("Network headloss amplifying factor"))
155
self.texts['dhalve'] = (23, self.tr("Double jacketed wells hydraulic diameter"), "m")
156
self.texts['dpvent'] = (24, self.tr("Inlet/outlet atmospheric pressure difference"), "Pa")
158
self.rows_disabled = []
160
stat = self.model.getConstrainedConvStatus()
162
if not 2 in self.rows_disabled and stat == "off":
163
self.rows_disabled.append(2)
165
stat = self.model.getInlineContainerNetworkStatus()
169
for variable in self.variables :
170
if variable[0] not in ['icofor', 'iconlg']:
171
val = self.model.getMatisseHydrauDoubleVar(variable[0])
172
self.variables[i][1] = val
174
if variable[0] == 'dhalve' :
175
stat = self.model_mat_type.node_alveo['status']
176
if not i in self.rows_disabled and stat == "off":
177
self.rows_disabled.append(i)
180
self.setRowCount(len(self.variables))
183
def data(self, index, role):
185
if not index.isValid():
188
if role == Qt.DisplayRole:
191
if index.column() == 0:
192
var = self.variables[row][0]
193
num = self.texts[var][0]
196
if index.column() == 1:
197
var = self.variables[row][0]
198
txt = self.texts[var][1]
201
if index.column() == 2:
202
var = self.variables[row][0]
203
val = self.variables[row][1]
206
if index.column() == 3:
207
var = self.variables[row][0]
208
if len(self.texts[var])>2:
209
unit = self.texts[var][2]
212
return QVariant(unit)
214
if role == Qt.CheckStateRole:
216
if index.row() == 0 and index.column() == 2:
217
if self.icofor == "on":
218
return QVariant(Qt.Checked)
220
return QVariant(Qt.Unchecked)
222
if index.row() == 1 and index.column() == 2:
223
if self.iconlg == "on":
224
return QVariant(Qt.Checked)
226
return QVariant(Qt.Unchecked)
231
def flags(self, index):
232
if not index.isValid():
233
return Qt.ItemIsEnabled
234
if index.row() in self.rows_disabled:
235
return Qt.ItemIsSelectable
236
if index.row() in [0,1] and index.column()== 2:
237
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable
238
if index.column() in [0,1,3]:
239
return Qt.ItemIsEnabled | Qt.ItemIsSelectable
241
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable
244
def setData(self, index, value, role):
246
if index.column() == 2:
248
if index.row() == 0: # icofor
249
v, ok = value.toInt()
250
if v == Qt.Unchecked:
252
if not 2 in self.rows_disabled:
253
self.rows_disabled.append(2)
256
if 2 in self.rows_disabled:
257
self.rows_disabled.remove(2)
258
self.model.setConstrainedConvStatus(self.icofor)
260
elif index.row() == 1: # iconlg
261
v, ok = value.toInt()
262
if v == Qt.Unchecked:
266
self.model.setInlineContainerNetworkStatus(self.iconlg)
269
tag = self.variables[index.row()][0]
270
num = self.texts[tag][0]
271
var = self.variables[index.row()][1]
272
v, ok = value.toDouble()
274
self.model.setMatisseHydrauVar(num, v) # ???
276
self.emit(SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"), index, index)
280
#-------------------------------------------------------------------------------
282
#-------------------------------------------------------------------------------
284
class MatisseHydrauView(QWidget, Ui_MatisseHydrauForm):
288
def __init__(self, parent, case):
292
QWidget.__init__(self, parent)
294
Ui_MatisseHydrauForm.__init__(self)
300
# Create the Page layout.
302
self.modelHydrau = StandardItemModelHydrau(self.case)
303
self.tableView.setModel(self.modelHydrau)
304
self.tableView.setAlternatingRowColors(True)
305
self.tableView.resizeColumnsToContents()
306
self.tableView.setShowGrid(False)
316
#-------------------------------------------------------------------------------
318
#-------------------------------------------------------------------------------
321
if __name__ == "__main__":
325
#-------------------------------------------------------------------------------
327
#-------------------------------------------------------------------------------
b'\\ No newline at end of file'