diff options
author | Marcus Leech | 2012-05-21 14:35:33 -0400 |
---|---|---|
committer | Tom Rondeau | 2012-05-21 14:35:33 -0400 |
commit | ed838eb9be22d769247a9c63f23423c8c2f81f72 (patch) | |
tree | e109cbd8d7ce5ea2ae3df2f6ce64256ad17aeecb /gr-wxgui/src | |
parent | d4fe4377e72165d88fdf00f6c8d5a5b986b25955 (diff) | |
download | gnuradio-ed838eb9be22d769247a9c63f23423c8c2f81f72.tar.gz gnuradio-ed838eb9be22d769247a9c63f23423c8c2f81f72.tar.bz2 gnuradio-ed838eb9be22d769247a9c63f23423c8c2f81f72.zip |
wxgui: allows LEFT click to set a flow-graph variable to the adjusted X value on either the FFT or waterfall display.
Diffstat (limited to 'gr-wxgui/src')
-rw-r--r-- | gr-wxgui/src/python/fft_window.py | 2 | ||||
-rw-r--r-- | gr-wxgui/src/python/fftsink_gl.py | 3 | ||||
-rw-r--r-- | gr-wxgui/src/python/plotter/channel_plotter.py | 8 | ||||
-rw-r--r-- | gr-wxgui/src/python/plotter/common.py | 1 | ||||
-rw-r--r-- | gr-wxgui/src/python/plotter/grid_plotter_base.py | 14 | ||||
-rw-r--r-- | gr-wxgui/src/python/plotter/plotter_base.py | 5 | ||||
-rw-r--r-- | gr-wxgui/src/python/plotter/waterfall_plotter.py | 8 | ||||
-rw-r--r-- | gr-wxgui/src/python/waterfall_window.py | 3 | ||||
-rw-r--r-- | gr-wxgui/src/python/waterfallsink_gl.py | 3 |
9 files changed, 45 insertions, 2 deletions
diff --git a/gr-wxgui/src/python/fft_window.py b/gr-wxgui/src/python/fft_window.py index 99c1cf6e1..fac83a4a3 100644 --- a/gr-wxgui/src/python/fft_window.py +++ b/gr-wxgui/src/python/fft_window.py @@ -300,6 +300,8 @@ class fft_window(wx.Panel, pubsub.pubsub): #initial update self.update_grid() + def set_callback(self,callb): + self.plotter.set_callback(callb) def autoscale(self, *args): """ diff --git a/gr-wxgui/src/python/fftsink_gl.py b/gr-wxgui/src/python/fftsink_gl.py index 6b268f6cb..dc31e84a1 100644 --- a/gr-wxgui/src/python/fftsink_gl.py +++ b/gr-wxgui/src/python/fftsink_gl.py @@ -127,6 +127,9 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): setattr(self.win, 'set_peak_hold', getattr(self, 'set_peak_hold')) #BACKWARDS #connect self.wxgui_connect(self, fft, sink) + + def set_callback(self,callb): + self.win.set_callback(callb) class fft_sink_f(_fft_sink_base): _fft_chain = blks2.logpwrfft_f diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py index a3a2b6451..4bcc36fd4 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -56,6 +56,7 @@ class channel_plotter(grid_plotter_base): self._channels = dict() #init channel plotter self.register_init(self._init_channel_plotter) + self.callback = None def _init_channel_plotter(self): """ @@ -150,6 +151,13 @@ class channel_plotter(grid_plotter_base): label_str += '\n%s: %s'%(channel, common.eng_format(y_value, self.y_units)) return label_str + def _call_callback (self, x_val, y_val): + if self.callback != None: + self.callback(x_val, y_val) + + def set_callback (self, callback): + self.callback = callback + def _draw_legend(self): """ Draw the legend in the upper right corner. diff --git a/gr-wxgui/src/python/plotter/common.py b/gr-wxgui/src/python/plotter/common.py index 6775b7057..88215e039 100644 --- a/gr-wxgui/src/python/plotter/common.py +++ b/gr-wxgui/src/python/plotter/common.py @@ -103,6 +103,7 @@ class point_label_thread(threading.Thread, mutex): self._plotter.Bind(wx.EVT_MOTION, lambda evt: self.enqueue(evt.GetPosition())) self._plotter.Bind(wx.EVT_LEAVE_WINDOW, lambda evt: self.enqueue(None)) self._plotter.Bind(wx.EVT_RIGHT_DOWN, lambda evt: plotter.enable_point_label(not plotter.enable_point_label())) + self._plotter.Bind(wx.EVT_LEFT_DOWN, lambda evt: plotter.call_freq_callback(evt.GetPosition())) #start the thread threading.Thread.__init__(self) self.start() diff --git a/gr-wxgui/src/python/plotter/grid_plotter_base.py b/gr-wxgui/src/python/plotter/grid_plotter_base.py index 5eaa76bc0..f1bc8f546 100644 --- a/gr-wxgui/src/python/plotter/grid_plotter_base.py +++ b/gr-wxgui/src/python/plotter/grid_plotter_base.py @@ -85,7 +85,19 @@ class grid_plotter_base(plotter_base): self._point_label_cache.changed(True) self.update() self.unlock() - + + def call_freq_callback(self, coor): + x, y = self._point_label_coordinate + if x < self.padding_left or x > self.width-self.padding_right: return + if y < self.padding_top or y > self.height-self.padding_bottom: return + #scale to window bounds + x_win_scalar = float(x - self.padding_left)/(self.width-self.padding_left-self.padding_right) + y_win_scalar = float((self.height - y) - self.padding_bottom)/(self.height-self.padding_top-self.padding_bottom) + #scale to grid bounds + x_val = x_win_scalar*(self.x_max-self.x_min) + self.x_min + y_val = y_win_scalar*(self.y_max-self.y_min) + self.y_min + self._call_callback(x_val, y_val) + def enable_grid_aspect_ratio(self, enable=None): """ Enable/disable the grid aspect ratio. diff --git a/gr-wxgui/src/python/plotter/plotter_base.py b/gr-wxgui/src/python/plotter/plotter_base.py index 5af580339..2fdd0f20a 100644 --- a/gr-wxgui/src/python/plotter/plotter_base.py +++ b/gr-wxgui/src/python/plotter/plotter_base.py @@ -189,7 +189,10 @@ class plotter_base(wx.glcanvas.GLCanvas, common.mutex): if self.use_persistence: if self.clear_accum: #GL.glClear(GL.GL_ACCUM_BUFFER_BIT) - GL.glAccum(GL.GL_LOAD, 1.0) + try: + GL.glAccum(GL.GL_LOAD, 1.0) + except: + pass self.clear_accum=False GL.glAccum(GL.GL_MULT, 1.0-self.persist_alpha) diff --git a/gr-wxgui/src/python/plotter/waterfall_plotter.py b/gr-wxgui/src/python/plotter/waterfall_plotter.py index f2456241c..6a6bf6330 100644 --- a/gr-wxgui/src/python/plotter/waterfall_plotter.py +++ b/gr-wxgui/src/python/plotter/waterfall_plotter.py @@ -110,6 +110,7 @@ class waterfall_plotter(grid_plotter_base): self._counter = 0 self.set_num_lines(0) self.set_color_mode(COLORS.keys()[0]) + self.callback = None def _init_waterfall(self): """ @@ -172,6 +173,13 @@ class waterfall_plotter(grid_plotter_base): """ return '%s: %s'%(self.x_label, common.eng_format(x_val, self.x_units)) + def _call_callback(self, x_val, y_val): + if self.callback != None: + self.callback(x_val,y_val) + + def set_callback(self,callback): + self.callback = callback + def _draw_legend(self): """ Draw the color scale legend. diff --git a/gr-wxgui/src/python/waterfall_window.py b/gr-wxgui/src/python/waterfall_window.py index c78244f04..cd60104d7 100644 --- a/gr-wxgui/src/python/waterfall_window.py +++ b/gr-wxgui/src/python/waterfall_window.py @@ -238,6 +238,9 @@ class waterfall_window(wx.Panel, pubsub.pubsub): #initial update self.update_grid() + def set_callback(self,callb): + self.plotter.set_callback(callb) + def autoscale(self, *args): """ Autoscale the waterfall plot to the last frame. diff --git a/gr-wxgui/src/python/waterfallsink_gl.py b/gr-wxgui/src/python/waterfallsink_gl.py index c2c4e8df7..b69c5dda0 100644 --- a/gr-wxgui/src/python/waterfallsink_gl.py +++ b/gr-wxgui/src/python/waterfallsink_gl.py @@ -113,6 +113,9 @@ class _waterfall_sink_base(gr.hier_block2, common.wxgui_hb): #connect self.wxgui_connect(self, fft, sink) + def set_callback(self,callb): + self.win.set_callback(callb) + class waterfall_sink_f(_waterfall_sink_base): _fft_chain = blks2.logpwrfft_f _item_size = gr.sizeof_float |