/usr/lib/python2.7/dist-packages/code_saturne/Pages/ElectricalView.py is in code-saturne-data 4.2.0+repack-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | # -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# This file is part of Code_Saturne, a general-purpose CFD tool.
#
# Copyright (C) 1998-2015 EDF S.A.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
#-------------------------------------------------------------------------------
"""
This module contains the following classes:
- ElectricalView
"""
#-------------------------------------------------------------------------------
# Standard modules
#-------------------------------------------------------------------------------
import os, logging
#-------------------------------------------------------------------------------
# Third-party modules
#-------------------------------------------------------------------------------
from PyQt4.QtCore import *
from PyQt4.QtGui import *
#-------------------------------------------------------------------------------
# Application modules import
#-------------------------------------------------------------------------------
from code_saturne.Base.Toolbox import GuiParam
from code_saturne.Base.Common import LABEL_LENGTH_MAX
from code_saturne.Base.QtPage import ComboModel, DoubleValidator, RegExpValidator
from code_saturne.Base.QtPage import setGreenColor, from_qvariant
from code_saturne.Pages.ElectricalForm import Ui_ElectricalForm
from code_saturne.Pages.ElectricalModel import ElectricalModel
#-------------------------------------------------------------------------------
# log config
#-------------------------------------------------------------------------------
logging.basicConfig()
log = logging.getLogger("ElectricalView")
log.setLevel(GuiParam.DEBUG)
#-------------------------------------------------------------------------------
# Main class
#-------------------------------------------------------------------------------
class ElectricalView(QWidget, Ui_ElectricalForm):
"""
"""
def __init__(self, parent, case, stbar):
"""
Constructor
"""
QWidget.__init__(self, parent)
Ui_ElectricalForm.__init__(self)
self.setupUi(self)
self.case = case
self.stbar = stbar
self.case.undoStopGlobal()
self.model = ElectricalModel(self.case)
# Combo model
self.modelJoule = ComboModel(self.comboBoxJouleModel, 4, 1)
self.modelJoule.addItem(self.tr("AC/DC"), "AC/DC")
self.modelJoule.addItem(self.tr("three-phase"), "three-phase")
self.modelJoule.addItem(self.tr("AC/DC with Transformer coupling"), "AC/DC+Transformer")
self.modelJoule.addItem(self.tr("three-phase with Transformer coupling"), "three-phase+Transformer")
self.modelJoule.disableItem(str_model="AC/DC+Transformer")
self.modelJoule.disableItem(str_model="three-phase+Transformer")
self.modelScaling = ComboModel(self.comboBoxScalingModel, 3, 1)
self.modelScaling.addItem(self.tr("general case"), "general_case")
self.modelScaling.addItem(self.tr("plane define"), "plane_define")
self.modelScaling.addItem(self.tr("user define"), "user")
self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1)
self.modelDirection.addItem(self.tr("X"), "X")
self.modelDirection.addItem(self.tr("Y"), "Y")
self.modelDirection.addItem(self.tr("Z"), "Z")
# Connections
self.connect(self.pushButtonPropertiesData, SIGNAL("pressed()"), self.__slotSearchPropertiesData)
self.connect(self.lineEditSRROM, SIGNAL("textChanged(const QString &)"), self.slotSRROM)
self.connect(self.lineEditPower, SIGNAL("textChanged(const QString &)"), self.slotPower)
self.connect(self.lineEditCurrent, SIGNAL("textChanged(const QString &)"), self.slotCurrent)
self.connect(self.checkBoxScaling, SIGNAL("clicked()"), self.slotScaling)
self.connect(self.comboBoxJouleModel, SIGNAL("activated(const QString&)"), self.slotJouleModel)
self.connect(self.comboBoxScalingModel, SIGNAL("activated(const QString&)"), self.slotScalingModel)
self.connect(self.comboBoxDirection, SIGNAL("clicked()"), self.slotDirection)
self.connect(self.lineEditPlaneDefinitionA, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefA)
self.connect(self.lineEditPlaneDefinitionB, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefB)
self.connect(self.lineEditPlaneDefinitionC, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefC)
self.connect(self.lineEditPlaneDefinitionD, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefD)
self.connect(self.lineEditEpsilon, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefEpsilon)
# Validators
validatorSRROM = DoubleValidator(self.lineEditSRROM, min=0.0, max=1.0)
validatorSRROM.setExclusiveMin(False)
validatorPower = DoubleValidator(self.lineEditPower, min=0.0)
validatorPower.setExclusiveMin(False)
validatorCurrent = DoubleValidator(self.lineEditCurrent, min=0.0)
validatorCurrent.setExclusiveMin(False)
validatorDefinitionA = DoubleValidator(self.lineEditPlaneDefinitionA)
validatorDefinitionB = DoubleValidator(self.lineEditPlaneDefinitionB)
validatorDefinitionC = DoubleValidator(self.lineEditPlaneDefinitionC)
validatorDefinitionD = DoubleValidator(self.lineEditPlaneDefinitionD)
validatorEpsilon = DoubleValidator(self.lineEditEpsilon)
self.lineEditSRROM.setValidator(validatorSRROM)
self.lineEditPower.setValidator(validatorPower)
self.lineEditCurrent.setValidator(validatorCurrent)
self.lineEditPlaneDefinitionA.setValidator(validatorDefinitionA)
self.lineEditPlaneDefinitionB.setValidator(validatorDefinitionB)
self.lineEditPlaneDefinitionC.setValidator(validatorDefinitionC)
self.lineEditPlaneDefinitionD.setValidator(validatorDefinitionD)
self.lineEditEpsilon.setValidator(validatorEpsilon)
# Initialize widget
self.__initializeWidget()
self.case.undoStartGlobal()
@pyqtSignature("")
def __initializeWidget(self):
"""
Initialize widget
"""
name = self.model.getPropertiesDataFileName()
if name != None:
self.labelPropertiesFile.setText(str(name))
setGreenColor(self.pushButtonPropertiesData, False)
else:
setGreenColor(self.pushButtonPropertiesData, True)
srrom = self.model.getSRROM()
self.lineEditSRROM.setText(str(srrom))
self.groupBoxRecalage.hide()
if self.model.getScaling() == 'on':
self.checkBoxScaling.setChecked(True)
self.labelScalingModel.show()
self.comboBoxScalingModel.show()
else:
self.checkBoxScaling.setChecked(False)
self.labelScalingModel.hide()
self.comboBoxScalingModel.hide()
if self.model.getElectricalModel() == "joule":
self.groupBoxJoule.show()
self.groupBoxElectricArc.hide()
model = self.model.getJouleModel()
self.modelJoule.setItem(str_model=str(model))
power = self.model.getPower()
self.lineEditPower.setText(str(power))
self.labelPropertiesData.hide()
self.pushButtonPropertiesData.hide()
self.labelPropertiesFile.hide()
self.pushButtonPropertiesData.hide()
self.labelPropertiesData.hide()
self.labelPropertiesFile.hide()
elif self.model.getElectricalModel() == "arc":
self.groupBoxJoule.hide()
self.groupBoxElectricArc.show()
current = self.model.getCurrent()
self.lineEditCurrent.setText(str(current))
if self.model.getScaling() == 'on':
model = self.model.getScalingModel()
self.modelScaling.setItem(str_model=str(model))
if model == 'plane_define':
self.groupBoxRecalage.show()
direction = self.model.getDirection()
self.modelDirection.setItem(str_model=str(direction))
definition = self.model.getPlaneDefinition("A")
self.lineEditPlaneDefinitionA.setText(str(definition))
definition = self.model.getPlaneDefinition("B")
self.lineEditPlaneDefinitionB.setText(str(definition))
definition = self.model.getPlaneDefinition("C")
self.lineEditPlaneDefinitionC.setText(str(definition))
definition = self.model.getPlaneDefinition("D")
self.lineEditPlaneDefinitionD.setText(str(definition))
definition = self.model.getPlaneDefinition("epsilon")
self.lineEditEpsilon.setText(str(definition))
@pyqtSignature("")
def __slotSearchPropertiesData(self):
"""
Select a properties file of data for electric arc
"""
data = self.case['data_path']
title = self.tr("Properties file of data.")
filetypes = self.tr("Properties data (*dp_ELE*);;All Files (*)")
file = QFileDialog.getOpenFileName(self, title, data, filetypes)
file = str(file)
if not file:
return
file = os.path.basename(file)
if file not in os.listdir(data):
title = self.tr("WARNING")
msg = self.tr("This selected file is not in the DATA directory")
QMessageBox.information(self, title, msg)
else:
self.labelPropertiesFile.setText(str(file))
self.model.setPropertiesDataFileName(file)
setGreenColor(self.pushButtonPropertiesData, False)
@pyqtSignature("const QString &")
def slotSRROM(self, text):
"""
Input Relaxation coefficient for mass density
"""
if self.sender().validator().state == QValidator.Acceptable:
srrom = from_qvariant(text, float)
self.model.setSRROM(srrom)
@pyqtSignature("const QString &")
def slotPower(self, text):
"""
Input Imposed Power
"""
if self.sender().validator().state == QValidator.Acceptable:
power = from_qvariant(text, float)
self.model.setPower(power)
@pyqtSignature("const QString &")
def slotCurrent(self, text):
"""
Input Imposed current intensity
"""
if self.sender().validator().state == QValidator.Acceptable:
current = from_qvariant(text, float)
self.model.setCurrent(current)
@pyqtSignature("")
def slotJouleModel(self, text):
"""
Input Joule model.
"""
model = self.modelJoule.dicoV2M[str(text)]
self.model.setJouleModel(model)
@pyqtSignature("")
def slotScaling(self):
"""
Input "Electric variables" scaling.
"""
if self.checkBoxScaling.isChecked():
self.model.setScaling("on")
else:
self.model.setScaling("off")
self.__initializeWidget()
@pyqtSignature("")
def slotScalingModel(self, text):
"""
Input scaling model.
"""
model = self.modelScaling.dicoV2M[str(text)]
self.model.setScalingModel(model)
self.__initializeWidget()
@pyqtSignature("")
def slotDirection(self, text):
"""
Input current density direction for scaling.
"""
direction = self.modelDirection.dicoV2M[str(text)]
self.model.setDirection(direction)
@pyqtSignature("const QString &")
def slotPlaneDefA(self, text):
"""
Input define plane
"""
if self.sender().validator().state == QValidator.Acceptable:
current = from_qvariant(text, float)
self.model.setPlaneDefinition("A", current)
@pyqtSignature("const QString &")
def slotPlaneDefB(self, text):
"""
Input define plane
"""
if self.sender().validator().state == QValidator.Acceptable:
current = from_qvariant(text, float)
self.model.setPlaneDefinition("B", current)
@pyqtSignature("const QString &")
def slotPlaneDefC(self, text):
"""
Input define plane
"""
if self.sender().validator().state == QValidator.Acceptable:
current = from_qvariant(text, float)
self.model.setPlaneDefinition("C", current)
@pyqtSignature("const QString &")
def slotPlaneDefD(self, text):
"""
Input define plane
"""
if self.sender().validator().state == QValidator.Acceptable:
current = from_qvariant(text, float)
self.model.setPlaneDefinition("D", current)
@pyqtSignature("const QString &")
def slotPlaneDefEpsilon(self, text):
"""
Input define plane
"""
if self.sender().validator().state == QValidator.Acceptable:
current = from_qvariant(text, float)
self.model.setPlaneDefinition("epsilon", current)
def tr(self, text):
"""
Translation.
"""
return text
#-------------------------------------------------------------------------------
# End
#-------------------------------------------------------------------------------
|