1
# -*- coding: iso-8859-1 -*-
1
# -*- coding: utf-8 -*-
3
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
5
# This file is part of Code_Saturne, a general-purpose CFD tool.
7
# Copyright (C) 1998-2011 EDF S.A.
9
# This program is free software; you can redistribute it and/or modify it under
10
# the terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
14
# This program is distributed in the hope that it will be useful, but WITHOUT
15
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19
# You should have received a copy of the GNU General Public License along with
20
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
21
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
23
#-------------------------------------------------------------------------------
31
26
This module defines the conjugate heat transfer view data management.
33
28
This module contains the following classes and function:
34
- SyrthesAppNumberDelegate
29
- SyrthesVerbosityDelegate
35
30
- ProjectionAxisDelegate
36
31
- SelectionCriteriaDelegate
37
32
- StandardItemModelSyrthes
59
54
from Base.Common import LABEL_LENGTH_MAX
60
55
from Base.Toolbox import GuiParam
61
from ConjugateHeatTransferForm import Ui_ConjugateHeatTransferForm
56
from Pages.ConjugateHeatTransferForm import Ui_ConjugateHeatTransferForm
62
57
from Base.QtPage import IntValidator, DoubleValidator, RegExpValidator, ComboModel
63
58
from Pages.ConjugateHeatTransferModel import ConjugateHeatTransferModel
71
66
log.setLevel(GuiParam.DEBUG)
73
68
#-------------------------------------------------------------------------------
74
# QLineEdit delegate for validation of Syrthes app number
69
# QLineEdit delegate for validation of Syrthes verbosity or visualization
75
70
#-------------------------------------------------------------------------------
77
class SyrthesAppNumberDelegate(QItemDelegate):
72
class SyrthesVerbosityDelegate(QItemDelegate):
78
73
def __init__(self, parent = None):
79
super(SyrthesAppNumberDelegate, self).__init__(parent)
74
super(SyrthesVerbosityDelegate, self).__init__(parent)
80
75
self.parent = parent
178
173
QStandardItemModel.__init__(self)
179
self.setColumnCount(4)
174
self.setColumnCount(5)
180
175
self.headers = [self.tr("Instance name"),
181
self.tr("Application number"),
176
self.tr("Verbosity"),
177
self.tr("Visualization"),
182
178
self.tr("Projection Axis"),
183
179
self.tr("Selection criteria")]
180
self.tooltip = [self.tr("Name of coupled instance"),
181
self.tr("Verbosity level"),
182
self.tr("Visualization output level (0 for none)"),
183
self.tr("Projection axis to match 2D Solid domain"),
184
self.tr("Selection criteria for coupled boundary faces")]
184
185
self.setColumnCount(len(self.headers))
185
186
self.dataSyrthes = []
186
187
self.__model = model
189
190
def data(self, index, role):
190
191
if not index.isValid():
191
192
return QVariant()
193
if role == Qt.ToolTipRole:
194
return QVariant(self.tooltip[index.column()])
192
195
if role == Qt.DisplayRole:
193
196
return QVariant(self.dataSyrthes[index.row()][index.column()])
194
197
elif role == Qt.TextAlignmentRole:
213
216
return QVariant()
215
218
row = index.row()
216
if index.column() in (0, 2, 3):
219
if index.column() in (0, 3, 4):
217
220
self.dataSyrthes[row][index.column()] = str(value.toString())
219
222
self.dataSyrthes[row][index.column()], ok = value.toInt()
222
225
self.__model.setSyrthesInstanceName(num, self.dataSyrthes[row][0])
223
self.__model.setSyrthesAppNumber(num, self.dataSyrthes[row][1])
224
self.__model.setSyrthesProjectionAxis(num, self.dataSyrthes[row][2])
225
self.__model.setSelectionCriteria(num, self.dataSyrthes[row][3])
226
self.__model.setSyrthesVerbosity(num, self.dataSyrthes[row][1])
227
self.__model.setSyrthesVisualization(num, self.dataSyrthes[row][2])
228
self.__model.setSyrthesProjectionAxis(num, self.dataSyrthes[row][3])
229
self.__model.setSelectionCriteria(num, self.dataSyrthes[row][4])
227
231
id1 = self.index(0, 0)
228
232
id2 = self.index(self.rowCount(), 0)
233
def addItem(self, syrthes_name, app_num, proj_axis, location):
237
def addItem(self, syrthes_name,
238
verbosity, visualization, proj_axis, location):
235
240
Add a row in the table.
237
self.dataSyrthes.append([syrthes_name, app_num, proj_axis, location])
242
self.dataSyrthes.append([syrthes_name,
243
verbosity, visualization, proj_axis, location])
238
244
row = self.rowCount()
239
245
self.setRowCount(row+1)
273
279
self.tableViewSyrthes.verticalHeader().setResizeMode(QHeaderView.ResizeToContents)
274
280
self.tableViewSyrthes.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
275
self.tableViewSyrthes.horizontalHeader().setResizeMode(3, QHeaderView.Stretch)
281
self.tableViewSyrthes.horizontalHeader().setResizeMode(4, QHeaderView.Stretch)
277
delegateSyrthesAppNum = SyrthesAppNumberDelegate(self.tableViewSyrthes)
278
self.tableViewSyrthes.setItemDelegateForColumn(1, delegateSyrthesAppNum)
283
delegateSyrthesVerbosity = SyrthesVerbosityDelegate(self.tableViewSyrthes)
284
self.tableViewSyrthes.setItemDelegateForColumn(1, delegateSyrthesVerbosity)
285
self.tableViewSyrthes.setItemDelegateForColumn(2, delegateSyrthesVerbosity)
279
286
delegateProjectionAxis = ProjectionAxisDelegate(self.tableViewSyrthes)
280
self.tableViewSyrthes.setItemDelegateForColumn(2, delegateProjectionAxis)
287
self.tableViewSyrthes.setItemDelegateForColumn(3, delegateProjectionAxis)
281
288
delegateSelectionCriteria = SelectionCriteriaDelegate(self.tableViewSyrthes, self.__model)
282
self.tableViewSyrthes.setItemDelegateForColumn(3, delegateSelectionCriteria)
289
self.tableViewSyrthes.setItemDelegateForColumn(4, delegateSelectionCriteria)
285
292
self.connect(self.pushButtonAdd, SIGNAL("clicked()"), self.slotAddSyrthes)
286
293
self.connect(self.pushButtonDelete, SIGNAL("clicked()"), self.slotDeleteSyrthes)
288
# Insert list of Syrthes coupling for view
295
# Insert list of Syrthes couplings for view
289
296
for c in self.__model.getSyrthesCouplingList():
290
[syrthes_name, app_num, proj_axis, location] = c
291
self.modelSyrthes.addItem(syrthes_name, app_num, proj_axis, location)
294
self.tableViewSyrthes.hideColumn(0)
295
self.tableViewSyrthes.hideColumn(1)
296
self.__pushButtonAddUpdate()
299
def __pushButtonAddUpdate(self):
304
if len(self.__model.getSyrthesCouplingList()) >= 1:
305
self.pushButtonAdd.setEnabled(False)
307
self.pushButtonAdd.setEnabled(True)
297
[syrthes_name, verbosity, visualization, proj_axis, location] = c
298
self.modelSyrthes.addItem(syrthes_name,
299
verbosity, visualization, proj_axis, location)
301
if len(self.__model.getSyrthesCouplingList()) < 2:
302
self.tableViewSyrthes.hideColumn(0)
310
305
@pyqtSignature("")
313
308
Set in view label and variables to see on profile
315
syrthes_name = self.__model.defaultValues()['syrthes_name']
316
app_num = self.__model.defaultValues()['syrthes_app_num']
317
proj_axis = self.__model.defaultValues()['projection_axis']
318
location = self.__model.defaultValues()['selection_criteria']
319
num = self.__model.addSyrthesCoupling(syrthes_name, app_num, proj_axis, location)
320
self.modelSyrthes.addItem(syrthes_name, app_num, proj_axis, location)
321
self.__pushButtonAddUpdate()
310
syrthes_name = self.__model.defaultValues()['syrthes_name']
311
verbosity = self.__model.defaultValues()['verbosity']
312
visualization = self.__model.defaultValues()['visualization']
313
proj_axis = self.__model.defaultValues()['projection_axis']
314
location = self.__model.defaultValues()['selection_criteria']
315
num = self.__model.addSyrthesCoupling(syrthes_name,
316
verbosity, visualization,
318
self.modelSyrthes.addItem(syrthes_name, verbosity, visualization,
320
if len(self.__model.getSyrthesCouplingList()) > 1:
321
self.tableViewSyrthes.showColumn(0)
324
324
@pyqtSignature("")