From 36649d4e472172fe840444ac0268c7b6b4da94b4 Mon Sep 17 00:00:00 2001 From: jcorgan Date: Thu, 14 Aug 2008 18:43:15 +0000 Subject: Merged changeset r9241:9289 from jblum/glwxgui into trunk. Adds OpenGL versions of fftsink, waterfallsink, and scopesink, and new constsink. See README.gl for use. (Josh Blum) git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9290 221aa14e-8319-0410-a670-987f0aec2ac5 --- gr-wxgui/src/python/plotter/channel_plotter.py | 225 +++++++++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 gr-wxgui/src/python/plotter/channel_plotter.py (limited to 'gr-wxgui/src/python/plotter/channel_plotter.py') diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py new file mode 100644 index 000000000..22126bd0b --- /dev/null +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -0,0 +1,225 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +import wx +from plotter_base import grid_plotter_base +from OpenGL.GL import * +from gnuradio.wxgui import common +import numpy +import gltext +import math + +LEGEND_TEXT_FONT_SIZE = 8 +LEGEND_BOX_PADDING = 3 +PADDING = 35, 15, 40, 60 #top, right, bottom, left +#constants for the waveform storage +SAMPLES_KEY = 'samples' +COLOR_SPEC_KEY = 'color_spec' +MARKERY_KEY = 'marker' + +################################################## +# Channel Plotter for X Y Waveforms +################################################## +class channel_plotter(grid_plotter_base): + + def __init__(self, parent): + """! + Create a new channel plotter. + """ + #init + grid_plotter_base.__init__(self, parent, PADDING) + self._channels = dict() + self.enable_legend(False) + + def _gl_init(self): + """! + Run gl initialization tasks. + """ + glEnableClientState(GL_VERTEX_ARRAY) + self._grid_compiled_list_id = glGenLists(1) + + def enable_legend(self, enable=None): + """! + Enable/disable the legend. + @param enable true to enable + @return the enable state when None + """ + if enable is None: return self._enable_legend + self.lock() + self._enable_legend = enable + self.changed(True) + self.unlock() + + def draw(self): + """! + Draw the grid and waveforms. + """ + self.lock() + self.clear() + #store the grid drawing operations + if self.changed(): + glNewList(self._grid_compiled_list_id, GL_COMPILE) + self._draw_grid() + self._draw_legend() + glEndList() + self.changed(False) + #draw the grid + glCallList(self._grid_compiled_list_id) + #use scissor to prevent drawing outside grid + glEnable(GL_SCISSOR_TEST) + glScissor( + self.padding_left+1, + self.padding_bottom+1, + self.width-self.padding_left-self.padding_right-1, + self.height-self.padding_top-self.padding_bottom-1, + ) + #draw the waveforms + self._draw_waveforms() + glDisable(GL_SCISSOR_TEST) + self._draw_point_label() + #swap buffer into display + self.SwapBuffers() + self.unlock() + + def _draw_waveforms(self): + """! + Draw the waveforms for each channel. + Scale the waveform data to the grid using gl matrix operations. + """ + for channel in reversed(sorted(self._channels.keys())): + samples = self._channels[channel][SAMPLES_KEY] + num_samps = len(samples) + #use opengl to scale the waveform + glPushMatrix() + glTranslatef(self.padding_left, self.padding_top, 0) + glScalef( + (self.width-self.padding_left-self.padding_right), + (self.height-self.padding_top-self.padding_bottom), + 1, + ) + glTranslatef(0, 1, 0) + if isinstance(samples, tuple): + x_scale, x_trans = 1.0/(self.x_max-self.x_min), -self.x_min + points = zip(*samples) + else: + x_scale, x_trans = 1.0/(num_samps-1), 0 + points = zip(numpy.arange(0, num_samps), samples) + glScalef(x_scale, -1.0/(self.y_max-self.y_min), 1) + glTranslatef(x_trans, -self.y_min, 0) + #draw the points/lines + glColor3f(*self._channels[channel][COLOR_SPEC_KEY]) + marker = self._channels[channel][MARKERY_KEY] + if marker: glPointSize(marker) + glVertexPointer(2, GL_FLOAT, 0, points) + glDrawArrays(marker is None and GL_LINE_STRIP or GL_POINTS, 0, len(points)) + glPopMatrix() + + def _populate_point_label(self, x_val, y_val): + """! + Get the text the will populate the point label. + Give X and Y values for the current point. + Give values for the channel at the X coordinate. + @param x_val the current x value + @param y_val the current y value + @return a string with newlines + """ + #create text + label_str = '%s: %s %s\n%s: %s %s'%( + self.x_label, + common.label_format(x_val), + self.x_units, self.y_label, + common.label_format(y_val), + self.y_units, + ) + for channel in sorted(self._channels.keys()): + samples = self._channels[channel][SAMPLES_KEY] + num_samps = len(samples) + if not num_samps: continue + if isinstance(samples, tuple): continue + #linear interpolation + x_index = (num_samps-1)*(x_val/self.x_scalar-self.x_min)/(self.x_max-self.x_min) + x_index_low = int(math.floor(x_index)) + x_index_high = int(math.ceil(x_index)) + y_value = (samples[x_index_high] - samples[x_index_low])*(x_index - x_index_low) + samples[x_index_low] + label_str += '\n%s: %s %s'%(channel, common.label_format(y_value), self.y_units) + return label_str + + def _draw_legend(self): + """! + Draw the legend in the upper right corner. + For each channel, draw a rectangle out of the channel color, + and overlay the channel text on top of the rectangle. + """ + if not self.enable_legend(): return + x_off = self.width - self.padding_right - LEGEND_BOX_PADDING + for i, channel in enumerate(reversed(sorted(self._channels.keys()))): + samples = self._channels[channel][SAMPLES_KEY] + if not len(samples): continue + color_spec = self._channels[channel][COLOR_SPEC_KEY] + txt = gltext.Text(channel, font_size=LEGEND_TEXT_FONT_SIZE) + w, h = txt.get_size() + #draw rect + text + glColor3f(*color_spec) + self._draw_rect( + x_off - w - LEGEND_BOX_PADDING, + self.padding_top/2 - h/2 - LEGEND_BOX_PADDING, + w+2*LEGEND_BOX_PADDING, + h+2*LEGEND_BOX_PADDING, + ) + txt.draw_text(wx.Point(x_off - w, self.padding_top/2 - h/2)) + x_off -= w + 4*LEGEND_BOX_PADDING + + def set_waveform(self, channel, samples, color_spec, marker=None): + """! + Set the waveform for a given channel. + @param channel the channel key + @param samples the waveform samples + @param color_spec the 3-tuple for line color + @param marker None for line + """ + self.lock() + if channel not in self._channels.keys(): self.changed(True) + self._channels[channel] = { + SAMPLES_KEY: samples, + COLOR_SPEC_KEY: color_spec, + MARKERY_KEY: marker, + } + self.unlock() + +if __name__ == '__main__': + app = wx.PySimpleApp() + frame = wx.Frame(None, -1, 'Demo', wx.DefaultPosition) + vbox = wx.BoxSizer(wx.VERTICAL) + + plotter = channel_plotter(frame) + plotter.set_x_grid(-1, 1, .2) + plotter.set_y_grid(-1, 1, .4) + vbox.Add(plotter, 1, wx.EXPAND) + + plotter = channel_plotter(frame) + plotter.set_x_grid(-1, 1, .2) + plotter.set_y_grid(-1, 1, .4) + vbox.Add(plotter, 1, wx.EXPAND) + + frame.SetSizerAndFit(vbox) + frame.SetSize(wx.Size(800, 600)) + frame.Show() + app.MainLoop() -- cgit From 580a21ac5aa342b79b8d616117478196c5072e71 Mon Sep 17 00:00:00 2001 From: jblum Date: Tue, 2 Sep 2008 18:13:40 +0000 Subject: patched channel plotter -> Stefan BrĂ¼ns git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9484 221aa14e-8319-0410-a670-987f0aec2ac5 --- gr-wxgui/src/python/plotter/channel_plotter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gr-wxgui/src/python/plotter/channel_plotter.py') diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py index 22126bd0b..e7e83e5fa 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -107,6 +107,7 @@ class channel_plotter(grid_plotter_base): for channel in reversed(sorted(self._channels.keys())): samples = self._channels[channel][SAMPLES_KEY] num_samps = len(samples) + if not num_samps: continue #use opengl to scale the waveform glPushMatrix() glTranslatef(self.padding_left, self.padding_top, 0) @@ -128,7 +129,7 @@ class channel_plotter(grid_plotter_base): glColor3f(*self._channels[channel][COLOR_SPEC_KEY]) marker = self._channels[channel][MARKERY_KEY] if marker: glPointSize(marker) - glVertexPointer(2, GL_FLOAT, 0, points) + glVertexPointerf(points) glDrawArrays(marker is None and GL_LINE_STRIP or GL_POINTS, 0, len(points)) glPopMatrix() -- cgit From 924831afcdb187b3de670be6fd1f6147d62be5cf Mon Sep 17 00:00:00 2001 From: jblum Date: Wed, 10 Sep 2008 01:23:21 +0000 Subject: Replaced """! with """. Exclamation mark showed in doxygen docs. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9549 221aa14e-8319-0410-a670-987f0aec2ac5 --- gr-wxgui/src/python/plotter/channel_plotter.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gr-wxgui/src/python/plotter/channel_plotter.py') diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py index e7e83e5fa..8fa28410b 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -41,7 +41,7 @@ MARKERY_KEY = 'marker' class channel_plotter(grid_plotter_base): def __init__(self, parent): - """! + """ Create a new channel plotter. """ #init @@ -50,14 +50,14 @@ class channel_plotter(grid_plotter_base): self.enable_legend(False) def _gl_init(self): - """! + """ Run gl initialization tasks. """ glEnableClientState(GL_VERTEX_ARRAY) self._grid_compiled_list_id = glGenLists(1) def enable_legend(self, enable=None): - """! + """ Enable/disable the legend. @param enable true to enable @return the enable state when None @@ -69,7 +69,7 @@ class channel_plotter(grid_plotter_base): self.unlock() def draw(self): - """! + """ Draw the grid and waveforms. """ self.lock() @@ -100,7 +100,7 @@ class channel_plotter(grid_plotter_base): self.unlock() def _draw_waveforms(self): - """! + """ Draw the waveforms for each channel. Scale the waveform data to the grid using gl matrix operations. """ @@ -134,7 +134,7 @@ class channel_plotter(grid_plotter_base): glPopMatrix() def _populate_point_label(self, x_val, y_val): - """! + """ Get the text the will populate the point label. Give X and Y values for the current point. Give values for the channel at the X coordinate. @@ -164,7 +164,7 @@ class channel_plotter(grid_plotter_base): return label_str def _draw_legend(self): - """! + """ Draw the legend in the upper right corner. For each channel, draw a rectangle out of the channel color, and overlay the channel text on top of the rectangle. @@ -189,7 +189,7 @@ class channel_plotter(grid_plotter_base): x_off -= w + 4*LEGEND_BOX_PADDING def set_waveform(self, channel, samples, color_spec, marker=None): - """! + """ Set the waveform for a given channel. @param channel the channel key @param samples the waveform samples -- cgit From d9744799b7df6c09180778540bf55eb9dc84281b Mon Sep 17 00:00:00 2001 From: jcorgan Date: Fri, 20 Mar 2009 02:16:20 +0000 Subject: Merged r10463:10658 from jblum/gui_guts into trunk. Trunk passes distcheck. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10660 221aa14e-8319-0410-a670-987f0aec2ac5 --- gr-wxgui/src/python/plotter/channel_plotter.py | 127 +++++++++++++------------ 1 file changed, 64 insertions(+), 63 deletions(-) (limited to 'gr-wxgui/src/python/plotter/channel_plotter.py') diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py index 8fa28410b..ff0a3a160 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -1,5 +1,5 @@ # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008, 2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,20 +20,21 @@ # import wx -from plotter_base import grid_plotter_base -from OpenGL.GL import * -from gnuradio.wxgui import common +from grid_plotter_base import grid_plotter_base +from OpenGL import GL +import common import numpy import gltext import math LEGEND_TEXT_FONT_SIZE = 8 LEGEND_BOX_PADDING = 3 -PADDING = 35, 15, 40, 60 #top, right, bottom, left +MIN_PADDING = 35, 10, 0, 0 #top, right, bottom, left #constants for the waveform storage SAMPLES_KEY = 'samples' COLOR_SPEC_KEY = 'color_spec' MARKERY_KEY = 'marker' +TRIG_OFF_KEY = 'trig_off' ################################################## # Channel Plotter for X Y Waveforms @@ -45,16 +46,21 @@ class channel_plotter(grid_plotter_base): Create a new channel plotter. """ #init - grid_plotter_base.__init__(self, parent, PADDING) - self._channels = dict() + grid_plotter_base.__init__(self, parent, MIN_PADDING) + #setup legend cache + self._legend_cache = self.new_gl_cache(self._draw_legend, 50) self.enable_legend(False) + #setup waveform cache + self._waveform_cache = self.new_gl_cache(self._draw_waveforms, 50) + self._channels = dict() + #init channel plotter + self.register_init(self._init_channel_plotter) - def _gl_init(self): + def _init_channel_plotter(self): """ Run gl initialization tasks. """ - glEnableClientState(GL_VERTEX_ARRAY) - self._grid_compiled_list_id = glGenLists(1) + GL.glEnableClientState(GL.GL_VERTEX_ARRAY) def enable_legend(self, enable=None): """ @@ -65,73 +71,55 @@ class channel_plotter(grid_plotter_base): if enable is None: return self._enable_legend self.lock() self._enable_legend = enable - self.changed(True) + self._legend_cache.changed(True) self.unlock() - def draw(self): + def _draw_waveforms(self): """ - Draw the grid and waveforms. + Draw the waveforms for each channel. + Scale the waveform data to the grid using gl matrix operations. """ - self.lock() - self.clear() - #store the grid drawing operations - if self.changed(): - glNewList(self._grid_compiled_list_id, GL_COMPILE) - self._draw_grid() - self._draw_legend() - glEndList() - self.changed(False) - #draw the grid - glCallList(self._grid_compiled_list_id) #use scissor to prevent drawing outside grid - glEnable(GL_SCISSOR_TEST) - glScissor( + GL.glEnable(GL.GL_SCISSOR_TEST) + GL.glScissor( self.padding_left+1, self.padding_bottom+1, self.width-self.padding_left-self.padding_right-1, self.height-self.padding_top-self.padding_bottom-1, ) - #draw the waveforms - self._draw_waveforms() - glDisable(GL_SCISSOR_TEST) - self._draw_point_label() - #swap buffer into display - self.SwapBuffers() - self.unlock() - - def _draw_waveforms(self): - """ - Draw the waveforms for each channel. - Scale the waveform data to the grid using gl matrix operations. - """ for channel in reversed(sorted(self._channels.keys())): samples = self._channels[channel][SAMPLES_KEY] num_samps = len(samples) if not num_samps: continue #use opengl to scale the waveform - glPushMatrix() - glTranslatef(self.padding_left, self.padding_top, 0) - glScalef( + GL.glPushMatrix() + GL.glTranslatef(self.padding_left, self.padding_top, 0) + GL.glScalef( (self.width-self.padding_left-self.padding_right), (self.height-self.padding_top-self.padding_bottom), 1, ) - glTranslatef(0, 1, 0) + GL.glTranslatef(0, 1, 0) if isinstance(samples, tuple): x_scale, x_trans = 1.0/(self.x_max-self.x_min), -self.x_min points = zip(*samples) else: - x_scale, x_trans = 1.0/(num_samps-1), 0 + x_scale, x_trans = 1.0/(num_samps-1), -self._channels[channel][TRIG_OFF_KEY] points = zip(numpy.arange(0, num_samps), samples) - glScalef(x_scale, -1.0/(self.y_max-self.y_min), 1) - glTranslatef(x_trans, -self.y_min, 0) + GL.glScalef(x_scale, -1.0/(self.y_max-self.y_min), 1) + GL.glTranslatef(x_trans, -self.y_min, 0) #draw the points/lines - glColor3f(*self._channels[channel][COLOR_SPEC_KEY]) + GL.glColor3f(*self._channels[channel][COLOR_SPEC_KEY]) marker = self._channels[channel][MARKERY_KEY] - if marker: glPointSize(marker) - glVertexPointerf(points) - glDrawArrays(marker is None and GL_LINE_STRIP or GL_POINTS, 0, len(points)) - glPopMatrix() + if marker is None: + GL.glVertexPointerf(points) + GL.glDrawArrays(GL.GL_LINE_STRIP, 0, len(points)) + elif isinstance(marker, (int, float)) and marker > 0: + GL.glPointSize(marker) + GL.glVertexPointerf(points) + GL.glDrawArrays(GL.GL_POINTS, 0, len(points)) + GL.glPopMatrix() + GL.glDisable(GL.GL_SCISSOR_TEST) def _populate_point_label(self, x_val, y_val): """ @@ -143,12 +131,9 @@ class channel_plotter(grid_plotter_base): @return a string with newlines """ #create text - label_str = '%s: %s %s\n%s: %s %s'%( - self.x_label, - common.label_format(x_val), - self.x_units, self.y_label, - common.label_format(y_val), - self.y_units, + label_str = '%s: %s\n%s: %s'%( + self.x_label, common.eng_format(x_val, self.x_units), + self.y_label, common.eng_format(y_val, self.y_units), ) for channel in sorted(self._channels.keys()): samples = self._channels[channel][SAMPLES_KEY] @@ -156,11 +141,12 @@ class channel_plotter(grid_plotter_base): if not num_samps: continue if isinstance(samples, tuple): continue #linear interpolation - x_index = (num_samps-1)*(x_val/self.x_scalar-self.x_min)/(self.x_max-self.x_min) + x_index = (num_samps-1)*(x_val-self.x_min)/(self.x_max-self.x_min) x_index_low = int(math.floor(x_index)) x_index_high = int(math.ceil(x_index)) - y_value = (samples[x_index_high] - samples[x_index_low])*(x_index - x_index_low) + samples[x_index_low] - label_str += '\n%s: %s %s'%(channel, common.label_format(y_value), self.y_units) + scale = x_index - x_index_low + self._channels[channel][TRIG_OFF_KEY] + y_value = (samples[x_index_high] - samples[x_index_low])*scale + samples[x_index_low] + label_str += '\n%s: %s'%(channel, common.eng_format(y_value, self.y_units)) return label_str def _draw_legend(self): @@ -178,7 +164,7 @@ class channel_plotter(grid_plotter_base): txt = gltext.Text(channel, font_size=LEGEND_TEXT_FONT_SIZE) w, h = txt.get_size() #draw rect + text - glColor3f(*color_spec) + GL.glColor3f(*color_spec) self._draw_rect( x_off - w - LEGEND_BOX_PADDING, self.padding_top/2 - h/2 - LEGEND_BOX_PADDING, @@ -188,21 +174,36 @@ class channel_plotter(grid_plotter_base): txt.draw_text(wx.Point(x_off - w, self.padding_top/2 - h/2)) x_off -= w + 4*LEGEND_BOX_PADDING - def set_waveform(self, channel, samples, color_spec, marker=None): + def clear_waveform(self, channel): + """ + Remove a waveform from the list of waveforms. + @param channel the channel key + """ + self.lock() + if channel in self._channels.keys(): + self._channels.pop(channel) + self._legend_cache.changed(True) + self._waveform_cache.changed(True) + self.unlock() + + def set_waveform(self, channel, samples=[], color_spec=(0, 0, 0), marker=None, trig_off=0): """ Set the waveform for a given channel. @param channel the channel key @param samples the waveform samples @param color_spec the 3-tuple for line color @param marker None for line + @param trig_off fraction of sample for trigger offset """ self.lock() - if channel not in self._channels.keys(): self.changed(True) + if channel not in self._channels.keys(): self._legend_cache.changed(True) self._channels[channel] = { SAMPLES_KEY: samples, COLOR_SPEC_KEY: color_spec, MARKERY_KEY: marker, + TRIG_OFF_KEY: trig_off, } + self._waveform_cache.changed(True) self.unlock() if __name__ == '__main__': -- cgit From 49fa13f9fce2037d176c86bf326a7e25a78b72a5 Mon Sep 17 00:00:00 2001 From: Martin Dudok van Heel Date: Mon, 26 Apr 2010 19:40:41 +0200 Subject: Add analog CRT screen afterglow emulation for gr-wxgui --- gr-wxgui/src/python/plotter/channel_plotter.py | 1 + 1 file changed, 1 insertion(+) (limited to 'gr-wxgui/src/python/plotter/channel_plotter.py') diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py index ff0a3a160..f046ae5a9 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -47,6 +47,7 @@ class channel_plotter(grid_plotter_base): """ #init grid_plotter_base.__init__(self, parent, MIN_PADDING) + self.set_emulate_analog(False) #setup legend cache self._legend_cache = self.new_gl_cache(self._draw_legend, 50) self.enable_legend(False) -- cgit From 3a730f46faf1942c713350b312a1dfeffb587550 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Thu, 13 May 2010 13:11:13 -0700 Subject: gr-wxgui: Renamed "emulate analog" feature to "use persistence" --- gr-wxgui/src/python/plotter/channel_plotter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-wxgui/src/python/plotter/channel_plotter.py') diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py index f046ae5a9..cf38786f2 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -47,7 +47,7 @@ class channel_plotter(grid_plotter_base): """ #init grid_plotter_base.__init__(self, parent, MIN_PADDING) - self.set_emulate_analog(False) + self.set_use_persistence(False) #setup legend cache self._legend_cache = self.new_gl_cache(self._draw_legend, 50) self.enable_legend(False) -- cgit From 2057623cf8f9e9738954b146d3a23577110f7906 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Thu, 13 May 2010 13:16:46 -0700 Subject: gr-wxgui: update copyrights --- gr-wxgui/src/python/plotter/channel_plotter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-wxgui/src/python/plotter/channel_plotter.py') diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py index cf38786f2..a3a2b6451 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -1,5 +1,5 @@ # -# Copyright 2008, 2009 Free Software Foundation, Inc. +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # -- cgit From ed838eb9be22d769247a9c63f23423c8c2f81f72 Mon Sep 17 00:00:00 2001 From: Marcus Leech Date: Mon, 21 May 2012 14:35:33 -0400 Subject: wxgui: allows LEFT click to set a flow-graph variable to the adjusted X value on either the FFT or waterfall display. --- gr-wxgui/src/python/plotter/channel_plotter.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gr-wxgui/src/python/plotter/channel_plotter.py') 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. -- cgit