def draw_cursor(self, event): #event is a MplEvent. Draw a cursor over the axes if event.inaxes is None: #info('Out !') self.erase_cursor() return figheight = self.m_canvas.figure.bbox.height ax = event.inaxes left,bottom,width,height = ax.bbox.bounds bottom = figheight-bottom top = bottom - height right = left + width x, y = event.x, event.y y = figheight-y time, value = event.xdata, event.ydata a,b = ax.get_xlim() period = b - a newx = left+((width/period)*int(time)) #debug('newx=%d width=%d period=%d time=%d' % (newx,width,period,int(time))) dc = wx.ClientDC(self.m_canvas) dc.SetLogicalFunction(wx.XOR) dc.SetBrush(wx.Brush(wx.Colour(255,255,255), wx.TRANSPARENT)) dc.SetPen(wx.Pen(wx.Colour(200, 200, 200), 1, wx.SOLID)) dc.ResetBoundingBox() dc.BeginDrawing() x, y, left, right, bottom, top = [int(val) for val in newx, y, left, right, bottom, top] self.erase_cursor() line1 = (x, bottom, x, top) line2 = (left, y, right, y) self.m_lastInfo = line1, line2, ax, dc if self.is_display_vcursor(): dc.DrawLine(*line1) # draw new if self.is_display_hcursor(): dc.DrawLine(*line2) # draw new #dc.EndDrawing() debug("Time=%d Value=%f"% (time, value)) # add x and y labels if int(time)<len(self.times): if self.is_display_vcursor(): self.m_xlabel = iTrade_wxLabelPopup(self.m_canvas,(x,bottom), label=self.GetXLabel(int(time))) self.m_xlabel.Draw() if self.is_display_hcursor(): self.m_ylabel = iTrade_wxLabelPopup(self.m_canvas,(right,y), label=self.GetYLabel(ax,value)) self.m_ylabel.Draw() # save some data for Timed behaviour self.m_xylabelMax = (right,bottom) self.m_xylabelPos = (x,y) self.m_xylabelData = (int(time),value) self.m_xylabelAxis = ax dc.EndDrawing()
def OnTimer(self,event): #debug('OnTimer') if self.cursorState(None) and (self.m_cursormode == CURSOR_MODE_IND): #debug('OnTimer create label') try: self.m_xylabel = iTrade_wxLabelPopup(self.m_canvas,self.m_xylabelPos,self.m_xylabelMax,label=self.GetXYLabel(self.m_xylabelAxis,self.m_xylabelData),multiline=True) except AttributeError: info('axis not managed') pass else: #debug('OnTimer draw label') self.m_xylabel.Draw()
def OnTimer(self, event): #debug('OnTimer') if self.cursorState(None) and (self.m_cursormode == CURSOR_MODE_IND): #debug('OnTimer create label') try: self.m_xylabel = iTrade_wxLabelPopup(self.m_canvas, self.m_xylabelPos, self.m_xylabelMax, label=self.GetXYLabel( self.m_xylabelAxis, self.m_xylabelData), multiline=True) except AttributeError: info('axis not managed') pass else: #debug('OnTimer draw label') self.m_xylabel.Draw()
def draw_cursor(self, event): #event is a MplEvent. Draw a cursor over the axes if event.inaxes is None: #info('Out !') self.erase_cursor() return figheight = self.m_canvas.figure.bbox.height ax = event.inaxes left, bottom, width, height = ax.bbox.bounds bottom = figheight - bottom top = bottom - height right = left + width x, y = event.x, event.y y = figheight - y time, value = event.xdata, event.ydata a, b = ax.get_xlim() period = b - a newx = left + ((width / period) * int(time)) #debug('newx=%d width=%d period=%d time=%d' % (newx,width,period,int(time))) dc = wx.ClientDC(self.m_canvas) dc.SetLogicalFunction(wx.XOR) dc.SetBrush(wx.Brush(wx.Colour(255, 255, 255), wx.TRANSPARENT)) dc.SetPen(wx.Pen(wx.Colour(200, 200, 200), 1, wx.SOLID)) dc.ResetBoundingBox() dc.BeginDrawing() x, y, left, right, bottom, top = [ int(val) for val in newx, y, left, right, bottom, top ] self.erase_cursor() line1 = (x, bottom, x, top) line2 = (left, y, right, y) self.m_lastInfo = line1, line2, ax, dc if self.is_display_vcursor(): dc.DrawLine(*line1) # draw new if self.is_display_hcursor(): dc.DrawLine(*line2) # draw new #dc.EndDrawing() debug("Time=%d Value=%f" % (time, value)) # add x and y labels if int(time) < len(self.times): if self.is_display_vcursor(): self.m_xlabel = iTrade_wxLabelPopup(self.m_canvas, (x, bottom), label=self.GetXLabel( int(time))) self.m_xlabel.Draw() if self.is_display_hcursor(): self.m_ylabel = iTrade_wxLabelPopup(self.m_canvas, (right, y), label=self.GetYLabel( ax, value)) self.m_ylabel.Draw() # save some data for Timed behaviour self.m_xylabelMax = (right, bottom) self.m_xylabelPos = (x, y) self.m_xylabelData = (int(time), value) self.m_xylabelAxis = ax dc.EndDrawing()