Changeset 7280

Show
Ignore:
Timestamp:
12/27/07 13:24:16
Author:
jcorgan
Message:

Applied changeset r6828 on trunk to release branch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/branches/releases/3.1/gr-wxgui/src/python/fftsink2.py

    r6044 r7280  
    226226        self.peak_hold = False 
    227227        self.peak_vals = None 
    228  
     228         
    229229        self.SetEnableGrid (True) 
    230230        # self.SetEnableZoom (True) 
     
    236236        wx.EVT_CLOSE (self, self.on_close_window) 
    237237        self.Bind(wx.EVT_RIGHT_UP, self.on_right_click) 
    238  
     238        self.Bind(wx.EVT_MOTION, self.evt_motion) 
     239         
    239240        self.input_watcher = input_watcher(fftsink.msgq, fftsink.fft_size, self) 
    240241 
     
    259260        if x >= 1e9: 
    260261            sf = 1e-9 
    261             units = "GHz" 
     262            self.units = "GHz" 
    262263        elif x >= 1e6: 
    263264            sf = 1e-6 
    264             units = "MHz" 
     265            self.units = "MHz" 
    265266        else: 
    266267            sf = 1e-3 
    267             units = "kHz" 
     268            self.units = "kHz" 
    268269 
    269270        if self.fftsink.input_is_real:     # only plot 1/2 the points 
     
    271272                       * (self.fftsink.sample_rate * sf / L)) 
    272273                      + self.fftsink.baseband_freq * sf) 
    273             points = numpy.zeros((len(x_vals), 2), numpy.float64) 
    274             points[:,0] = x_vals 
    275             points[:,1] = dB[0:L/2] 
     274            self.points = numpy.zeros((len(x_vals), 2), numpy.float64) 
     275            self.points[:,0] = x_vals 
     276            self.points[:,1] = dB[0:L/2] 
    276277        else: 
    277278            # the "negative freqs" are in the second half of the array 
     
    279280                       * (self.fftsink.sample_rate * sf / L)) 
    280281                      + self.fftsink.baseband_freq * sf) 
    281             points = numpy.zeros((len(x_vals), 2), numpy.float64) 
    282             points[:,0] = x_vals 
    283             points[:,1] = numpy.concatenate ((dB[L/2:], dB[0:L/2])) 
    284  
    285  
    286         lines = plot.PolyLine (points, colour='BLUE') 
     282            self.points = numpy.zeros((len(x_vals), 2), numpy.float64) 
     283            self.points[:,0] = x_vals 
     284            self.points[:,1] = numpy.concatenate ((dB[L/2:], dB[0:L/2])) 
     285 
     286 
     287        lines = plot.PolyLine (self.points, colour='BLUE') 
    287288 
    288289        graphics = plot.PlotGraphics ([lines], 
    289290                                      title=self.fftsink.title, 
    290                                       xLabel = units, yLabel = "dB") 
     291                                      xLabel = self.units, yLabel = "dB") 
    291292 
    292293        self.Draw (graphics, xAxis=None, yAxis=self.y_range) 
     
    350351        self.PopupMenu(menu, event.GetPosition()) 
    351352 
    352  
     353    def evt_motion(self, event): 
     354        # Clip to plotted values 
     355        (ux, uy) = self.GetXY(event)      # Scaled position 
     356        x_vals = numpy.array(self.points[:,0]) 
     357        if ux < x_vals[0] or ux > x_vals[-1]: 
     358            tip = self.GetToolTip() 
     359            if tip: 
     360                tip.Enable(False) 
     361            return 
     362 
     363        # Get nearest X value (is there a better way)? 
     364        index = numpy.argmin(numpy.abs(x_vals-ux)) 
     365        x_val = x_vals[index] 
     366        db_val = self.points[index, 1] 
     367        text = "%3.3f %s dB=%3.3f" % (x_val, self.units, db_val) 
     368 
     369        # Display the tooltip 
     370        tip = wx.ToolTip(text) 
     371        tip.Enable(True) 
     372        tip.SetDelay(0) 
     373        self.SetToolTip(tip) 
     374         
    353375    def build_popup_menu(self): 
    354376        self.id_incr_ref_level = wx.NewId() 
     
    363385        self.id_average = wx.NewId() 
    364386        self.id_peak_hold = wx.NewId() 
    365  
     387         
    366388        self.Bind(wx.EVT_MENU, self.on_average, id=self.id_average) 
    367389        self.Bind(wx.EVT_MENU, self.on_peak_hold, id=self.id_peak_hold) 
     
    375397        self.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_10) 
    376398        self.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_20) 
    377  
    378  
     399         
    379400        # make a menu 
    380401        menu = wx.Menu()