# -*- coding: iso-8859-1 -*-
#
#-------------------------------------------------------------------------------
# Code_Saturne version 1.3
# ------------------------
#
#
# This file is part of the Code_Saturne User Interface, element of the
# Code_Saturne CFD tool.
#
# Copyright (C) 1998-2007 EDF S.A., France
#
# contact: saturne-support@edf.fr
#
# The Code_Saturne User Interface 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.
#
# The Code_Saturne User Interface 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 the Code_Saturne Kernel; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA
#
#-------------------------------------------------------------------------------
"""
This module defines some useful classes and functions used mainly by
the BaseTkGUI class.
This module defines the following classes and functions:
- setupFontDefault
- setupWmDefault
- GuiParam
- CreateHlist
- displaySelectedPage
- Text
- dicoLabel
- reload_modules
- reload_all_modules
- reload_current_page
"""
#-------------------------------------------------------------------------------
# Library modules import
#-------------------------------------------------------------------------------
import os, sys
#-------------------------------------------------------------------------------
# Application modules import
#-------------------------------------------------------------------------------
from Common import *
#-------------------------------------------------------------------------------
# Setup Windows Manager default
#-------------------------------------------------------------------------------
def setupFontDefault(root):
"""
Define default font for Tk GUI and resource specification lines.
Note: this function is not really required, because of the wm dico
from module Common.py
"""
root.option_add("*Button*font", fN)
root.option_add("*Checkbutton*font", fN)
root.option_add("*Entry*font", fN)
root.option_add("*Label*font", fN)
root.option_add("*Listbox*font", fN)
root.option_add("*Hlist*font", fN)
root.option_add("*Menu*font", fN)
root.option_add("*Menubutton*font", fN)
root.option_add("*Radiobutton*font", fN)
root.option_add("*Scale*font", fN)
root.option_add("*Text*font", fN)
def setupWmDefault(root, wm):
"""
Define default color scheme and font for Tk GUI. This function
must be called before the first Tix instance.
"""
# Uncomment the following line to view the Tix's internal state
# current settings.
#
#print root.tk.call('tix', 'configure')
# Make sure that the color scheme and the fontset to use for the Tix widgets
# are the good one (i.e. 'WmDefault').
#
try:
root.tk.call('tix', 'resetoption', 'WmDefault', 'WmDefault')
except:
pass
# List of all the settings controlled by WmDefault with their
# default value (obtained with 'print WmDefault.parray(root)':
#
# activebackground #ececec
# activeforeground Black
# alinkcolor #800080
# background #dcdcdc
# borderwidth 2 - this option does not work !
# disabledbackground #a3a3a3 - this option does not work !
# disabledforeground #808080
# disabledtextbackground #dcdcdc - this option does not work !
# fixed_font courier -14
# fixedfamily courier
# focusmodel clicktofocus
# font courier
# fontsize 14 - in pixels under Unix, in points under Windows
# foreground Black
# geometry 0+0+1280+1024
# highlightbackground #dcdcdc
# highlightcolor Black
# highlightthickness 2
# linkcolor #0000ff - not working completely yet
# menu_font helvetica -14 - this option does not work !
# menubackground #dcdcdc - this option does not work !
# menufamily helvetica - work but not used
# menuforeground Black - this option does not work !
# priority 75
# scrollbars #c3c3c3 - scrollbar trough color
# selectbackground #000080
# selectcolor yellow
# selectforeground white
# system_font helvetica -14 - a Tcl font spec, a list of family size weight
# systemfamily helvetica
# text_font helvetica -14
# textbackground white - background for entry
# textfamily helvetica - work but not used
# textforeground Black - foreground for entry
# vlinkcolor #800000
# wm kde2 - one of windows gnome kde1 kde2 cde kde
#
import WmDefault
WmDefault.setup(root)
if WmDefault.getoptions(root)['wm'] not in \
('windows','gnome','kde1','kde2','cde','kde'):
WmDefault.addoptions(root, {'wm': 'gnome'})
for short, long in [('fg','foreground'),
('bg','background'),
('bd','borderwidth')]: # -- this option does not work !
if wm.has_key(long):
wm[short] = wm[long]
elif wm.has_key(short):
wm[long] = wm[short]
for key in wm.keys():
WmDefault.addoptions(root, {key : wm[key]})
#print WmDefault.parray(root)
#print WmDefault.getoptions(root)
#-------------------------------------------------------------------------------
# Language and other things
#-------------------------------------------------------------------------------
class GuiParam:
"""
Language default chooser, and bell ON/OFF switch.
Code stolen from: "N3S interface".
"""
# 'fr' or 'en' (default)
#
try:
lang = os.environ['LANG'][0:2]
except Exception:
lang = 'fr'
# 'on' (default) or 'off'
#
beep = 'on'
# pdf reader
#
pdfReader = 'on'
# 'yes' (default) or 'no'
#
saved = 'yes'
# False (default) or True
#
matisse = False
#-------------------------------------------------------------------------------
# Class for TreeNavigator building and its binding with the selected Page
#-------------------------------------------------------------------------------
class CreateHlist:
"""
Put a simple hierarchy into the TreeNavigator (two levels max please !).
This class contains our little relational database.
There is a rule for the page display : when a folder has a file-child,
this folder don't have any associated page, when a folder has no
file-child, if has a page to display. Simple, isn't it ?
If the folders and files lists are modified, you have to adapt the Page:
'AnalysisFeatures'.
"""
def __init__(self):
"""
Simple constructor.
"""
self.parents = self._treeFolders()
self.childs = self._treeFiles()
self.parents_key = []
for parent, label in self.parents:
self.parents_key.append(parent)
self.childs_key = []
for child, parent, label in self.childs:
key = parent + '/' + child
self.childs_key.append(key)
def _treeFolders(self):
"""
For each folder, we have the name of the folder, the label for the
display on the Tree.
"""
if GuiParam.lang == 'fr':
folders = [
('envirt', "Environnement du calcul" ),
('mtentr', "Description de l'entrepôt" ),
('mtphys', "Paramètres thermohydrauliques"),
('models', "Modèles thermophysiques" ),
('proper', "Propriétés physiques" ),
('scalar', "Scalaires supplémentaires" ),
('lagran', "Modélisation Lagrangienne" ),
('bounda', "Conditions aux limites" ),
('output', "Suivi du calcul" ),
('numpar', "Paramètres numériques" ),
('managt', "Gestion du calcul" )
]
else:
folders = [
('envirt', "Analysis environment" ),
('mtentr', "Storage system description" ),
('mtphys', "Thermohydraulic parameters" ),
('models', "Thermophysical models" ),
('proper', "Physical properties" ),
('scalar', "Additional scalars" ),
('lagran', "Lagrangian Modeling" ),
('bounda', "Boundary conditions" ),
('output', "Analysis control" ),
('numpar', "Numerical parameters" ),
('managt', "Calcul management" )
]
return folders
def _treeFiles(self):
"""
For each files, we have the name of the file, the name of the parent folder
and finally the label for the display on the Tree.
"""
# Make sure the keys (e.g. 'folder/file') you choose are unique names.
# If you cannot be sure of this (because of the structure of your
# database, e.g.) you can use the 'add_child' command instead:
#
# hlist.addchild( folder, text=name)
# ^^^^^
# parent entryPath
#
if GuiParam.lang == 'fr':
files = [
('identi', 'envirt', 'Identité et chemins' ),
('envelo', 'envirt', 'Domaine de Résolution' ),
('mttype', 'mtentr', "Type d'entrepôt" ),
('mtgeom', 'mtentr', "Géométrie de l'entrepôt" ),
('mtinle', 'mtentr', "Description de l'entrée" ),
('mtoutl', 'mtentr', "Description de la sortie" ),
('mtnetw', 'mtentr', "Description du réseau" ),
('mthydr', 'mtphys', "Charge hydraulique" ),
('mtther', 'mtphys', "Charge thermique" ),
('featur', 'models', 'Physiques particulières' ),
('turbul', 'models', 'Turbulence' ),
('therma', 'models', 'Modèle thermique' ),
('flame', 'models', 'Combustion gaz' ),
('species', 'models', 'Espèces courantes' ),
('pucoal', 'models', 'Charbon pulvérisé' ),
('joule', 'models', 'Modèles électriques' ),
('radiat', 'models', 'Rayonnement thermique' ),
('initia', 'models', 'Initialisation' ),
('prestp', 'proper', 'Valeurs de référence' ),
('molpro', 'proper', 'Caractéristiques fluide' ),
('gravit', 'proper', 'Gravité, pression hydrostatique' ),
('define', 'scalar', 'Définition et initialisation' ),
('prosca', 'scalar', 'Propriétés physiques' ),
('models', 'lagran', 'Paramètres globaux' ),
('statis', 'lagran', 'Statistiques' ),
('define', 'bounda', 'Définitions des frontières' ),
('dynami', 'bounda', 'Variables dynamiques' ),
('scalar', 'bounda', 'Scalaires' ),
('scaray', 'bounda', 'Rayonnement thermique' ),
#('mean', 'output', 'Moyennes temporelles' ),
('time', 'output', 'Pas de temps' ),
('output', 'output', 'Contrôle des sorties' ),
('soluti', 'output', 'Contrôle des variables' ),
('solutray','output','Contrôle du rayonnement.' ),
('numequ', 'numpar', 'Paramètres équations' ),
('numglo', 'numpar', 'Paramètres globaux' ),
('rstart', 'managt', 'Suite de calcul' ),
('batch', 'managt', 'Exécution en arrière-plan' )
]
else:
files = [
('identi', 'envirt', 'Identity and paths' ),
('envelo', 'envirt', 'Solution Domain' ),
('mttype', 'mtentr', "Storage system type" ),
('mtgeom', 'mtentr', "Storage system geometry" ),
('mtinle', 'mtentr', "Inlet description" ),
('mtoutl', 'mtentr', "Outlet description" ),
('mtnetw', 'mtentr', "Network description" ),
('mthydr', 'mtphys', "Hydraulic load" ),
('mtther', 'mtphys', "Thermal load" ),
('featur', 'models', 'Analysis features' ),
('turbul', 'models', 'Turbulence models' ),
('therma', 'models', 'Thermal model' ),
('flame', 'models', 'Gas combustion' ),
('species', 'models', 'Current species' ),
('pucoal', 'models', 'Pulveried coal combustion' ),
('joule', 'models', 'Electrical models' ),
('radiat', 'models', 'Thermal radiation' ),
('initia', 'models', 'Initialization' ),
('prestp', 'proper', 'Reference values' ),
('molpro', 'proper', 'Fluid properties' ),
('gravit', 'proper', 'Gravity, hydrostatic pressure' ),
('define', 'scalar', 'Definition and initialization' ),
('prosca', 'scalar', 'Physicals properties' ),
('models', 'lagran', 'Global parameters' ),
('statis', 'lagran', 'Statistics' ),
('define', 'bounda', 'Define boundary regions' ),
('dynami', 'bounda', 'Dynamic variables boundaries' ),
('scalar', 'bounda', 'Scalars boundaries' ),
('scaray', 'bounda', 'Radiative boundary conditions' ),
#('mean' , 'output', 'Temporal means' ),
('time', 'output', 'Time step' ),
('output', 'output', 'Output control' ),
('soluti', 'output', 'Solution control' ),
('solutray','output','Thermal radiative control' ),
('numequ', 'numpar', 'Equations parameters ' ),
('numglo', 'numpar', 'Global parameters ' ),
('rstart', 'managt', 'Start/Restart' ),
('batch', 'managt', 'Prepare batch analysis' )
]
return files
#-------------------------------------------------------------------------------
# displaySelectedPage direct to the good page with its name
#-------------------------------------------------------------------------------
def displaySelectedPage(root, page_name, case, stbar, study, tree):
"""
This function enables to display a new page when the TreeNavigator
send the order.
"""
# 'win' is the frame-support of the Pages
# 'thisPage' is the instance of classes which create thePages
# 'page_name' is the name of the Tree entry
#
win = root
case['currentPage'] = page_name
# '/' is the separator character we chose.
# parent entryPath / child's name
#
if page_name == "envirt/identi":
import Pages.IdentityAndPathes as Page
thisPage = Page.IdentityAndPathesView(win, case, stbar, tree, study)
elif page_name == "envirt/envelo":
import Pages.SolutionDomain as Page
thisPage = Page.SolutionDomainView(win, case, stbar)
elif page_name == "mtentr/mttype":
import Pages.MatisseType as Page
thisPage = Page.MatisseTypeView(win, case, stbar)
elif page_name == "mtentr/mtgeom":
import Pages.MatisseGeom as Page
thisPage = Page.MatisseGeomView(win, case, stbar)
elif page_name == "mtentr/mtinle":
import Pages.MatisseRangeDescription as Page
thisPage = Page.MatisseRangeDescriptionView(win, case, 'inlet_range', stbar)
elif page_name == "mtentr/mtoutl":
import Pages.MatisseRangeDescription as Page
thisPage = Page.MatisseRangeDescriptionView(win, case, 'outlet_range', stbar)
elif page_name == "mtentr/mtnetw":
import Pages.MatisseNetwork as Page
thisPage = Page.MatisseNetworkView(win, case, stbar)
elif page_name == "mtphys/mthydr":
import Pages.MatisseHydrau as Page
thisPage = Page.MatisseHydrauView(win, case, stbar)
elif page_name == "mtphys/mtther":
import Pages.MatisseThermic as Page
thisPage = Page.MatisseThermicView(win, case, stbar)
elif page_name == "models/featur":
import Pages.AnalysisFeatures as Page
thisPage = Page.AnalysisFeaturesView(win, case, stbar, tree)
elif page_name == "models/turbul":
import Pages.Turbulence as Page
thisPage = Page.TurbulenceView(win, case, stbar)
elif page_name == "models/therma":
import Pages.ThermalScalar as Page
thisPage = Page.ThermalScalarView(win, case, stbar, tree)
elif page_name == "models/flame":
thisPage = root.fr2.p2.fr.window.myPage
elif page_name == "models/species":
import Pages.CurrentSpecies as Page
thisPage = Page.CurrentSpeciesView(win, case, stbar, tree)
elif page_name == "models/pucoal":
import Pages.CoalCombustion as Page
thisPage = Page.CoalCombustionView(win, case, stbar, tree)
elif page_name == "models/joule":
thisPage = root.fr2.p2.fr.window.myPage
elif page_name == "models/radiat":
import Pages.ThermalRadiation as Page
thisPage = Page.ThermalRadiationView(win, case, stbar, tree)
elif page_name == "models/initia":
import Pages.Initialization as Page
thisPage = Page.InitializationView(win, case, stbar, tree)
elif page_name == "proper/prestp":
import Pages.ReferenceValues as Page
thisPage = Page.ReferenceValuesView(win, case, stbar)
elif page_name == "proper/molpro":
import Pages.FluidCharacteristics as Page
thisPage = Page.FluidCharacteristicsView(win, case, stbar)
elif page_name == "proper/gravit":
import Pages.BodyForces as Page
thisPage = Page.BodyForcesView(win, case, stbar)
elif page_name == "scalar/define":
import Pages.DefineUserScalars as Page
thisPage = Page.DefineUserScalarsView(win, case, stbar)
elif page_name == "scalar/prosca":
import Pages.UserScalarProperties as Page
thisPage = Page.UserScalarPropertiesView(win, case, stbar, tree)
elif page_name == "lagran/models":
import Pages.LagrangianView as Page
thisPage = Page.LagrangianView(win, case, stbar, tree)
elif page_name == "lagran/statis":
thisPage = root.fr2.p2.fr.window.myPage
elif page_name == "bounda/define":
import Pages.DefineBoundaryRegions as Page
thisPage = Page.DefBCView(win, case, stbar, tree)
#thisPage = Page.BoundaryRegions(win, case, stbar)
elif page_name == "bounda/dynami":
import Pages.BoundConditions as Page
thisPage = Page.BoundaryConditionsView(win, case, stbar, tree)
elif page_name == "bounda/scalar":
import Pages.ScalarsBoundaries as Page
thisPage = Page.ScalarsBoundariesView(win, case, stbar, tree)
elif page_name == "bounda/scaray":
import Pages.RadiativeBoundaries as Page
thisPage = Page.RadiativeBoundariesView(win, case, stbar, tree)
elif page_name == "output/mean":
thisPage = root.fr2.p2.fr.window.myPage
#import Pages.TestingBlt as Page
#thisPage = Page.TestingBlt(win, case, stbar)
elif page_name == "output/time":
import Pages.TimeStep as Page
if GuiParam.matisse :
thisPage = Page.TimeStepMatisseView(win, case, stbar)
else :
thisPage = Page.TimeStepView(win, case, stbar)
elif page_name == "output/output":
import Pages.OutputControl as Page
thisPage = Page.OutputControlView(win, case, stbar, tree)
elif page_name == "output/soluti":
import Pages.OutputVariables as Page
thisPage = Page.OutputVariables(win, case, stbar, tree)
elif page_name == "output/solutray":
import Pages.OutputVarRay as Page
thisPage = Page.OutputVarRayView(win, case, stbar, tree)
elif page_name == "numpar/numequ":
import Pages.NumericalParamEquation as Page
thisPage = Page.NumericalParamEquatView(win, case, stbar)
elif page_name == "numpar/numglo":
import Pages.NumericalParamGlobal as Page
thisPage = Page.NumericalParamGlobalView(win, case, stbar)
elif page_name == "managt/rstart":
import Pages.StartRestart as Page
thisPage = Page.StartRestartView(win, case, stbar)
elif page_name == "managt/batch":
import Pages.BatchRunning as Page
thisPage = Page.BatchRunning(win, case, stbar)
else:
import tkMessageBox
msg = "Warning: the corresponding Page doesn't exist!"
tkMessageBox.showerror('PAGE ERROR', msg)
return thisPage
#-------------------------------------------------------------------------------
# Text and messages
#-------------------------------------------------------------------------------
class Text:
"""
Code stolen from: "N3S interface".
Storage of all texts and messages.
"""
def __init__(self):
# 1) Texts
#
if GuiParam.lang == 'fr':
self.ABOUT = "À propos"
self.BGCOLOR = "Couleur du fond"
self.CASE_DISPLAY = "Affichage du cas courant"
self.CASE_NAME = "Nom du cas :"
self.CHEK_XML = "Vérification XML"
self.CLOSERUB = "Fermer rubriques"
self.ENGLISH = "anglais"
self.ERROR = "Erreur"
self.FILE = "Fichier"
self.FRENCH = "français"
self.GUI_TITLE = " Interface utilisateur de Code_Saturne"
self.HELP = "Aide"
self.LANGUAGE = "Langage"
self.LICENCE = "Licence"
self.NEW_FILE = "Nouveau fichier"
self.OFF = "off"
self.ON = "on"
self.OPEN = "Ouvrir"
self.OPENRUB = "Ouvrir rubriques"
self.OPENXTERM = "Ouvrir un terminal"
self.OPTION = "Options"
self.QUIT = "Quitter"
self.REFRESH = "Rafraîchir"
self.RELOAD = "Recharger"
self.RELOAD_ALL_MOD = "Recharge tous les modules"
self.RELOAD_PAGE = "Recharge la page courante"
self.RESIZE = "Redimensionne la fenêtre"
self.SAVE = "Enregister"
self.SAVE_AS = "Enregister sous..."
self.STUDY_NAME = "Nom de l'étude :"
self.SOUND = "Bip d'erreur"
self.TOOLS = "Outils"
self.TREEPOPUP = "Menu popup"
self.USER_MANUAL = "Manuels utilisateur"
self.USER_CS = "Code_Saturne"
self.USER_ECS = "Solution Domain"
self.USER_CS_KERNEL = "Code_Saturne Noyau"
self.USER_ECS_INFOS = "Code_Saturne Infos"
self.WARNING = "Attention"
self.WELCOME_PAGE = "Page d'accueil"
self.XML_NAME = "Nom du fichier XML :"
else:
self.ABOUT = "About"
self.BGCOLOR = "Background color"
self.CASE_DISPLAY = "Current case displaying"
self.CASE_NAME = "Case name:"
self.CHEK_XML = "XML checking"
self.CLOSERUB = "Collapse"
self.ENGLISH = "english"
self.ERROR = "Error"
self.FILE = "File"
self.FRENCH = "french"
self.HELP = "Help"
self.GUI_TITLE = "Code_Saturne user interface"
self.LANGUAGE = "Language"
self.LICENCE = "Licence"
self.NEW_FILE = "New file"
self.OFF = "off"
self.ON = "on"
self.OPEN = "Open"
self.OPENRUB = "Expand"
self.OPENXTERM = "Open shell"
self.OPTION = "Options"
self.QUIT = "Quit"
self.REFRESH = "Refresh"
self.RELOAD = "Reload"
self.RELOAD_ALL_MOD = "Reload all loaded modules"
self.RELOAD_PAGE = "Reload the loaded page"
self.RESIZE = "Resize window"
self.SAVE = "Save"
self.SAVE_AS = "Save as..."
self.SOUND = "Error beep"
self.STUDY_NAME = "Study name:"
self.TOOLS = "Tools"
self.TREEPOPUP = "Popup menu"
self.USER_MANUAL = "User manuals"
self.USER_CS = "Code_Saturne"
self.USER_ECS = "Solution Domain"
self.USER_CS_KERNEL = "Code_Saturne Kernel"
self.USER_ECS_INFOS = "Code_Saturne Infos"
self.WARNING = "Warning"
self.WELCOME_PAGE = "Welcome page"
self.XML_NAME = "XML file name:"
# 2) Dialogue Messages
#
if GuiParam.lang == 'fr':
self.EXIT = "Les modifications du cas courant "\
"ne sont pas enregistrées.\n\n"\
"Voulez-vous vraiment terminer ?\n"
self.MSG_NO_ACROREAD = "Acrobat Reader n'est pas disponible."
self.MSG_NO_INFO_CS = "Le shellscript 'info_cs' n'est pas disponible."
self.MSG_SUBDIR = "Des sous-répertoires du cas sont manquants. "\
"Un répertoire correct de cas doit être donné, "\
"ou le répertoire du cas doit être créé avec "\
"l'utilitaire 'cree_sat'."
self.MSG_TREE = "Cliquer le bouton droit pour "\
"le menu contextuel."
self.NEW_CASE = "Ouverture d'un nouveau cas."
self.NEW_CASE2 = "Appuyer pour créer un nouveau cas."
self.NO_SAVE = "Les modifications du cas courant "\
"ne sont pas enregistrés.\n\n"\
"Confirmez-vous l'ouverture d'un nouveau "\
"cas et la perte des modifications ?\n"
self.NO_XML = "Ouvrir un cas avant de selectionner "\
"une rubrique."
self.OLD_CASE = "Ouverture d'un cas précédent."
self.OLD_CASE2 = "Appuyer pour ouvrir un cas précédent."
self.RELOAD_F = "Recharge le cas courant à partir\n"\
"de sa dernière sauvegarde."
self.SAVE_CASE = "Enregistrement du cas courant."
self.SAVE_CASE2 = "Appuyer pour enregistrer le cas courant."
self.WRONG_FILE = "Attention : le fichier specifié en argument "\
"n'existe pas à l'endroit indiqué. Veuillez "\
"donner un autre fichier ou ouvrir un nouveau cas."
self.XML_ERR = "Erreur à la lecture du fichier XML. "\
"Ce fichier n'est pas conforme à la norme XML"\
". Corrigez le et vérifiez sa conformité avec "\
"l'outil XMLcheck."
else:
self.EXIT = "The current case is modified and not "\
"saved.\n\n"\
"Do you want really quit?\n"
self.MSG_NO_ACROREAD = "Acrobat Reader is not avalaible."
self.MSG_NO_INFO_CS = "The shellscript 'info_cs' is not avalaible."
self.MSG_SUBDIR = "Some case sub-directories are missing. You have "\
"to give a correct case path, or to build the "\
"case directory with the script 'cree_sat'."
self.MSG_TREE = "Click right button for popup menu."
self.NEW_CASE = "Open a new case."
self.NEW_CASE2 = "Press this button to open a new case"
self.NO_SAVE = "The current case is modified and not "\
"saved.\n\n"\
"Do you confirme the opening of a new case?\n"
self.NO_XML = "Please open a case before selecting an item."
self.OLD_CASE = "Opening a previous case."
self.OLD_CASE2 = "Press this button to open a previous case."
self.RELOAD_F = "Reload the current case from the last save."
self.SAVE_CASE = "Save the current case."
self.SAVE_CASE2 = "Press this button to save the current case."
self.WRONG_FILE = "Warning: the given file does not exist at "\
"the specified location. Please retry with "\
"another file or open a new case."
self.XML_ERR = "XML file reading error. "\
"This file is not in accordance with XML "\
"specifications. Please correct it and verify "\
"it with XMLcheck tool."
#-------------------------------------------------------------------------------
# Dictionary : dependance between names and labels
#-------------------------------------------------------------------------------
def dicoLabel(name):
"""
Correspondence between the names and the labels according to
whether one is in French or in English.
"""
for (n, labF, labE) in [('velocity_U', "VitesseX", "VelocitU"),
('velocity_V', "VitesseY", "VelocitV"),
('velocity_W', "VitesseZ", "VelocitW"),
('pressure', "Pression", "Pressure"),
('turb_k', "EnerTurb", "TurbEner"),
('turb_eps', "Dissip", "Dissip"),
('turb_viscosity', "visc. tu", "turb. vi"),
('component_R11', "R11", "R11"),
('component_R22', "R22", "R22"),
('component_R33', "R33", "R33"),
('component_R12', "R12", "R12"),
('component_R13', "R13", "R13"),
('component_R23', "R23", "R23"),
('turb_phi', "phi", "phi"),
('turb_fb', "fb", "fb"),
('turb_omega', "omega", "omega"),
('smagorinsky_constant', "Csdyn2", "Csdyn2"),
('temperature_celsius', "Temp.C", "Temp.C"),
('temperature_kelvin', "Temp.K", "Temp.K"),
('enthalpy', "Enthal.", "Enthalpy"),
('density', "Masse vo", "Density"),
('molecular_viscosity', "Visc. la", "Lam. vis"),
('specific_heat', "Ch.spec.", "Sp. heat"),
('thermal_conductivity', "Cond. th", "Th. cond"),
('local_time_step', "pdtlocal", "loc.time"),
('courant_number', "Nb Courant", "Courant nb"),
('fourier_number', "Nb Fourier", "Fourier nb"),
('weight_matrix_X', "Tx", "Tx"),
('weight_matrix_Y', "Ty", "Ty"),
('weight_matrix_Z', "Tz", "Tz")]:
if n == name:
if GuiParam.lang == 'fr':
label = labF
else:
label = labE
return label
def dicoRayLabel():
"""
"""
dico = {}
rayName = ['srad', 'qrad', 'absorp', 'emiss', 'coefAb',
'wall_temp', 'flux_incident', 'thermal_conductivity', 'thickness',
'emissivity', 'flux_net', 'flux_convectif', 'coeff_ech_conv']
raylabF = ['Srad', 'Qrad', 'Absorp', 'Emiss', 'CoefAb',
'Temp_paroi', 'Flux_incident', 'Conductivite_th', 'Epaisseur',
'Emissivite', 'Flux_net', 'Flux_convectif', 'Coeff_ech_conv']
raylabE = ['Srad', 'Qrad', 'Absorp', 'Emiss', 'CoefAb',
'Wall_temp', 'Flux_incident', 'Th_conductivity', 'Thickness',
'Emissivity','Flux_net', 'Flux_convectif', 'Coeff_ech_conv']
dico['name'] = rayName
dico['labF'] = raylabF
dico['labE'] = raylabE
if GuiParam.lang == 'fr':
label = dico['labF']
else:
label = dico['labE']
return dico['name'], label
#-------------------------------------------------------------------------------
# XML utility functions
#-------------------------------------------------------------------------------
##def xmlNewFile():
## """
## This important function initialize the xml document in the Saturne Case.
## Tere are two ways to do the initialization:
## The first one is just to create the root element of the XML document.
## It is the purpose of the next commented lines.
## The second one (and actually prefered) deals with a string which contains
## the root element and some importants headings and datas, in order to set
## good initial values and to make sure their presence in the final xml
## document.
## """
## # These lines are an first version of the function.
## #
## #xmldoc = Document()
## #xmltag = xmldoc.createElement(ROOT)
## #xmltag.setAttribute(ATTR_VERSION, VERSION)
## #xmltag.setAttribute(ATTR_STUDY, 'no_name')
## #xmltag.setAttribute(ATTR_CASE, 'no_name')
## #xmldoc.appendChild(xmltag)
## #
## #return xmldoc
##
## # Here we have the second version of the function.
## #
## # Here is a new version with label and correspondance
## # between label and name .....
##
##
## if GuiParam.lang == 'fr':
## xmldoc = \
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## ''+\
## '' +\
## '' +\
## '1.17862' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '1.83e-05' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '1017.24' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## ''
##
## else:
## xmldoc = \
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '1.17862' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '1.83e-05' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '1017.24' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## '' +\
## ''
##
## return xmldoc
##
#-------------------------------------------------------------------------------
# Debugging functions
#-------------------------------------------------------------------------------
def reload_modules(my_dir, dont_load):
"""
This function reloads all the currently loaded modules.
Very useful while debugging.
Code stolen from: MayaVi
"""
for key in sys.modules.keys():
if key not in dont_load:
mod = sys.modules[key]
if mod and hasattr(mod, '__file__'):
p = os.path.abspath(mod.__file__)
if os.path.commonprefix([p, my_dir]) == my_dir:
clean_pyc = os.path.dirname(os.path.abspath(mod.__file__))
clean_pyc = clean_pyc + '/*.pyc'
try:
os.remove(clean_pyc)
except:
pass
reload(mod)
def reload_all_modules():
"""
This function reload all modules currently loaded.
All '*.pyc' files are erased.
Only the 'Base.Common' module can not be reloaded.
Activated with the 'Ctrl+A' accelerator.
"""
my_dir = os.path.dirname(os.path.abspath(__name__))
dont_load = list(sys.builtin_module_names)
dont_load.append('Base.Common')
# All modules are reloaded twice because of trouble shooting
# with the Main.py module.
#
reload_modules(my_dir, dont_load)
reload_modules(my_dir, dont_load)
def reload_current_page():
"""
This function reload the currently loaded Page.
All '*.pyc' files are erased in the 'Pages' directory.
Activated with the 'Ctrl+R' accelerator.
"""
my_dir = PAGES_PATH
dont_load = list(sys.builtin_module_names)
reload_modules(my_dir, dont_load)
#-------------------------------------------------------------------------------
# End of Toolbox
#-------------------------------------------------------------------------------