[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9204 - in gnuradio/branches/features/experimental-gui
From: |
jblum |
Subject: |
[Commit-gnuradio] r9204 - in gnuradio/branches/features/experimental-gui: . plotter |
Date: |
Thu, 7 Aug 2008 14:51:49 -0600 (MDT) |
Author: jblum
Date: 2008-08-07 14:51:49 -0600 (Thu, 07 Aug 2008)
New Revision: 9204
Modified:
gnuradio/branches/features/experimental-gui/const_window.py
gnuradio/branches/features/experimental-gui/fft_window.py
gnuradio/branches/features/experimental-gui/plotter/channel_plotter.py
gnuradio/branches/features/experimental-gui/plotter/gltext.py
gnuradio/branches/features/experimental-gui/scope_window.py
Log:
pointer label + channel values
Modified: gnuradio/branches/features/experimental-gui/const_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/const_window.py 2008-08-07
19:51:49 UTC (rev 9203)
+++ gnuradio/branches/features/experimental-gui/const_window.py 2008-08-07
20:51:49 UTC (rev 9204)
@@ -124,6 +124,7 @@
self.plotter.set_title(title)
self.plotter.set_x_label('Inphase')
self.plotter.set_y_label('Quadrature')
+ 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)
Modified: gnuradio/branches/features/experimental-gui/fft_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/fft_window.py 2008-08-07
19:51:49 UTC (rev 9203)
+++ gnuradio/branches/features/experimental-gui/fft_window.py 2008-08-07
20:51:49 UTC (rev 9204)
@@ -155,6 +155,7 @@
self.plotter = plotter.channel_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)
@@ -172,6 +173,7 @@
self._register_set_prop(self, BASEBAND_FREQ_KEY, baseband_freq)
self._register_set_prop(self, RUNNING_KEY, True)
#register events
+ self.subscribe(PEAK_HOLD_KEY, self.plotter.enable_legend)
self.ext_controller.subscribe(msg_key, self.handle_msg)
self.ext_controller.subscribe(self.sample_rate_key,
self.update_grid)
for key in (
@@ -180,6 +182,7 @@
Y_DIVS_KEY, REF_LEVEL_KEY,
): self.subscribe(key, self.update_grid)
#initial update
+ self.plotter.enable_legend(self[PEAK_HOLD_KEY])
self.update_grid()
def handle_msg(self, msg):
Modified: gnuradio/branches/features/experimental-gui/plotter/channel_plotter.py
===================================================================
--- gnuradio/branches/features/experimental-gui/plotter/channel_plotter.py
2008-08-07 19:51:49 UTC (rev 9203)
+++ gnuradio/branches/features/experimental-gui/plotter/channel_plotter.py
2008-08-07 20:51:49 UTC (rev 9204)
@@ -29,7 +29,7 @@
POINT_LABEL_COLOR_SPEC = (1, 1, .5)
POINT_LABEL_PADDING = 3
LEGEND_TEXT_FONT_SIZE = 8
-LEGEND_BOX_WIDTH, LEGEND_BOX_HEIGHT = 26, 20
+LEGEND_BOX_PADDING = 3
PADDING = 35, 15, 40, 60 #top, right, bottom, left
##################################################
@@ -43,9 +43,9 @@
"""
#init
grid_plotter_base.__init__(self, parent, PADDING)
- self.channels = dict()
+ self._channels = dict()
self.enable_legend(False)
- self.enable_point_label(True)
+ 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)
@@ -135,8 +135,8 @@
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, color_spec, marker = self.channels[channel]
+ for channel in reversed(sorted(self._channels.keys())):
+ samples, color_spec, marker = self._channels[channel]
num_samps = len(samples)
#use opengl to scale the waveform
glPushMatrix()
@@ -181,9 +181,16 @@
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)
+ 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]
+ num_samps = len(samples)
+ if not num_samps: continue
+ if isinstance(samples, tuple): continue
+ x_index = x_scalar*(num_samps-1)
+ label_str += '\n%s: %g %s'%(channel, samples[x_index],
self.y_units)
txt = gltext.Text(label_str, font_size=POINT_LABEL_FONT_SIZE)
- w, h = txt._aloc_text._text_size #FIXME
+ 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)
@@ -196,31 +203,33 @@
and overlay the channel text on top of the rectangle.
"""
if not self.enable_legend(): return
- for i, channel in enumerate(sorted(self.channels.keys())):
- x_off = 1.1*LEGEND_BOX_WIDTH*(len(self.channels) - i -
1) + LEGEND_BOX_WIDTH/2
- color_spec = self.channels[channel][1]
- #draw colored rectangle
+ x_off = self.width - self.padding_right - LEGEND_BOX_PADDING
+ for i, channel in
enumerate(reversed(sorted(self._channels.keys()))):
+ color_spec = self._channels[channel][1]
+ txt = gltext.Text(channel,
font_size=LEGEND_TEXT_FONT_SIZE)
+ w, h = txt.get_size()
+ #draw rect + text
glColor3f(*color_spec)
self._draw_rect(
- self.width - self.padding_right - x_off -
LEGEND_BOX_WIDTH/2,
- (self.padding_top-LEGEND_BOX_HEIGHT)/2.0,
- LEGEND_BOX_WIDTH,
- LEGEND_BOX_HEIGHT,
+ 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,
)
- #draw label text
- txt = gltext.Text('Ch%s'%channel,
font_size=LEGEND_TEXT_FONT_SIZE, centered=True)
- txt.draw_text(wx.Point(self.width - self.padding_right
- x_off, self.padding_top/2.0))
+ 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 number
+ @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()
- self.channels[channel] = samples, color_spec, marker
+ if channel not in self._channels.keys(): self.changed(True)
+ self._channels[channel] = samples, color_spec, marker
self.unlock()
if __name__ == '__main__':
Modified: gnuradio/branches/features/experimental-gui/plotter/gltext.py
===================================================================
--- gnuradio/branches/features/experimental-gui/plotter/gltext.py
2008-08-07 19:51:49 UTC (rev 9203)
+++ gnuradio/branches/features/experimental-gui/plotter/gltext.py
2008-08-07 20:51:49 UTC (rev 9204)
@@ -458,6 +458,12 @@
if reinit:
self._initText()
+ def get_size(self):
+ """
+ Returns a text size tuple
+ """
+ return self._aloc_text._text_size
+
def getTexture_size(self):
"""
Returns a texture size tuple
Modified: gnuradio/branches/features/experimental-gui/scope_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/scope_window.py 2008-08-07
19:51:49 UTC (rev 9203)
+++ gnuradio/branches/features/experimental-gui/scope_window.py 2008-08-07
20:51:49 UTC (rev 9204)
@@ -200,6 +200,7 @@
self.plotter.SetSize(wx.Size(*size))
self.plotter.set_title(title)
self.plotter.enable_legend(self.num_inputs > 1)
+ 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)
@@ -283,7 +284,7 @@
if num_samps < 2: num_samps = 0
#plot samples
self.plotter.set_waveform(
- channel=i+1,
+ channel='Ch%d'%(i+1),
samples=samples[:num_samps],
color_spec=CHANNEL_COLOR_SPECS[i],
)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9204 - in gnuradio/branches/features/experimental-gui: . plotter,
jblum <=