From 9e9d90d528c8833c5b6a0a0982d7df198b6c9451 Mon Sep 17 00:00:00 2001
From: jcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Date: Thu, 8 Nov 2007 19:46:06 +0000
Subject: Adds 'ctrl-double-click to re-center on maximum power' to usrp_fft.py

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6837 221aa14e-8319-0410-a670-987f0aec2ac5
---
 gr-utils/src/python/usrp_fft.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

(limited to 'gr-utils/src')

diff --git a/gr-utils/src/python/usrp_fft.py b/gr-utils/src/python/usrp_fft.py
index 5aee24fe6e..fae5ae4cd7 100755
--- a/gr-utils/src/python/usrp_fft.py
+++ b/gr-utils/src/python/usrp_fft.py
@@ -28,7 +28,7 @@ from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, form,
 from optparse import OptionParser
 import wx
 import sys
-
+import numpy
 
 def pick_subdevice(u):
     """
@@ -261,8 +261,18 @@ class app_top_block(stdgui2.std_top_block):
 	    
     def evt_left_dclick(self, event):
 	(ux, uy) = self.scope.win.GetXY(event)
-	target_freq = ux/self.scope.win._scale_factor
-	self.set_freq(target_freq)
+	if event.CmdDown():
+	    # Re-center on maximum power
+	    points = self.scope.win._points
+            ind = numpy.argmax(points[:,1])
+            (freq, pwr) = points[ind]
+	    target_freq = freq/self.scope.win._scale_factor
+            self.set_freq(target_freq)            
+	else:
+	    # Re-center on clicked frequency
+	    target_freq = ux/self.scope.win._scale_factor
+	    self.set_freq(target_freq)
+	    
 	
 def main ():
     app = stdgui2.stdapp(app_top_block, "USRP FFT", nstatus=1)
-- 
cgit v1.2.3