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
#-------------------------------------------------------------------------------
42
#-------------------------------------------------------------------------------
44
#-------------------------------------------------------------------------------
46
from PyQt4.QtCore import *
47
from PyQt4.QtGui import *
49
#-------------------------------------------------------------------------------
50
# Application modules import
51
#-------------------------------------------------------------------------------
53
from Base.Toolbox import GuiParam
55
from MatisseCustomForm import Ui_MatisseCustomForm
56
import Base.QtPage as QtPage
58
import Pages.MatisseTypeModel as MatisseType
59
import Pages.MatisseGeomModel as MatisseGeom
61
from Pages.MatisseRangeDescriptionModel import MatisseRangeDescriptionModel
62
from Pages.MatisseNetworkModel import MatisseNetworkModel
63
from Pages.MatisseThermicModel import MatisseThermicModel
65
#-------------------------------------------------------------------------------
67
#-------------------------------------------------------------------------------
70
log = logging.getLogger("MatisseCustomView")
71
log.setLevel(GuiParam.DEBUG)
73
#-------------------------------------------------------------------------------
74
# StandarItemModel class
75
#-------------------------------------------------------------------------------
79
class StandardItemModelMatisseCustom(QStandardItemModel):
81
QStandardItemModel associated with the QtableView for common Matisse operations.
83
Behavior depends on the value of attribute tagName (self.tagName).
86
def __init__(self, parent, case, tagName, dico):
89
QStandardItemModel.__init__(self)
93
self.tagName = tagName
96
self.setColumnCount(len(self.dico['headers']))
101
def __initXMLModel(self):
104
if self.tagName in ["inlet_range_line", "inlet_range_height",
105
"outlet_range_line", "outlet_range_height",
106
"network_line", "network_row"]:
108
self.default_row = ["default", 0., 0., 0., 0.]
109
self.columns_editable = [0, 1, 2]
110
self.column_step_min = 3
111
self.column_step_max = 4
114
if self.tagName in ["network_line", "network_row"]:
116
self.model = MatisseNetworkModel(self.case)
118
model_geom = MatisseGeom.MatisseGeomModel(self.case)
119
self.lineStep = model_geom.getMatisseGeomDoubleVar('ptrres')
120
self.rowStep = model_geom.getMatisseGeomDoubleVar('plgres')
121
self.heightStep = model_geom.getMatisseGeomDoubleVar('epchel')
122
self.lineMax = model_geom.getMatisseGeomDoubleVar('nptran')
123
self.rowMax = model_geom.getMatisseGeomDoubleVar('nplgrs')
124
self.heightMax = model_geom.getMatisseGeomDoubleVar('nchest')
126
model_mat_type = MatisseType.MatisseTypeModel(self.case)
127
self.alveoStat = model_mat_type.node_alveo['status']
129
elif self.tagName in ["inlet_range_line", "inlet_range_height"]:
131
self.model = MatisseRangeDescriptionModel(self.case, 'inlet_range')
133
model_geom = MatisseGeom.MatisseGeomModel(self.case)
134
self.lineStep = model_geom.getMatisseGeomDoubleVar('ptrres')
135
self.heightStep = model_geom.getMatisseGeomDoubleVar('epchel')
136
self.lineMax = model_geom.getMatisseGeomDoubleVar('nptran')
137
self.heightMax = model_geom.getMatisseGeomDoubleVar('nchest')
139
elif self.tagName in ["outlet_range_line", "outlet_range_height"]:
141
self.model = MatisseRangeDescriptionModel(self.case, 'outlet_range')
143
model_geom = MatisseGeom.MatisseGeomModel(self.case)
144
self.lineStep = model_geom.getMatisseGeomDoubleVar('ptrres')
145
self.heightStep = model_geom.getMatisseGeomDoubleVar('epchel')
146
self.lineMax = model_geom.getMatisseGeomDoubleVar('nptran')
147
self.heightMax = model_geom.getMatisseGeomDoubleVar('nchest')
150
#elif self.tagName in ["thermal_line", "thermal_row", "thermal_height"]:
153
self.areatype = self.dico['areatype']
155
self.default_row = ["default", 0., 0., 0., 0., 0.]
156
self.columns_editable = [0, 1, 2, 3]
157
self.column_step_min = 4
158
self.column_step_max = 5
161
self.model = MatisseThermicModel(self.case)
163
self.model_mat_type = MatisseType.MatisseTypeModel(self.case)
164
model_geom = MatisseGeom.MatisseGeomModel(self.case)
165
self.lineStep = model_geom.getMatisseGeomDoubleVar('ptrres')
166
self.rowStep = model_geom.getMatisseGeomDoubleVar('plgres')
167
self.heightStep = model_geom.getMatisseGeomDoubleVar('epchel')
169
self.lineMax = model_geom.getMatisseGeomDoubleVar('nptran')
170
self.rowMax = model_geom.getMatisseGeomDoubleVar('nplgrs')
171
self.heightMax = model_geom.getMatisseGeomDoubleVar('nchest')
174
self.areatype = self.dico['areatype']
175
if self.areatype == 'line' :
176
self.step = self.lineStep
177
elif self.areatype == 'height' :
178
self.step = self.heightStep
179
elif self.areatype == 'row' :
180
self.step = self.rowStep
183
def __initData(self):
187
if self.tagName in ["inlet_range_line", "inlet_range_height",
188
"outlet_range_line", "outlet_range_height",
189
"network_line", "network_row"]:
191
llabel, lbmin, lbmax = self.model.GetAreas(self.areatype)
194
if ((n != len(lbmin)) or (n != len(lbmax))):
195
print "XML format error : bad definition of <area> "
198
for area in range(0,len(llabel)):
199
row = self.default_row
200
row[0] = llabel[area]
201
row[1] = float(lbmin[area])
202
row[2] = float(lbmax[area])
203
row[self.column_step_min] = self.step * row[1]
204
row[self.column_step_max] = self.step * row[2]
205
self.dataMatisse.append(row)
206
nrows = self.rowCount()
207
self.setRowCount(nrows+1)
209
elif self.tagName in ["thermal_line", "thermal_row", "thermal_height"]:
211
llabel, lbmin, lbmax, lval = self.model.GetAreas(self.areatype)
214
if ((n != len(lbmin)) or (n != len(lbmax)) or (n != len(lval))):
215
print "XML format error : bad definition of <area> "
219
if len(llabel) == 0 :
220
dlabel, dmin, dmax, dval = self.model.DefaultArea(self.areatype)
221
self.model.NewArea(self.areatype, dlabel, dmin, dmax, dval)
222
llabel.append(dlabel)
227
for area in range(0,len(llabel)):
228
row = self.default_row
229
row[0] = llabel[area]
230
row[1] = float(lbmin[area])
231
row[2] = float(lbmax[area])
232
row[3] = float(lval[area])
233
row[self.column_step_min] = self.step * row[1]
234
row[self.column_step_max] = self.step * row[2]
235
self.dataMatisse.append(row)
236
nrows = self.rowCount()
237
self.setRowCount(nrows+1)
240
def data(self, index, role):
241
if not index.isValid():
243
if role == Qt.DisplayRole:
246
return QVariant(self.dataMatisse[row][col])
250
def flags(self, index):
251
if not index.isValid():
252
return Qt.ItemIsEnabled
254
return Qt.ItemIsEnabled | Qt.ItemIsSelectable
257
def headerData(self, section, orientation, role):
258
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
259
return QVariant(self.dico['headers'][section])
263
def setData(self, index, value, role):
264
self.emit(SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"), index, index)
268
def addRow(self, label, sbmin, sbmax, svalue):
270
Add a row in the model.
274
if self.tagName in ["inlet_range_line", "inlet_range_height",
275
"outlet_range_line", "outlet_range_height",
276
"network_line", "network_row"]:
278
bool_create = self.__addRowRangeDescriptionNetwork(label, sbmin, sbmax, self.areatype, self.step)
280
if self.tagName in ["thermal_line", "thermal_row", "thermal_height"]:
282
bool_create = self.__addRowThermal(label, sbmin, sbmax, svalue, self.areatype, self.step)
286
row = self.default_row
290
row[self.column_step_min] = self.step * row[1]
291
row[self.column_step_max] = self.step * row[2]
292
self.dataMatisse.append(row)
293
nrows = self.rowCount()
294
self.setRowCount(nrows+1)
297
def editRow(self, row, new_label, new_bmin, new_bmax, new_value):
299
Edit a row in the model
301
if self.tagName in ["inlet_range_line", "inlet_range_height",
302
"outlet_range_line", "outlet_range_height",
303
"network_line", "network_row"]:
305
[label, sbmin, sbmax, sbmin2, sbmax2] = self.dataMatisse[row]
306
bool_modify = self.__editRangeDescription(new_label, new_bmin, new_bmax,
308
self.areatype, self.step)
310
if self.tagName in ["thermal_line", "thermal_row", "thermal_height"]:
311
[label, sbmin, sbmax, svalue, sbmin2, sbmax2] = self.dataMatisse[row]
312
bool_modify = self.__editRangeThermal(new_label, new_bmin, new_bmax, new_value,
313
label, sbmin, sbmax, svalue,
314
self.areatype, self.step)
320
def deleteRow(self, row):
322
Delete a row in the model.
324
log.debug("deleteRow")
326
if self.tagName in ["inlet_range_line", "inlet_range_height",
327
"outlet_range_line", "outlet_range_height",
328
"network_line", "network_row"]:
330
[label, sbmin, sbmax, sbmin2, sbmax2] = self.dataMatisse[row]
331
bool_cancel = self.__deleteRowRangeDescription(label, sbmin, sbmax, self.areatype)
333
if self.tagName in ["thermal_line", "thermal_row", "thermal_height"]:
334
[label, sbmin, sbmax, svalue, sbmin2, sbmax2] = self.dataMatisse[row]
335
bool_cancel = self.__deleteRowThermal(label, sbmin, sbmax, svalue, self.areatype)
340
del self.dataMatisse[row]
341
nrows = self.rowCount()
342
self.setRowCount(nrows-1)
345
# RangeDescription & Network
346
# --------------------------
348
def __addRowRangeDescriptionNetwork(self, label, sbmin, sbmax, areatype, step):
350
Add a row : test for RangeDescription & Network
352
log.debug("__addRowRangeDescriptionNetwork")
361
title = self.tr("Warning")
362
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
363
QMessageBox.warning(self.parent, title, msg)
366
llabel, lbmin, lbmax = self.model.GetAreas(areatype)
370
if (bmin > bmax) or (bmin < 0):
372
if (areatype == 'line'):
373
if (bmax > self.lineMax) :
375
elif (areatype == 'height'):
376
if (bmax > self.heightMax) :
378
elif (areatype == 'row'):
379
if (bmax > self.rowMax) :
382
for area in range(0,len(llabel)) :
383
if ((label == llabel[area]) and
384
(abs(bmin - float(lbmin[area])) < _EPSILON) and
385
(abs(bmax - float(lbmax[area])) < _EPSILON)):
391
if (((bmin > float(lbmin[area])) and (bmin < float(lbmax[area]))) or
392
((bmax > float(lbmin[area])) and (bmax < float(lbmax[area])))) :
396
#name = self.insertHlist(h, label, sbmin, sbmax, step)
397
self.model.NewArea(areatype, label, bmin, bmax)
399
title = self.tr("Warning")
400
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
401
QMessageBox.warning(self.parent, title, msg)
406
def __editRowRangeDescriptionNetwork(self, new_label, new_bmin, new_bmax, label, sbmin, sbmax, areatype):
408
Edit row : test for RangeDescription & Network
412
new_label = "Default"
414
if areatype == 'line' :
416
elif areatype == 'height' :
417
step = self.heightStep
418
elif areatype == 'row' :
421
#if len(self.currentEntry) == 1 : # TODO ONE SELECTION
424
## entry = self.currentEntry
426
## label, sbmin, sbmax = self.select.areaInfo(entry)
427
## elif h == self.h3 :
428
## label, sbmin, sbmax = self.select3.areaInfo(entry)
433
llabel, lbmin, lbmax = self.model.GetAreas(areatype)
442
fnew_bmin=float(new_bmin)
443
fnew_bmax=float(new_bmax)
446
title = self.tr("Warning")
447
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
448
QMessageBox.warning(self.parent, title, msg)
451
if (fnew_bmin > fnew_bmax) or (fnew_bmin < 0):
453
if (areatype == 'line'):
454
if fnew_bmax > self.lineMax :
456
elif (areatype == 'height'):
457
if (fnew_bmax > self.heightMax) :
461
title = self.tr("Warning")
462
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
463
QMessageBox.warning(self.parent, title, msg)
466
for area in range(0,len(llabel)) :
467
if ((label == llabel[area]) and
468
(abs(bmin - float(lbmin[area])) <= _EPSILON) and
469
(abs(bmax - float(lbmax[area])) <= _EPSILON)):
472
if ((label != new_label) or
473
(abs(bmax - fnew_bmax) >= _EPSILON) or
474
(abs(bmin - fnew_bmin) >= _EPSILON)) :
476
for area1 in range(0,len(llabel)) :
478
if (((fnew_bmin > float(lbmin[area1])) and (fnew_bmin < float(lbmax[area1]))) or
479
((fnew_bmax > float(lbmin[area1])) and (fnew_bmax < float(lbmax[area1])))) :
483
self.model.SetArea(areatype, area, new_label, new_bmin, new_bmax)
484
#self.replaceHlist(h, entry, new_label, new_bmin, new_bmax, step)
486
title = self.tr("Warning")
487
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
488
QMessageBox.warning(self.parent, title, msg)
490
else: # # TODO MULTI-SELECTION
491
for entry in self.currentEntry:
494
## label, sbmin, sbmax = self.select.areaInfo(entry)
495
## elif h == self.h3 :
496
## label, sbmin, sbmax = self.select3.areaInfo(entry)
501
llabel, lbmin, lbmax = self.model.GetAreas(areatype)
503
for area in range(0,len(llabel)) :
504
if ((label == llabel[area]) or
505
(abs(bmin - float(lbmin[area])) <= _EPSILON) and
506
(abs(bmax - float(lbmax[area])) <= _EPSILON)):
508
if (label != new_label) :
510
if (new_label != _MULTISEL) :
511
self.model.SetArea(areatype, area, new_label, None , None)
512
#self.replaceHlist( h, entry, new_label, bmin, bmax,step)
518
def __deleteRowRangeDescriptionNetwork(self, label, sbmin, sbmax, areatype):
520
Delete row : test for RangeDescription & Network
522
log.debug("__deleteRowRangeDescriptionNetwork")
527
llabel, lbmin, lbmax = self.model.GetAreas(areatype)
530
for area in range(0,len(llabel)) :
531
if ((label == llabel[area]) and
532
(abs(bmin - float(lbmin[area])) < _EPSILON) and
533
(abs(bmax - float(lbmax[area])) < _EPSILON)):
535
self.model.EraseArea(areatype, area)
540
## # Delete boundary region from the Hlist
543
## print "Entry is in Hlist but not in XML"
547
## # Pb : si on ne supprime pas le dernier elt : lors de la creation d'une nouvelle hlist
548
## # il recupere un nom deja donne !!!
549
## ## if h == self.h :
550
## ## self.entriesNumberH1 = self.entriesNumberH1 -1
551
## ## elif h == self.h3 :
552
## ## self.entriesNumberH3 = self.entriesNumberH3 -1
553
## h.hlist.delete_entry(entry)
560
def __addRowRangeThermal(self, label, sbmin, sbmax, svalue, areatype, step):
562
Add a row : test for Thermal load
564
log.debug("__addRowThermal")
566
# Reading and add to Hlist
574
value = float(svalue)
576
title = self.tr("Warning")
577
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
578
QMessageBox.warning(self.parent, title, msg)
581
llabel, lbmin, lbmax, lval = self.model.GetAreas(areatype)
586
if (bmin > bmax) or (bmin < 0):
588
if (areatype == 'line'):
589
if (bmax > self.lineMax) :
591
elif (areatype == 'row'):
592
if (bmax > self.rowMax) :
594
elif (areatype == 'height'):
595
if (bmax > self.heightMax) :
598
for area in range(0,len(llabel)) :
601
if ((label == llabel[area]) and
602
(abs(bmin - float(lbmin[area])) < _EPSILON) and
603
(abs(bmax - float(lbmax[area])) < _EPSILON) and
604
(abs(value - float(lval[area])) < _EPSILON)) :
607
if (((bmin > float(lbmin[area])) and (bmin < float(lbmax[area]))) or
608
((bmax > float(lbmin[area])) and (bmax < float(lbmax[area])))) :
613
#name = self.insertHlist(h, label, sbmin, sbmax, svalue ,step)
614
self.model.NewArea(areatype, label, bmin, bmax, value)
616
title = self.tr("Warning")
617
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
618
QMessageBox.warning(self.parent, title, msg)
623
def __editRowThermal(self, new_label, new_bmin, new_bmax, label, sbmin, sbmax, areatype):
625
Edit row : test for Thermal load
627
log.debug("__editRowThermal")
631
new_label = "Default"
633
if areatype == 'line' :
635
elif areatype == 'row' :
637
elif areatype == 'height' :
638
step = self.heightStep
641
#if len(self.currentEntry) == 1 :
645
value = float(svalue)
647
llabel, lbmin, lbmax, lval = self.model.GetAreas(areatype)
656
fnew_bmin=float(new_bmin)
657
fnew_bmax=float(new_bmax)
658
fnew_value=float(new_value)
660
title = self.tr("Warning")
661
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
662
QMessageBox.warning(self.parent, title, msg)
665
if (fnew_bmin > fnew_bmax) or (fnew_bmin < 0):
667
if (areatype == 'line'):
668
if fnew_bmax > self.lineMax :
670
elif (areatype == 'height'):
671
if (fnew_bmax > self.heightMax) :
673
elif (areatype == 'row'):
674
if (fnew_bmax > self.rowMax) :
678
title = self.tr("Warning")
679
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
680
QMessageBox.warning(self.parent, title, msg)
682
for area in range(0,len(llabel)) :
683
if ((label == llabel[area]) and
684
(abs(bmin - float(lbmin[area])) <= _EPSILON) and
685
(abs(bmax - float(lbmax[area])) <= _EPSILON) and
686
(abs(value - float(lval[area])) <= _EPSILON)) :
688
if ((label != new_label) or
689
(abs(bmax - fnew_bmax) >= _EPSILON) or
690
(abs(bmin - fnew_bmin) >= _EPSILON) or
691
(abs(value - fnew_value) >= _EPSILON)) :
693
for area1 in range(0,len(llabel)) :
695
if (((fnew_bmin > float(lbmin[area1])) and (fnew_bmin < float(lbmax[area1]))) or
696
((fnew_bmax > float(lbmin[area1])) and (fnew_bmax < float(lbmax[area1])))) :
700
self.model.SetArea(areatype, area, new_label, new_bmin, new_bmax, new_value)
701
#self.replaceHlist(h, entry, new_label, new_bmin, new_bmax, new_value, step)
703
title = self.tr("Warning")
704
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
705
QMessageBox.warning(self.parent, title, msg)
709
for entry in self.currentEntry:
713
value = float(svalue)
715
llabel, lbmin, lbmax, lval = self.model.GetAreas(areatype)
720
fnew_value=float(new_value)
722
if new_value != _MULTISEL :
723
title = self.tr("Warning")
724
msg = self.tr("'%1' bad definition: see the bounds definition").arg(label)
725
QMessageBox.warning(self.parent, title, msg)
729
for area in range(0,len(llabel)) :
730
if ((label == llabel[area]) or
731
(abs(bmin - float(lbmin[area])) <= _EPSILON) and
732
(abs(bmax - float(lbmax[area])) <= _EPSILON) and
733
(abs(value - float(lval[area])) <= _EPSILON)) :
735
if ((label != new_label) or new_value == _MULTISEL or
736
(abs(value - fnew_value) >= _EPSILON)) :
738
if (new_label == _MULTISEL) and (new_value != _MULTISEL):
739
self.model.SetArea(areatype, area, None, None , None , new_value)
740
#self.replaceHlist( h, entry, label, bmin, bmax, new_value, step)
742
elif (new_value == _MULTISEL) and (new_label != _MULTISEL) :
743
self.model.SetArea(areatype, area, new_label , None , None , None)
744
#self.replaceHlist( h, entry, new_label, bmin, bmax, value, step)
746
elif (new_value != _MULTISEL) and (new_label != _MULTISEL) :
747
self.model.SetArea(areatype, area, new_label, None , None , new_value)
748
#self.replaceHlist( h, entry, new_label, bmin, bmax, new_value, step)
754
def __deleteRowThermal(self, label, sbmin, sbmax, svalue, areatype):
756
Delete row : test for Thermal
758
log.debug("__deleteRowThermal")
760
llabel, lbmin, lbmax, lval = self.model.GetAreas(areatype)
762
for area in range(0,len(llabel)) :
763
if ((label == llabel[area]) and
764
(abs(bmin - float(lbmin[area])) < _EPSILON) and
765
(abs(bmax - float(lbmax[area])) < _EPSILON) and
766
(abs(value - float(lval[area])) < _EPSILON)) :
767
self.model.EraseArea(areatype, area)
772
#-------------------------------------------------------------------------------
774
#-------------------------------------------------------------------------------
776
class MatisseCustomView(QWidget, Ui_MatisseCustomForm):
780
def __init__(self, *args):
784
QWidget.__init__(self, *args)
785
Ui_MatisseCustomForm.__init__(self)
789
def initWidget(self, case, tagName):
791
Method to initialize the widget.
792
Must be explicitly called.
795
self.tagName = tagName
796
self._createWidgets()
801
Return the name of the boundary condition. It 's not allowed to have
802
blank or not ASCII caracters in this name.
804
label = str(self.lineEditLabel.text())
805
return string.join(string.split(label), '_')
811
bmin, ok = self.lineEditMin.text().toFloat()
818
bmax, ok = self.lineEditMax.text().toFloat()
825
value, ok = self.lineEditValue.text().toFloat()
829
def createItem(self):
830
label = self.getLabel()
831
sbmin = self.getBmin()
832
sbmax = self.getBmax()
833
svalue = self.getValue()
834
self.modelMatisseCustom.addRow(label, sbmin, sbmax, svalue)
837
def modifyItem(self):
838
new_label = self.getLabel()
839
new_bmin = self.getBmin()
840
new_bmax = self.getBmax()
841
new_value = self.getValue()
844
selectionModel = self.tableView.selectionModel()
845
for index in selectionModel.selectedRows():
846
tab_rows.append(index.row())
848
log.debug("modifyItem nrows = %i tab_rows = %s "%(nrows, str(tab_rows)))
850
self.modelMatisseCustom.editRow(row, new_label, new_bmin, new_bmax, new_value)
853
def cancelItem(self):
856
selectionModel = self.tableView.selectionModel()
857
for index in selectionModel.selectedRows():
858
tab_rows.append(index.row())
860
log.debug("cancelItem nrows = %i tab_rows = %s "%(nrows, str(tab_rows)))
862
self.modelMatisseCustom.deleteRow(row)
865
def _createWidgets(self):
867
Create the Page layout.
869
if self.tagName == "":
870
log.debug("_createWidgets self.tagName is not set!")
874
dico = self.dico_custom[self.tagName]
876
# Update title and labels in the view
877
self.groupBox.setTitle(dico['title'])
878
self.labelLabel.setText(QString(dico['label']))
879
self.labelMin.setText(QString(dico['min']))
880
self.labelMax.setText(QString(dico['max']))
881
self.labelValue.hide()
882
self.lineEditValue.hide()
884
if 'value' in dico.keys():
885
self.labelValue.setText(QString(dico['value']))
886
self.labelValue.show()
887
self.lineEditValue.show()
889
# Set model for tableView
890
self.modelMatisseCustom = StandardItemModelMatisseCustom(self, self.case, self.tagName, dico)
891
self.tableView.setModel(self.modelMatisseCustom)
892
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
893
self.tableView.setSelectionMode(QAbstractItemView.ExtendedSelection)
896
self.connect(self.pushButtonNew, SIGNAL("clicked()"), self.createItem)
897
self.connect(self.pushButtonModify, SIGNAL("clicked()"), self.modifyItem)
898
self.connect(self.pushButtonDelete, SIGNAL("clicked()"), self.cancelItem)
901
regExp = QRegExp("[_A-Za-z0-9]*") # QRegExp("^all[ ]*$|^[0-9\ ]*$")
902
validatorLabel = QRegExpValidator(regExp, self.lineEditLabel)
903
self.lineEditLabel.setValidator(validatorLabel)
905
validatorFloat = QtPage.DoubleValidator(self.lineEditMin)
906
self.lineEditMin.setValidator(validatorFloat)
907
self.lineEditMax.setValidator(validatorFloat)
908
self.lineEditValue.setValidator(validatorFloat)
918
def __initDico(self):
920
Set a dictionnary which contains field names.
923
line = { 'areatype' : "line",
924
'title' : self.tr("headloss in line") ,
925
'label' : self.tr("Label"),
926
'min' : self.tr("Distance min \n (in lines)"),
927
'max' : self.tr("Distance max \n (in lines)"),
928
'headers' : [self.tr("Label"),
929
self.tr("Distance min \n (in lines)"),
930
self.tr("Distance max \n (in lines)"),
931
self.tr("Distance min \n (m)"),
932
self.tr("Distance max \n (m)")]
935
height = { 'areatype' : "height",
936
'title' : self.tr("headloss in height") ,
937
'label' : self.tr("Label"),
938
'min' : self.tr("Height min \n (in cells)"),
939
'max' : self.tr("Height max \n (in cells)"),
940
'headers' : [self.tr("Label"),
941
self.tr("Height min \n (in cells)"),
942
self.tr("Height max \n (in cells)"),
943
self.tr("Height min \n (m)"),
944
self.tr("Height max \n (m)")]
947
row = { 'areatype' : "row",
948
'title' : self.tr("Headloss in row") ,
949
'label' : self.tr("Label"),
950
'min' : self.tr("Distance min \n (in rows)"),
951
'max' : self.tr("Distance max \n (in rows)"),
952
'headers' : [self.tr("Label"),
953
self.tr("Distance min \n (in rows)"),
954
self.tr("Distance max \n (in rows)"),
955
self.tr("Distance min \n (m)"),
956
self.tr("Distance max \n (m)")]
960
dico_custom['inlet_range_line'] = line
961
dico_custom['inlet_range_height'] = height
962
dico_custom['outlet_range_line'] = line
963
dico_custom['outlet_range_height'] = height
964
dico_custom['network_line'] = line
965
dico_custom['network_row'] = row
966
dico_custom['thermal_line'] = line
967
dico_custom['thermal_height'] = height
968
dico_custom['thermal_row'] = row
970
self.dico_custom = dico_custom
972
#-------------------------------------------------------------------------------
974
#-------------------------------------------------------------------------------
976
if __name__ == "__main__":
979
#-------------------------------------------------------------------------------
981
#-------------------------------------------------------------------------------