# -*- 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 the 'Meshes and Enveloppe' page. This module defines the following classes: - MeshFormatDialog - FacesSelectorDialog - SolutionDomainView - PageText """ #------------------------------------------------------------------------------- # Library modules import #------------------------------------------------------------------------------- import os, sys, string, types import Tix from Tkconstants import * import tkFileDialog #------------------------------------------------------------------------------- # Application modules import #------------------------------------------------------------------------------- from Base.Common import * import Base.Toolbox as Tool import Base.Dialog as Dialog import Base.TkPage as TkPage from SolutionDomainModel import SolutionDomainModel #------------------------------------------------------------------------------- # Popup window: Mesh Format dialog window #------------------------------------------------------------------------------- class MeshFormatDialog(Dialog.Dialog): """ All dirty stuff is done by the Dialog module """ def body(self, master): """ Format selector layout """ # Main initialization # t = PageText() # Variables declaration # self.mesh_format = Tix.StringVar() # Layout # la = Tix.Label(master, text=t.MAKE_CHOICE, font=fT) la.pack(side=TOP, fill=BOTH, anchor=N, padx=4, pady=10) f = Tix.Frame(master, bd=2, relief=FLAT) f.pack(side=TOP, expand=YES, padx=10, pady=2) r = [0]*9 l = [0]*9 for (num, v, txt) in [(0, 'cgns', 'CGNS 2.4 ".cgns"') , (1, 'hex', 'NUMECA Hex".hex"') , (2, 'unv', 'I-deas Universal ".unv"'), (3, 'med', 'MED 2.3 ".med"') , (4, 'des', 'NOPO (Simail) ".des"') , (5, 'msh', 'Gmsh ".msh"') , (6, 'ngeom','Comet ".ngeom"') , (7, 'case', 'EnSight (>= 6) ".case"'), (8, 'neu', 'GAMBIT neutral ".neu"' )]: r[num] = Tix.Radiobutton(f, value=v, variable=self.mesh_format) l[num] = Tix.Label(f, text=txt) r[num].grid(row=num, column=0) l[num].grid(row=num, column=1, sticky=W) # Activate the default format : "NOPO Simail (.des)" # r[4].select() def apply(self): """ What to do when user clicks on 'OK'? """ self.result = self.mesh_format.get() #------------------------------------------------------------------------------- # Popup window: Faces selector dialog window #------------------------------------------------------------------------------- class FacesSelectorDialog(Dialog.Dialog): """ All dirty stuff is done by the Dialog module """ def getString(self, item, key): """ Just verify if the item value is a positive integer, when the key is for a color. """ ans = 1 if key == 'color': try: item = int(item) if item < 0: raise ValueError except: self.e[0].bell() self.e[0].selection_range(0,END) self.e[0].config(selectbackground='red') ans = 0 return ans def setListbox(self, num, list): """ Add colors and groups input in entries in the good list. """ t = PageText() iok = [] # 1) Which key is it ? # if num == 0: key = 'color' elif num == 1: key = 'group' else: raise ValueError for item in list: if self.getString(item, key): # 2) Verify that the input is not allready in the Listbox # if item in self.result[key]: iok.append(item) self.e[num].delete(0,END) else: # 3) Update element # self.result[key].append(str(item)) # 4) Update Listbox, clean entry # self.l[num].listbox.insert(END, item) self.e[num].delete(0,END) if iok: item = string.join(iok, '\n') Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_ALLREADY+item) def getColorGroup(self, num, var, event=None): """ Add colors and groups input in entries in the good list. """ list = string.split(var.get()) if list: self.setListbox(num, list) def killSelection(self, num, event=None): """ Delete the selection from the listbox (one by one). """ # 1) Is there something to delete ? # item = self.l[num].listbox.curselection() if item: # 2) Delete item from listbox # index = int(item[0]) self.l[num].listbox.delete(index) # 3) Delete item from self.result # if num == 0: del self.result['color'][index] elif num == 1: del self.result['group'][index] def getParameters(self, num, var, event=None): """ 1) Input '-fraction', '-plan' parameters. """ if self.check2.isPositive(self.efp[num], var): var.get() def body(self, master): """ Faces selector layout """ # Main initialization # t = PageText() # Variables declaration and initialization # self.color = Tix.StringVar() self.group = Tix.StringVar() self.reverse = Tix.StringVar() self.type = Tix.StringVar() self.fraction = Tix.StringVar() self.plan = Tix.StringVar() self.result = self.default.copy() self.result['color'] = [] self.result['group'] = [] #self.result['reverse'] = "" #self.result['type'] = "" #self.result['fraction'] = "" #self.result['plan'] = "" #self.node = ['faces_fraction', 'faces_plan'] #self.def_values = [0.1, 0.8] # Lay out # self.img = Tix.PhotoImage(file = PIC_PATH+'mana_blk.gif') # Display the two listbox # f = [0]*2 g = [0]*2 h = [0]*2 self.l = [0]*2 self.e = [0]*2 b = [0]*2 for (num, txt1, txt2, var) in [(0, t.COLOR_LIST, t.COLOR_NEW, self.color), (1, t.GROUP_LIST, t.GROUP_NEW, self.group)]: f[num] = Tix.LabelFrame(master, label=txt1, bd=2) f[num].label.config(font=fT) f[num].pack(side=TOP, expand=YES, padx=10, pady=2) w1 = f[num].frame self.l[num] = Tix.ScrolledListBox(w1, scrollbar='auto', width=200, height=60) self.l[num].pack(side=TOP, expand=YES, padx=4, pady=10) self.l[num].vsb.config(width=10, bd=1) self.l[num].hsb.config(width=10, bd=1) g[num] = Tix.Frame(w1, relief=FLAT) g[num].pack(side=TOP, fill=BOTH) w2 = g[num] h[num] = Tix.Label(w2, text=txt2) h[num].grid(row=0, column=0, padx=4, sticky=W) self.e[num] = Tix.Entry(w2, width=20, textvariable=var) self.e[num].event_add("<>", "", "", "") self.e[num].bind("<>", TkPage.Callback(self.getColorGroup,num,var)) self.e[num].grid(row=1, column=0, padx=4) self.e[num].delete(0,END) # Kill buttons # b[num] = Tix.Button(w2, image=self.img, command=TkPage.Callback(self.killSelection,num)) b[num].grid(row=1, column=1, padx=2, pady=1) self.balloon.bind_widget(b[num], statusmsg=t.MSG_DEL_SEL) self.balloon.bind_widget(h[0], statusmsg=t.MSG_SEL_REF) self.balloon.bind_widget(h[1], statusmsg=t.MSG_SEL_GRP) self.balloon.bind_widget(self.e[0], statusmsg=t.MSG_SEL_REF) self.balloon.bind_widget(self.e[1], statusmsg=t.MSG_SEL_GRP) # Display the boundary and internal buttons # k1 = Tix.Frame(master, relief=GROOVE, bd=2) k1.pack(side=TOP, fill=BOTH, padx=14, pady=2) self.sel = Tix.Select(k1, label=t.FACES_TYPES, labelside=TOP, allowzero=1, radio=0, orientation='vertical', variable=self.type) self.sel.label.config(font=fT) self.sel.add('int', text=t.FACES_INTERNAL) self.sel.add('bord', text=t.FACES_BOUNDARY) self.sel.pack(side=TOP, padx=5, pady=5) k2 = Tix.Frame(master, relief=GROOVE, bd=2) k2.pack(side=TOP, fill=BOTH, padx=14, pady=8) # Reversal Selection # la = Tix.Label(k2, text=t.FACES_REVERSE, font=fT, pady=2) la.grid(row=0, column=0, padx=3, pady=2, sticky=W) self.c = Tix.Checkbutton(k2, onvalue='on', offvalue='off', variable=self.reverse) self.c.grid(row=0, column=1, pady=2, sticky=E) # Parameters : Fraction and Plan # self.k3 = Tix.LabelFrame(master, label=t.PARAM, bd=2) self.k3.label.config(font=fT) self.k3.pack(side=TOP, expand=YES, padx=10, pady=2) k3fp = self.k3.frame #w123 = Tix.Frame(self.w122, relief=FLAT) #w123.pack(side=TOP, anchor=W, pady=5) lfp = [0]*2 for (i, tx1, tx2, tx3) in [(0, t.PASTE_FRACTION, t.MSG_FRACTION, '-fraction'), (1, t.PASTE_PLAN, t.MSG_PLAN, '-plan')]: lfp[i] = Tix.Label(k3fp, text=tx1) lfp[i].grid(row=i, column=0, padx=5, sticky=W) self.balloon.bind_widget(lfp[i], statusmsg=tx2, balloonmsg=t.KEYWORD_E+tx3) self.efp = [0]*2 for (i, var) in [(0, self.fraction), (1, self.plan)]: self.efp[i] = Tix.Entry(k3fp, bd=2, width=10, textvariable=var) self.efp[i].grid(row=i, column=1, padx=5, sticky=E) self.efp[i].event_add("<>", "", "", "") self.efp[i].bind("<>", TkPage.Callback(self.getParameters,i,var)) # Default configuration # if self.default['config'] in ["faces_paste", "faces_periodic", "faces_select"]: self.sel.bord.invoke() self.sel.label.config(state=DISABLED) self.sel.bord.config(state=DISABLED) self.sel.int.config(state=DISABLED) self.c.deselect() self.fraction.set(0.1) self.plan.set(0.8) if self.default['config'] == "faces_select" or self.default['config'] == "faces_syrthes": self.k3.pack_forget() # Previous values # try: if self.default['reverse'] == 'on': self.c.select() except: pass for (i,s) in [(0,'color'), (1,'group')]: try: if self.default[s]: self.setListbox(i, string.split(self.default[s])) except: pass if self.default['config'] in ["faces_paste", "faces_periodic"]: for (p, var) in [('fraction', self.fraction), ('plan' , self.plan)]: try: if self.default[p]: var.set(self.default[p]) except: pass try: if self.default['type']: for type in string.split(self.default['type']): if type == 'bord': self.sel.bord.invoke() if type == 'int': self.sel.int.invoke() except: pass def apply(self): """ What to do when user clicks on 'OK'? """ for name in ['color', 'group']: l = self.result[name] self.result[name] = string.join(l, ' ') if self.result[name] == []: self.result[name] = None self.result['reverse'] = self.reverse.get() self.result['type'] = self.type.get() self.result['fraction'] = self.fraction.get() self.result['plan'] = self.plan.get() def sequence(self): """ Bind the dialog window with only 'Echap' (delete sequence 'Return', because of the entries) """ self.bind("", self.cancel) #------------------------------------------------------------------------------- # Main class #------------------------------------------------------------------------------- class SolutionDomainView(TkPage.Page): """ Class to open Thermal Scalar Transport Page. """ def _dependsPages(self, name): """ Construction of the list of dependencies Pages. """ self.case[name]['depends'] = ['models/initia', 'bounda/scalar'] def _tkControlVariables(self): """ Tkinter variables declaration. """ self.mesh = Tix.StringVar() self.rc_on_off = Tix.StringVar() self.x_tv = Tix.DoubleVar() self.y_tv = Tix.DoubleVar() self.z_tv = Tix.DoubleVar() self.dx_r1 = Tix.DoubleVar() self.dy_r1 = Tix.DoubleVar() self.dz_r1 = Tix.DoubleVar() self.ang_r1 = Tix.DoubleVar() self.ptx_r1 = Tix.DoubleVar() self.pty_r1 = Tix.DoubleVar() self.ptz_r1 = Tix.DoubleVar() self.ptx_r2 = Tix.DoubleVar() self.pty_r2 = Tix.DoubleVar() self.ptz_r2 = Tix.DoubleVar() self.mat11 = Tix.DoubleVar() self.mat12 = Tix.DoubleVar() self.mat13 = Tix.DoubleVar() self.mat21 = Tix.DoubleVar() self.mat22 = Tix.DoubleVar() self.mat23 = Tix.DoubleVar() self.mat31 = Tix.DoubleVar() self.mat32 = Tix.DoubleVar() self.mat33 = Tix.DoubleVar() self.df_on_off = Tix.StringVar() self.warp = Tix.DoubleVar() self.perio_name = Tix.StringVar() self.syr_on_off = Tix.StringVar() self.perio_on_off = Tix.StringVar() self.perio_mode = Tix.StringVar() self.syr2d_on_off = Tix.StringVar() self.ec_on_off = Tix.StringVar() self.echo_num = Tix.IntVar() self.sc_on_off = Tix.StringVar() self.ascii_on_off = Tix.StringVar() self.check_on_off = Tix.StringVar() self.sel_on_off = Tix.StringVar() self.activate = Tix.StringVar() self.post_on_off = Tix.StringVar() self.med_on_off = Tix.StringVar() self.post_dir = Tix.StringVar() self.dec_poly_on_off = Tix.StringVar() def _pageControl(self): """ XML node declaration and supplementary default value settings. """ self.node_ecs = self.case.xmlInitNodeList('solution_domain')[0] self.node_models = self.case.xmlInitNodeList('thermophysical_models')[0] self.node_turb = self.node_models.xmlInitNodeList('turbulence', 'model')[0] self.node_meshes = self.node_ecs.xmlInitNodeList('meshes_list')[0] self.node_paste = self.node_ecs.xmlInitNodeList('paste_meshes', "status")[0] self.node_cut = self.node_ecs.xmlInitNodeList('faces_cutting', "status")[0] self.node_syrthes = self.node_ecs.xmlInitNodeList('syrthes_coupling', "status")[0] self.node_perio = self.node_ecs.xmlInitNodeList('periodic_boundary', 'status')[0] ## self.node_miscel = self.node_ecs.xmlInitNodeList('miscellaneous')[0] self.node_standalone = self.node_ecs.xmlInitNodeList('standalone')[0] self.node_post = self.node_standalone.xmlInitNodeList('post-processing', 'status', format="ensight7 gold")[0] self.node_med = self.node_standalone.xmlInitNodeList('post-processing', 'status', format="med")[0] self.node = ['faces_fraction', 'faces_plan', 'warp_angle_max'] self.def_values = [0.1, 0.8, 0.01] self.time = 0 self.perio = 1 def setLink(self, fullfile): """ Tab1: set link between asked file and case's directory "MAILLAGE" and keep dependance between file ena directory if destruction """ name = os.path.basename(fullfile) new_full = self.case['mesh_path'] + "/" + name os.symlink(fullfile,new_full) def getMeshFormat(self, mesh): """ Tab1: return the format and the listbox name fo the given elementNode. Put the format in attribute of the elementNode if necessary. """ t = PageText() label = string.split(mesh,".")[0] try: format = string.split(mesh,".")[1] except: format = None if format not in ["unv","des","hex","med","cgns", "msh","ngeom","case","neu"]: dialog = MeshFormatDialog(self.master, title=t.MESH_FORMAT, default="") format = dialog.result if format: mesh = mesh + "." + format else: format = "" return format, label, mesh def addMeshInList(self, event=None): """ Tab1: add input new meshes in the listbox and case. """ input_meshes = string.split(self.mesh.get()) if not input_meshes: return t = PageText() self.stbar.busy() # 1) Verify if the all new meshes are the mesh_path directory. # for mesh in input_meshes: if mesh not in os.listdir(self.case['mesh_path']): Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_MESH + t.MSG_IDENTITY) # 1) Verify that the new mesh is not allready in the case # for mesh in input_meshes: # 2) Mesh format # format, label, mesh = self.getMeshFormat(mesh) nameList = SolutionDomainModel(self.case).getMeshList() if mesh in nameList: Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_ALLREADY+mesh) else: # 2) Add in the list # nameList.append(mesh) # 3) Update Listbox or delete elementNode if # something is wrong with the format # if format in ["unv","des","hex","med","cgns","msh","ngeom","case","neu"]: self.list.listbox.insert(END, mesh) SolutionDomainModel(self.case).setMesh(mesh, format) self.stbar.idle() def searchMesh(self, event=None): """ Tab1: open a FileDialog in order to search a mesh file in the system file. """ t = PageText() self.stbar.busy() #self.stbar.set(t.MSG_NEW_SEL + self.case['mesh_path'] + ").") file_name = "" tk_fopen = tkFileDialog.askopenfilename if self.case['mesh_path'] and os.path.isdir(self.case['mesh_path']): dir = self.case['mesh_path'] else: dir = os.getcwd() file_name = tk_fopen (title=t.NEW_MESH, initialdir=dir, filetypes=[ ("All files","*") , ("CGNS 2.2 files","*.cgns") , ("Hexa NUMECA files","*.hex") , ("I-DEAS files","*.unv") , ("MED 2.1 files","*.med") , ("NOPO (Simail) files","*.des"), ("GMSH files","*.msh") , ("Comet files","*.ngeom") , ("EnSight files","*.case") , ("GAMBIT neutral files","*.neu")] ) if file_name: if os.path.dirname(file_name) != self.case['mesh_path']: self.setLink(file_name) self.stbar.set(t.MSG_NEW_SEL + self.case['mesh_path'] + ").") self.mesh.set(os.path.basename(file_name)) self.addMeshInList() self.stbar.idle() def selectListbox(self, list): """ Return the selected item from the listbox (one by one). """ try: index = int(list.listbox.curselection()[0]) select = list.listbox.get(index) except IndexError: select = None index = None return select, index def delMesh(self, event=None): """ Tab1: delete the selected mesh from the listbox (one by one). """ self.stbar.busy() # 1) Is there a mesh to delete ? # select, index = self.selectListbox(self.list) if select: t = PageText() # 2) Delete mesh from listbox # self.list.listbox.delete(index) # 3) Delete mesh from case # SolutionDomainModel(self.case).delMesh(select) # 4) Delete link in directory if it's an imported file # new_full = self.case['mesh_path'] + "/" + select l = string.split(select," ")[0] try: f = string.split(l,".")[1] except: f = None if f not in ["unv","des","hex","med","cgns","msh","ngeom","case","neu"]: new_full= self.case['mesh_path'] + "/" + l try: ldir = os.readlink(new_full) except: ldir = new_full ## if ldir != new_full: ## Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_DEL_LINK) ## os.unlink(new_full) self.stbar.force_idle() def getPasteMeshes(self, event=None): """ Tab1: do we paste any meshes ? """ self.stbar.busy() answer = self.rc_on_off.get() SolutionDomainModel(self.case).setPasteMeshesStatus(answer) if answer == 'off': self.w122.pack_forget() else: self.w122.pack(side=TOP, anchor=W, pady=5) self.stbar.idle() def listboxLabel(self, status, tagName, color="", group="", fraction="", plan="", type="", reverse=""): """ Return the label to input in the listbox, associated with the selected faces. """ t = PageText() name = "" if color: name = name + t.REFERENCE + color + " - " if group: name = name + t.GROUP + group + " - " if fraction: name = name + t.FRACTION + fraction + " - " if plan: name = name + t.PLAN + plan + " - " if tagName == 'faces_select' and type: name = name + t.TYPE + type + " - " if reverse == 'on': name = name + t.FACES_REVERSE + " - " if color or group or type or reverse: if status == 'on': name = name + t.ACTIVATE else: name = name + t.DESACTIVATE return name def modifyStringList(self, parentNode, tagName): """ Return the nodesList which is a part of the case, and the associated list of the labels which are in the listbox. """ self.stbar.busy() result = {} stringList = [] nodeList = SolutionDomainModel(self.case).getListNodes(parentNode, tagName) for node in nodeList: result = SolutionDomainModel(self.case).getFaces(node) status = node['status'] name = self.listboxLabel(status, tagName, result['color'], result['group'], result['fraction'], result['plan'], result['type'], result['reverse']) stringList.append(name) self.stbar.idle() return nodeList, stringList def addListbox(self, parentNode, tagName, list, event=None): """ Popup the dialog window for faces selecting. Update the case and the listbox 'list'. """ t = PageText() if tagName == "faces_syrthes": line = SolutionDomainModel(self.case).getFacesSyrthesSelection() if line: Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_SYRTHONE) return if tagName == "faces_select": line = SolutionDomainModel(self.case).getSelectCommand() if line: Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_SELECTONE) return if tagName == "faces_periodic": line = SolutionDomainModel(self.case).getFacesPeriodicSelection(self.perio) if line: Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_PERIOONE) return self.stbar.busy() default = {} default['config'] = tagName default['color'] = "" default['group'] = "" default['fraction']= "0.1" default['plan'] = "0.8" default['reverse'] = "off" default['type'] = "" default['semiconf'] = "" dialog = FacesSelectorDialog(self.master, title=t.FACES_TITLE, stbar=self.stbar, default=default) select = dialog.result.copy() if select['color'] or select['group'] or select['fraction'] or select['plan']or select['type'] or select['reverse']: node = SolutionDomainModel(self.case).getNodeAdd(parentNode, tagName, self.perio) SolutionDomainModel(self.case).setFacesSelect(node, tagName, select) # Update Listbox # if tagName in ("faces_syrthes", "faces_select"): select['fraction'] ="" select['plan'] ="" if tagName in ("faces_select"): select['type'] ="" name = self.listboxLabel("on", tagName, select['color'], select['group'], select['fraction'], select['plan'], select['type'], select['reverse']) if name: list.listbox.insert(END, name) self.stbar.idle() def modifyListbox(self, parentNode, tagName, list, event=None): """ Modify entry either in the listbox and the case. """ self.stbar.busy() t = PageText() select, index = self.selectListbox(list) # Is there something to modify? # if select: nodesList, stringList = self.modifyStringList(parentNode, tagName) inode = stringList.index(select) default = SolutionDomainModel(self.case).getFacesSelect(nodesList, inode) default['config'] = tagName dialog = FacesSelectorDialog(self.master, title=t.FACES_TITLE, stbar=self.stbar, default=default) select = dialog.result.copy() if select['color'] or select['group'] or select['fraction'] or select['plan'] or select['type'] or select['reverse']: SolutionDomainModel(self.case).setFacesSelect(nodesList[inode], tagName, select) # Update Listbox # name = self.listboxLabel(SolutionDomainModel(self.case).getStatusNode(nodesList[inode]), tagName, select['color'], select['group'], select['fraction'], select['plan'], select['type'], select['reverse']) if name: list.listbox.delete(index) list.listbox.insert(index, name) self.stbar.idle() def delListbox(self, parentNode, tagName, list, event=None): """ Delete the selection from the listbox (one by one). """ self.stbar.busy() select, index = self.selectListbox(list) # 1) Is there something to delete? # if select: nodesList, stringList = self.modifyStringList(parentNode, tagName) inode = stringList.index(select) # 2) Delete item from listbox # list.listbox.delete(index) # 3) Delete selection from case # SolutionDomainModel(self.case).delNode(nodesList[inode]) # 4) Release the 2D mesh button if necessary # if tagName == 'faces_syrthes': self.syr2d_on_off.set('off') self.stbar.idle() def activeListbox(self, parentNode, tagName, list, event=None): """ Activate/Desactivate the node 'parentNode' with the change of its attribute 'status' to on/off """ self.stbar.busy() select, index = self.selectListbox(list) # 1) Is there something to delete? # if select: nodesList, stringList = self.modifyStringList(parentNode, tagName) inode = stringList.index(select) # 2) Change the value of the attribute 'status' # status = SolutionDomainModel(self.case).getStatusNode(nodesList[inode]) if status == 'on': status = 'off' else: if tagName == "faces_syrthes": line = SolutionDomainModel(self.case).getFacesSyrthesSelection() status = 'on' if line: t = PageText() Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_SYRTHONE) return elif tagName == "faces_select": line = SolutionDomainModel(self.case).getSelectCommand() status = 'on' if line: t = PageText() Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_SELECTONE) return elif tagName == "faces_periodic": line = SolutionDomainModel(self.case).getFacesPeriodicSelection(self.perio) status = 'on' if line: t = PageText() Dialog.ShowInfo(self.master, title=t.WARNING, text=t.MSG_PERIOONE) return else: status = 'on' SolutionDomainModel(self.case).setStatusNode(nodesList[inode], status) # 3) Update istbox # default = SolutionDomainModel(self.case).getFacesSelect(nodesList, inode) name = self.listboxLabel(SolutionDomainModel(self.case).getStatusNode(nodesList[inode]) , tagName, default['color'], default['group'], default['fraction'], default['plan'], default['type'], default['reverse']) if name: list.listbox.delete(index) list.listbox.insert(index, name) self.stbar.idle() def getFacesCutting(self, event=None): """ Do we cut any faces ? """ self.stbar.busy() answer = self.df_on_off.get() SolutionDomainModel(self.case).setCutStatus(answer) if answer == 'off': self.w132.pack_forget() else: self.w132.pack(side=TOP, anchor=W) self.stbar.idle() def getPasteCutParam(self, var, node, event=None): """ Input '-dec-faces' parameters. """ self.stbar.busy() self.getFacesCutting() # Input information only if it is different from default value # if self.check2.isPositive(self.ewarp, var): SolutionDomainModel(self.case).setCutAngle(var.get()) self.stbar.idle() def getSyrthesCoupling(self, event=None): """ Do we have a syrthes coupling ? """ self.stbar.busy() answer = self.syr_on_off.get() SolutionDomainModel(self.case).setSyrthesCouplingStatus(answer) if answer == 'off': self.sp31.pack_forget() self.sp32.pack_forget() self.w32.pack_forget() self.wf2d.pack_forget() else: self.sp31.pack(side=TOP, fill=X) self.w32.pack(side=TOP) self.sp32.pack(side=TOP, fill=X) self.wf2d.pack(side=BOTTOM, anchor=W, padx=40, pady=5) if SolutionDomainModel(self.case).getSyrthes2dMeshStatus() == 'on': self.box32[0].select() else: self.box32[1].select() self.stbar.idle() def getSyrthes2dMesh(self, event=None): """ Is the mesh for Syrthes a 2D mesh ? This command is invoked with 2 arguments. The first is the name of the button subwidget that has toggled. The second is a boolean value indicating whether the button subwidget is selected. """ self.stbar.busy() if self.syr2d_on_off.get() == 'on': SolutionDomainModel(self.case).setSyrthes2dMeshStatus('on') else: SolutionDomainModel(self.case).delSyrthes2dMeshNode() self.box32[1].select() self.stbar.idle() def setValuesTranslation(self): """ Put values found in xml file as soon as mode is "translation" """ if not SolutionDomainModel(self.case).getTranslationDir(self.perio): SolutionDomainModel(self.case).setTranslationDefault(self.perio) else: dx, dy, dz = SolutionDomainModel(self.case).getTranslationDir(self.perio) self.x_tv.set(dx) self.y_tv.set(dy) self.z_tv.set(dz) def setValuesRotation1(self, mode): """ Put values found in xml file as soon as mode is "rotation1" """ if not SolutionDomainModel(self.case).getRotationAngle(self.perio) and not SolutionDomainModel(self.case).getRotationDir(self.perio) and not SolutionDomainModel(self.case).getRotationCenter(self.perio, mode): SolutionDomainModel(self.case).setRotation1Default(self.perio) else: angle = SolutionDomainModel(self.case).getRotationAngle(self.perio) rx, ry, rz = SolutionDomainModel(self.case).getRotationDir(self.perio) px, py, pz = SolutionDomainModel(self.case).getRotationCenter(self.perio, mode) self.ang_r1.set(angle) self.dx_r1.set(rx) self.dy_r1.set(ry) self.dz_r1.set(rz) self.ptx_r1.set(px) self.pty_r1.set(py) self.ptz_r1.set(pz) def setValuesRotation2(self, mode): """ Put values found in xml file as soon as mode is "rotation"2 """ if not SolutionDomainModel(self.case).getRotationMatrix(self.perio, mode): SolutionDomainModel(self.case).setRotation2Default(self.perio) else: m11,m12,m13,m21,m22,m23,m31,m32,m33 = SolutionDomainModel(self.case).getRotationMatrix(self.perio, mode) px, py, pz = SolutionDomainModel(self.case).getRotationCenter(self.perio, mode) self.mat11.set(m11) self.mat12.set(m12) self.mat13.set(m13) self.mat21.set(m21) self.mat22.set(m22) self.mat23.set(m23) self.mat31.set(m31) self.mat32.set(m32) self.mat33.set(m33) self.ptx_r2.set(px) self.pty_r2.set(py) self.ptz_r2.set(pz) def setValuesPeriodicTransformation(self, mode): """ Put values found in xml file as soon as mode of transformation is choosen """ if mode == "translation" : self.setValuesTranslation() if mode == "rotation1": self.setValuesRotation1(mode) if mode == "rotation2": self.setValuesRotation2(mode) if mode == "tr+rota1": self.setValuesTranslation() self.setValuesRotation1(mode) if mode == "tr+rota2": self.setValuesTranslation() self.setValuesRotation2(mode) def getPeriodicity(self, event=None): """ Do we have a periodicity ? """ self.stbar.busy() answer = self.perio_on_off.get() if answer == 'off': self.w22.pack_forget() SolutionDomainModel(self.case).setPeriodicStatus(answer) else: self.sp21.pack(side=TOP, fill=X) self.w22.pack(side=TOP) SolutionDomainModel(self.case).setPeriodicStatus(answer) self.getPeriodicityMode() self.stbar.idle() def getPeriodicityMode(self, event=None): """ Do we have a periodicity ? """ self.stbar.busy() if self.perio_mode.get() =="": self.b22.config(value='translation') self.setValuesTranslation() if self.perio_mode.get() == "translation": self.rota1.pack_forget() self.rota2.pack_forget() self.faces.pack(side=TOP, fill=X, padx=5, pady=5) self.tvect.pack(side=TOP, fill=X, padx=5, pady=5) self.setValuesTranslation() elif self.perio_mode.get() == "rotation1": self.tvect.pack_forget() self.rota2.pack_forget() self.faces.pack(side=TOP, fill=X, padx=5, pady=5) self.rota1.pack(side=TOP, fill=X, padx=5, pady=5) self.setValuesRotation1(self.perio_mode.get()) elif self.perio_mode.get() == "rotation2": self.tvect.pack_forget() self.rota1.pack_forget() self.faces.pack(side=TOP, fill=X, padx=5, pady=5) self.rota2.pack(side=TOP, fill=X, padx=5, pady=5) self.setValuesRotation2(self.perio_mode.get()) elif self.perio_mode.get() == "tr+rota1": self.rota2.pack_forget() self.faces.pack(side=TOP, fill=X, padx=5, pady=5) self.tvect.pack(side=TOP, fill=X, padx=5, pady=5) self.rota1.pack(side=TOP, fill=X, padx=5, pady=5) self.setValuesTranslation() self.setValuesRotation1(self.perio_mode.get()) elif self.perio_mode.get() == "tr+rota2": self.rota1.pack_forget() self.faces.pack(side=TOP, fill=X, padx=5, pady=5) self.tvect.pack(side=TOP, fill=X, padx=5, pady=5) self.rota2.pack(side=TOP, fill=X, padx=5, pady=5) self.setValuesTranslation() self.setValuesRotation2(self.perio_mode.get()) SolutionDomainModel(self.case).setPeriodicTransformation(self.perio, self.perio_mode.get()) self.setValuesPeriodicTransformation(self.perio_mode.get()) self.stbar.idle() def getDirTranslation(self, i, dir, val, event=None): """ Periodicity translation """ self.stbar.busy() if self.check2.hasType(self.enttv[i], val): if self.perio_mode.get() != "rotation1" or self.perio_mode.get() != "rotation2": SolutionDomainModel(self.case).setTranslationDir(self.perio, dir, val.get()) self.stbar.idle() def getDirRotation(self, i, dir, val, event=None): """ Periodicity rotation """ self.stbar.busy() if self.check2.hasType(self.entr1[i], val): if self.perio_mode.get() == "rotation1" or self.perio_mode.get() =="tr+rota1": SolutionDomainModel(self.case).setRotationDir(self.perio, dir, val.get()) self.stbar.idle() def getAngleRotation(self, angle, event=None): """ Periodicity rotation angle """ self.stbar.busy() if self.check2.hasType(self.entang, angle): if self.perio_mode.get() == "rotation1" or self.perio_mode.get() =="tr+rota1": SolutionDomainModel(self.case).setRotationAngle(self.perio, angle.get()) self.stbar.idle() def getCenterRotation(self, i, pos, val, event=None): """ Periodicity : center of rotation """ self.stbar.busy() if self.check2.hasType(self.eptr1[i], val) or self.check2.hasType(self.eptr2[i], val): if self.perio_mode.get() != "translation": SolutionDomainModel(self.case).setRotationCenter(self.perio, self.perio_mode.get(), pos, val.get()) self.stbar.idle() def getMatrixRotation(self, i, pos, val, event=None): """ Periodicity translation """ self.stbar.busy() if self.check2.hasType(self.entmat[i], val): if self.perio_mode.get() == "rotation2" or self.perio_mode.get() == "tr+rota2": SolutionDomainModel(self.case).setRotationMatrix(self.perio, self.perio_mode.get(), pos, val.get()) self.stbar.idle() def getSyrthes2dMesh(self, event=None): """ Is the mesh for Syrthes a 2D mesh ? This command is invoked with 2 arguments. The first is the name of the button subwidget that has toggled. The second is a boolean value indicating whether the button subwidget is selected. """ self.stbar.busy() if self.syr2d_on_off.get() == 'on': SolutionDomainModel(self.case).setSyrthes2dMeshStatus('on') else: SolutionDomainModel(self.case).delSyrthes2dMeshNode() self.box32[1].select() self.stbar.idle() ## #TODO: à deplacer dans batchRunning (idem pour appel à classe ## def getEchoComm(self, event=None): ## """ ## Tab 4: Input '-echo-comm' parameters : when the echo-comm is NO, no ## input is set in the case, when the echo-comm is YES, ## the value of the number of element to display is put in ## the node 'echo_communication'. ## """ ## self.stbar.busy() ## ## # Input information only if it is different from default value ## # ## self.sp.pack_forget() ## self.w43.pack_forget() #### if self.ec_on_off.get() == 'off': #### SolutionDomainModel(self.case).setEchoCommStatus("off") ## #### else: #### SolutionDomainModel(self.case).setEchoCommStatus("on") ## if self.ec_on_off.get() != 'off': ## self.sp.pack(side=TOP, fill=X) ## self.w43.pack(side=TOP, padx=10) ## self.getEchoNum() ## ## ## self.stbar.idle() ## ## ## ## def getEchoNum(self, event=None): ## """ ## Tab 4: Input value of number of elements when echo-comm is ON ## """ ## self.stbar.busy() ## ## num = self.echo_num.get() ## #TODO: à déplacer ds batchRunning ains que l'appel à la classe #### if self.check2.isPositive(self.e41, self.echo_num): #### SolutionDomainModel(self.case).setNbElementEchocomm(num) ## ## self.stbar.idle() def getSimComm(self): """ Tab 4: Simmulation of communication (-sim-comm) """ self.stbar.busy() v = self.sc_on_off.get() # Warning: the node sim-comm can not be erase when the value its 'off' # because of the default value is 'on'. # SolutionDomainModel(self.case).setSimCommStatus(v) if v == 'on': self.b52.config(state=DISABLED) self.l52.config(state=DISABLED) else: self.b52.config(state=NORMAL) self.l52.config(state=NORMAL) self.stbar.idle() def getAsciiComm(self): """ Tab 4: Communication file in ascii (-ascii) """ self.stbar.busy() v = self.ascii_on_off.get() SolutionDomainModel(self.case).setAsciiCommStatus(v) self.stbar.idle() ## def getMeshCheck(self): ## """ ## Tab 4: Check mesh ## """ ## self.stbar.busy() ## SolutionDomainModel(self.case).setMeshCheckStatus(self.check_on_off.get()) ## self.stbar.idle() def getPostProcessing(self, event=None): """ Tab 4: Activate/Desactivate the Ensight command """ self.stbar.busy() self.s57.pack_forget() self.w57.pack_forget() v = self.post_on_off.get() SolutionDomainModel(self.case).setEnsightStatus(v) m = self.med_on_off.get() SolutionDomainModel(self.case).setMedStatus(m) if v == 'off': self.l57.config(state=DISABLED) self.b57.config(state=DISABLED) if m == 'off': self.e56.select_range(0,0) self.e56.config(state=DISABLED, bg='grey') self.l56.config(state=DISABLED) elif m == 'on': self.e56.config(state=NORMAL) self.l56.config(state=NORMAL) self.check2.begin(self.e56) else: self.e56.config(state=NORMAL) self.l56.config(state=NORMAL) self.check2.begin(self.e56) self.s57.pack(side=TOP, padx=5, fill=X) self.w57.pack(side=TOP, padx=10) self.l57.config(state=NORMAL) self.b57.config(state=NORMAL) self.stbar.idle() def getPostDirectory(self, event=None): """ Tab 4: Name of the Ensight Case directory """ self.stbar.busy() dir = self.post_dir.get() if dir != 'cas_defaut': SolutionDomainModel(self.case).createPostDir(dir) self.check2.begin(self.e56) else: SolutionDomainModel(self.case).delPostDir() ## SolutionDomainModel(self.case).delMed() self.stbar.idle() def getPolygonalFacesCut(self, event=None): """ Tab 4: If some faces are not triangle or square, there are cut """ self.stbar.busy() v = self.dec_poly_on_off.get() if v == 'on': SolutionDomainModel(self.case).setPolygonalNodeStatus(v) else: SolutionDomainModel(self.case).delPolygonalNode() self.stbar.idle() def ecsBatchRunning(self): """ Tab 4: """ t = PageText() self.stbar.busy() # a info to say that batch running and the results are in RESU directory # #Dialog.ShowInfo(self.master, title=t.RUNNING, ans = Dialog.askyesno(self.master, title=t.RUNNING, image='ordinateur.gif', text=t.MSG_BATCH) #image='sablier.gif', text=t.MSG_BATCH) if ans == 'no': self.stbar.idle() return lines = [] # Meshes and formats list # nameList = SolutionDomainModel(self.case).getMeshList() line_mesh = SolutionDomainModel(self.case).getMeshCommand() lines.append(line_mesh) # Paste # line_paste = SolutionDomainModel(self.case).getPasteCommand() lines.append(line_paste) # Cut # line_cut = SolutionDomainModel(self.case).getCutCommand() lines.append(line_cut) # perio # line_perio = SolutionDomainModel(self.case).getPerioCommand(self.perio) lines.append(line_perio) ## # syrthes ## # ## line_syr = SolutionDomainModel(self.case).getSyrthesCommand() ## lines.append(line_syr) #TODO: à déplacer dans batchRunning (+ appel à classe) ## # echo-comm ## # ## line_echo = SolutionDomainModel(self.case).getEchoCommCommand() ## lines.append(line_echo) # sim-comm # line_sim = SolutionDomainModel(self.case).getSimCommCommand() lines.append(line_sim) # ascii # ## # verif ## # ## line_verif = SolutionDomainModel(self.case).getVerifMaillCommand() ## lines.append(line_verif) # select # line_sel = SolutionDomainModel(self.case).getSelectCommand() lines.append(line_sel) # ensight/cas # line_ens = SolutionDomainModel(self.case).getEnsightCommand() lines.append(line_ens) line_med = SolutionDomainModel(self.case).getMedCommand() lines.append(line_med) # Write the list "lines" in the new file # lines.append(" ") file = self.case['resu_path']+ '/' +'ecs_gui_cmd' f = open(file, 'w') f.writelines(lines) f.close() os.system('chmod +x ' + file) # on recupere la variable d'environnement de l'enveloppe dans "lance" # et on execute l'enveloppe #toto = os.popen('grep "ECS=/" ' + self.case['scripts_path'] + '/lance' + ' &').read() toto = os.popen('echo $ECS_HOME').read() cmd = toto[:-1] + "/bin/ecs -cwd " os.system(cmd +self.case['resu_path'] + ' -in ' + file + ' | tee '+ self.case['resu_path'] +'/listenv.pre &') self.stbar.idle() def DoubleClick(self, event=None): """ This method is correcting a Tkinter bug with the listbox widget. Note : The following Sequence does not work with the listbox widget: - Double-1 - Return - Up - Down About events, see www.python.org 16.1.6.7 """ if abs(event.time - self.time) < 300: print "widget = ", event.widget self.time = event.time def _make_page1(self): """ The first page of the notebook is devoted the the meshes: - selection - paste - warp faces cutting """ t = PageText() # Frames for layout # top = Tix.Frame(self.nb.page1, bd=2, relief=GROOVE) top.pack(side=TOP, fill=X, padx=10, pady=10) w11 = Tix.Frame(top, relief=FLAT) w11.pack(side=TOP, pady=10) # Meshes List in a Listbox # w111 = Tix.Frame(w11, relief=FLAT) w111.pack(side=LEFT) l111 = Tix.Label(w111, relief=FLAT, text=t.MESHES_LIST) l111.pack(side=TOP, anchor=W, padx=10) self.balloon.bind_widget(l111, balloonmsg=t.KEYWORD_E+"-maillage") self.list = Tix.ScrolledListBox(w111, scrollbar='auto +x +y', width=250, height=100) self.list.vsb.config(width=10, bd=1) self.list.hsb.config(width=10, bd=1) self.list.pack(side=LEFT, padx=10) self.balloon.bind_widget(self.list, balloonmsg=t.KEYWORD_E+"-maillage") # Meshes selection # w112 = Tix.Frame(w11, relief=FLAT) w112.pack(side=LEFT, padx=10, pady=5) # Add and Kill buttons # w113 = Tix.Frame(w112, relief=FLAT) w113.pack(side=TOP, anchor=W) self.img113 = Tix.PhotoImage(file=PIC_PATH+'search1.gif') b113 = Tix.Button(w113, image=self.img113, command=self.searchMesh) b113.grid(row=0, column=1, sticky=W, pady=5) self.balloon.bind_widget(b113, balloonmsg=t.SEARCH_MESH) self.img114 = Tix.PhotoImage(file=PIC_PATH+'skull.gif') b114 = Tix.Button(w113, image=self.img114, command=self.delMesh) b114.grid(row=1, column=1, sticky=W) self.balloon.bind_widget(b114, balloonmsg=t.MSG_DEL_MESH) # Separator # Tix.Frame(top, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) # Paste meshes # w12 = Tix.Frame(top, relief=FLAT) w12.pack(side=TOP, anchor=CENTER, padx=10, pady=5) w121 = Tix.Frame(w12, relief=FLAT) w121.pack(side=TOP, anchor=W, pady=5) l121 = Tix.Label(w121, text=t.PASTE_MESHES) l121.grid(row=0, column=0, sticky=W) self.balloon.bind_widget(l121, balloonmsg=t.KEYWORD_E+"-recollement") self.b121 = [0]*2 for (i, tx1, tx2) in [(0, t.ON, 'on') , (1, t.OFF, 'off') ]: self.b121[i] = Tix.Radiobutton(w121, text=tx1, value=tx2, variable=self.rc_on_off, command=self.getPasteMeshes) self.b121[i].grid(row=0, column=i+1, padx=3, sticky=E) # Sélection de faces pour affichages # self.w122 = Tix.Frame(w12, relief=FLAT) self.w122.pack(side=TOP, anchor=W, pady=5) l122 = Tix.Label(self.w122, text=t.PASTE_FACES) l122.pack(side=TOP, anchor=W) self.balloon.bind_widget(l122, statusmsg=t.MSG_PASTE_SEL) self.list1 = Tix.ScrolledListBox(self.w122, scrollbar='auto +x +y', width=350, height=90) self.list1.vsb.config(width=10, bd=1) self.list1.hsb.config(width=10, bd=1) self.list1.pack(side=TOP, anchor=W) #self.list1.listbox.bind('<1>', self.DoubleClick) self.balloon.bind_widget(self.list1, statusmsg=t.MSG_PASTE_SEL) box1 = Tix.ButtonBox(self.w122, orientation=HORIZONTAL, relief=FLAT) box1.add('create', text=t.ADD, command=TkPage.Callback(self.addListbox, self.node_paste, 'faces_paste', self.list1)) box1.add('modify', text=t.MODIFY, command=TkPage.Callback(self.modifyListbox, self.node_paste, 'faces_paste', self.list1)) box1.add('erase', text=t.ERASE, command=TkPage.Callback(self.delListbox, self.node_paste, 'faces_paste', self.list1)) box1.add('active', text=t.ACTDESAC, command=TkPage.Callback(self.activeListbox, self.node_paste, 'faces_paste', self.list1)) box1.pack(side=TOP, anchor=W, pady=5) # Separator # Tix.Frame(top, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) # Faces cutting # w13 = Tix.Frame(top, relief=FLAT) w13.pack(side=TOP, anchor=CENTER, padx=10, pady=5) w131 = Tix.Frame(w13, relief=FLAT) w131.pack(side=TOP, anchor=W) l131 = Tix.Label(w131, text=t.CUTTING) l131.grid(row=0, column=0, pady=5, sticky=W) self.balloon.bind_widget(l131, balloonmsg=t.KEYWORD_E+"-dec-faces") self.c131 = [0]*2 for (i, tx1, tx2) in [(0, t.ON,'on'), (1, t.OFF, 'off')]: self.c131[i] = Tix.Radiobutton(w131, text=tx1, value=tx2, variable=self.df_on_off, command=self.getFacesCutting) self.c131[i].grid(row=0, column=i+1, padx=3, pady=5, sticky=E) self.w132 = Tix.Frame(w13, relief=FLAT) self.w132.pack(side=TOP, anchor=W) l132 = Tix.Label(self.w132, text=t.WARP) l132.grid(row=0, column=0, pady=5, sticky=W) self.balloon.bind_widget(l132, statusmsg=t.MSG_CUTTING) self.ewarp = Tix.Entry(self.w132, bd=2, width=10, textvariable=self.warp) self.ewarp.grid(row=0, column=1, pady=5, padx=3, sticky=E) self.ewarp.event_add("<>", "", "", "") self.ewarp.bind ("<>", TkPage.Callback(self.getPasteCutParam,self.warp,self.node_cut)) def _make_page2(self): """ The second page of the notebook is devoted the the periodic boundaries. """ t = PageText() # Frames for layout # top = Tix.Frame(self.nb.page2, bd=2, relief=GROOVE) top.pack(side=TOP, fill=X, padx=10, pady=10) w20 = Tix.Frame(top, relief=FLAT) w20.pack(side=TOP, pady=5) w21 = Tix.Frame(w20, relief=FLAT) w21.pack(side=TOP, pady=5) l21 = Tix.Label(w21, text=t.PERIODICITY) l21.grid(row=0, column=0, sticky=W) # self.balloon.bind_widget(l21, balloonmsg=t.KEYWORD_E+"-perio") self.b21 = [0]*2 for (i, tx1, tx2) in [(0, t.ON, 'on' ), (1, t.OFF, 'off') ]: self.b21[i] = Tix.Radiobutton(w21, text=tx1, value=tx2, variable=self.perio_on_off, command=self.getPeriodicity) self.b21[i].grid(row=0, column=i+1, padx=3, sticky=E) # Periodic mode self.w22 = Tix.Frame(w20, relief=FLAT) self.w22.pack(side=TOP, anchor=W, pady=5) #separator self.sp21 = Tix.Frame(self.w22, height=2, bd=2, relief=SUNKEN) self.sp21.pack(side=TOP, fill=X) #Choice of periodicity's mode w221 = Tix.Frame(self.w22, relief=FLAT) w221.pack(side=TOP, pady=0) self.b22 = Tix.OptionMenu(w221, options='menubutton.width 45') self.b22.menubutton.config(bd=2, relief=RAISED) self.balloon.bind_widget(self.b22, statusmsg=t.MSG_PERIO_MODE, balloonmsg=t.KEYWORD+"-trans or -rota") self.b22.grid(row=0, column=0, padx=10, pady=20) self.b22.add_command('translation', label=t.TRANS) self.b22.add_command('rotation1', label=t.ROTA1) self.b22.add_command('rotation2', label=t.ROTA2) self.b22.add_command('tr+rota1', label=t.TETROTA1) self.b22.add_command('tr+rota2', label=t.TETROTA2) self.b22.config(variable=self.perio_mode, command=self.getPeriodicityMode) #list of faces for type of periodicity self.faces = Tix.LabelFrame(self.w22, label=t.FACES_PERIO, relief=FLAT) self.faces.label.config(font=fT) self.faces.pack(side=TOP, fill=X) self.wlist = Tix.Frame(self.faces.frame, relief=FLAT) self.wlist.pack(side=TOP, pady=0) self.listp = Tix.ScrolledListBox(self.wlist, scrollbar='auto +x +y', width=350, height=50) self.listp.vsb.config(width=10, bd=1) self.listp.hsb.config(width=10, bd=1) self.listp.pack(side=TOP, anchor=W) boxp = Tix.ButtonBox(self.wlist, orientation=HORIZONTAL, relief=FLAT) boxp.add('create', text=t.ADD, command=TkPage.Callback(self.addListbox, self.node_perio, 'faces_periodic', self.listp)) boxp.add('modify', text=t.MODIFY, command=TkPage.Callback(self.modifyListbox, self.node_perio, 'faces_periodic', self.listp)) boxp.add('erase', text=t.ERASE, command=TkPage.Callback(self.delListbox, self.node_perio, 'faces_periodic', self.listp)) boxp.add('active', text=t.ACTDESAC, command=TkPage.Callback(self.activeListbox, self.node_perio, 'faces_periodic', self.listp)) boxp.pack(side=TOP, anchor=W, pady=5) #Type of periodicity's mode self.tvect = Tix.LabelFrame(self.w22, label=t.TRANS_VECT, relief=FLAT) self.tvect.label.config(font=fT) self.tvect.pack(side=TOP, fill=X, padx=5) self.tval = Tix.Frame(self.tvect.frame, relief=FLAT) self.tval.pack(side=TOP, fill=X, padx=5) self.labtv = [0]*3 self.enttv = [0]*3 for (i, dir, xmldir, var) in [(0, 'TX', 'translation_x', self.x_tv), (1, 'TY', 'translation_y', self.y_tv), (2, 'TZ', 'translation_z', self.z_tv)]: self.labtv[i] = Tix.Label(self.tval, text=dir) self.labtv[i].grid(row=0, column=i*2, padx=5, pady=2) self.balloon.bind_widget(self.labtv[i],balloonmsg=t.KEYWORD+"-trans") self.enttv[i] = Tix.Entry(self.tval, bd=2, width=10, textvariable=var) self.enttv[i].grid(row=0, column=1+i*2, padx=5, pady=2) self.enttv[i].event_add("<>", "", "", "") self.enttv[i].bind ("<>", TkPage.Callback(self.getDirTranslation, i, xmldir, var)) #definition of rotation with angle and vector self.rota1 = Tix.LabelFrame(self.w22, label=t.ROTA_ANG, relief=FLAT) self.rota1.label.config(font=fT) self.rota1.pack(side=TOP, fill=X, padx=5) # for angle self.rotang = Tix.Frame(self.rota1.frame, relief=FLAT) self.rotang.pack(side=TOP, fill=X, padx=0) self.labang = Tix.Label(self.rotang, text="angle") self.labang.grid(row=0, column=0,padx=5, pady=2) self.entang = Tix.Entry(self.rotang, bd=2, width=10, textvariable=self.ang_r1) self.entang.grid(row=0, column=1, padx=5, pady=2) self.entang.event_add("<>", "", "", "") self.entang.bind ("<>", TkPage.Callback(self.getAngleRotation, self.ang_r1)) self.uniang = Tix.Label(self.rotang, text='deg') self.uniang.grid(row=0, column=2, padx=5, pady=2) # separator Tix.Frame(self.rota1.frame, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) # for direction vector self.rotdir = Tix.Frame(self.rota1.frame, relief=FLAT) self.rotdir.pack(side=TOP, fill=X, padx=0) self.labdir = Tix.Label(self.rotdir, text=t.VECTDIR) self.labdir.grid(row=0, column=0, columnspan=9, padx=10) self.labr1 = [0]*3 self.entr1 = [0]*3 for (i, dir, xmldir, var) in [(0, 'DX', "rotation_x", self.dx_r1), (1, 'DY', "rotation_y", self.dy_r1), (2, 'DZ', "rotation_z", self.dz_r1)]: self.labr1[i] = Tix.Label(self.rotdir, text=dir) self.labr1[i].grid(row=1, column=i*2, padx=5, pady=2) self.balloon.bind_widget(self.labr1[i],balloonmsg=t.KEYWORD+"-trans") self.entr1[i] = Tix.Entry(self.rotdir, bd=2, width=10, textvariable=var) self.entr1[i].grid(row=1, column=1+i*2, padx=5, pady=2) self.entr1[i].event_add("<>", "", "", "") self.entr1[i].bind ("<>", TkPage.Callback(self.getDirRotation, i, xmldir, var)) # separator Tix.Frame(self.rota1.frame, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) # for center of rotation self.rotcen = Tix.Frame(self.rota1.frame, relief=FLAT) self.rotcen.pack(side=TOP, fill=X, padx=0) self.labpt = Tix.Label(self.rotcen, text=t.PT) self.labpt.grid(row=0, column=0, columnspan=9, padx=10) self.lptr1 = [0]*3 self.eptr1 = [0]*3 for (i, pos, xmlpos, val) in [(0, 'X', "rotation_center_x", self.ptx_r1), (1, 'Y', "rotation_center_y", self.pty_r1), (2, 'Z', "rotation_center_z", self.ptz_r1)]: self.lptr1[i] = Tix.Label(self.rotcen, text=pos) self.lptr1[i].grid(row=1, column=i*2, padx=5, pady=5) self.eptr1[i] = Tix.Entry(self.rotcen, bd=2, width=10, textvariable=val) self.eptr1[i].grid(row=1, column=1+i*2, padx=5, pady=5) self.eptr1[i].event_add("<>", "", "", "") self.eptr1[i].bind ("<>", TkPage.Callback(self.getCenterRotation, i, xmlpos, val)) #definition of rotation with matrice self.rota2 = Tix.LabelFrame(self.w22, label=t.ROTA_ANG, relief=FLAT) self.rota2.label.config(font=fT) self.rota2.pack(side=TOP, fill=X, padx=5) self.rotmat = Tix.Frame(self.rota2.frame, relief=FLAT) self.rotmat.pack(side=TOP, fill=X, padx=0) self.labm = Tix.Label(self.rotmat, text=t.MAT) self.labm.grid(row=0, column=0, columnspan=9, padx=10, pady=10) self.labmat = [0]*9 self.entmat = [0]*9 for (i,r,c,num,xmlm,var) in [(0, 1, 0, 'm11', "rotation_matrix_11",self.mat11), (1, 1, 3, 'm12', "rotation_matrix_12",self.mat12), (2, 1, 6, 'm13', "rotation_matrix_13",self.mat13), (3, 2, 0, 'm21', "rotation_matrix_21",self.mat21), (4, 2, 3, 'm22', "rotation_matrix_22",self.mat22), (5, 2, 6, 'm23', "rotation_matrix_23",self.mat23), (6, 3, 0, 'm31', "rotation_matrix_31",self.mat31), (7, 3, 3, 'm32', "rotation_matrix_32",self.mat32), (8, 3, 6, 'm33', "rotation_matrix_33",self.mat33)]: self.labmat[i] = Tix.Label(self.rotmat, text=num) self.labmat[i].grid(row=r, column=c, padx=2, pady=2, sticky=E) self.balloon.bind_widget(self.labmat[i],balloonmsg=t.KEYWORD+"-trans") self.entmat[i] = Tix.Entry(self.rotmat, bd=2, width=10, textvariable=var) self.entmat[i].grid(row=r, column=c+1, padx=2, pady=2, sticky=W) self.entmat[i].event_add("<>", "", "", "") self.entmat[i].bind ("<>", TkPage.Callback(self.getMatrixRotation, i, xmlm, var)) # separator Tix.Frame(self.rota2.frame, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) # for direction vector self.rotdir2 = Tix.Frame(self.rota2.frame, relief=FLAT) self.rotdir2.pack(side=TOP, fill=X, padx=0) self.labpt2 = Tix.Label(self.rotdir2, text=t.PT) self.labpt2.grid(row=0, column=0, columnspan=9, padx=10) self.lptr2 = [0]*3 self.eptr2 = [0]*3 for (i, pos, xmlpos, val) in [(0, 'X', "rotation_center_x", self.ptx_r2), (1, 'Y', "rotation_center_y", self.pty_r2), (2, 'Z', "rotation_center_z", self.ptz_r2)]: self.lptr2[i] = Tix.Label(self.rotdir2, text=pos) self.lptr2[i].grid(row=1, column=i*3, pady=5) self.eptr2[i] = Tix.Entry(self.rotdir2, bd=2, width=10, textvariable=val) self.eptr2[i].grid(row=1, column=1+i*3, pady=5) self.eptr2[i].event_add("<>", "", "", "") self.eptr2[i].bind ("<>", TkPage.Callback(self.getCenterRotation, i, xmlpos, val)) def _make_page3(self): """ """ t = PageText() # syrthes coupling # top = Tix.Frame(self.nb.page3, bd=2, relief=GROOVE) top.pack(side=TOP, fill=X, padx=10, pady=10) w30 = Tix.Frame(top, relief=FLAT) w30.pack(side=TOP, pady=5) w31 = Tix.Frame(w30, relief=FLAT) w31.pack(side=TOP, anchor=W, pady=5) l31 = Tix.Label(w31, text=t.SYRTHES_COUPLING) l31.grid(row=0, column=0, sticky=W) self.balloon.bind_widget(l31, balloonmsg=t.KEYWORD_E+"-syrthes") self.b31 = [0]*2 for (i, tx1, tx2) in [(0, t.ON, 'on' ), (1, t.OFF, 'off') ]: self.b31[i] = Tix.Radiobutton(w31, text=tx1, value=tx2, variable=self.syr_on_off, command=self.getSyrthesCoupling) self.b31[i].grid(row=0, column=i+1, padx=3, sticky=E) # Separator # #Tix.Frame(top, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) self.sp31 = Tix.Frame(top, height=2, bd=2, relief=SUNKEN) self.sp31.pack(side=TOP, fill=X) # self.w32 = Tix.Frame(top, relief=FLAT) self.w32.pack(side=TOP, pady =5) w321 = Tix.Frame(self.w32, relief=FLAT) w321.pack(side=TOP, anchor=W, pady=5) l321 = Tix.Label(w321, text=t.SYRTHES_FACES) l321.pack(side=TOP, anchor=W) self.balloon.bind_widget(l321, statusmsg=t.MSG_SYRTHES) self.list3 = Tix.ScrolledListBox(w321, scrollbar='auto +x +y', width=350, height=90) self.list3.vsb.config(width=10, bd=1) self.list3.hsb.config(width=10, bd=1) self.list3.pack(side=TOP, anchor=W) self.balloon.bind_widget(self.list3, statusmsg=t.MSG_SYRTHES) w33 = Tix.Frame(w321, relief=FLAT) w33.pack(side=TOP, anchor=W, pady=5) box31 = Tix.ButtonBox(w33, orientation=HORIZONTAL, relief=FLAT) box31.add('create', text=t.ADD, command=TkPage.Callback(self.addListbox, self.node_syrthes, 'faces_syrthes', self.list3)) box31.add('modify', text=t.MODIFY, command=TkPage.Callback(self.modifyListbox, self.node_syrthes, 'faces_syrthes', self.list3)) box31.add('erase', text=t.ERASE, command=TkPage.Callback(self.delListbox, self.node_syrthes, 'faces_syrthes', self.list3)) box31.add('active', text=t.ACTDESAC, command=TkPage.Callback(self.activeListbox, self.node_syrthes, 'faces_syrthes', self.list3)) box31.pack(side=TOP, pady=15) # Separator # #Tix.Frame(top, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) self.sp32 = Tix.Frame(top, height=2, bd=2, relief=SUNKEN) self.sp32.pack(side=TOP, fill=X) # self.wf2d = Tix .Frame(top, relief = FLAT) self.wf2d.pack(side=BOTTOM, anchor=W, padx=40, pady=5) l32 = Tix.Label(self.wf2d, text=t.SYRTHES_2D) l32.grid(row=0, column=0, padx=0, pady=10, sticky=W) self.box32 = [0]*2 for (i, tx1, tx2) in [(0, t.ON, 'on' ), (1, t.OFF, 'off') ]: self.box32[i] = Tix.Radiobutton(self.wf2d, text=tx1, value=tx2, variable=self.syr2d_on_off, command=self.getSyrthes2dMesh) self.box32[i].grid(row=0, column=i+1, padx=3, sticky=E) #self.box32 = Tix.Select(w33, relief=FLAT, allowzero=1, radio=1, # variable=self.syr2d_on_off, # command=self.getSyrthes2dMesh) #self.box32.add('mesh2d', text=t.SYRTHES_2D) #self.box32.pack(side=TOP, pady=15) ## def _make_page4(self): ## """ ## Tab 4 : MISC ## """ ## t = PageText() ## ## ## # ECHO COMM ## # ## f42 = Tix.Frame(self.nb.page4, bd=2, relief=GROOVE) ## f42.pack(side=TOP, fill=X, padx=10, pady=10) ## ## w42 = Tix.Frame(f42, relief=FLAT) ## w42.pack(side=TOP, padx=10) ## ## l42 = Tix.Label(w42, text=t.ECHO_COMM) ## l42.grid(row=0, column=0, padx=0, pady=10, sticky=W) ## self.balloon.bind_widget(l42, balloonmsg=t.KEYWORD_E+"-echo-comm") ## ## self.b42 = [0]*2 ## for (i, tx1, tx2) in [(0, t.ON, 'on' ), ## (1, t.OFF, 'off') ]: ## ## self.b42[i] = Tix.Radiobutton(w42, text=tx1, value=tx2, ## variable=self.ec_on_off, ## command=self.getEchoComm) ## self.b42[i].grid(row=0, column=i+1, sticky=W) ## ## # Separator ## self.sp = Tix.Frame(f42, height=2, bd=2, relief=SUNKEN) ## self.sp.pack(side=TOP, fill=X) ## ## self.w43 = Tix.Frame(f42, relief=FLAT) ## self.w43.pack(side=TOP, padx=10) ## ## ## #self.l43 = Tix.Label(self.w43, text=t.ECHO_VALUE, state=DISABLED) ## self.l43 = Tix.Label(self.w43, text=t.ECHO_VALUE) ## self.l43.grid(row=0, column=0, padx=3, pady=2, sticky=W) ## self.balloon.bind_widget(self.l43, statusmsg=t.MSG_ECHO) ## ## #self.e41 = Tix.Entry(self.w43, bd=2, width=10, state=DISABLED, ## self.e41 = Tix.Entry(self.w43, bd=2, width=10, ## textvariable=self.echo_num) ## self.e41.grid(row=0, column=1, pady=2, sticky=E) ## self.e41.event_add("<>", "", "", "") ## self.e41.bind ("<>", self.getEchoNum) def _make_page4(self): """ Tab 4 : STANDALONE """ t = PageText() WIDTH = 41 f51 = Tix.Frame(self.nb.page4, bd=2, relief=GROOVE) f51.pack(side=TOP, fill=X, padx=10, pady=10) # sim-comm # w51 = Tix.Frame(f51, relief=FLAT) w51.pack(side=TOP, padx=10) l51 = Tix.Label(w51, text=t.SIM_COMM, width=WIDTH, anchor=W) l51.pack(side=LEFT, padx=3, pady=10) self.balloon.bind_widget(l51, balloonmsg=t.KEYWORD_E+"-sim-comm", statusmsg=t.MSG_SIM_COMM) self.b51 = Tix.Checkbutton(w51, onvalue='on', offvalue='off', width=6, anchor=W, variable=self.sc_on_off, command=self.getSimComm) self.b51.pack(side=LEFT, padx=3) # Separator # Tix.Frame(f51, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) # Ascii # w52 = Tix.Frame(f51, relief=FLAT) w52.pack(side=TOP, padx=10) self.l52 = Tix.Label(w52, text=t.ASCII, width=WIDTH, anchor=W) self.l52.pack(side=LEFT, padx=3, pady=10) self.balloon.bind_widget(self.l52, balloonmsg=t.KEYWORD_E+"-ascii") self.b52 = Tix.Checkbutton(w52, onvalue='on', offvalue='off', width=6, anchor=W, variable=self.ascii_on_off, command=self.getAsciiComm) self.b52.pack(side=LEFT, padx=3) #### 7fev06 : TO DO : A jeter apres réponse YF (option -noeud) # Separator # #Tix.Frame(f51, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) # Noeuds # #w53 = Tix.Frame(f51, relief=FLAT) #w53.pack(side=TOP, padx=10) # # l53 = Tix.Label(w53, text=t.NODE, width=WIDTH, anchor=W) # l53.pack(side=LEFT, padx=3, pady=10) # self.balloon.bind_widget(l53, balloonmsg=t.KEYWORD_E+"-noeud") # # self.b53 = Tix.Checkbutton(w53, onvalue='on', offvalue='off', # width=6, anchor=W, # variable=self.node_on_off, # command=self.getNodeConnectivity) # self.b53.pack(side=LEFT, padx=3) ## # Separator ## # ## Tix.Frame(f51, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) ## ## # Verification du maillage ## # ## w532 = Tix.Frame(f51, relief=FLAT) ## w532.pack(side=TOP, padx=10) ## ## l532 = Tix.Label(w532, text=t.CHECK, width=WIDTH, anchor=W) ## l532.pack(side=LEFT, padx=3, pady=10) ## self.balloon.bind_widget(l532, balloonmsg=t.KEYWORD_E+"-verif") ## ## self.b532 = Tix.Checkbutton(w532, onvalue='on', offvalue='off', ## width=6, anchor=W, ## variable=self.check_on_off, ## command=self.getMeshCheck) ## self.b532.pack(side=LEFT, padx=3) # Separator # Tix.Frame(f51, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) # Sélection de faces pour affichages # w54 = Tix.Frame(f51, relief=FLAT) w54.pack(side=TOP, padx=10, pady=5) w504 = Tix.Frame(w54, relief=FLAT) w504.pack(side=TOP, pady=5, anchor=W) l54 = Tix.Label(w504, text=t.SELECT_FACES) l54.pack(side=TOP, anchor=W) self.balloon.bind_widget(l54, balloonmsg=t.KEYWORD_E+"-fac-int", statusmsg=t.MSG_SELECT) self.list5 = Tix.ScrolledListBox(w504, scrollbar='auto +x +y', width=350, height=70) self.list5.vsb.config(width=10, bd=1) self.list5.hsb.config(width=10, bd=1) self.list5.pack(side=TOP, anchor=W) self.balloon.bind_widget(self.list5, statusmsg=t.MSG_SELECT) box5 = Tix.ButtonBox(w54, orientation=HORIZONTAL, relief=FLAT) box5.add('create', text=t.ADD, command=TkPage.Callback(self.addListbox, self.node_standalone, 'faces_select', self.list5)) box5.add('modify', text=t.MODIFY, command=TkPage.Callback(self.modifyListbox, self.node_standalone, 'faces_select', self.list5)) box5.add('erase', text=t.ERASE, command=TkPage.Callback(self.delListbox, self.node_standalone, 'faces_select', self.list5)) box5.add('active', text=t.ACTDESAC, command=TkPage.Callback(self.activeListbox, self.node_standalone, 'faces_select', self.list5)) box5.pack(side=TOP, anchor=W) # Separator # Tix.Frame(f51, height=2, bd=2, relief=SUNKEN).pack(side=TOP, fill=X) # ensight/cas/dec-poly # w505 = Tix.Frame(f51, relief=FLAT) w505.pack(side=TOP, padx=10) w55 = Tix.Frame(w505, relief=FLAT) w55.pack(side=TOP, padx=10, anchor=W) l55 = Tix.Label(w55, text=t.POST) l55.grid(row=0, column=0, padx=3, pady=10, sticky=W) self.balloon.bind_widget(l55, balloonmsg=t.KEYWORD_E+"-ensight") self.b55 = [0]*2 for (i, tx1, tx2) in [(0, t.ON, 'on' ), (1, t.OFF, 'off') ]: self.b55[i] = Tix.Radiobutton(w55, text=tx1, value=tx2, variable=self.post_on_off, command=self.getPostProcessing) self.b55[i].grid(row=0, column=i+1, sticky=E) w55_m = Tix.Frame(w505, relief=FLAT) w55_m.pack(side=TOP, padx=10, anchor=W) l55_m = Tix.Label(w55_m, text=t.MED_DIR) l55_m.grid(row=0, column=0, padx=3, pady=2, sticky=W) self.balloon.bind_widget(l55_m, balloonmsg=t.KEYWORD_E+"-med") self.b55_m = [0]*2 for (i, tx1, tx2) in [(0, t.ON, 'on' ), (1, t.OFF, 'off') ]: self.b55_m[i] = Tix.Radiobutton(w55_m, text=tx1, value=tx2, variable=self.med_on_off, command=self.getPostProcessing) self.b55_m[i].grid(row=0, column=i+1, sticky=E) w56 = Tix.Frame(w505, relief=FLAT) w56.pack(side=TOP, padx=10, anchor=W) self.l56 = Tix.Label(w56, text=t.POST_DIR, state=DISABLED) self.l56.grid(row=0, column=0, padx=3, pady=2, sticky=W) self.balloon.bind_widget(self.l56, balloonmsg=t.KEYWORD_E+"-cas") self.balloon.bind_widget(self.l56, statusmsg=t.MSG_CASRESU) self.e56 = Tix.Entry(w56, bd=2, width=20, state=DISABLED, textvariable=self.post_dir) self.e56.grid(row=0, column=1, pady=10, sticky=E) self.e56.event_add("<>", "", "", "") self.e56.bind ("<>", self.getPostDirectory) self.balloon.bind_widget(self.e56, balloonmsg=t.KEYWORD_E+"-cas") # Separator # self.s57 = Tix.Frame(f51, height=2, bd=2, relief=SUNKEN) self.s57.pack(side=TOP, padx=5, fill=X) self.w57 = Tix.Frame(f51, relief=FLAT) self.w57.pack(side=TOP, padx=10) self.l57 = Tix.Label(self.w57, text=t.DEC_POLY) self.l57.grid(row=0, column=0, padx=3, pady=10, sticky=W) self.balloon.bind_widget(self.l57, balloonmsg=t.KEYWORD_E+"-ensight -dec-poly") self.b57 = Tix.Checkbutton(self.w57, onvalue='on', offvalue='off', variable=self.dec_poly_on_off, command=self.getPolygonalFacesCut) self.b57.grid(row=0, column=1, sticky=E) # Batch Running button # f501 = Tix.Frame(self.nb.page4, bd=2, relief=GROOVE) f501.pack(side=TOP, fill=X, padx=10, pady=10) f502 = Tix.Frame(f501, relief=FLAT) f502.pack(side=TOP, pady=10) l2 = Tix.Label(f502, text=t.ECS_RUN, justify=LEFT) l2.grid(row=0, column=0, sticky=W) #self.img52 = Tix.PhotoImage(file=PIC_PATH+'rubic1c.gif') self.img52 = Tix.PhotoImage(file=PIC_PATH+'launcher.gif') b501 = Tix.Button(f502, image=self.img52, command=self.ecsBatchRunning) b501.grid(row=0, column=1, sticky=W, padx=5) def _createWidgets(self): """ Create the Page layout. """ t = PageText() # NoteBook and tabs layout # self.nb = Tix.NoteBook(self.myPage) self.nb.pack(side=TOP, fill=BOTH, expand=1) self.nb.nbframe.config(relief=RAISED, bd=2, font=fT, tabpadx='2', tabpady='1', focuscolor=self.bg, backpagecolor=self.bg, inactivebackground=wm['inactivebackground']) self.nb.add('page1', anchor='center', label=t.MESHES_TITLE) self.nb.add('page2', anchor='center', label=t.PERIODIC_TITLE) self.nb.add('page3', anchor='center', label=t.SYRTHES_TITLE) self.nb.add('page4', anchor='center', label=t.STANDALONE_TITLE) self._make_page1() self._make_page2() self._make_page3() self._make_page4() 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. """ t = PageText() # Tab 1: MESHES # 1) Paste parameters / Warp faces cutting self.balloon.bind_widget(self.list5, statusmsg=t.MSG_SELECT) # if self.node_paste["status"] == 'on': self.b121[0].select() self.w122.pack(side=TOP, anchor=W, pady=5) else: self.node_paste["status"] = "off" self.b121[1].select() self.w122.pack_forget() if self.node_cut["status"] == 'on': self.c131[0].select() self.w132.pack(side=TOP, anchor=W) else: self.node_cut["status"] = "off" self.c131[1].select() self.w132.pack_forget() #list = self.node_paste.xmlGetNodeList('faces_paste') list = SolutionDomainModel(self.case).getListNodes(self.node_paste, 'faces_paste') result = {} if list: for node in list: result = SolutionDomainModel(self.case).getFaces(node) name = self.listboxLabel(node['status'], 'faces_paste',result['color'], result['group'], result['fraction'], result['plan'], result['type'], result['reverse']) if name: self.list1.listbox.insert(END,name) #if not node.xmlGetDouble(self.node[2]): v = SolutionDomainModel(self.case).getValue(self.node_cut, self.node[2]) if not v: self.warp.set(self.def_values[2]) else: self.warp.set(v) self.balloon.bind_widget(self.list5, statusmsg=t.MSG_SELECT) # 2) Meshes list # msg = "" nameList = SolutionDomainModel(self.case).getMeshList() if nameList: for mesh in nameList: if mesh not in os.listdir(self.case['mesh_path']): msg = msg + mesh + '\n' if msg: msg = msg + '\n' Dialog.Warning(self.master, title=t.WARNING, text=t.MSG_MESH2 + msg + t.MSG_IDENTITY) self.list.listbox.insert(END, mesh) elif os.listdir(self.case['mesh_path']): for lmesh in os.listdir(self.case['mesh_path']): format = lmesh[-3:] if format == ".gz": format = string.split(lmesh,".")[1] if format == "eom": format = lmesh[-5:] if format == "gns" or format == "ase": format = lmesh[-4:] if format in ["unv","des","hex","med","cgns","msh","ngeom","case","neu"]: self.list.listbox.insert(END, lmesh) format, label, mesh = self.getMeshFormat(lmesh) SolutionDomainModel(self.case).setMesh(mesh, format) #self.node_meshes.xmlInitNodeList('mesh',name=mesh, # format=format)[0] # Tab 2: PERIODIC # status = SolutionDomainModel(self.case).getPeriodicStatus() if status != 'on': self.b21[1].select() self.w22.pack_forget() else: self.b21[0].select() self.w22.pack(side=TOP) mode = SolutionDomainModel(self.case).getPeriodicTransformation(self.perio) self.perio_mode.set(mode) self.setValuesPeriodicTransformation(mode) #list_perio = self.node_perio.xmlGetNodeList('faces_periodic') result = {} list_perio = SolutionDomainModel(self.case).getListNodes(self.node_perio, 'faces_periodic') if list_perio: for node in list_perio: result = SolutionDomainModel(self.case).getFaces(node) name = self.listboxLabel(node['status'], 'faces_periodic',result['color'], result['group'], result['fraction'], result['plan'], result['type'], result['reverse']) if name: self.listp.listbox.insert(END,name) # Tab 3: SYRTHES # if SolutionDomainModel(self.case).getSyrthesCouplingStatus() == 'on': self.b31[0].select() self.sp31.pack(side=TOP, fill=X) self.w32.pack(side=TOP) self.sp32.pack(side=TOP, fill=X) self.wf2d.pack(side=BOTTOM, anchor=W, padx=40, pady=5) if SolutionDomainModel(self.case).getSyrthes2dMeshStatus() == 'on': self.box32[0].select() else: self.box32[1].select() else: SolutionDomainModel(self.case).setSyrthesCouplingStatus('off') self.b31[1].select() self.sp31.pack_forget() self.sp32.pack_forget() self.w32.pack_forget() self.wf2d.pack_forget() #for node in self.node_syrthes.xmlGetNodeList('faces_syrthes'): result = {} list_syrt = SolutionDomainModel(self.case).getListNodes(self.node_syrthes, 'faces_syrthes') for node in list_syrt: result = SolutionDomainModel(self.case).getFaces(node) name = self.listboxLabel(node['status'], 'faces_syrthes',result['color'], result['group'], result['fraction'], result['plan'], result['type'], result['reverse']) #n_rev = node.xmlGetNodeList('faces_reverse','status') #color = node.xmlGetString('faces_color') #group = node.xmlGetString('faces_group') #type = node.xmlGetString('faces_type') #reverse = n_rev[0]['status'] if name: self.list3.listbox.insert(END,name) # Tab 4: STANDALONE # node = self.node_standalone.xmlInitNode('ascii_communication', 'status') if node['status'] == 'on': self.ascii_on_off.set('on') else: self.ascii_on_off.set('off') self.node_standalone.xmlRemoveChild('ascii_communication') node = self.node_standalone.xmlInitNode('simulation_communication', 'status') v = node['status'] if not v or v == 'on': self.sc_on_off.set('on') node['status'] = "on" else: self.sc_on_off.set('off') node['status'] = "off" ## node = self.node_standalone.xmlInitNode('check_mesh', 'status') ## if not node['status'] or node['status'] == 'on': ## self.check_on_off.set('on') ## node['status'] = "on" ## else: ## self.check_on_off.set('off') ## node['status'] = "off" result = {} list_stand = SolutionDomainModel(self.case).getListNodes(self.node_standalone, 'faces_select') for node in list_stand: result = SolutionDomainModel(self.case).getFaces(node) name = self.listboxLabel(node['status'], 'faces_select',result['color'], result['group'], result['fraction'], result['plan'], result['type'], result['reverse']) if name: self.list5.listbox.insert(END,name) if self.node_post['status'] == 'off': self.post_on_off.set('off') else: self.node_post['status'] = 'on' self.post_on_off.set('on') if self.node_med['status'] == 'on': self.med_on_off.set('on') else: self.node_med['status'] = 'off' self.med_on_off.set('off') self.getPostProcessing() dir = self.node_standalone.xmlGetString('post_directory') if dir: self.post_dir.set(dir) else: self.post_dir.set('cas_defaut') node = self.node_post.xmlInitNode('polygonal_faces_cutting', 'status') if node['status'] == 'on': self.dec_poly_on_off.set('on') else: self.dec_poly_on_off.set('off') node.xmlRemoveNode() #------------------------------------------------------------------------------- # 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.ACTDESAC = "Activer/Desactiver" self.ACTIVATE = "[activée]" self.ADD = "Ajouter" self.ASCII = "Fichier de communication avec le Noyau en ASCII" self.CHECK = "Vérification du maillage" self.COLOR_LIST = "Sélection par références" self.COLOR_NEW = "Nouvelles références :" self.CUTTING = "Découpage des faces non planes :" self.DEC_POLY = "Découpage en triangles des faces polygonales" self.DESACTIVATE = "[desactivée]" ## self.ECHO_COMM = "Affichage des entêtes des messages échangés :" ## self.ECHO_VALUE = "Nombre de premiers/derniers éléments" self.ECS_RUN = "Exécution de l'Enveloppe Code_Saturne" self.ERASE = "Supprimer" self.ERROR = "Erreur" self.FACES_BOUNDARY = "faces de bord" self.FACES_INTERNAL = "faces internes" self.FACES_PERIO = "Liste des faces pour cette periodicité" self.FACES_REVERSE = "Inversion de la sélection" self.FACES_TITLE = "Sélection de faces" self.FACES_TYPES = "Sélection des faces par type" self.FRACTION = "Fraction : " self.GROUP = "Groupes : " self.GROUP_LIST = "Sélection par groupes" self.GROUP_NEW = "Nouveaux groupes :" self.INPUT_MESH = "Ajouter à la liste :" self.KEYWORD = "Mot clé Code_Saturne : " self.KEYWORD_E = "Option Enveloppe : " self.MAT = "Définition de la matrice de rotation" self.MAKE_CHOICE = "Veuillez sélectionner le format du maillage" self.MED_DIR = "Post-processing au format Med :" self.MESH2D = "Maillage Syrthes 2D" self.MESH_FORMAT = "Sélection du format de maillage" self.MESH_PATH = "Répertoires des maillages" self.MESHES_LIST = "Liste des maillages :" self.MESHES_TITLE = "MAILLAGES" self.MODIFY = "Modifier" self.NEW_MESH = "Nouveau maillage" self.NO = "non" self.OFF = "non" self.ON = "oui" self.PARAM = "Paramètres" self.PASTE_FACES = "Sélections des faces de bord à recoller :" self.PASTE_FRACTION = "fraction" self.PASTE_MESHES = "Recollement de maillages :" self.PASTE_PLAN = "plan" self.PERIODICITY = "Périodicité" self.PERIO_LABEL = "Nouvelles frontières périodiques :" self.PERIO_LIST = "Liste des frontières périodiques :" self.PERIODIC_TITLE = "FRONTIÈRES\nPÉRIODIQUES" self.PLAN = "Plan : " self.POST = "Post-processing au format Ensight Gold :" #self.POST_DIR = "Nom du répertoire du cas Ensight" self.POST_DIR = "Nom du cas" self.PT = "Position d'un point fixe" self.REFERENCE = "Références : " self.ROTA_ANG = "Définition de la rotation" self.ROTA1 = "Périodicité de rotation (définie par angle "\ "et direction)" self.ROTA2 = "Périodicité de rotation (définie par matrice)" self.RUNNING = "Execution en batch de l'Enveloppe.\n" self.SEARCH_MESH = "Rechercher et ajouter à la liste" self.SELECT_FACES = "Sélection de faces internes pour visualisation :" self.SELECT_LIST = "Liste des sélections :" self.SIM_COMM = "Simulation de la communication avec le Noyau" self.STANDALONE_TITLE = "FONCTIONNEMENT\nAUTONOME" self.SYRTHES_TITLE = "COUPLAGE\nSYRTHES" self.SYRTHES_2D = "Le maillage Syrthes correspondant est 2D :" self.SYRTHES_COUPLING = "Couplage Syrthes : " self.SYRTHES_FACES = "Sélections des faces de bord de couplage :" self.TRANS = "Périodicité de translation " self.TRANS_VECT = "Vecteur translation " self.TETROTA1 = "Translation et rotation (définie par angle "\ "et direction)" self.TETROTA2 = "Translation et rotation (définie par matrice)" self.TYPE = "Type de faces : " self.VECTDIR = "Vecteur de rotation " self.WARNING = "Attention" self.WARP = "Angle max de distorsion" self.YES = "oui" else: self.ACTDESAC = "Activate/Desactivate" self.ACTIVATE = "[activated]" self.ADD = "Add" self.ASCII = "Communication file with the Core in ASCII" self.CHECK = "Mesh checking" self.COLOR_LIST = "Select by references" self.COLOR_NEW = "Input references:" self.CUTTING = "Warp faces cutting:" self.DEC_POLY = "Polygonal faces cutting in triangles" self.DESACTIVATE = "[desactivate]" ## self.ECHO_COMM = "Enveloppe/Core passing messages headings:" ## self.ECHO_VALUE = "Number of first and last displaying elements" self.ECS_RUN = "Enveloppe Code_Saturne batch running" self.ERASE = "Erase" self.ERROR = "Error" self.FACES_BOUNDARY = "boundary faces" self.FACES_INTERNAL = "internal faces" self.FACES_PERIO = "List of faces for this periodicity" self.FACES_REVERSE = "Reverse selection" self.FACES_TITLE = "Faces selection" self.FACES_TYPES = "Select faces by type" self.FRACTION = "Fraction: " self.GROUP = "Groups: " self.GROUP_LIST = "Select by groups" self.GROUP_NEW = "Input groups:" self.INPUT_MESH = "Input new meshes in list:" self.KEYWORD = "Code_Saturne key word: " self.KEYWORD_E = "Enveloppe option: " self.MAT = "Définition of the matrix of rotation" self.MAKE_CHOICE = "Please, select the mesh file format" self.MED_DIR = "Post-processing in Med format:" self.MESH2D = "2D Syrthes mesh" self.MESH_FORMAT = "Mesh format selection" self.MESH_PATH = "Meshes directory" self.MESHES_LIST = "List of meshes:" self.MESHES_TITLE = "MESHES" self.NEW_MESH = "New mesh" self.MODIFY = "Modify" self.NO = "no" self.OFF = "off" self.ON = "on" self.PARAM = "Parameters" self.PASTE_FACES = "Select boundary faces to paste:" self.PASTE_FRACTION = "fraction" self.PASTE_MESHES = "Paste meshes:" self.PASTE_PLAN = "plan" self.PERIODICITY = "Periodicity" self.PERIO_LABEL = "New periodic boundaries:" self.PERIO_LIST = "List of periodic boundaries:" self.PERIODIC_TITLE = "PERIODIC\nBOUNDARIES" self.PLAN = "Plan: " self.POST = "Post-processing in Ensight Gold format:" self.PT = "Position of a fixed point" self.POST_DIR = "Case name" self.REFERENCE = "References: " self.ROTA_ANG = "Définition of the rotation" self.ROTA1 = "Periodicity of rotation (defined by angle"\ " and direction)" self.ROTA2 = "Periodicity of rotation (defined by matrix)" self.RUNNING = "Batch running of the enveloppe" self.SEARCH_MESH = "Research and add in list" self.SIM_COMM = "Simulation of communication" self.SELECT_FACES = "Visualization for internal faces selection:" self.SELECT_LIST = "Selections list:" self.STANDALONE_TITLE = "STAND-ALONE\nRUNNING" self.SYRTHES_TITLE = "SYRTHES\nCOUPLING" self.SYRTHES_2D = "The corresponding mesh for Syrthes is 2D:" self.SYRTHES_COUPLING = "Syrthes coupling:" self.SYRTHES_FACES = "Select boundary faces for Syrthes coupling:" self.TRANS = "Periodicity of translation " self.TRANS_VECT = "Translation's vector " self.TETROTA1 = "Translation + rotation (defined by angle"\ " and direction)" self.TETROTA2 = "Translation + rotation (defined by matrix)" self.TYPE = "Faces type: " self.VECTDIR = "Rotation vector" self.WARNING = "Warning" self.WARP = "Max warp angle" self.YES = "yes" # 2) Messages # if Tool.GuiParam.lang == 'fr': self.MSG_ALLREADY = "Attention, l'entrée suivante est déjà " \ "enregistée dans la liste :\n\n" self.MSG_BATCH = "L'exécution de l'enveloppe se fera dans " \ "le répertoire RESU.\n\nLes résultats de cette " \ "exécution seront aussi stockés dans ce " \ "répertoire.\n\n" \ "Voulez-vous vraiment exécuter l'enveloppe ?" self.MSG_CASRESU = "Ce répertoire sera créé dans RESU" self.MSG_CUTTING = "Découpage en triangles des faces dont la " \ "distorsion est supérieure à un angle minimal " \ "en degrés (valeur par défaut : 0.01)." self.MSG_DEL_LINK = "Le lien existant est détruit "\ "du répertoire MAILLAGE du cas." self.MSG_DEL_MESH = "Supprimer le maillage sélectionné de la "\ "liste des maillages." self.MSG_DEL_SEL = "Supprimer la sélection de la liste." self.MSG_ECHO = "Affichage des entêtes des messages échangés : "\ "nombre des premiers/derniers éléments (optionel)." self.MSG_FRACTION = "Fraction de la longueur de la plus petite " \ "arête à partir de laquelle on considère " \ "que deux noeuds peuvent être fusionnés " \ "(valeur par défaut : 0.1)." self.MSG_IDENTITY = "Vérifier l'existence et l'emplacement des " \ "fichiers de maillage, ainsi que la rubrique " \ "'Identité et chemins'." self.MSG_NEW_MESH = "Entrer les noms des fichiers de maillages " \ "sans chemin unix " \ "(les fichiers doivent être dans le répertoire " self.MSG_NEW_MESH2 = "Rechercher un fichier de maillages " \ "(le fichier doit être dans le répertoire " self.MSG_NEW_PERIO = "Entrer un nom pour repérer une nouvelle " \ "frontière périodique. Chaque périodicité " \ "peut être désactivée." self.MSG_NEW_SEL = "Sélectionner un fichier de maillages " \ "(le fichier doit être dans le répertoire " self.MSG_MESH = "Le nouveau fichier de maillage entré n'est " \ "pas dans le répertoire des maillages précisé " \ "dans la rubrique 'Identité et chemins'" \ "Un lien est donc crée dans ce répertoire'.\n\n" self.MSG_MESH2 = "Les fichiers de maillage suivants ne sont pas "\ "dans le répertoire des maillages précisé "\ "dans la rubrique 'Identité et chemins' :\n\n" # self.MSG_OPEN_DIALOG = "Ouverture de la fenêtre de dialogue." self.MSG_PLAN = "Cosinus minimal des normales de deux faces " \ "coplanaires (valeur par défaut : 0.8)." self.MSG_PASTE_SEL = "Sélections des faces de bord pour recollement " \ "de maillages. Ces sélections sont optionnelles. " \ "Une sélection peut être active ou non. " self.MSG_PERIO_MODE= "Sélection du mode de transformation de la périodicité " self.MSG_PERIOONE = "Pour la Périodicité, une seule sélection de faces " \ "est autorisée. Ici vous en avez déjà une. " \ self.MSG_SELECT = "Sélection de faces internes (comptage et affichage). " \ "Une sélection peut être active ou non. " \ "La visualisation des sélections est possible " \ "si le post-processing est activé." self.MSG_SEL_REF = "Il est possible d'entrer plusieurs références à la " \ "fois en les séparant avec un espace ou des caractères." self.MSG_SEL_GRP = "Il est possible d'entrer plusieurs groupes à la " \ "fois en les séparant avec au moins un espace." self.MSG_SYRTHES = "Sélections de faces de bord pour un couplage avec " \ "le code Syrthes. Ces sélections sont optionnelles. " \ "Une sélection peut être active ou non. " \ self.MSG_SYRTHONE = "Pour Syrthes, une seule sélection de faces " \ "est autorisée. Ici vous en avez déjà une. " \ self.MSG_SELECTONE = "Une seule sélection de faces internes" \ "est autorisée. Ici vous en avez déjà une. " \ self.MSG_SIM_COMM = "Désactive l'écriture du fichier de " \ "communication entre l'Enveloppe et le Noyau." else: self.MSG_ALLREADY = "Warning, the following input is allready " \ "uploaded in the list:\n\n" self.MSG_BATCH = "The batch running of enveloppe will be in " \ "RESU directory.\n\nResults of this running " \ "will be stored in this RESU directory.\n\n" \ "Do you really want to execute enveloppe ?" self.MSG_CASRESU = "This directory will be created in RESU" self.MSG_CUTTING = "Faces are cut with a Delaunay method if their " \ "warp angle is greatter than an minimal angle in " \ "degrees (default angle value: 0.01)." self.MSG_DEL_LINK = "The existing link is destroyed "\ "from case's directory MAILLAGE." self.MSG_DEL_MESH = "Delete the selected mesh from the meshes list." self.MSG_DEL_SEL = "Delete the selection from the list." self.MSG_ECHO = "Heading of the messages passing between "\ "Enveloppe and the CORE: "\ "number of first and last values (optional)." self.MSG_FRACTION = "Length fraction of the smallest edge from " \ "which we suppose that two nodes are in the " \ "same place (default value: 0.1)." self.MSG_IDENTITY = "Verify existence and location of the meshes "\ "files, and the 'Identity and Pathes' rubric." self.MSG_NEW_MESH = "Input the meshes files name without their "\ "unix path (the files must be in the directory " self.MSG_NEW_MESH2 = "Research a meshes file "\ "(the file must be in the directory " self.MSG_NEW_PERIO = "Input a label for a new periodic boundary."\ "Each periodic boundary may desactivated or not." self.MSG_NEW_SEL = "Select a meshes file "\ "(the file must be in the directory " self.MSG_MESH = "The new mesh entry is not in meshes directory "\ "given in the 'Identity and paths' rubric." \ "One link is created in this directory.\n\n" self.MSG_MESH2 = "The following meshes are not in the meshes "\ "directory given in the 'Identity and paths' "\ "rubric:\n\n" # self.MSG_OPEN_DIALOG = "Open the dialog window." self.MSG_PLAN = "Minimal cosinus of two normals from coplanar faces " \ "(default value: 0.8)." self.MSG_PASTE_SEL = "Boundary faces selections for meshes paste. " \ "These selections are optional. " \ "A selection can be activated or not. " self.MSG_PERIO_MODE= "Periodicity's transformation mode selection " self.MSG_PERIOONE = "For Periodicity, only one faces selection is "\ "allowed. Here you want one more.\n\n" self.MSG_SELECT = "Faces selection (counting and display). " \ "A selection can be activated or not. " \ "The visualization of the selections is " \ "possible when the post-processing is activated." self.MSG_SEL_REF = "It is possible to input several references in one time " \ "if they are separate with one space caracter or a string." self.MSG_SEL_GRP = "It is possible to input several groups in one time " \ "if they are separate with at least one space caracter." self.MSG_SYRTHES = "Boundary faces selections for Syrthes coupling. " \ "These selections are optional. " \ "A selection can be activated or not. " self.MSG_SELECTONE = "For internal faces selection, only one selection is "\ "allowed. Here you want one more.\n\n" self.MSG_SIM_COMM = "Disabled the creation of the communication " \ "file between the Enveloppe and the Core." #------------------------------------------------------------------------------- # End #-------------------------------------------------------------------------------