commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9263 - in gnuradio/branches/developers/jblum/glwxgui:


From: jblum
Subject: [Commit-gnuradio] r9263 - in gnuradio/branches/developers/jblum/glwxgui: gr-utils/src/python gr-wxgui/src/python gr-wxgui/src/python/plotter
Date: Tue, 12 Aug 2008 17:37:57 -0600 (MDT)

Author: jblum
Date: 2008-08-12 17:37:57 -0600 (Tue, 12 Aug 2008)
New Revision: 9263

Modified:
   gnuradio/branches/developers/jblum/glwxgui/gr-utils/src/python/usrp_fft.py
   
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/channel_plotter.py
   
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
   
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/waterfall_plotter.py
   
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
Log:
freq label in waterfall, usrpfft fix

Modified: 
gnuradio/branches/developers/jblum/glwxgui/gr-utils/src/python/usrp_fft.py
===================================================================
--- gnuradio/branches/developers/jblum/glwxgui/gr-utils/src/python/usrp_fft.py  
2008-08-12 23:03:03 UTC (rev 9262)
+++ gnuradio/branches/developers/jblum/glwxgui/gr-utils/src/python/usrp_fft.py  
2008-08-12 23:37:57 UTC (rev 9263)
@@ -251,7 +251,7 @@
             if self.show_debug_info:
                 self.myform['baseband'].set_value(r.baseband_freq)
                 self.myform['ddc'].set_value(r.dxc_freq)
-           if not self.options.waterfall and not self.options.oscilloscope:
+           if not self.options.oscilloscope:
                self.scope.win.set_baseband_freq(target_freq)
            return True
 

Modified: 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/channel_plotter.py
===================================================================
--- 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/channel_plotter.py
   2008-08-12 23:03:03 UTC (rev 9262)
+++ 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/channel_plotter.py
   2008-08-12 23:37:57 UTC (rev 9263)
@@ -26,9 +26,6 @@
 import gltext
 import math
 
-POINT_LABEL_FONT_SIZE = 8
-POINT_LABEL_COLOR_SPEC = (1, 1, .5)
-POINT_LABEL_PADDING = 3
 LEGEND_TEXT_FONT_SIZE = 8
 LEGEND_BOX_PADDING = 3
 PADDING = 35, 15, 40, 60 #top, right, bottom, left
@@ -46,29 +43,7 @@
                grid_plotter_base.__init__(self, parent, PADDING)
                self._channels = dict()
                self.enable_legend(False)
-               self.enable_point_label(False)
-               self._mouse_coordinate = None
-               self.Bind(wx.EVT_MOTION, self._on_motion)
-               self.Bind(wx.EVT_LEAVE_WINDOW, self._on_leave_window)
 
-       def _on_motion(self, event):
-               """!
-               Mouse motion, record the position X, Y.
-               """
-               self.lock()
-               self._mouse_coordinate = event.GetPosition()
-               self.update()
-               self.unlock()
-
-       def _on_leave_window(self, event):
-               """!
-               Mouse leave window, set the position to None.
-               """
-               self.lock()
-               self._mouse_coordinate = None
-               self.update()
-               self.unlock()
-
        def _gl_init(self):
                """!
                Run gl initialization tasks.
@@ -88,18 +63,6 @@
                self.changed(True)
                self.unlock()
 
-       def enable_point_label(self, enable=None):
-               """!
-               Enable/disable the point label.
-               @param enable true to enable
-               @return the enable state when None
-               """
-               if enable is None: return self._enable_point_label
-               self.lock()
-               self._enable_point_label = enable
-               self.changed(True)
-               self.unlock()
-
        def draw(self):
                """!
                Draw the grid and waveforms.
@@ -163,24 +126,15 @@
                        glDrawArrays(marker is None and GL_LINE_STRIP or 
GL_POINTS, 0, len(points))
                        glPopMatrix()
 
-       def _draw_point_label(self):
+       def _populate_point_label(self, x_val, y_val):
                """!
-               Draw the point label for the last mouse motion coordinate.
-               The mouse coordinate must be an X, Y tuple.
-               The label will be drawn at the X, Y coordinate.
-               The values of the X, Y coordinate will be scaled to the current 
X, Y bounds.
+               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
                """
-               if not self.enable_point_label(): return
-               if not self._mouse_coordinate: return
-               x, y = self._mouse_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_scalar = float(x - 
self.padding_left)/(self.width-self.padding_left-self.padding_right)
-               y_scalar = float((self.height - y) - 
self.padding_bottom)/(self.height-self.padding_top-self.padding_bottom)
-               #scale to grid bounds
-               x_val = x_scalar*(self.x_max-self.x_min) + self.x_min
-               y_val = y_scalar*(self.y_max-self.y_min) + self.y_min
                #create text
                label_str = '%s: %g %s\n%s: %g %s'%(self.x_label, x_val, 
self.x_units, self.y_label, y_val, self.y_units)
                for channel in sorted(self._channels.keys()):
@@ -189,17 +143,12 @@
                        if not num_samps: continue
                        if isinstance(samples, tuple): continue 
                        #linear interpolation
