# -*- 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 manages the layout of outputs control:
- listing printing
- post-processing and relationship with the FVM library
- monitoring points
This module defines the following classes:
- MultiSelect
- OutputControlView
- PageText
"""
#-------------------------------------------------------------------------------
# Library modules import
#-------------------------------------------------------------------------------
import string, sys
from types import FloatType
from xml.dom.minidom import parse
import Tix
from Tkconstants import *
#-------------------------------------------------------------------------------
# Application modules import
#-------------------------------------------------------------------------------
from Base.Common import *
import Base.Toolbox as Tool
import Base.Dialog as Dialog
import Base.TkPage as TkPage
from OutputControlModel import OutputControlModel
from SolutionDomainModel import SolutionDomainModel
#-------------------------------------------------------------------------------
# Multi-selection string
#-------------------------------------------------------------------------------
MULTISEL = "*****"
#-------------------------------------------------------------------------------
# Hlist multi-selection class
#-------------------------------------------------------------------------------
class MultiSelect:
"""
This class is design in order to manage the storage of the selected items in
the Hlist.
"""
def __init__(self, Hlist):
"""
Constructor
"""
self.Hlist = Hlist
def _initList(self):
"""
For each mouse selection we reinitialize all lists.
"""
self.NoL = []
self.XL = []
self.YL = []
self.ZL = []
def probeInfo(self, entry):
"""
Return info from the argument entry.
"""
# Here we must call the tk function directly without passing in
# Tix.py, because of a bug in tix8.1 in the Hlist.item_cget function
#
ctab = self.Hlist
numero = ctab.tk.call(ctab, 'item', 'cget', entry, 1, '-text')
coordX = ctab.tk.call(ctab, 'item', 'cget', entry, 2, '-text')
coordY = ctab.tk.call(ctab, 'item', 'cget', entry, 3, '-text')
coordZ = ctab.tk.call(ctab, 'item', 'cget', entry, 4, '-text')
return numero, float(coordX), float(coordY), float(coordZ)
def setItems(self, entriesL):
"""
Store values when a new selection is done.
"""
self._initList()
for entry in entriesL:
numero, coordX, coordY, coordZ = self.probeInfo(entry)
self.NoL.append(numero)
self.XL.append(coordX)
self.YL.append(coordY)
self.ZL.append(coordZ)
def getItems(self, entriesL):
"""
"""
self.setItems(entriesL)
return self.NoL, self.XL, self.YL, self.ZL
def widgetText(self):
"""
Find the right texts for the widget layout.
"""
numero = self.NoL[0]
coordX = self.XL[0]
coordY = self.YL[0]
coordZ = self.ZL[0]
for i in self.NoL:
if numero != i:
numero = MULTISEL
for i in self.XL:
if coordX != i:
coordX = MULTISEL
for i in self.YL:
if coordY != i:
coordY = MULTISEL
for i in self.ZL:
if coordZ != i:
coordZ = MULTISEL
if coordX != MULTISEL: coordX = "%g" % (coordX)
if coordY != MULTISEL: coordY = "%g" % (coordY)
if coordZ != MULTISEL: coordZ = "%g" % (coordZ)
return numero, coordX, coordY, coordZ
#-------------------------------------------------------------------------------
# View class
#-------------------------------------------------------------------------------
class OutputControlView(TkPage.Page):
"""
Class to open Turbulence Page.
"""
def _dependsPages(self, name):
"""
Construction of the list of dependencies Pages.
"""
self.case[name]['depends'] = ['models/turbul',
'models/therma',
'models/flame',
'models/pucoal',
'models/joule',
'models/radiat']
def _pageControl(self):
"""
Xml node declaration and supplementary default value settings.
"""
self.mdl = OutputControlModel(self.case)
self.selectedEntry = None
self.currentEntry = None
def _tkControlVariables(self):
"""
Tkinter variables declaration.
"""
self.ntlist = Tix.IntVar()
self.ntchr = Tix.IntVar()
self.nthist = Tix.IntVar()
self.ichrvl = Tix.StringVar()
self.ichrbo = Tix.StringVar()
self.ichrsy = Tix.StringVar()
self.listing = Tix.StringVar()
self.chrono = Tix.StringVar()
self.histo = Tix.StringVar()
self.format = Tix.StringVar()
self.opt_format = Tix.StringVar()
self.opt_bigendian = Tix.StringVar()
self.opt_splittens = Tix.StringVar()
self.opt_polygon = Tix.StringVar()
self.opt_polyhed = Tix.StringVar()
self.X = Tix.StringVar()
self.Y = Tix.StringVar()
self.Z = Tix.StringVar()
def getListing(self, event=None):
"""
INPUT choice of the output listing
"""
self.stbar.busy()
listing= self.listing.get()
if listing == "None":
ntlist = -1
self.mdl.setListingFrequency(ntlist)
self.ntlist.set(ntlist)
self.n.config(state=DISABLED, bg='grey')
if listing == "At each step":
ntlist = 1
self.mdl.setListingFrequency(ntlist)
self.ntlist.set(ntlist)
self.n.config(state=DISABLED, bg='grey')
if listing == "Frequency_l":
self.n.config(state=NORMAL,bg='white')
if self.ntlist.get() < 1 : self.ntlist.set(1)
self.getFreqL()
self.stbar.idle()
def getPostprocessing(self, event=None):
"""
INPUT choice of the output for the Postprocessor (Ensight,...)
"""
self.stbar.busy()
chrono = self.chrono.get()
if chrono == "At the end":
ntchr = -1
self.mdl.setPostprocessingFrequency(ntchr)
self.ntchr.set(ntchr)
self.fens.config(state=DISABLED, bg='grey')
elif chrono == "Frequency_c":
self.fens.config(state=NORMAL, bg='white')
if self.ntchr.get() < 1 : self.ntchr.set(1)
self.getFreqC()
self.stbar.idle()
def getStatusSyrthes(self):
"""
Return "on" if wall thermal coupling is enabled, "off" otherwise.
"""
return SolutionDomainModel(self.case).getSyrthesCouplingStatus()
def getIchr(self, num, var, event=None):
"""
Input value of ICHRVL et ICHRBO et ICHRSY
"""
self.stbar.busy()
v = var.get()
if self.getIchrStatus(num) != v:
self.setIchrStatus(num,v)
self.stbar.idle()
def getIchrStatus(self, num):
if num == 0: self.mdl.getFluidDomainPostProStatus()
if num == 1: self.mdl.getDomainBoundaryPostProStatus()
if num == 2: self.mdl.getSyrthesBoundaryPostProStatus()
def setIchrStatus(self, num ,status):
if num == 0: self.mdl.setFluidDomainPostProStatus(status)
if num == 1: self.mdl.setDomainBoundaryPostProStatus(status)
if num == 2: self.mdl.setSyrthesBoundaryPostProStatus(status)
def getFormat(self, event=None):
"""
Input format of post-processing
"""
self.stbar.busy()
fmt = self.format.get()
if self.mdl.getPostProFormat() != fmt:
self.mdl.setPostProFormat(fmt)
line = self.mdl.defaultInitialValues()['postprocessing_options']
self.mdl.setPostProOptionsFormat(line)
self.updateOptionsFormat(line)
self.stbar.idle
def updateOptionsFormat(self, line):
"""
Update ligne for command of format's options at each modification of
post processing format
"""
list = string.split(line, ',')
for opt in list:
if opt == 'binary' or opt == 'text':
self.optf.config(value=opt)
if opt == 'discard_polygons' or opt == 'divide_polygons':
self.optpg.config(value=opt)
if opt == 'discard_polyhedra' or opt == 'divide_polyhedra':
self.optph.config(value=opt)
if self.format.get() == 'EnSight':
if opt == 'big_endian':
self.opt_bigendian.set('on')
if opt == 'split_tensors':
self.opt_splittens.set('on')
if 'discard_polygons' not in list and 'divide_polygons' not in list:
self.optpg.config(value="display")
if 'discard_polyhedra' not in list and 'divide_polyhedra' not in list:
self.optph.config(value="display")
if 'big_endian' not in list:
self.opt_bigendian.set('off')
if 'split_tensors' not in list:
self.opt_splittens.set('off')
if self.format.get() != "EnSight":
self.optf.disable('text')
self.optf.config(value="binary")
self.loptbe.config(state=DISABLED)
self.optbe.config(state=DISABLED)
self.loptsp.config(state=DISABLED)
self.optsp.config(state=DISABLED)
else:
self.optf.enable('text')
self.optf.config(state=NORMAL)
self.loptbe.config(state=NORMAL)
self.optbe.config(state=NORMAL)
self.loptsp.config(state=NORMAL)
self.optsp.config(state=NORMAL)
def buildOptionsFormat(self, event=None ):
"""
Create characters ligne for command of format's options
"""
line = []
line.append(self.opt_format.get())
if self.opt_bigendian.get() == "on" : line.append('big_endian')
if self.opt_splittens.get() == "on" : line.append('split_tensors')
if self.opt_polygon.get() != 'display': line.append(self.opt_polygon.get())
if self.opt_polyhed.get() != 'display': line.append(self.opt_polyhed.get())
l = string.join(line, ',')
self.mdl.setPostProOptionsFormat(l)
def getHisto(self, event=None):
"""
Input choice of the output of monitoring points files
"""
self.stbar.busy()
histo = self.histo.get()
if histo == "None":
nthist = -1
self.mdl.setMonitoringPointFrequency(nthist)
self.nthist.set(nthist)
self.fhis.config(state=DISABLED, bg='grey')
if histo == "At each step_h":
nthist = 1
self.mdl.setMonitoringPointFrequency(nthist)
self.nthist.set(nthist)
self.fhis.config(state=DISABLED, bg='grey')
if histo == "Frequency_h":
nthist = 1
self.fhis.config(state=NORMAL, bg='white')
if self.nthist.get() < 1 : self.nthist.set(1)
self.getFreqH()
self.stbar.idle()
def getFreqL(self, event=None):
"""
Input the frequency of the listing output
"""
self.stbar.busy()
if self.listing.get() == "Frequency_l":
if self.check2.isSPositive(self.n, self.ntlist):
ntlist = self.ntlist.get()
self.mdl.setListingFrequency(ntlist)
else:
t = PageText()
self.stbar.set(t.MSG_POSITIV)
self.stbar.idle()
def getFreqC(self, event=None):
"""
Input the frequency of the post-processing output
"""
self.stbar.busy()
if self.chrono.get() == "Frequency_c":
if self.check2.isSPositive(self.fens, self.ntchr):
ntchr = self.ntchr.get()
self.mdl.setPostprocessingFrequency(ntchr)
else:
t = PageText()
self.stbar.set(t.MSG_POSITIV)
self.stbar.idle()
def getFreqH(self, event=None):
"""
Input the frequency of the monitoring point output
"""
self.stbar.busy()
if self.histo.get() == "Frequency_h":
if self.check2.isSPositive(self.fhis, self.nthist):
nthist = self.nthist.get()
self.mdl.setMonitoringPointFrequency(nthist)
else:
t = PageText()
self.stbar.set(t.MSG_POSITIV)
self.stbar.idle()
def _make_style(self):
"""
Define beautiful style in order to display columns in teh Hlist
"""
self.style = {}
self.style['header'] = Tix.DisplayStyle(Tix.TEXT,
refwindow=self.ftab,
anchor=CENTER,
padx=5, pady=2, font=fB)
self.style['styleV'] = Tix.DisplayStyle(Tix.TEXT,
refwindow=self.ftab,
anchor=CENTER,
padx=5, fg='brown', font=fN)
self.style['style'] = Tix.DisplayStyle(Tix.TEXT,
refwindow=self.ftab,
anchor=CENTER,
padx=5, fg='brown', font=fN)
self.style['check'] = Tix.DisplayStyle(Tix.IMAGETEXT,
refwindow=self.ftab,
fg='brown', font=fN)
def isFloat(self, entry, var):
"""
Verify if the 'entry' contents a float. If not, signal an error
and return None.
"""
try:
double = float(var.get())
except:
self.check2.error(entry)
double = None
return double
def string2float(self, entry, var):
"""
If the StringVar() 'var' associated to the 'entry', is not a 'MULTISEL',
convert it to a float.
"""
self.check2.begin(entry)
# Several selections in Hlist
if self.currentEntry and len(self.currentEntry) > 1:
if var.get() != MULTISEL:
double = self.isFloat(entry, var)
else:
double = MULTISEL
# Only one selection in Hlist
else:
double = self.isFloat(entry, var)
return double
def getX(self, event=None):
"""
Store the X coordinate.
"""
if not self.X.get(): self.X.set('0.0')
return self.string2float(self.ent[0], self.X)
def getY(self, event=None):
"""
Store the Y coordinate.
"""
if not self.Y.get(): self.Y.set('0.0')
return self.string2float(self.ent[1], self.Y)
def getZ(self, event=None):
"""
Store the Z coordinate.
"""
if not self.Z.get(): self.Z.set('0.0')
return self.string2float(self.ent[2], self.Z)
def insertHlist(self, num, X, Y, Z):
"""
Add a new 'item' into the Hlist.
"""
probe_num = self.mdl.dicoName[str(num)]
self.ctab.hlist.add(probe_num, itemtype=Tix.IMAGETEXT,
style=self.style['check'])
self.ctab.hlist.item_create(probe_num, 1, itemtype=Tix.TEXT, text=num,
style=self.style['style'])
self.ctab.hlist.item_create(probe_num, 2, itemtype=Tix.TEXT, text=X,
style=self.style['style'])
self.ctab.hlist.item_create(probe_num, 3, itemtype=Tix.TEXT, text=Y,
style=self.style['style'])
self.ctab.hlist.item_create(probe_num, 4, itemtype=Tix.TEXT, text=Z,
style=self.style['style'])
def replaceHlist(self, num, X, Y, Z):
"""
Update the 'item' into the Hlist.
"""
item = self.mdl.dicoName[str(num)]
self.ctab.hlist.item_configure(item, 2, itemtype=Tix.TEXT, text=X,
style=self.style['style'])
self.ctab.hlist.item_configure(item, 3, itemtype=Tix.TEXT, text=Y,
style=self.style['style'])
self.ctab.hlist.item_configure(item, 4, itemtype=Tix.TEXT, text=Z,
style=self.style['style'])
def eraseEntries(self, event=None):
"""
Delete all caracters in the entries.
"""
t = PageText()
self.ent[0].delete(0, END)
self.ent[1].delete(0, END)
self.ent[2].delete(0, END)
def addHlist(self, event=None):
"""
Add one monitoring point with these coordinates in the list in the Hlist
The number of the monitoring point is added at the precedent one
"""
X = self.getX()
Y = self.getY()
Z = self.getZ()
for c in X,Y,Z:
if type(c) != FloatType: return
self.stbar.busy()
ind = self.mdl.addMonitoringPoint(x=X, y=Y, z=Z)
self.insertHlist(ind, X, Y, Z)
self.stbar.idle()
def setEditedValueHlist(self, num, old_X, old_Y, old_Z):
"""
Checking consistency of values and interpreting
complexe entry for reference if necessary.
"""
# Get back data from entries
#
self.stbar.busy()
new_X = self.getX()
new_Y = self.getY()
new_Z = self.getZ()
if new_X != None and new_Y != None and new_Z != None:
if new_X == MULTISEL: new_X = old_X
if new_Y == MULTISEL: new_Y = old_Y
if new_Z == MULTISEL: new_Z = old_Z
self.mdl.replaceMonitoringPointCoordinates(name=str(num),
x=new_X, y=new_Y, z=new_Z)
self.replaceHlist(num, new_X, new_Y, new_Z)
self.stbar.idle()
def modifyHlist(self, event=None):
"""
"""
if not self.currentEntry: return
self.stbar.busy()
for entry in self.currentEntry:
num, X, Y, Z = self.select.probeInfo(entry)
self.setEditedValueHlist(num, X, Y, Z)
self.selectHlist()
self.stbar.idle()
def deleteHlist(self, event=None):
"""
Just delete the current selected entries from the Hlist and
of course from the XML file.
"""
if not self.currentEntry: return
self.stbar.busy()
numL, XL, YL, ZL = self.select.getItems(self.currentEntry)
for entry in self.currentEntry:
num, X, Y, Z = self.select.probeInfo(entry)
self.ctab.hlist.delete_entry(self.mdl.dicoName[str(num)])
self.mdl.deleteMonitoringPointsList(numL)
# on efface toute la Hlist et on la recharge
self.selectHlistAll()
self.cancelSelection()
self.reloadHlist()
self.eraseEntries()
self.currentEntry = None
self.selectHlist()
self.stbar.idle()
def selectHlist(self,entry=None):
"""
Browsecmd:
Every single Clik on the Button1 of the mouse send TWO signal to the GUI
the first one when man push the button, and the second one when the
button gets back.
Command:
Every double-Click and Return send only ONE signal to the GUI.
"""
self.selectedEntry = self.ctab.hlist.info_selection()
if not self.selectedEntry:
self.ent[0].config(state=NORMAL)
self.ent[1].config(state=NORMAL)
self.ent[2].config(state=NORMAL)
elif self.currentEntry != self.selectedEntry:
self.currentEntry = self.selectedEntry
self.select.setItems(self.currentEntry)
num, X, Y, Z = self.select.widgetText()
self.ent[0].delete(0,END)
self.ent[0].insert(0,X)
self.ent[0].icursor(END)
self.ent[1].delete(0,END)
self.ent[1].insert(0,Y)
self.ent[1].icursor(END)
self.ent[2].delete(0,END)
self.ent[2].insert(0,Z)
self.ent[2].icursor(END)
else:
num, X, Y, Z = self.select.widgetText()
def reloadHlist(self):
"""
Destroy the contents of the Hlist, and reload the scalar data
from the XMLdoc.
"""
t = PageText()
try:
self.ctab.hlist.delete_all()
except:
pass
probes, X, Y, Z = self.mdl.getMonitoringPointInfo()
for i in range(len(probes)):
self.insertHlist(probes[i], X[i], Y[i], Z[i])
def selectHlistAll(self):
"""
Fonction for the Popup Menu.
Select everything in the Hlist.
"""
try:
key = self.mdl.dicoName.keys()[0]
first = self.mdl.dicoName[key]
except:
first = 1
try:
L= map(int, self.mdl.dicoName.keys())
ind = reduce(max,L)
last = self.mdl.dicoName[str(ind)]
except:
last = 1
# ça plante sans try ...except
# et je ne sais pas pourquoi (pour l'instant :-) )
try: self.ctab.hlist.selection_set(first, last)
except: pass
self.currentEntry = None
self.selectHlist()
def cancelSelection(self):
"""
Fonction for the Popup Menu.
Blank the selection.
"""
self.ctab.hlist.selection_clear()
self.eraseEntries()
self.currentEntry = None
self.selectHlist()
def _createWidgets(self):
"""
Create the Page layout.
"""
t = PageText()
# NoteBook and tabs layout
#
nb = Tix.NoteBook(self.myPage)
nb.pack(expand=1, side=TOP, fill=BOTH)
nb.nbframe.config(background=self.bg, backpagecolor=self.bg)
nb.nbframe.config(focuscolor=self.bg, inactivebackground=wm['inactivebackground'])
nb.nbframe.config(relief=RAISED)
nb.nbframe.config(font=fT, tabpadx='10', tabpady='2')
nb.add('page1', anchor='center', label=t.OUTPUT_TITLE)
nb.add('page2', anchor='center', label=t.SONDES_TITLE)
########################################################
# NoteBook Page 1
########################################################
# ******** Output LISTING *******
#
f1 = Tix.LabelFrame(nb.page1, label=t.LISTING, relief=FLAT)
f1.label.config(font=fT)
f1.pack(side=TOP, fill=X, padx=10, pady=5)
w1 = Tix.Frame(f1.frame, relief=FLAT)
w1.pack(side=TOP, fill=X)
self.c = Tix.OptionMenu(w1)
self.c.menubutton.config(width=34, bd=2, relief=RAISED)
self.c.grid(row=0, column=0, padx=10, pady=10, sticky=W)
self.c.add_command('None', label=t.NO_OUTPUT)
self.c.add_command('At each step', label=t.EACH_STEP)
self.c.add_command('Frequency_l', label=t.FREQUENCY)
self.c.config(variable=self.listing, command=self.getListing)
# Frequency 'n' for output listing if 'frequency' asked
self.w2 = Tix.Frame(w1, relief=FLAT)
self.w2.grid(row=0, column=1, padx=10, pady=10, sticky=E)
self.n = Tix.Entry(self.w2,width=6,textvariable=self.ntlist)
self.n.grid(row=0,column=2,padx=10, pady=10, sticky=E)
self.n.event_add("<<Event>>","<Return>","<Leave>","<FocusOut>")
self.n.bind("<<Event>>",self.getFreqL)
self.balloon.bind_widget(self.n,balloonmsg=t.KEYWORD+'NTLIST')
# ******** Post processing *******
#
f2 = Tix.LabelFrame(nb.page1, label=t.CHRONO, relief=FLAT)
f2.label.config(font=fT)
f2.pack(side=TOP, fill=X, padx=10, pady=5)
wens = Tix.Frame(f2.frame, relief=FLAT)
wens.pack(side=TOP, fill=X)
self.ch = Tix.OptionMenu(wens)
self.ch.menubutton.config(width=34, bd=2, relief=RAISED)
self.ch.grid(row=0, column=0, padx=10, pady=10, sticky=W)
self.ch.add_command('At the end', label=t.ATHEND)
self.ch.add_command('Frequency_c', label=t.FREQCHRO)
self.ch.config(variable=self.chrono, command=self.getPostprocessing)
# Frequency 'c' for output chrono if 'frequency' asked
#
self.wens2 = Tix.Frame(wens, relief=FLAT)
self.wens2.grid(row=0, column=1, padx=10, pady=10, sticky=E)
self.fens = Tix.Entry(self.wens2,width=6,textvariable=self.ntchr)
self.fens.grid(row=0,column=2,padx=10, pady=10, sticky=E)
self.fens.event_add("<<Event>>","<Return>","<Leave>","<FocusOut>")
self.fens.bind("<<Event>>",self.getFreqC)
self.balloon.bind_widget(self.fens,balloonmsg=t.KEYWORD+'NTCHR')
# separator
Tix.Frame(f2.frame, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X)
wdom = Tix.Frame(f2.frame, relief=FLAT)
wdom.pack(side=TOP, fill=X)
# we search if Syrthes is used
syr = self.getStatusSyrthes()
ldom=[0]*3
self.bdom=[0]*3
for (num, var, tt,tx) in [(0, self.ichrvl, t.ICHRVL, "ICHRVL"),
(1, self.ichrbo, t.ICHRBO, "ICHRBO"),
(2, self.ichrsy, t.ICHRSY, "ICHRSY")]:
if num == 2 and syr != "on":
pass
else:
ldom[num] = Tix.Label(wdom, text=tt)
ldom[num].grid(row=num, column=0, padx=20, pady=2, sticky=W)
self.bdom[num] = Tix.Checkbutton(wdom, onvalue='on', offvalue='off',
width=6, anchor=W,
variable=var,
command=TkPage.Callback(self.getIchr, num, var))
self.bdom[num].grid(row=num, column=1, padx=20, pady=2, sticky=W)
self.balloon.bind_widget(ldom[num],balloonmsg=t.KEYWORD+tx)
# separator
Tix.Frame(f2.frame, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X)
wens = Tix.Frame(f2.frame, relief=FLAT)
wens.pack(side=TOP, fill=X)
Tix.Label(wens, text=t.FORMATS).grid(row=0, column=0, padx=12, pady=10, sticky=W)
self.f = Tix.OptionMenu(wens)
self.f.menubutton.config(width=15, bd=2, relief=RAISED)
self.f.grid(row=0, column=1, padx=10, pady=10, sticky=E)
self.f.add_command('EnSight', label=t.ENSGOLD)
self.f.add_command('MED_fichier', label=t.MED)
self.f.add_command('CGNS', label=t.CGNS)
self.f.config(variable=self.format, command=self.getFormat)
self.balloon.bind_widget(self.f, balloonmsg=t.KEYWORD+"FMTCHR")
fopt = Tix.LabelFrame(f2.frame, label=t.OPTIONS, relief=FLAT)
fopt.label.config(font=fT)
fopt.pack(side=TOP, fill=X, padx=10, pady=0)
wfmt = Tix.Frame(fopt.frame, relief=FLAT)
wfmt.pack(side=TOP, fill=X)
Tix.Label(wfmt, text=t.FORMAT).grid(row=0, column=0, padx=10, pady=10, sticky=W)
self.optf = Tix.OptionMenu(wfmt)
self.optf.menubutton.config(width=10, bd=2, relief=RAISED)
self.optf.grid(row=0, column=1, padx=10, pady=5, sticky=E)
self.optf.add_command('binary', label=t.FBINARY)
self.optf.add_command('text', label=t.FTEXT)
self.optf.config(variable=self.opt_format, command=self.buildOptionsFormat)
Tix.Label(wfmt, text=t.FPOLYGON).grid(row=1, column=0, padx=10, pady=10, sticky=W)
self.optpg = Tix.OptionMenu(wfmt)
self.optpg.menubutton.config(width=10, bd=2, relief=RAISED)
self.optpg.grid(row=1, column=1, padx=10, pady=5, sticky=E)
self.optpg.add_command('display', label=t.FDISPLAY)
self.optpg.add_command('discard_polygons', label=t.FDISCARD)
self.optpg.add_command('divide_polygons', label=t.FDIVIDE)
self.optpg.config(variable=self.opt_polygon, command=self.buildOptionsFormat)
self.balloon.bind_widget(self.optpg, balloonmsg=t.KEYWORD+"OPTCHR")
Tix.Label(wfmt, text=t.FPOLYHED).grid(row=2, column=0, padx=10, pady=10, sticky=W)
self.optph = Tix.OptionMenu(wfmt)
self.optph.menubutton.config(width=10, bd=2, relief=RAISED)
self.optph.grid(row=2, column=1, padx=10, pady=5, sticky=E)
self.optph.add_command('display', label=t.FDISPLAY)
self.optph.add_command('discard_polyhedra', label=t.FDISCARD)
self.optph.add_command('divide_polyhedra', label=t.FDIVIDE)
self.optph.config(variable=self.opt_polyhed, command=self.buildOptionsFormat)
self.balloon.bind_widget(self.optph, balloonmsg=t.KEYWORD+"OPTCHR")
self.loptbe = Tix.Label(wfmt, text=t.FBIGEND)
self.loptbe.grid(row=3, column=0, padx=10, pady=2, sticky=W)
self.balloon.bind_widget(self.loptbe, balloonmsg=t.KEYWORD+"OPTCHR")
self.optbe = Tix.Checkbutton(wfmt, onvalue='on', offvalue='off',
width=6, anchor=W,
variable=self.opt_bigendian,
command=self.buildOptionsFormat)
self.optbe.grid(row=3, column=1, padx=10, pady=2, sticky=W)
self.loptsp = Tix.Label(wfmt, text=t.FSPLITTENS)
self.loptsp.grid(row=4, column=0, padx=10, pady=2, sticky=W)
self.balloon.bind_widget(self.loptsp, balloonmsg=t.KEYWORD+"OPTCHR")
self.optsp = Tix.Checkbutton(wfmt, onvalue='on', offvalue='off',
width=6, anchor=W,
variable=self.opt_splittens,
command=self.buildOptionsFormat)
self.optsp.grid(row=4, column=1, padx=10, pady=2, sticky=W)
########################################################
# NoteBook Page 2
########################################################
# ******** DEFINITION OF MONITORING POINTS *******
#
# Put a Hlist
# frame for board
self.ftab = Tix.Frame(nb.page2, relief=FLAT)
self.ftab.pack(side=TOP, fill=X)
self.ctab = Tix.ScrolledHList(self.ftab, options=' \
hlist.columns 6 \
hlist.header 1 \
hlist.wideSelection "1" ')
self.ctab.config(scrollbar="auto +x +y")
self.ctab.hlist.config(browsecmd=self.selectHlist,
selectmode='extended',
bg=wm['hlistbackground'],
relief=SUNKEN, bd=2)
self.ctab.vsb.config(width=10, bd=1)
self.ctab.hsb.config(width=10, bd=1)
self.ctab.pack(expand=1, fill=BOTH, padx=10, pady=5, side=TOP)
# labels of colums
self._make_style()
self.ctab.hlist.header_create(0, itemtype=Tix.TEXT, text="", style=self.style['header'])
self.ctab.hlist.header_create(1, itemtype=Tix.TEXT, text='n', style=self.style['header'])
self.ctab.hlist.header_create(2, itemtype=Tix.TEXT, text='X', style=self.style['header'])
self.ctab.hlist.header_create(3, itemtype=Tix.TEXT, text='Y', style=self.style['header'])
self.ctab.hlist.header_create(4, itemtype=Tix.TEXT, text='Z', style=self.style['header'])
self.ctab.hlist.column_width(5,0)
self.ctab.hlist.column_width(0, chars=0)
self.ctab.hlist.column_width(1, chars=6)
self.ctab.hlist.column_width(2, chars=15)
self.ctab.hlist.column_width(3, chars=15)
self.ctab.hlist.column_width(4, chars=15)
# Create the mouse selection instance
#
self.select = MultiSelect(self.ctab.hlist)
# Popup Menu
#
pm = Tix.PopupMenu(self.ctab.hlist, title=t.POPUP, state=NORMAL)
pm.bind_widget(self.ctab.hlist)
pm.menu.add_separator()
pm.menu.add_command(label=t.SELECT_ALL, command=self.selectHlistAll)
pm.menu.add_command(label=t.UNSELECT, command=self.cancelSelection)
pm.menu.m1 = Tix.Menu(pm.menu)
# widgets for label of model scalar
#
self.cent = Tix.LabelFrame(nb.page2, label=t.COORD, relief=FLAT)
self.cent.label.config(font=fT)
self.cent.pack(side=TOP, fill=X,padx=10, pady=5)
cw1 = Tix.Frame(self.cent.frame, relief=FLAT)
cw1.pack(side=TOP, fill=X, padx=10, pady=10 )
self.lab = [0]*3
self.ent = [0]*3
self.uni = [0]*3
for (i, coor, var, tx) in [(0, 'X', self.X, t.TX),
(1, 'Y', self.Y, t.TY),
(2, 'Z', self.Z, t.TZ)]:
self.lab[i] = Tix.Label(cw1, text=coor)
self.lab[i].grid(row=i, column=0, padx=5, pady=2, sticky=E)
self.balloon.bind_widget(self.lab[i],balloonmsg=t.KEYWORD+tx)
self.ent[i] = Tix.Entry(cw1, bd=2, width=10, textvariable=var)
self.ent[i].grid(row=i, column=1, padx=0, pady=2, sticky=W)
self.uni[i] = Tix.Label(cw1, text='m')
self.uni[i].grid(row=i, column=2, padx=5, sticky=W)
box = Tix.ButtonBox(cw1, orientation=VERTICAL, relief=FLAT)
box.add('add', text=t.ADD, command=self.addHlist)
box.add('modify', text=t.MODIFY, command=self.modifyHlist)
box.add('delete', text=t.DELETE, command=self.deleteHlist)
box.grid(row=0, column=3, rowspan=3, padx=30)
# ******** Output for Monitoring points files *******
#
f3 = Tix.LabelFrame(nb.page2, label=t.HISTO, relief=FLAT)
f3.label.config(font=fT)
f3.pack(side=TOP, fill=X, padx=10, pady=5)
wi = Tix.Frame(f3.frame, relief=FLAT)
wi.pack(side=TOP, fill=X, pady=10)
whis = Tix.Frame(wi, relief=FLAT)
whis.pack(side=TOP, fill=X, pady=5)
self.h = Tix.OptionMenu(whis)
self.h.menubutton.config(width=34, bd=2, relief=RAISED)
self.h.grid(row=0, column=0, padx=10, pady=5, sticky=W)
self.h.add_command('None', label=t.NO_HISTO)
self.h.add_command('At each step_h', label=t.EACH_STEPH)
self.h.add_command('Frequency_h', label=t.FREQH)
self.h.config(variable=self.histo, command=self.getHisto)
# Frequency for output
self.whf = Tix.Frame(whis, relief=FLAT)
self.whf.grid(row=0, column=1, padx=10, pady=5, sticky=E)
self.fhis = Tix.Entry(self.whf,width=6,textvariable=self.nthist)
self.fhis.grid(row=0,column=1,padx=10, pady=5, sticky=E)
self.fhis.event_add("<<Event>>","<Return>","<Leave>","<FocusOut>")
self.fhis.bind("<<Event>>",self.getFreqH)
self.balloon.bind_widget(self.fhis,balloonmsg=t.KEYWORD+'NTHIST')
def _initializeWidgets(self):
"""
Extract resquested informations from XML document.
This informations are used to initialize the widgets.
For this page default values of all widgets are necessary
included in the XML file.
Fonction used in the Popup Menu to.
"""
t = PageText()
# Initialisation of the listing frequency
#
ntlist = self.mdl.getListingFrequency()
self.ntlist.set(ntlist)
if ntlist == -1:
self.c.config(value="None")
elif ntlist == 1:
self.c.config(value="At each step")
else:
self.c.config(value="Frequency_l")
# Initialisation of the output for the postprocessor :
# Number of outputs
ntchr = self.mdl.getPostprocessingFrequency()
self.ntchr.set(ntchr)
if ntchr == -1:
self.ch.config(value="At the end")
else:
self.ch.config(value="Frequency_c")
# values of post processing's keywords
for (num, var, tt) in [(0, self.ichrvl, t.ICHRVL),
(1, self.ichrbo, t.ICHRBO),
(2, self.ichrsy, t.ICHRSY)]:
if num == 2 and self.getStatusSyrthes() != "on":
pass
if num == 0:
var.set('on')
status = self.mdl.getFluidDomainPostProStatus()
if status == "off": var.set('off')
if num == 1:
var.set('off')
status = self.mdl.getDomainBoundaryPostProStatus()
if status == "on": var.set('on')
if num == 2:
var.set('off')
status = self.mdl.getDomainBoundaryPostProStatus()
if self.getStatusSyrthes() == "on":
var.set('on')
if status == "off": var.set('off')
# values of post processing's format
fmt = self.mdl.getPostProFormat()
self.f.config(value=fmt)
line = self.mdl.getPostProOptionsFormat()
self.updateOptionsFormat(line)
# Initialisation of the monitoring points files :
#
nthist = self.mdl.getMonitoringPointFrequency()
if nthist == -1:
self.h.config(value="None")
elif nthist == 1:
self.h.config(value="At each step_h")
else:
self.nthist.set(nthist)
self.h.config(value="Frequency_h")
if Tool.GuiParam.matisse :
self.cent.pack_forget()
self.reloadHlist()
self.cancelSelection()
#-------------------------------------------------------------------------------
# Text and messages for this page
#-------------------------------------------------------------------------------
class PageText:
"""
Storage of all texts and messages for this page.
"""
def __init__(self):
# 1) Texts
#
if Tool.GuiParam.lang == 'fr':
self.ADD = "Ajouter"
self.ATHEND = "Post traitement à la fin du calcul"
self.CGNS = "CGNS"
self.CHRONO = "Post traitement"
self.COORD = "Coordonnées des points de monitoring"
self.DELETE = "Supprimer"
self.EACH_STEP = "Sortie listing à chaque pas de temps"
self.EACH_STEPH = "Fichiers à chaque pas de temps"
self.ENSGOLD = "EnSight Gold"
self.FBINARY = "binaire"
self.FTEXT = "texte"
self.FBIGEND = "big_endian"
self.FDISPLAY = "afficher"
self.FDISCARD = "ignorer"
self.FDIVIDE = "diviser"
self.FSPLITTENS = "split_tensors"
self.FORMATS = "Format"
self.FORMAT = "format"
self.FREQCHRO = "Chronologique à tous les 'n' pas de temps"
self.FREQH = "Fichiers à tous les 'n' pas de temps"
self.FREQUENCY = "Sortie à tous les 'n' pas de temps"
self.HISTO = "Fichiers des points de monitoring"
self.ICHRVL = "Post traitement du domaine fluide"
self.ICHRBO = "Post traitement des bords du domaine"
self.ICHRSY = "Post traitement des bords Syrthes"
self.KEYWORD = "Mot clé Code_Saturne : "
self.LISTING = "Sorties listing"
self.MED = "MED_fichier"
self.MODIFY = "Modifier"
self.NO_OUTPUT = "Aucune sortie listing"
self.NO_HISTO = "Aucun fichier"
self.OPTIONS = "Options"
self.OUTPUT_TITLE = "GESTION DES SORTIES"
self.FPOLYGON = "polygones"
self.FPOLYHED = "polyedres"
self.POPUP = "Menu popup"
self.SELECT_ALL = "Tout sélectionner"
self.SONDES_TITLE = "GESTION DES POINTS DE MONITORING"
self.TX = "XYZCAPT(1,n) avec n : n° du point de monitoring"
self.TY = "XYZCAPT(2,n) avec n : n° de point de monitoring"
self.TZ = "XYZCAPT(3,n) avec n : n° de point de monitoring"
self.UNSELECT = "Désélectionner"
else:
self.ADD = "Add"
self.ATHEND = "Only at the end of calculation"
self.CGNS = "CGNS"
self.CHRONO = "Post processing"
self.COORD = "Monitoring points's coordinates"
self.DELETE = "Delete"
self.EACH_STEP = "Output listing at each time step"
self.EACH_STEPH = "Monitoring points files at each time step"
self.ENSGOLD = "EnSight Gold"
self.FBINARY = "binary"
self.FTEXT = "text"
self.FBIGEND = "big_endian"
self.FDISPLAY = "to display"
self.FDISCARD = "to discard"
self.FDIVIDE = "to divide"
self.FSPLITTENS = "split_tensors"
self.FORMATS = "Format"
self.FORMAT = "format"
self.FREQCHRO = "Chronologics at each 'n' time steps"
self.FREQH = "Monitoring points file at each 'n' time steps"
self.FREQUENCY = "Output at each 'n' time steps"
self.HISTO = "Monitoring points Files"
self.ICHRVL = "Fluid domain post processing"
self.ICHRBO = "Domain boundary post processing "
self.ICHRSY = "Syrthes boundary post processing"
self.KEYWORD = "Code_Saturne key word: "
self.LISTING = "Outputs listings"
self.MED = "MED_file"
self.MODIFY = "Modify"
self.NO_OUTPUT = "No output"
self.NO_HISTO = "No monitoring points file"
self.OPTIONS = "Options"
self.OUTPUT_TITLE = "OUTPUT CONTROL"
self.FPOLYGON = "polygons"
self.FPOLYHED = "polyhedra"
self.POPUP = "Menu popup"
self.SELECT_ALL = "Select all"
self.SONDES_TITLE = "MONITORING POINTS MANAGEMENT"
self.TX = "XYZCAPT(1,n) with n : Monitoring point's number"
self.TY = "XYZCAPT(2,n) with n : Monitoring point's number"
self.TZ = "XYZCAPT(3,n) with n : Monitoring point's number"
self.UNSELECT = "Unselect"
# 2) Messages
#
if Tool.GuiParam.lang == 'fr':
self.MSG_ERR_VIT = "Votre fichier xml a été 'trafiqué'"
self.MSG_HLIST = "Cliquer le bouton droit pour " +\
"le menu contextuel."
self.MSG_LONGWORD= "Attention : le nombre de caractères est limité à 80 !!!"
self.MSG_POSITIV = "Cette valeur est forcément positive"
else:
self.MSG_ERR_VIT = "Your xmlfile has been corrupted"
self.MSG_HLIST = "Click right button for popup menu."
self.MSG_LONGWORD= "Warning : the number of characters is limited at 80 !!!"
self.MSG_POSITIV = "This value is obligatory positive"
#-------------------------------------------------------------------------------
# End
#-------------------------------------------------------------------------------
syntax highlighted by Code2HTML, v. 0.9.1