Changeset 7280
- Timestamp:
- 12/27/07 13:24:16
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/branches/releases/3.1/gr-wxgui/src/python/fftsink2.py
r6044 r7280 226 226 self.peak_hold = False 227 227 self.peak_vals = None 228 228 229 229 self.SetEnableGrid (True) 230 230 # self.SetEnableZoom (True) … … 236 236 wx.EVT_CLOSE (self, self.on_close_window) 237 237 self.Bind(wx.EVT_RIGHT_UP, self.on_right_click) 238 238 self.Bind(wx.EVT_MOTION, self.evt_motion) 239 239 240 self.input_watcher = input_watcher(fftsink.msgq, fftsink.fft_size, self) 240 241 … … 259 260 if x >= 1e9: 260 261 sf = 1e-9 261 units = "GHz"262 self.units = "GHz" 262 263 elif x >= 1e6: 263 264 sf = 1e-6 264 units = "MHz"265 self.units = "MHz" 265 266 else: 266 267 sf = 1e-3 267 units = "kHz"268 self.units = "kHz" 268 269 269 270 if self.fftsink.input_is_real: # only plot 1/2 the points … … 271 272 * (self.fftsink.sample_rate * sf / L)) 272 273 + self.fftsink.baseband_freq * sf) 273 points = numpy.zeros((len(x_vals), 2), numpy.float64)274 points[:,0] = x_vals275 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] 276 277 else: 277 278 # the "negative freqs" are in the second half of the array … … 279 280 * (self.fftsink.sample_rate * sf / L)) 280 281 + self.fftsink.baseband_freq * sf) 281 points = numpy.zeros((len(x_vals), 2), numpy.float64)282 points[:,0] = x_vals283 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') 287 288 288 289 graphics = plot.PlotGraphics ([lines], 289 290 title=self.fftsink.title, 290 xLabel = units, yLabel = "dB")291 xLabel = self.units, yLabel = "dB") 291 292 292 293 self.Draw (graphics, xAxis=None, yAxis=self.y_range) … … 350 351 self.PopupMenu(menu, event.GetPosition()) 351 352 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 353 375 def build_popup_menu(self): 354 376 self.id_incr_ref_level = wx.NewId() … … 363 385 self.id_average = wx.NewId() 364 386 self.id_peak_hold = wx.NewId() 365 387 366 388 self.Bind(wx.EVT_MENU, self.on_average, id=self.id_average) 367 389 self.Bind(wx.EVT_MENU, self.on_peak_hold, id=self.id_peak_hold) … … 375 397 self.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_10) 376 398 self.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_20) 377 378 399 379 400 # make a menu 380 401 menu = wx.Menu()
