Commit 01bf6642 authored by Rafaela Meissner's avatar Rafaela Meissner
Browse files

modificações na interface e comandos de usuário

parent 2a20cc3f
MCA = 175
#MCB = 174
MCB = 174
#MCC = 174
#MCD = xxx
No preview for this file type
MCA = 175
MCB = 174
#MCB = 174
#MCC = 174
#MCD = xxx
......@@ -32,11 +32,12 @@ timer1=None
##############################################################################
# GLOBAL VARIABLES AND DEFINITIONS
Control = dict(text_cursor='Cursor:',Refresh=300, bmin=0, bmax=512, bmaxold=512, filename='temp', count=0, paused=True, count_roi=0, ROIctrl=list(),CALIctrl=list(), Logaritmo=False, graphic1=True, graphic2=True, G_cursor=None, Grid=True, Aux_Cursor=None)
Control = dict(text_cursor='Cursor:',Refresh=300, bmin=0, bmax=512, bmaxold=512, filename='temp', count=0, paused=True, count_roi=0, ROIctrl=list(),CALIctrl=list(), Logaritmo=False, graphic1=True, graphic2=True, G_cursor=None, Grid=True, Aux_Cursor=None, widgets = list(), selected_widget= None)
FocusControl = dict( full_screen= False, aux_click='gg')
L_Graficos=list()
L_Modulos=list() #lista com módulos, instancias da classe (arquivo Modulo)
ROIs=list()
L_widgets = list()
Interface = dict(frames=list(), buttons=list(), labels=list(), spinboxes=list(), entries=list(), labelframes=list())
# Sai do programa
......@@ -172,15 +173,15 @@ class InterestRegion:
self.xmaxe = tk.Entry(labfrm, width=5)
self.xmaxe.pack(side='left')
self.xmaxe.insert(0, self.xmax)
self.ok_button = tk.Button(labfrm, text = 'OK', command = lambda i=i: self.apply_roi(), bd=2, height=1)
self.ok_button.pack(side='left')
#self.ok_button = tk.Button(labfrm, text = 'OK', command = lambda i=i: self.apply_roi(), bd=2, height=1)
#self.ok_button.pack(side='left')
self.label2 = tk.Label(labfrm, text=self.text)
self.label2.pack(side='bottom')
def apply_roi(self):
global L_Modulos, L_Graficos
if self.xmine.get().isdigit() and self.xmaxe.get().isdigit() and int(self.xmine.get()) >= 0 and int(self.xmaxe.get()) >= 0 and int(self.xmaxe.get()) < int(Interface['spinboxes'][0].get()) and int(self.xmine.get()) < int(Interface['spinboxes'][0].get()):
if self.xmine.get().isdigit() and self.xmaxe.get().isdigit() and int(self.xmine.get()) >= 0 and int(self.xmaxe.get()) >= 0:# and int(self.xmaxe.get()) < int(Interface['spinboxes'][0].get()) and int(self.xmine.get()) < int(Interface['spinboxes'][0].get()):
for xx in range(len(L_Modulos)):
if int(self.xmaxe.get()) >= int(self.xmine.get()):
......@@ -208,14 +209,13 @@ class InterestRegion:
self.label2['text']=self.text
self.roi.remove()
self.roi = L_Graficos[0].subplot.axvspan(self.xmin, self.xmax, ymin = 0, ymax = 1, facecolor='c', alpha=0.3)
L_Graficos[0].fig.canvas.draw()
print self.xmax, self.xmin, self.Area[xx]
else:
self.label2['text']="Invalid values"
# Destroy todos os ROIs previamente configurados
#def Close_ROI():
# global roiwin
......@@ -231,23 +231,26 @@ def roiroi():
Labelsf = list()
roiwin = tk.Tk()
roiwin.title('ROI')
roibut = tk.Button(roiwin, text = 'Add', command = lambda i=i: addROI(), bd=2, width=7, height=1)
roibut.pack(side='top')
addROI()
#roiwin.protocol('WM_DELETE_WINDOW', Close_ROI)
roiwin.protocol('WM_DELETE_WINDOW', CloseRoi())
roiwin.mainloop()
def addROI():
Labelsf.insert(Control['count_roi'], tk.LabelFrame(roiwin, text='ROI %d' %Control['count_roi']))
Labelsf[Control['count_roi']].pack(side='top')
ROIs.insert(Control['count_roi'], InterestRegion(Labelsf[Control['count_roi']], Control['count_roi']))
Control['ROIctrl'].insert(Control['count_roi'], 0)
Control['ROIctrl'][int(Control['count_roi'])] = 1
ROIs[Control['count_roi']].apply_roi()
Control['count_roi'] = Control['count_roi'] + 1
#Control['ROIctrl'].insert(Control['count_roi'], 0)
#Control['ROIctrl'][int(Control['count_roi'])] = 1
#ROIs[Control['j']].apply_roi()
#ROIs[Control['j']].count_roi()
def upd_CursorLabel():
Control['text_cursor']='Cursor '
......@@ -400,9 +403,9 @@ def realtimeplot(): # Funcao recursiva para plot em tempo real
try:
graphic()
root.after(Control['Refresh'], realtimeplot)
#for n in range(len(Control['ROIctrl'])):
# if Control['ROIctrl'][n] == 1:
# ROIs[n].apply_roi()
for n in range(len(Control['ROIctrl'])):
if Control['ROIctrl'][n] == 1:
ROIs[n].apply_roi()
except ValueError:
pass
......@@ -495,6 +498,10 @@ def pause(): # Para/Continua a aquisicao de dados
else:
Interface['buttons'][0]['text'] = 'Pause'
Interface['labels'][3*len(L_Graficos)+1]['text'] = 'Acquiring'
for G in L_Graficos:
Control['widgets'].append(G.Canvas.get_tk_widget())
#for x in range(len(Control['widgets'])):
# print x, Control['widgets'][x]
realtimeplot()
def save(): # Salva os dados no arquivo selecionado (grafico= g1(salva g1) g2(salva g2) g12(salva os dois)
......@@ -906,49 +913,43 @@ Interface['labels'][aux+3].pack(side='right')
#def key_3():
# roiroi()
#def key_4(event): #'button_press_event'
# G=G_cursor
# G=G_cursor
# if event.inaxes != G.subplot.axes: # se não estiver dentro dos eixos, apenas pega o foco
# G.Canvas.get_tk_widget().focus_set()
# return
# G.pressx = float(event.xdata)
# G.pressy = float(event.ydata)
# if event.button == 3:#botao direito do mouse
# G.limupdtx = G.limupdtx
# G.limupdtx = G.limupdtx #
# elif event.button == 2:#botao do meio do mouse
#G.limupdty = True
# G.limupdtx = True
# G.limtrans = False
# if event.button == 2:#botao do meio do mouse
# G.subplot.set_xlim(xmin=0,xmax=int(Interface['spinboxes'][0].get()))
#elif event.button == 1:#esq
#G.limupdtx = False
#G.limtrans = True
# elif event.button == 1:#esq
# G.limupdtx = False
# G.limtrans = True
#def key_5(event):# 'motion_notify_event'
# G=G_cursor
# G=G_cursor
# if event.inaxes != G.subplot.axes: return
# Interface['labels'][3+3*len(L_Graficos+1)].configure(text=' (%.1f' %float(event.xdata)+ ',%.1f)'%float(event.ydata))
# Interface['labels'][3+3*len(L_Graficos)+1].configure(text=' (%.1f' %float(event.xdata)+ ',%.1f)'%float(event.ydata))
#def key_6(event): #'button_release_event'
# G=G_cursor
# Control['Aux_Cursor']=int(event.xdata)
# Xm , XM = G.subplot.get_xlim()
# Ym , YM = G.subplot.get_ylim()
def key_6(event): #'button_release_event'
G=G_cursor
Control['Aux_Cursor']=int(event.xdata)
Xm , XM = G.subplot.get_xlim()
Ym , YM = G.subplot.get_ylim()
# if event.inaxes != G.subplot.axes:
# if event.button == 3:
# FocusControl['aux_click']='g1'
# xp,yp= G.fig.canvas._tkcanvas.winfo_pointerxy()
# rig_but_menu.tk_popup(xp,yp)
#if event.inaxes != G.subplot.axes:
if event.button == 3:
FocusControl['aux_click']='g1'
xp,yp= G.fig.canvas._tkcanvas.winfo_pointerxy()
rig_but_menu.tk_popup(xp,yp)
# if event.button == 1:
#print event.y, event.x
......@@ -1020,12 +1021,12 @@ Interface['labels'][aux+3].pack(side='right')
#def get_x(event):
# global G_cursor
# for a in range(len(L_Graficos)):
# if event.x_root-root.winfo_rootx() <= float((root.winfo_width())*(a+1)/len(L_Graficos)):
# G_cursor=L_Graficos[a]
# return
def get_x(event):
global G_cursor
for a in range(len(L_Graficos)):
if event.x_root-root.winfo_rootx() <= float((root.winfo_width())*(a+1)/len(L_Graficos)):
G_cursor=L_Graficos[a]
return
......@@ -1067,8 +1068,18 @@ root.bind_all("<Down>",lambda i=i:y_scale_minus())
root.bind_all("<Left>",lambda i=i: Shift_Cursor(False,-1))
root.bind_all("<Right>",lambda i=i: Shift_Cursor(False,1))
root.bind_all("<Next>", lambda i=i: Shift_Cursor(False, -10))#page down
root.bind_all("<Prior>", lambda i=i: Shift_Cursor(False, 10))#page up
root.bind_all("<Next>", lambda i=i: Shift_Cursor(False, -Controle['Nmr_canais']/51.2))#next = page down
root.bind_all("<Prior>", lambda i=i: Shift_Cursor(False, Controle['Nmr_canais']/51.2))#prior = page up
#root.bind_all("<Tab>", lambda i=i: select())
#def select():
# root.focus_set(root.tk_focusNext())
# print(root.tk_focusNext())
# root.tk_focusNext()
# print(root.focus_get())
# for G in L_Graficos:
# print G.Canvas.get_tk_widget()
# return 'break'
#root.bind_all("<T>", lambda i=i:teste())
#root.bind_all("<Shift-Up>",lambda i=i:mult_zoom(1.25,1))
......@@ -1159,15 +1170,23 @@ for G in L_Graficos:
G.subplot.set_ybound(0,1000)
G.subplot.set_xbound(0,512)
G.x_bounds = (0, 512)
# L_widgets.append((G.Canvas.get_tk_widget(), G))
#Control['selected_widget'] = root.focus_get()
#for i in L-widgets:
# if i[0] == Control['selected_widget'];
#print root.focus_get()
#print root.tk_focusNext()
xlabel('Channel')
ylabel('Counts')
#for G in L_Graficos:
# G.fig.canvas.mpl_connect('button_press_event', key_4)
for G in L_Graficos:
#G.fig.canvas.mpl_connect('button_press_event', key_4)
#G.fig.canvas.mpl_connect('motion_notify_event', key_5)
#G.fig.canvas.mpl_connect('button_release_event', key_6)
# G.Frame.bind("<Enter>", get_x)
G.fig.canvas.mpl_connect('button_release_event', key_6)
G.Frame.bind("<Enter>", get_x)
##############################################################################
##############################################################################
......
......@@ -32,11 +32,12 @@ timer1=None
##############################################################################
# GLOBAL VARIABLES AND DEFINITIONS
Control = dict(text_cursor='Cursor:',Refresh=300, bmin=0, bmax=512, bmaxold=512, filename='temp', count=0, paused=True, count_roi=0, ROIctrl=list(),CALIctrl=list(), Logaritmo=False, graphic1=True, graphic2=True, G_cursor=None, Grid=True, Aux_Cursor=None)
Control = dict(text_cursor='Cursor:',Refresh=300, bmin=0, bmax=512, bmaxold=512, filename='temp', count=0, paused=True, count_roi=0, ROIctrl=list(),CALIctrl=list(), Logaritmo=False, graphic1=True, graphic2=True, G_cursor=None, Grid=True, Aux_Cursor=None, widgets = list(), selected_widget= None)
FocusControl = dict( full_screen= False, aux_click='gg')
L_Graficos=list()
L_Modulos=list() #lista com módulos, instancias da classe (arquivo Modulo)
ROIs=list()
L_widgets = list()
Interface = dict(frames=list(), buttons=list(), labels=list(), spinboxes=list(), entries=list(), labelframes=list())
# Sai do programa
......@@ -172,15 +173,15 @@ class InterestRegion:
self.xmaxe = tk.Entry(labfrm, width=5)
self.xmaxe.pack(side='left')
self.xmaxe.insert(0, self.xmax)
self.ok_button = tk.Button(labfrm, text = 'OK', command = lambda i=i: self.apply_roi(), bd=2, height=1)
self.ok_button.pack(side='left')
#self.ok_button = tk.Button(labfrm, text = 'OK', command = lambda i=i: self.apply_roi(), bd=2, height=1)
#self.ok_button.pack(side='left')
self.label2 = tk.Label(labfrm, text=self.text)
self.label2.pack(side='bottom')
def apply_roi(self):
global L_Modulos, L_Graficos
if self.xmine.get().isdigit() and self.xmaxe.get().isdigit() and int(self.xmine.get()) >= 0 and int(self.xmaxe.get()) >= 0 and int(self.xmaxe.get()) < int(Interface['spinboxes'][0].get()) and int(self.xmine.get()) < int(Interface['spinboxes'][0].get()):
if self.xmine.get().isdigit() and self.xmaxe.get().isdigit() and int(self.xmine.get()) >= 0 and int(self.xmaxe.get()) >= 0:# and int(self.xmaxe.get()) < int(Interface['spinboxes'][0].get()) and int(self.xmine.get()) < int(Interface['spinboxes'][0].get()):
for xx in range(len(L_Modulos)):
if int(self.xmaxe.get()) >= int(self.xmine.get()):
......@@ -208,14 +209,13 @@ class InterestRegion:
self.label2['text']=self.text
self.roi.remove()
self.roi = L_Graficos[0].subplot.axvspan(self.xmin, self.xmax, ymin = 0, ymax = 1, facecolor='c', alpha=0.3)
L_Graficos[0].fig.canvas.draw()
print self.xmax, self.xmin, self.Area[xx]
else:
self.label2['text']="Invalid values"
# Destroy todos os ROIs previamente configurados
#def Close_ROI():
# global roiwin
......@@ -231,23 +231,26 @@ def roiroi():
Labelsf = list()
roiwin = tk.Tk()
roiwin.title('ROI')
roibut = tk.Button(roiwin, text = 'Add', command = lambda i=i: addROI(), bd=2, width=7, height=1)
roibut.pack(side='top')
addROI()
#roiwin.protocol('WM_DELETE_WINDOW', Close_ROI)
roiwin.protocol('WM_DELETE_WINDOW', CloseRoi())
roiwin.mainloop()
def addROI():
Labelsf.insert(Control['count_roi'], tk.LabelFrame(roiwin, text='ROI %d' %Control['count_roi']))
Labelsf[Control['count_roi']].pack(side='top')
ROIs.insert(Control['count_roi'], InterestRegion(Labelsf[Control['count_roi']], Control['count_roi']))
Control['ROIctrl'].insert(Control['count_roi'], 0)
Control['ROIctrl'][int(Control['count_roi'])] = 1
ROIs[Control['count_roi']].apply_roi()
Control['count_roi'] = Control['count_roi'] + 1
#Control['ROIctrl'].insert(Control['count_roi'], 0)
#Control['ROIctrl'][int(Control['count_roi'])] = 1
#ROIs[Control['j']].apply_roi()
#ROIs[Control['j']].count_roi()
def upd_CursorLabel():
Control['text_cursor']='Cursor '
......@@ -400,9 +403,9 @@ def realtimeplot(): # Funcao recursiva para plot em tempo real
try:
graphic()
root.after(Control['Refresh'], realtimeplot)
#for n in range(len(Control['ROIctrl'])):
# if Control['ROIctrl'][n] == 1:
# ROIs[n].apply_roi()
for n in range(len(Control['ROIctrl'])):
if Control['ROIctrl'][n] == 1:
ROIs[n].apply_roi()
except ValueError:
pass
......@@ -495,6 +498,10 @@ def pause(): # Para/Continua a aquisicao de dados
else:
Interface['buttons'][0]['text'] = 'Pause'
Interface['labels'][3*len(L_Graficos)+1]['text'] = 'Acquiring'
for G in L_Graficos:
Control['widgets'].append(G.Canvas.get_tk_widget())
#for x in range(len(Control['widgets'])):
# print x, Control['widgets'][x]
realtimeplot()
def save(): # Salva os dados no arquivo selecionado (grafico= g1(salva g1) g2(salva g2) g12(salva os dois)
......@@ -872,7 +879,7 @@ for Mod in L_Modulos:
ROIlabel = tk.Label(Interface['frames'][12+aux/3], text='ROIs\n', height=5, bg='grey')
Interface['labels'].insert(aux+3,ROIlabel)
ROIlabel.insert(
#ROIlabel.insert(
Interface['labels'][aux+3].pack(side='left', fill = 'x', expand = 1)
......@@ -906,49 +913,43 @@ Interface['labels'][aux+3].pack(side='right')
#def key_3():
# roiroi()
#def key_4(event): #'button_press_event'
# G=G_cursor
# G=G_cursor
# if event.inaxes != G.subplot.axes: # se não estiver dentro dos eixos, apenas pega o foco
# G.Canvas.get_tk_widget().focus_set()
# return
# G.pressx = float(event.xdata)
# G.pressy = float(event.ydata)
# if event.button == 3:#botao direito do mouse
# G.limupdtx = G.limupdtx
# G.limupdtx = G.limupdtx #
# elif event.button == 2:#botao do meio do mouse
#G.limupdty = True
# G.limupdtx = True
# G.limtrans = False
# if event.button == 2:#botao do meio do mouse
# G.subplot.set_xlim(xmin=0,xmax=int(Interface['spinboxes'][0].get()))
#elif event.button == 1:#esq
#G.limupdtx = False
#G.limtrans = True
# elif event.button == 1:#esq
# G.limupdtx = False
# G.limtrans = True
#def key_5(event):# 'motion_notify_event'
# G=G_cursor
# G=G_cursor
# if event.inaxes != G.subplot.axes: return
# Interface['labels'][3+3*len(L_Graficos+1)].configure(text=' (%.1f' %float(event.xdata)+ ',%.1f)'%float(event.ydata))
# Interface['labels'][3+3*len(L_Graficos)+1].configure(text=' (%.1f' %float(event.xdata)+ ',%.1f)'%float(event.ydata))
#def key_6(event): #'button_release_event'
# G=G_cursor
# Control['Aux_Cursor']=int(event.xdata)
# Xm , XM = G.subplot.get_xlim()
# Ym , YM = G.subplot.get_ylim()
def key_6(event): #'button_release_event'
G=G_cursor
Control['Aux_Cursor']=int(event.xdata)
Xm , XM = G.subplot.get_xlim()
Ym , YM = G.subplot.get_ylim()
# if event.inaxes != G.subplot.axes:
# if event.button == 3:
# FocusControl['aux_click']='g1'
# xp,yp= G.fig.canvas._tkcanvas.winfo_pointerxy()
# rig_but_menu.tk_popup(xp,yp)
#if event.inaxes != G.subplot.axes:
if event.button == 3:
FocusControl['aux_click']='g1'
xp,yp= G.fig.canvas._tkcanvas.winfo_pointerxy()
rig_but_menu.tk_popup(xp,yp)
# if event.button == 1:
#print event.y, event.x
......@@ -1020,12 +1021,12 @@ Interface['labels'][aux+3].pack(side='right')
#def get_x(event):
# global G_cursor
# for a in range(len(L_Graficos)):
# if event.x_root-root.winfo_rootx() <= float((root.winfo_width())*(a+1)/len(L_Graficos)):
# G_cursor=L_Graficos[a]
# return
def get_x(event):
global G_cursor
for a in range(len(L_Graficos)):
if event.x_root-root.winfo_rootx() <= float((root.winfo_width())*(a+1)/len(L_Graficos)):
G_cursor=L_Graficos[a]
return
......@@ -1067,8 +1068,18 @@ root.bind_all("<Down>",lambda i=i:y_scale_minus())
root.bind_all("<Left>",lambda i=i: Shift_Cursor(False,-1))
root.bind_all("<Right>",lambda i=i: Shift_Cursor(False,1))
root.bind_all("<Next>", lambda i=i: Shift_Cursor(False, -10))#page down
root.bind_all("<Prior>", lambda i=i: Shift_Cursor(False, 10))#page up
root.bind_all("<Next>", lambda i=i: Shift_Cursor(False, -Controle['Nmr_canais']/51.2))#next = page down
root.bind_all("<Prior>", lambda i=i: Shift_Cursor(False, Controle['Nmr_canais']/51.2))#prior = page up
root.bind_all("<Tab>", lambda i=i: select())
#def select():
# root.focus_set(root.tk_focusNext())
# print(root.tk_focusNext())
root.tk_focusNext()
# print(root.focus_get())
# for G in L_Graficos:
# print G.Canvas.get_tk_widget()
# return 'break'
#root.bind_all("<T>", lambda i=i:teste())
#root.bind_all("<Shift-Up>",lambda i=i:mult_zoom(1.25,1))
......@@ -1159,15 +1170,23 @@ for G in L_Graficos:
G.subplot.set_ybound(0,1000)
G.subplot.set_xbound(0,512)
G.x_bounds = (0, 512)
# L_widgets.append((G.Canvas.get_tk_widget(), G))
#Control['selected_widget'] = root.focus_get()
#for i in L-widgets:
# if i[0] == Control['selected_widget'];
#print root.focus_get()
#print root.tk_focusNext()
xlabel('Channel')
ylabel('Counts')
#for G in L_Graficos:
# G.fig.canvas.mpl_connect('button_press_event', key_4)
for G in L_Graficos:
#G.fig.canvas.mpl_connect('button_press_event', key_4)
#G.fig.canvas.mpl_connect('motion_notify_event', key_5)
#G.fig.canvas.mpl_connect('button_release_event', key_6)
# G.Frame.bind("<Enter>", get_x)
G.fig.canvas.mpl_connect('button_release_event', key_6)
G.Frame.bind("<Enter>", get_x)
##############################################################################
##############################################################################
......
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