[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9151 - in gnuradio/branches/features/experimental-gui
From: |
jblum |
Subject: |
[Commit-gnuradio] r9151 - in gnuradio/branches/features/experimental-gui: . plotter |
Date: |
Sat, 2 Aug 2008 11:10:04 -0600 (MDT) |
Author: jblum
Date: 2008-08-02 11:10:02 -0600 (Sat, 02 Aug 2008)
New Revision: 9151
Modified:
gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
gnuradio/branches/features/experimental-gui/waterfall_window.py
Log:
waterfall local buffer
Modified:
gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
===================================================================
--- gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
2008-08-02 02:01:13 UTC (rev 9150)
+++ gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
2008-08-02 17:10:02 UTC (rev 9151)
@@ -45,35 +45,35 @@
"""
#init
grid_plotter_base.__init__(self, parent, PADDING)
- self._buffer_init = False
- self._data_queue = list()
self._minimum = 0
self._maximum = 0
+ self._fft_size = 0
+ self._num_lines = 0
+ self._buffer = ''
+ self._counter = 0
def _gl_init(self):
"""!
Run gl initialization tasks.
"""
self._grid_compiled_list_id = glGenLists(1)
- self._buffer_init = True
def draw(self):
"""!
Draw the grid and waveforms.
"""
self.semaphore.acquire(True)
- while self._data_queue:
- data = self._data_queue.pop(0)
- 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)
+ #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)
+ self.clear()
+ #draw the grid
+ glCallList(self._grid_compiled_list_id)
+ if self._buffer:
#use scissor to prevent drawing outside grid
glEnable(GL_SCISSOR_TEST)
glScissor(
@@ -83,38 +83,17 @@
self.height-self.padding_top-self.padding_bottom-1,
)
#draw the waterfall
- self._draw_waterfall(data)
+ glPixelZoom(
+
float(self.width-self.padding_left-self.padding_right)/self._fft_size,
+
float(self.height-self.padding_top-self.padding_bottom+1)/self._num_lines,
+ )
+ glRasterPos2f(self.padding_left+1,
self.height-self.padding_bottom-1)
+ glDrawPixels(self._fft_size, self._num_lines, GL_RGBA,
GL_UNSIGNED_BYTE, self._buffer)
glDisable(GL_SCISSOR_TEST)
- #swap buffer into display
- self.SwapBuffers()
+ #swap buffer into display
+ self.SwapBuffers()
self.semaphore.release()
- def _draw_waterfall(self, data):
- """!
- Draw a new sample onto the waterfall display.
- The pixels will be scaled to fit within the grid area.
- @param data the fft bsample as color data
- """
- fft_size = len(data)/4
- #pixel zoom
- x_zoom =
float(self.width-self.padding_left-self.padding_right)/fft_size
- y_zoom =
float(self.height-self.padding_top-self.padding_bottom+1)/self._num_lines
- #draw and shift the previous samples
- glReadBuffer(GL_FRONT)
- glPixelZoom(1, 1)
- glRasterPos2f(self.padding_left+1,
self.height-self.padding_bottom-int(y_zoom))
- glCopyPixels(
- self.padding_left+1,
- self.padding_bottom,
- self.width-self.padding_left-self.padding_right,
-
self.height-self.padding_top-self.padding_bottom-int(y_zoom),
- GL_COLOR,
- )
- #draw a new fft sample
- glPixelZoom(x_zoom, y_zoom)
- glRasterPos2f(self.padding_left+1,
self.height-self.padding_bottom-1)
- glDrawPixels(fft_size, 1, GL_RGBA, GL_UNSIGNED_BYTE, data)
-
def _draw_legend(self):
"""!
Draw the color scale legend.
@@ -135,27 +114,34 @@
txt = gltext.Text('%ddB'%int(dB),
font_size=LEGEND_FONT_SIZE)
txt.draw_text(wx.Point(x+LEGEND_BLOCK_WIDTH+LEGEND_RIGHT_PAD, y+block_height/4))
- def set_samples(self, samples, min, max, num_lines):
+ def set_samples(self, samples, minimum, maximum, num_lines):
"""!
Set the samples to the waterfall.
Convert the samples to color data.
@param samples the array of floats
- @param min the minimum value to scale
- @param max the maximum value to scale
+ @param minimum the minimum value to scale
+ @param maximum the maximum value to scale
@param num_lines the number of lines
"""
self.semaphore.acquire(True)
#set the min, max values
- if self._minimum != min or self._maximum != max:
- self._minimum = min
- self._maximum = max
+ if self._minimum != minimum or self._maximum != maximum:
+ self._minimum = minimum
+ self._maximum = maximum
self.changed(True)
- self._num_lines = num_lines
+ if self._fft_size != len(samples) or self._num_lines !=
num_lines:
+ self._fft_size = len(samples)
+ self._num_lines = num_lines
+ self._buffer = self._buffer +
numpy.zeros(self._num_lines*self._fft_size*4, numpy.uint8).tostring()
+ self.changed(True)
#normalize the samples to min/max
- samples = (samples - min)*float(255/(max-min))
+ samples = (samples - minimum)*float(255/(maximum-minimum))
samples = numpy.minimum(samples, 255) #clip
samples = numpy.maximum(samples, 0) #clip
samples = numpy.array(samples, numpy.uint8)
data = numpy.array([RGBA_ARRAY[sample] for sample in
samples]).tostring()
- self._data_queue.append(data)
+ self._buffer = (data +
self._buffer)[:self._num_lines*self._fft_size*4]
+ #selective update, dont update for sub-pixel counts
+ if self._counter == 0: self.update()
+ self._counter = (self._counter + 1)%max(2,
2*self._num_lines/self.height)
self.semaphore.release()
Modified: gnuradio/branches/features/experimental-gui/waterfall_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-08-02 02:01:13 UTC (rev 9150)
+++ gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-08-02 17:10:02 UTC (rev 9151)
@@ -37,7 +37,7 @@
DEFAULT_FRAME_RATE = 30
DEFAULT_WIN_SIZE = (600, 300)
DIV_LEVELS = (1, 2, 5, 10, 20)
-MIN_NUM_LINES, MAX_NUM_LINES = 1000, 10
+MIN_NUM_LINES, MAX_NUM_LINES = 10, 1000
MIN_DYNAMIC_RANGE, MAX_DYNAMIC_RANGE = 10, 200
DYNAMIC_RANGE_KEY = 'dynamic_range'
NUM_LINES_KEY = 'num_lines'
@@ -168,7 +168,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.controller, DYNAMIC_RANGE_KEY,
dynamic_range)
- self._register_set_prop(self.controller, NUM_LINES_KEY, 128)
+ self._register_set_prop(self.controller, NUM_LINES_KEY, 256)
self._register_set_prop(self.controller, Y_DIVS_KEY, 10)
self._register_set_prop(self.controller, X_DIVS_KEY, 8)
#approximate
self._register_set_prop(self.controller, REF_LEVEL_KEY,
ref_level)
@@ -207,8 +207,6 @@
self.controller[DYNAMIC_RANGE_KEY] +
self.controller[REF_LEVEL_KEY],
self.controller[NUM_LINES_KEY],
)
- #update the plotter
- self.plotter.update()
def update_grid(self, *args):
"""!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9151 - in gnuradio/branches/features/experimental-gui: . plotter,
jblum <=