Commit 88cbd2dc authored by Matheus Müller's avatar Matheus Müller

Correção de bugs, adicionado labels de identificacao nos graficos, melhorias...

Correção de bugs, adicionado labels de identificacao nos graficos, melhorias na interface das propriedades dos elementos
parent 6f03c13b
......@@ -25,9 +25,9 @@ Econtrol = 0
##############################################################################
# Element callback
def elem_callback(x, edict , ebutton):
global Labentrys
PTable(edict[x] , ebutton[x], Labentrys)
def elem_callback(x, edict , ebutton, t):
global Labentrys, Econtrol
PTable(edict[x] , ebutton[x], Labentrys, t)
##############################################################################
# Element selection
......@@ -58,7 +58,7 @@ def elem_select(i, button, grafico, f, a, t):
grafico.set_xdata(Edict[i]['dist'].axisdepth())
grafico.set_ydata(Edict[i]['dist'].data)
t.set_text('%s' %Edict[i]['symbol'])
t.set_text('%s' %Edict[i]['symbol'] + ' Distribution')
a.set_ylim(0,1)
a.set_xlim(0,Edict[int(Econtrol)]['profundidademax'])
f.canvas.draw()
......@@ -67,7 +67,7 @@ def elem_select(i, button, grafico, f, a, t):
##############################################################################
# Init
def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, Labelframe, grafico, f, a):
t = f.suptitle('Hf')
t = f.suptitle('Hf' + ' Distribution')
##############################################################################
# Element addition
......@@ -84,9 +84,9 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
global i, Edict, Ebuttons, Econtrol
if i > 1:
i = i-1
for a in range(Econtrol+1,i+1):
Edict[a-1] = Edict[a]
Ebuttons[a-1].configure(text = Ebuttons[a]['text'])
for p in range(Econtrol+1,i+1):
Edict[p-1] = Edict[p]
Ebuttons[p-1].configure(text = Ebuttons[p]['text'])
del Edict[i]
Ebuttons[i].destroy()
......@@ -349,23 +349,20 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
##############################################################################
# Buttons
but = tk.Button(Frames[3], command=create, text='Add element', bd=1, height=1,width=15, pady='4')
but.pack()
butrmv = tk.Button(Frames[4], command=remove, text='Remove element', bd=1, height=1,width=14, pady='4')
butrmv.pack()
butPTE = tk.Button(Frames[5], text='Select from PTE', bd=1, width=15, command=lambda i=i :elem_callback(Econtrol,Edict,Ebuttons) )
butPTE = tk.Button(Frames[5], text='Select from PTE', bd=1, width=15, command=lambda i=i :elem_callback(Econtrol,Edict,Ebuttons,t), pady='1' )
butPTE.pack()
BUpdate = tk.Button(Frames[5], text ='Update properties', command=lambda i=int(Econtrol) :update(Econtrol), width=15)
BUpdate.pack()
but = tk.Button(Frames[5], command=create, text='Add element ->', bd=1, height=1,width=15, pady='1')
but.pack()
butrmv = tk.Button(Frames[5], command=remove, text='<- Remove element', bd=1, height=1,width=15, pady='1')
butrmv.pack()
##############################################################################
# Distribution
def changestate():
BLayer['state']='normal'
BUpdateD['state']='disabled'
RS['state']='disabled'
RL['state']='disabled'
OFlabentries[9]['state']='disabled'
OFlabentries[10]['state']='disabled'
for i in arange(6, 12):
......@@ -380,9 +377,6 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
def changestate2():
BLayer['state']='disabled'
BUpdateD['state']='normal'
RS['state']='normal'
RL['state']='normal'
OFlabentries[9]['state']='normal'
OFlabentries[10]['state']='normal'
for i in arange(6, 12):
......@@ -399,16 +393,8 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
layers() # funcao de layers.py
# By Layers
BLayer = tk.Button(Labeldist, text ='Open Layers', command = lambda i = int(Econtrol) : call_layers(), width=15)
BLayer = tk.Button(Labeldist, text ='Open Layers', command = lambda i = int(Econtrol) : call_layers(), width=15, pady='1')
BLayer.pack()
# By Drawing
BUpdateD = tk.Button(Labeldist, text = 'Element Distribution', command = lambda i = int(Econtrol) : os.system("python profiler.py %s %s %s %s &" %( Edict[int(Econtrol)]['symbol'], str(methodvar.get()), str(Labentrys[11].get()), str(OFlabentries[17].get()) ) ), width=15)
BUpdateD.pack()
# Interpolation methods
RS = tk.Radiobutton(Labeldist, text="Step", variable=methodvar, value='step')
RS.pack(side='left')
RL = tk.Radiobutton(Labeldist, text="Lines", variable=methodvar, value='reta')
RL.pack(side='right')
# Distribution methods
RLay = tk.Radiobutton(Frames[7], text="Layers", command=lambda i=int(Econtrol) :changestate(), variable=distvar, value=0)
RLay.pack(side='left')
......@@ -450,7 +436,6 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
Rions.invoke()
RDra.invoke()
RS.select()
elem_select(0,Ebuttons,grafico, f, a, t)
##############################################################################
......
No preview for this file type
......@@ -271,11 +271,9 @@ def init_calc():
if int(modevar.get()) == 0:
if int(distvar.get()) == 1:
for i in range(len(Edict)):
Edict[i]['dist'] = np.loadtxt(Edict[i]['symbol']+".prof")
calc(param, str(modelvar.get()), ionb, OFlabentries, LSi, CGi, 'draw', espectro, OFlabentries[14].get(), Plot[Pcontrol], f2, FT, Plotbuttons[Pcontrol]['text'])
calc(param, str(modelvar.get()), ionb, OFlabentries, LSi, CGi, 'draw', espectro, OFlabentries[14].get(), Plot, f2, FT, Plotbuttons, Pcontrol)
elif int(distvar.get()) == 0:
calc(param, str(modelvar.get()), ionb, OFlabentries, LSi, CGi, 'layer', espectro, OFlabentries[14].get(), Plot[Pcontrol], f2, FT, Plotbuttons[Pcontrol]['text'])
calc(param, str(modelvar.get()), ionb, OFlabentries, LSi, CGi, 'layer', espectro, OFlabentries[14].get(), Plot, f2, FT, Plotbuttons, Pcontrol)
elif int(modevar.get()) == 1:
pass #spectroRNA(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()), temp)
......
......@@ -5,7 +5,7 @@ from numpy import arange
####################################################
# PTE building
def PTable(Elem , Elembut, Labentrys):
def PTable(Elem , Elembut, Labentrys, t):
####################################################
# Returns element parameters on click
......@@ -31,6 +31,8 @@ def PTable(Elem , Elembut, Labentrys):
Labentrys[8].insert(0, atom['Z'])
Labentrys[9].insert(0, atom['symbol'])
t.set_text('%s' %atom['symbol'] + ' Distribution')
master = tk.Tk()
master.title('Periodic Table of Elements')
......
No preview for this file type
......@@ -47,10 +47,18 @@ def variables(OFlabentries):
dose = float(OFlabentries[24].get())
return EPasso, passox, e, resol, dose, Emin, Emax
def labeler(plotes, botoes, fig):
labels = list()
grafs = list()
for l in range(len(botoes)):
labels.insert(l, botoes[l]['text'])
grafs.insert(l, plotes[l])
fig.legend(grafs, labels)
####################################################################################################################################################
####################################################################################################################################################
def calc(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, metodo, espectro, emin, temp, fig, firsttime, nome):
def calc(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, metodo, espectro, emin, plote, fig, firsttime, botoes, indice):
EPasso, passox, e, resol, dose, Emin, Emax = variables(OFlabentries)
espectro.clear()
......@@ -66,7 +74,7 @@ def calc(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, metodo, espectr
for componente in Edict:
mt = Edict[componente]['mass']
c = Edict[componente]['dist']
c = Edict[componente]['dist'].data
alpha_lineshape = Edict[componente]['LineShape']
k = kinematic(mt, mi, Theta_s)
......@@ -79,7 +87,7 @@ def calc(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, metodo, espectr
# Calcula a contribuição de cada camada
for x in arange(0, Edict[componente]['profundidademax'], passox):
# Seção de choque - CSRf(Z1, Z2, Ein, M1, M2, Theta):
CS = c[int(x/passox)]*k*CSRf(ion['Z'], Edict[componente]['Z'], k*p['E0']-dedxef*x, mi, mt, Theta_s)*passox
# É multiplicada pelo passo para manter a escala do gráfico independente do mesmo.
......@@ -119,8 +127,8 @@ def calc(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, metodo, espectr
espectro.ConvolveGauss(resol/2.35482)
espectro.multiply(dose)
temp.set_xdata(espectro.axisenergy())
temp.set_ydata(espectro.spectro)
plote[indice].set_xdata(espectro.axisenergy())
plote[indice].set_ydata(espectro.spectro)
spect_file(espectro.axisenergy(), espectro.spectro, espectro.eshift, dose)
......@@ -128,7 +136,7 @@ def calc(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, metodo, espectr
if firsttime == True:
xlim([Emin,Emax])
fig.legend([temp], [nome])
labeler(plote,botoes,fig)
fig.canvas.draw()
fig.show()
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment