[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10785 - in gnuradio/branches/features/experimental-gu
From: |
jblum |
Subject: |
[Commit-gnuradio] r10785 - in gnuradio/branches/features/experimental-gui: . forms |
Date: |
Mon, 6 Apr 2009 16:10:34 -0600 (MDT) |
Author: jblum
Date: 2009-04-06 16:10:34 -0600 (Mon, 06 Apr 2009)
New Revision: 10785
Modified:
gnuradio/branches/features/experimental-gui/forms/converters.py
gnuradio/branches/features/experimental-gui/forms/forms.py
gnuradio/branches/features/experimental-gui/usrp2_siggen_gui.py
Log:
Log slider for amplitude in usrp2 siggen gui.
Log and linear sliders now subclass from the same base class.
Remove rounding of internal representation.
Modified: gnuradio/branches/features/experimental-gui/forms/converters.py
===================================================================
--- gnuradio/branches/features/experimental-gui/forms/converters.py
2009-04-06 22:04:48 UTC (rev 10784)
+++ gnuradio/branches/features/experimental-gui/forms/converters.py
2009-04-06 22:10:34 UTC (rev 10785)
@@ -125,7 +125,7 @@
self._scaler = float(maximum - minimum)/num_steps
self._cast = cast
def external_to_internal(self, v):
- return int(round((v - self._offset)/self._scaler))
+ return (v - self._offset)/self._scaler
def internal_to_external(self, v):
return self._cast(v*self._scaler + self._offset)
def help(self):
Modified: gnuradio/branches/features/experimental-gui/forms/forms.py
===================================================================
--- gnuradio/branches/features/experimental-gui/forms/forms.py 2009-04-06
22:04:48 UTC (rev 10784)
+++ gnuradio/branches/features/experimental-gui/forms/forms.py 2009-04-06
22:10:34 UTC (rev 10785)
@@ -158,17 +158,13 @@
########################################################################
# Slider Form
########################################################################
-class slider(_form_base):
+class _slider_base(_form_base):
"""
- A generic linear slider.
- @param cast a cast function, int, or float (default=float)
+ Base class for linear and log slider.
@param length the length of the slider in px
@param style wx.SL_HORIZONTAL or wx.SL_VERTICAL
"""
- def __init__(self, label='', length=-1, minimum=-100, maximum=100,
num_steps=100, step_size=None, cast=float, style=wx.SL_HORIZONTAL,
converter=None, **kwargs):
- assert step_size or num_steps
- if step_size is not None: num_steps = (maximum -
minimum)/step_size
- if not converter: converter =
converters.slider_converter(minimum=minimum, maximum=maximum,
num_steps=num_steps, cast=cast)
+ def __init__(self, label='', length=-1, converter=None, num_steps=100,
style=wx.SL_HORIZONTAL, **kwargs):
_form_base.__init__(self, converter=converter, **kwargs)
if style & wx.SL_HORIZONTAL: slider_size = wx.Size(length, -1)
elif style & wx.SL_VERTICAL: slider_size = wx.Size(-1, length)
@@ -180,14 +176,26 @@
def _handle(self, event): self[INT_KEY] = self._slider.GetValue()
def _update(self, value): self._slider.SetValue(value)
-class log_slider(slider):
+class slider(_slider_base):
"""
+ A generic linear slider.
+ @param cast a cast function, int, or float (default=float)
+ """
+ def __init__(self, minimum=-100, maximum=100, num_steps=100,
step_size=None, cast=float, **kwargs):
+ assert step_size or num_steps
+ if step_size is not None: num_steps = (maximum -
minimum)/step_size
+ converter = converters.slider_converter(minimum=minimum,
maximum=maximum, num_steps=num_steps, cast=cast)
+ _slider_base.__init__(self, converter=converter,
num_steps=num_steps, **kwargs)
+
+class log_slider(_slider_base):
+ """
A generic log slider.
"""
- def __init__(self, min_exp=0, max_exp=1, base=10, num_steps=100,
converter=None, **kwargs):
- if not converter:
- converter =
converters.log_slider_converter(min_exp=min_exp, max_exp=max_exp,
num_steps=num_steps, base=base)
- slider.__init__(self, converter=converter, **kwargs)
+ def __init__(self, min_exp=0, max_exp=1, base=10, num_steps=100,
step_size=None, **kwargs):
+ assert step_size or num_steps
+ if step_size is not None: num_steps = (max_exp -
min_exp)/step_size
+ converter = converters.log_slider_converter(min_exp=min_exp,
max_exp=max_exp, num_steps=num_steps, base=base)
+ _slider_base.__init__(self, converter=converter,
num_steps=num_steps, **kwargs)
########################################################################
# Check Box Form
Modified: gnuradio/branches/features/experimental-gui/usrp2_siggen_gui.py
===================================================================
--- gnuradio/branches/features/experimental-gui/usrp2_siggen_gui.py
2009-04-06 22:04:48 UTC (rev 10784)
+++ gnuradio/branches/features/experimental-gui/usrp2_siggen_gui.py
2009-04-06 22:10:34 UTC (rev 10785)
@@ -204,14 +204,15 @@
label="Level (0.0-1.0)",
)
lvl_hbox.AddSpacer(10)
- forms.slider(
+ forms.log_slider(
parent=self.panel, sizer=lvl_hbox,
proportion=2,
ps=self.tb,
key=usrp2_siggen.AMPLITUDE_KEY,
- minimum=0,
- maximum=1,
- num_steps=100,
+ min_exp=-5,
+ max_exp=0,
+ base=10,
+ step_size=1,
)
lvl_hbox.AddSpacer(5)
if self.tb[usrp2_siggen.GAIN_RANGE_KEY][0] <
self.tb[usrp2_siggen.GAIN_RANGE_KEY][1]:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10785 - in gnuradio/branches/features/experimental-gui: . forms,
jblum <=