[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9269 - in gnuradio/branches/developers/jblum/glwxgui/
From: |
jblum |
Subject: |
[Commit-gnuradio] r9269 - in gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python: . plotter |
Date: |
Wed, 13 Aug 2008 16:46:55 -0600 (MDT) |
Author: jblum
Date: 2008-08-13 16:46:54 -0600 (Wed, 13 Aug 2008)
New Revision: 9269
Modified:
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/scope_window.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfallsink_gl.py
Log:
scaling fix
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-13 21:49:19 UTC (rev 9268)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/channel_plotter.py
2008-08-13 22:46:54 UTC (rev 9269)
@@ -29,6 +29,10 @@
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
@@ -100,7 +104,7 @@
Scale the waveform data to the grid using gl matrix operations.
"""
for channel in reversed(sorted(self._channels.keys())):
- samples, color_spec, marker = self._channels[channel]
+ samples = self._channels[channel][SAMPLES_KEY]
num_samps = len(samples)
#use opengl to scale the waveform
glPushMatrix()
@@ -120,7 +124,8 @@
glScalef(x_scale, -1.0/(self.y_max-self.y_min), 1)
glTranslatef(x_trans, -self.y_min, 0)
#draw the points/lines
- glColor3f(*color_spec)
+ 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))
@@ -138,12 +143,12 @@
#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()):
- samples = self._channels[channel][0]
+ samples = self._channels[channel][SAMPLES_KEY]
num_samps = len(samples)
if not num_samps: continue
- if isinstance(samples, tuple): continue
+ if isinstance(samples, tuple): continue
#linear interpolation
- x_index =
(num_samps-1)*(x_val-self.x_min)/(self.x_max-self.x_min)
+ 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]
@@ -159,9 +164,9 @@
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][0]
+ samples = self._channels[channel][SAMPLES_KEY]
if not len(samples): continue
- color_spec = self._channels[channel][1]
+ 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
@@ -185,7 +190,11 @@
"""
self.lock()
if channel not in self._channels.keys(): self.changed(True)
- self._channels[channel] = samples, color_spec, marker
+ self._channels[channel] = {
+ SAMPLES_KEY: samples,
+ COLOR_SPEC_KEY: color_spec,
+ MARKERY_KEY: marker,
+ }
self.unlock()
if __name__ == '__main__':
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-13 21:49:19 UTC (rev 9268)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
2008-08-13 22:46:54 UTC (rev 9269)
@@ -384,11 +384,11 @@
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)
+ 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_scalar*(self.x_max-self.x_min) + self.x_min
- y_val = y_scalar*(self.y_max-self.y_min) + self.y_min
+ x_val = self.x_scalar*(x_win_scalar*(self.x_max-self.x_min) +
self.x_min)
+ y_val = self.y_scalar*(y_win_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)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scope_window.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scope_window.py
2008-08-13 21:49:19 UTC (rev 9268)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scope_window.py
2008-08-13 22:46:54 UTC (rev 9269)
@@ -470,9 +470,10 @@
else: units, scalar = 'ns', 1e9
self.plotter.set_x_label('Time', units)
self.plotter.set_x_grid(
- scalar*t_off,
- scalar*t_per_div*t_divs + scalar*t_off,
- scalar*t_per_div,
+ t_off,
+ t_per_div*t_divs + t_off,
+ t_per_div,
+ scalar,
)
#update the y axis
self.plotter.set_y_label('Voltage')
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-13 21:49:19 UTC (rev 9268)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
2008-08-13 22:46:54 UTC (rev 9269)
@@ -154,6 +154,7 @@
title,
real,
fft_size,
+ num_lines,
decimation_key,
baseband_freq,
sample_rate_key,
@@ -193,7 +194,7 @@
self.ext_controller[self.average_key] =
self.ext_controller[self.average_key]
self.ext_controller[self.avg_alpha_key] =
self.ext_controller[self.avg_alpha_key]
self._register_set_prop(self, DYNAMIC_RANGE_KEY, dynamic_range)
- self._register_set_prop(self, NUM_LINES_KEY, 256)
+ self._register_set_prop(self, NUM_LINES_KEY, num_lines)
self._register_set_prop(self, Y_DIVS_KEY, 8)
self._register_set_prop(self, X_DIVS_KEY, 8) #approximate
self._register_set_prop(self, REF_LEVEL_KEY, ref_level)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfallsink_gl.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfallsink_gl.py
2008-08-13 21:49:19 UTC (rev 9268)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfallsink_gl.py
2008-08-13 22:46:54 UTC (rev 9269)
@@ -51,6 +51,7 @@
size=waterfall_window.DEFAULT_WIN_SIZE,
ref_scale=2.0,
dynamic_range=80,
+ num_lines=256,
):
#ensure avg alpha
if avg_alpha is None: avg_alpha = 2.0/fft_rate
@@ -89,7 +90,7 @@
self.controller.publish(FRAME_RATE_KEY, fft.frame_rate)
#start input watcher
def setter(p, k, x): # lambdas can't have assignments :(
- p[k] = x
+ p[k] = x
common.input_watcher(msgq, lambda x: setter(self.controller,
MSG_KEY, x))
#create window
self.win = waterfall_window.waterfall_window(
@@ -99,6 +100,7 @@
title=title,
real=self._real,
fft_size=fft_size,
+ num_lines=num_lines,
baseband_freq=baseband_freq,
decimation_key=DECIMATION_KEY,
sample_rate_key=SAMPLE_RATE_KEY,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9269 - in gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python: . plotter,
jblum <=