Exemple #1
0
    def _draw_legend(self, dc, width, height):
        if self.data is not None:
            dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
            dc.SetTextBackground(self.GetBackgroundColour())
            dc.SetTextForeground('BLACK')
            dc.SetFont(self.GetFont())
            dc.Clear()
            scale = self.scale
            data = self.data
            zoom = self.zoom
            scalezoom = scale * zoom

            def sample_time(sample):
                '''Return time of occurence of sample #sample.'''
                return float(sample) / data.frequency

            def place_text(text, sample):
                tw, th = dc.GetTextExtent(text)
                tx = min(width - tw, max(0, int(sample * scalezoom) - tw / 2))
                dc.DrawText(text, tx, 0)

            place_text(
                time_with_units(sample_time(data.delay_count -
                                            data.read_count)), 0)
            place_text(time_with_units(sample_time(data.delay_count)),
                       data.read_count - 1)
            if 0 < data.delay_count < data.read_count:
                place_text('0', data.read_count - data.delay_count)
	def _draw_legend (self, dc, width, height):
		if self.data is not None:
			dc.SetBackground (wx.Brush (self.GetBackgroundColour()))
			dc.SetTextBackground (self.GetBackgroundColour())
			dc.SetTextForeground ('BLACK')
			dc.SetFont (self.GetFont())
			dc.Clear()
			scale = self.scale
			data = self.data
			zoom = self.zoom
			scalezoom = scale * zoom
			
			def sample_time (sample):
				'''Return time of occurence of sample #sample.'''
				return float (sample)/data.frequency
				
			def place_text (text, sample):
				tw, th = dc.GetTextExtent (text)
				tx = min (width-tw, max (0, int (sample * scalezoom) - tw/2))
				dc.DrawText (text, tx, 0)
				
			place_text (time_with_units (sample_time (data.delay_count-data.read_count)), 0)
			place_text (time_with_units (sample_time (data.delay_count)), data.read_count-1)
			if 0 < data.delay_count < data.read_count:
				place_text ('0', data.read_count - data.delay_count)
	def OnGraphMouseMotion (self, evt):
		if evt.Moving():
			graphs = evt.GetEventObject()
			sample = graphs.CalcXSample (evt.m_x)
			sample_time = graphs.CalcXSampleTime (evt.m_x)
			if sample_time is not None:
				wx.CallAfter (self.GetStatusBar().SetStatusText, '%d -- %s' % (sample, time_with_units (sample_time)))
		evt.Skip()
Exemple #4
0
 def OnGraphMouseMotion(self, evt):
     if evt.Moving():
         graphs = evt.GetEventObject()
         sample = graphs.CalcXSample(evt.m_x)
         sample_time = graphs.CalcXSampleTime(evt.m_x)
         if sample_time is not None:
             wx.CallAfter(
                 self.GetStatusBar().SetStatusText,
                 '%d -- %s' % (sample, time_with_units(sample_time)))
     evt.Skip()