diff options
Diffstat (limited to 'gr-wxgui/src/python/plotter')
-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 |
5 files changed, 34 insertions, 2 deletions
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. |