summaryrefslogtreecommitdiff
path: root/gr-wxgui
diff options
context:
space:
mode:
Diffstat (limited to 'gr-wxgui')
-rw-r--r--gr-wxgui/grc/top_block_gui.py8
-rw-r--r--gr-wxgui/grc/wxgui_fftsink2.xml12
-rw-r--r--gr-wxgui/grc/wxgui_waterfallsink2.xml12
-rw-r--r--gr-wxgui/src/python/fft_window.py2
-rw-r--r--gr-wxgui/src/python/fftsink_gl.py3
-rw-r--r--gr-wxgui/src/python/plotter/channel_plotter.py8
-rw-r--r--gr-wxgui/src/python/plotter/common.py1
-rw-r--r--gr-wxgui/src/python/plotter/grid_plotter_base.py14
-rw-r--r--gr-wxgui/src/python/plotter/plotter_base.py5
-rw-r--r--gr-wxgui/src/python/plotter/waterfall_plotter.py8
-rw-r--r--gr-wxgui/src/python/waterfall_window.py3
-rw-r--r--gr-wxgui/src/python/waterfallsink_gl.py3
12 files changed, 75 insertions, 4 deletions
diff --git a/gr-wxgui/grc/top_block_gui.py b/gr-wxgui/grc/top_block_gui.py
index 333ccf1c1..479f55a30 100644
--- a/gr-wxgui/grc/top_block_gui.py
+++ b/gr-wxgui/grc/top_block_gui.py
@@ -48,7 +48,7 @@ class top_block_gui(gr.top_block):
def SetIcon(self, *args, **kwargs): self._frame.SetIcon(*args, **kwargs)
- def Run(self, start=True):
+ def Run(self, start=True, max_nouts=0):
"""
Setup the wx gui elements.
Start the gr top block.
@@ -69,6 +69,10 @@ class top_block_gui(gr.top_block):
self._frame.Show(True)
self._app.SetTopWindow(self._frame)
#start flow graph
- if start: self.start()
+ if start:
+ if max_nouts != 0:
+ self.start(max_nouts)
+ else:
+ self.start()
#blocking main loop
self._app.MainLoop()
diff --git a/gr-wxgui/grc/wxgui_fftsink2.xml b/gr-wxgui/grc/wxgui_fftsink2.xml
index ec5501838..74ee5b173 100644
--- a/gr-wxgui/grc/wxgui_fftsink2.xml
+++ b/gr-wxgui/grc/wxgui_fftsink2.xml
@@ -36,6 +36,12 @@ fftsink2.$(type.fcn)(
$(parent).Add(self.$(id).win)
#else
$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
+#end if
+#if $freqvar() is not None
+def $(id)_callback(x, y):
+ self.set_$(freqvar)(x)
+
+self.$(id).set_callback($(id)_callback)
#end if</make>
<callback>set_baseband_freq($baseband_freq)</callback>
<callback>set_sample_rate($samp_rate)</callback>
@@ -216,6 +222,12 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
<value></value>
<type>notebook</type>
</param>
+ <param>
+ <name>Freq Set Varname</name>
+ <key>freqvar</key>
+ <value>None</value>
+ <type>raw</type>
+ </param>
<check>not $win_size or len($win_size) == 2</check>
<sink>
<name>in</name>
diff --git a/gr-wxgui/grc/wxgui_waterfallsink2.xml b/gr-wxgui/grc/wxgui_waterfallsink2.xml
index da6a8a3d1..8921e87f9 100644
--- a/gr-wxgui/grc/wxgui_waterfallsink2.xml
+++ b/gr-wxgui/grc/wxgui_waterfallsink2.xml
@@ -34,6 +34,12 @@ waterfallsink2.$(type.fcn)(
$(parent).Add(self.$(id).win)
#else
$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
+#end if
+#if $freqvar() is not None
+def $(id)_callback(x, y):
+ self.set_$(freqvar)(x)
+
+self.$(id).set_callback($(id)_callback)
#end if</make>
<callback>set_baseband_freq($baseband_freq)</callback>
<callback>set_sample_rate($samp_rate)</callback>
@@ -173,6 +179,12 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
<value></value>
<type>notebook</type>
</param>
+ <param>
+ <name>Freq Set Varname</name>
+ <key>freqvar</key>
+ <value>None</value>
+ <type>raw</type>
+ </param>
<check>not $win_size or len($win_size) == 2</check>
<sink>
<name>in</name>
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