-                       x_index = x_scalar*(num_samps-1)
+                       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: %g %s'%(channel, y_value, 
self.y_units)
-               txt = gltext.Text(label_str, font_size=POINT_LABEL_FONT_SIZE)
-               w, h = txt.get_size()
-               #draw rect + text
-               glColor3f(*POINT_LABEL_COLOR_SPEC)
-               self._draw_rect(x, y-h-2*POINT_LABEL_PADDING, 
w+2*POINT_LABEL_PADDING, h+2*POINT_LABEL_PADDING)
-               txt.draw_text(wx.Point(x+POINT_LABEL_PADDING, 
y-h-POINT_LABEL_PADDING))
+               return label_str
 
        def _draw_legend(self):
                """!

Modified: 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
===================================================================
--- 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
      2008-08-12 23:03:03 UTC (rev 9262)
+++ 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
      2008-08-12 23:37:57 UTC (rev 9263)
@@ -32,6 +32,9 @@
 TITLE_TEXT_FONT_SIZE = 13
 UNITS_TEXT_FONT_SIZE = 9
 TICK_LABEL_PADDING = 5
+POINT_LABEL_FONT_SIZE = 8
+POINT_LABEL_COLOR_SPEC = (1, 1, .5)
+POINT_LABEL_PADDING = 3
 
 ##################################################
 # OpenGL WX Plotter Canvas
@@ -119,7 +122,42 @@
                #init the grid to some value
                self.set_x_grid(-1, 1, 1)
                self.set_y_grid(-1, 1, 1)
+               #setup point label
+               self.enable_point_label(False)
+               self._mouse_coordinate = None
+               self.Bind(wx.EVT_MOTION, self._on_motion)
+               self.Bind(wx.EVT_LEAVE_WINDOW, self._on_leave_window)
 
+       def _on_motion(self, event):
+               """!
+               Mouse motion, record the position X, Y.
+               """
+               self.lock()
+               self._mouse_coordinate = event.GetPosition()
+               self.update()
+               self.unlock()
+
+       def _on_leave_window(self, event):
+               """!
+               Mouse leave window, set the position to None.
+               """
+               self.lock()
+               self._mouse_coordinate = None
+               self.update()
+               self.unlock()
+
+       def enable_point_label(self, enable=None):
+               """!
+               Enable/disable the point label.
+               @param enable true to enable
+               @return the enable state when None
+               """
+               if enable is None: return self._enable_point_label
+               self.lock()
+               self._enable_point_label = enable
+               self.changed(True)
+               self.unlock()
+
        def set_title(self, title):
                """!
                Set the title.
@@ -323,3 +361,30 @@
                glVertex2f(x+width, y+height)
                glVertex2f(x, y+height)
                glEnd()
+
+       def _draw_point_label(self):
+               """!
+               Draw the point label for the last mouse motion coordinate.
+               The mouse coordinate must be an X, Y tuple.
+               The label will be drawn at the X, Y coordinate.
+               The values of the X, Y coordinate will be scaled to the current 
X, Y bounds.
+               """
+               if not self.enable_point_label(): return
+               if not self._mouse_coordinate: return
+               x, y = self._mouse_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_scalar = float(x - 
self.padding_left)/(self.width-self.padding_left-self.padding_right)
+               y_scalar = float((self.height - y) - 
self.padding_bottom)/(self.height-self.padding_top-self.padding_bottom)
+               #scale to grid bounds
+               x_val = x_scalar*(self.x_max-self.x_min) + self.x_min
+               y_val = y_scalar*(self.y_max-self.y_min) + self.y_min
+               #create text
+               label_str = self._populate_point_label(x_val, y_val)
+               txt = gltext.Text(label_str, font_size=POINT_LABEL_FONT_SIZE)
+               w, h = txt.get_size()
+               #draw rect + text
+               glColor3f(*POINT_LABEL_COLOR_SPEC)
+               self._draw_rect(x, y-h-2*POINT_LABEL_PADDING, 
w+2*POINT_LABEL_PADDING, h+2*POINT_LABEL_PADDING)
+               txt.draw_text(wx.Point(x+POINT_LABEL_PADDING, 
y-h-POINT_LABEL_PADDING))

Modified: 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/waterfall_plotter.py
===================================================================
--- 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/waterfall_plotter.py
 2008-08-12 23:03:03 UTC (rev 9262)
+++ 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/waterfall_plotter.py
 2008-08-12 23:37:57 UTC (rev 9263)
@@ -123,6 +123,7 @@
                #draw the grid
                glCallList(self._grid_compiled_list_id)
                self._draw_waterfall()
+               self._draw_point_label()
                #swap buffer into display
                self.SwapBuffers()
                self.unlock()
@@ -169,6 +170,16 @@
                glPopMatrix()
                glDisable(GL_TEXTURE_2D)
 
+       def _populate_point_label(self, x_val, y_val):
+               """!
+               Get the text the will populate the point label.
+               Give the X value for the current point.
+               @param x_val the current x value
+               @param y_val the current y value
+               @return a value string with units
+               """
+               return '%s: %g %s'%(self.x_label, x_val, self.x_units)
+
        def _draw_legend(self):
                """!
                Draw the color scale legend.

Modified: 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
  2008-08-12 23:03:03 UTC (rev 9262)
+++ 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
  2008-08-12 23:37:57 UTC (rev 9263)
@@ -179,6 +179,7 @@
                self.plotter = plotter.waterfall_plotter(self)
                self.plotter.SetSize(wx.Size(*size))
                self.plotter.set_title(title)
+               self.plotter.enable_point_label(True)
                #setup the box with plot and controls
                self.control_panel = control_panel(self)
                main_box = wx.BoxSizer(wx.HORIZONTAL)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]