Opened 8 years ago

Closed 8 years ago

#5 closed task (fixed)

Add the algorithm that extracts the counts value with the mouse clicked and update up and left canvas

Reported by: yanll Owned by: yanll
Priority: major Milestone:
Component: component1 Version:
Keywords: Cc:
Blocked By: Blocking:
Parent ID: Parent Tickets:
Estimated Number of Hours: 0.0 Add Hours to Ticket: 0
Billable?: yes Total Hours: 0

Description

1 def getXYData(self,xdata, ydata, value):

_xdata = 0
_ydata = 0
xlist = []
ylist = []
_minx=0
_miny=0
xindex=0
yindex=0
xcounts=[]
ycounts=[]

for i in range(len(value[0])):

xlist.append(abs(value[0][i]-xdata))

_minx = min(xlist)
xindex=xlist.index(_minx)
_xdata= value[0][xindex]

for i in range(len(value[1])):

ylist.append(abs(value[1][i]-ydata))

_miny=min(ylist)
yindex=ylist.index(_miny)
_ydata = value[1][yindex]

ytmp=value[2][yindex]
for j in ytmp:

ycounts.append(j)

for i in range(len(value[1])):

xcounts.append(value[2][i][xindex])

return xcounts, ycounts

2 def changeXYFigure(self,event):

self.leftCanvas.ax.clear()
self.upCanvas.ax.clear()
color2D = 'r'
_datax, _datay = self.getXYData(event.xdata, event.ydata, self.value)
if event.button == 1:

try:

self.leftCanvas.ax.plot(_datax, self.value[1], color=color2D)
#self.leftCanvas.fig.set_xdata(_datax, color=color2D)
self.leftCanvas.draw()

except:

pass

elif event.button == 3:

try:

self.upCanvas.ax.plot(self.value[0], _datay, color=color2D)
#self.upCanvas.fig.set_ydata(_datay, color=color2D)
self.upCanvas.draw()

except:

pass

3 def changeRegion(self,event):

_canvas = self.mainCanvas

if event.button == 1:

#_canvas.y1.set_ydata([event.ydata,event.ydata])
_canvas.y1 = _canvas.ax.axvline(event.ydata,color='red')
_canvas.draw()

elif event.button == 3:

#_canvas.x1.set_xdata([event.xdata,event.xdata])
_canvas.x1 = _canvas.ax.axhline(event.xdata,color='white')
_canvas.draw()

else:

pass

4 def mouseClickedEvents(self):

self.mainCanvas.mpl_connect('button_press_event', self.changeRegion)
#self.slitImageCanvas.mpl_connect('motion_notify_event', self.changeRegion)
#self.slitImageCanvas.mpl_connect('button_release_event', self.changeXYFigure)
self.mainCanvas.mpl_connect('button_press_event', self.changeXYFigure)

Subtickets

Child Tickets

Change History (1)

comment:1 Changed 8 years ago by yanll

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.