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

« back to all changes in this revision

Viewing changes to gui/Pages/ConjugateHeatTransferView.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
 
#
 
1
# -*- coding: utf-8 -*-
 
2
 
3
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
 
#
 
4
 
 
5
# This file is part of Code_Saturne, a general-purpose CFD tool.
 
6
#
 
7
# Copyright (C) 1998-2011 EDF S.A.
 
8
#
 
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
 
12
# version.
 
13
#
 
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
 
17
# details.
 
18
#
 
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.
 
22
 
28
23
#-------------------------------------------------------------------------------
29
24
 
30
25
"""
31
26
This module defines the conjugate heat transfer view data management.
32
27
 
33
28
This module contains the following classes and function:
34
 
- SyrthesAppNumberDelegate
 
29
- SyrthesVerbosityDelegate
35
30
- ProjectionAxisDelegate
36
31
- SelectionCriteriaDelegate
37
32
- StandardItemModelSyrthes
58
53
 
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
64
59
 
71
66
log.setLevel(GuiParam.DEBUG)
72
67
 
73
68
#-------------------------------------------------------------------------------
74
 
# QLineEdit delegate for validation of Syrthes app number
 
69
# QLineEdit delegate for validation of Syrthes verbosity or visualization
75
70
#-------------------------------------------------------------------------------
76
71
 
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
81
76
 
82
77
 
176
171
        """
177
172
        """
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()
214
217
 
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())
218
221
        else:
219
222
            self.dataSyrthes[row][index.column()], ok = value.toInt()
220
223
 
221
224
        num = row + 1
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])
226
230
 
227
231
        id1 = self.index(0, 0)
228
232
        id2 = self.index(self.rowCount(), 0)
230
234
        return True
231
235
 
232
236
 
233
 
    def addItem(self, syrthes_name, app_num, proj_axis, location):
 
237
    def addItem(self, syrthes_name,
 
238
                verbosity, visualization, proj_axis, location):
234
239
        """
235
240
        Add a row in the table.
236
241
        """
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)
240
246
 
272
278
 
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)
276
282
 
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)
283
290
 
284
291
        # Connections
285
292
        self.connect(self.pushButtonAdd,    SIGNAL("clicked()"), self.slotAddSyrthes)
286
293
        self.connect(self.pushButtonDelete, SIGNAL("clicked()"), self.slotDeleteSyrthes)
287
294
 
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)
292
 
 
293
 
        #FIXME:
294
 
        self.tableViewSyrthes.hideColumn(0)
295
 
        self.tableViewSyrthes.hideColumn(1)
296
 
        self.__pushButtonAddUpdate()
297
 
 
298
 
 
299
 
    def __pushButtonAddUpdate(self):
300
 
        """
301
 
        Temporay function.
302
 
        """
303
 
        #FIXME:
304
 
        if len(self.__model.getSyrthesCouplingList()) >= 1:
305
 
            self.pushButtonAdd.setEnabled(False)
306
 
        else:
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)
 
300
 
 
301
        if len(self.__model.getSyrthesCouplingList()) < 2:
 
302
            self.tableViewSyrthes.hideColumn(0)
308
303
 
309
304
 
310
305
    @pyqtSignature("")
312
307
        """
313
308
        Set in view label and variables to see on profile
314
309
        """
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,
 
317
                                              proj_axis, location)
 
318
        self.modelSyrthes.addItem(syrthes_name, verbosity, visualization,
 
319
                                  proj_axis, location)
 
320
        if len(self.__model.getSyrthesCouplingList()) > 1:
 
321
            self.tableViewSyrthes.showColumn(0)
322
322
 
323
323
 
324
324
    @pyqtSignature("")
335
335
        else:
336
336
            self.modelSyrthes.deleteRow(row)
337
337
            self.__model.deleteSyrthesCoupling(row+1)
338
 
        self.__pushButtonAddUpdate()
 
338
            if len(self.__model.getSyrthesCouplingList()) < 2:
 
339
                self.tableViewSyrthes.hideColumn(0)
339
340
 
340
341
 
341
342
    def tr(self, text):