Revision 51af4269 gr-wxgui/src/python/waterfall_window.py
| b/gr-wxgui/src/python/waterfall_window.py | ||
|---|---|---|
| 30 | 30 |
import pubsub |
| 31 | 31 |
from constants import * |
| 32 | 32 |
from gnuradio import gr #for gr.prefs |
| 33 |
import forms |
|
| 33 | 34 |
|
| 34 | 35 |
################################################## |
| 35 | 36 |
# Constants |
| ... | ... | |
| 64 | 65 |
wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) |
| 65 | 66 |
control_box = wx.BoxSizer(wx.VERTICAL) |
| 66 | 67 |
control_box.AddStretchSpacer() |
| 67 |
control_box.Add(common.LabelText(self, 'Options'), 0, wx.ALIGN_CENTER) |
|
| 68 |
#color mode |
|
| 69 |
control_box.AddStretchSpacer() |
|
| 70 |
color_mode_chooser = common.DropDownController(self, COLOR_MODES, parent, COLOR_MODE_KEY) |
|
| 71 |
control_box.Add(common.LabelBox(self, 'Color', color_mode_chooser), 0, wx.EXPAND) |
|
| 68 |
options_box = forms.static_box_sizer( |
|
| 69 |
parent=self, sizer=control_box, label='Options', |
|
| 70 |
bold=True, orient=wx.VERTICAL, |
|
| 71 |
) |
|
| 72 | 72 |
#average |
| 73 |
forms.check_box( |
|
| 74 |
sizer=options_box, parent=self, label='Average', |
|
| 75 |
ps=parent, key=AVERAGE_KEY, |
|
| 76 |
) |
|
| 77 |
avg_alpha_text = forms.static_text( |
|
| 78 |
sizer=options_box, parent=self, label='Avg Alpha', |
|
| 79 |
converter=forms.float_converter(lambda x: '%.4f'%x), |
|
| 80 |
ps=parent, key=AVG_ALPHA_KEY, width=50, |
|
| 81 |
) |
|
| 82 |
avg_alpha_slider = forms.log_slider( |
|
| 83 |
sizer=options_box, parent=self, |
|
| 84 |
min_exp=AVG_ALPHA_MIN_EXP, |
|
| 85 |
max_exp=AVG_ALPHA_MAX_EXP, |
|
| 86 |
num_steps=SLIDER_STEPS, |
|
| 87 |
ps=parent, key=AVG_ALPHA_KEY, |
|
| 88 |
) |
|
| 89 |
for widget in (avg_alpha_text, avg_alpha_slider): |
|
| 90 |
parent.subscribe(AVERAGE_KEY, widget.Enable) |
|
| 91 |
widget.Enable(parent[AVERAGE_KEY]) |
|
| 92 |
#begin axes box |
|
| 73 | 93 |
control_box.AddStretchSpacer() |
| 74 |
average_check_box = common.CheckBoxController(self, 'Average', parent, AVERAGE_KEY)
|
|
| 75 |
control_box.Add(average_check_box, 0, wx.EXPAND)
|
|
| 76 |
control_box.AddSpacer(2)
|
|
| 77 |
avg_alpha_slider = common.LogSliderController(
|
|
| 78 |
self, 'Avg Alpha',
|
|
| 79 |
AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP, SLIDER_STEPS,
|
|
| 80 |
parent, AVG_ALPHA_KEY,
|
|
| 81 |
formatter=lambda x: ': %.4f'%x,
|
|
| 94 |
axes_box = forms.static_box_sizer(
|
|
| 95 |
parent=self, sizer=control_box, label='Axes Options',
|
|
| 96 |
bold=True, orient=wx.VERTICAL,
|
|
| 97 |
)
|
|
| 98 |
#num lines buttons
|
|
| 99 |
forms.incr_decr_buttons(
|
|
| 100 |
parent=self, sizer=axes_box, label='Time Scale',
|
|
| 101 |
on_incr=self._on_incr_time_scale, on_decr=self._on_decr_time_scale,
|
|
| 82 | 102 |
) |
| 83 |
parent.subscribe(AVERAGE_KEY, avg_alpha_slider.Enable) |
|
| 84 |
control_box.Add(avg_alpha_slider, 0, wx.EXPAND) |
|
| 85 | 103 |
#dyanmic range buttons |
| 86 |
control_box.AddStretchSpacer() |
|
| 87 |
control_box.Add(common.LabelText(self, 'Dynamic Range'), 0, wx.ALIGN_CENTER) |
|
| 88 |
control_box.AddSpacer(2) |
|
| 89 |
dynamic_range_buttons = common.IncrDecrButtons(self, self._on_incr_dynamic_range, self._on_decr_dynamic_range) |
|
| 90 |
control_box.Add(dynamic_range_buttons, 0, wx.ALIGN_CENTER) |
|
| 104 |
forms.incr_decr_buttons( |
|
| 105 |
parent=self, sizer=axes_box, label='Dyn Range', |
|
| 106 |
on_incr=self._on_incr_dynamic_range, on_decr=self._on_decr_dynamic_range, |
|
| 107 |
) |
|
| 91 | 108 |
#ref lvl buttons |
| 92 |
control_box.AddStretchSpacer()
|
|
| 93 |
control_box.Add(common.LabelText(self, 'Set Ref Level'), 0, wx.ALIGN_CENTER)
|
|
| 94 |
control_box.AddSpacer(2)
|
|
| 95 |
ref_lvl_buttons = common.IncrDecrButtons(self, self._on_incr_ref_level, self._on_decr_ref_level)
|
|
| 96 |
control_box.Add(ref_lvl_buttons, 0, wx.ALIGN_CENTER)
|
|
| 97 |
#num lines buttons
|
|
| 98 |
control_box.AddStretchSpacer()
|
|
| 99 |
control_box.Add(common.LabelText(self, 'Set Time Scale'), 0, wx.ALIGN_CENTER)
|
|
| 100 |
control_box.AddSpacer(2)
|
|
| 101 |
time_scale_buttons = common.IncrDecrButtons(self, self._on_incr_time_scale, self._on_decr_time_scale)
|
|
| 102 |
control_box.Add(time_scale_buttons, 0, wx.ALIGN_CENTER)
|
|
| 109 |
forms.incr_decr_buttons(
|
|
| 110 |
parent=self, sizer=axes_box, label='Ref Level',
|
|
| 111 |
on_incr=self._on_incr_ref_level, on_decr=self._on_decr_ref_level,
|
|
| 112 |
) |
|
| 113 |
#color mode
|
|
| 114 |
forms.drop_down(
|
|
| 115 |
parent=self, sizer=axes_box, width=100,
|
|
| 116 |
ps=parent, key=COLOR_MODE_KEY, label='Color',
|
|
| 117 |
choices=map(lambda x: x[1], COLOR_MODES),
|
|
| 118 |
labels=map(lambda x: x[0], COLOR_MODES),
|
|
| 119 |
) |
|
| 103 | 120 |
#autoscale |
| 104 |
control_box.AddStretchSpacer()
|
|
| 105 |
autoscale_button = wx.Button(self, label='Autoscale', style=wx.BU_EXACTFIT)
|
|
| 106 |
autoscale_button.Bind(wx.EVT_BUTTON, self.parent.autoscale)
|
|
| 107 |
control_box.Add(autoscale_button, 0, wx.EXPAND)
|
|
| 121 |
forms.single_button(
|
|
| 122 |
parent=self, sizer=axes_box, label='Autoscale',
|
|
| 123 |
callback=self.parent.autoscale,
|
|
| 124 |
) |
|
| 108 | 125 |
#clear |
| 109 |
clear_button = wx.Button(self, label='Clear', style=wx.BU_EXACTFIT) |
|
| 110 |
clear_button.Bind(wx.EVT_BUTTON, self._on_clear_button) |
|
| 111 |
control_box.Add(clear_button, 0, wx.EXPAND) |
|
| 126 |
control_box.AddStretchSpacer() |
|
| 127 |
forms.single_button( |
|
| 128 |
parent=self, sizer=control_box, label='Clear', |
|
| 129 |
callback=self._on_clear_button, |
|
| 130 |
) |
|
| 112 | 131 |
#run/stop |
| 113 |
run_button = common.ToggleButtonController(self, parent, RUNNING_KEY, 'Stop', 'Run') |
|
| 114 |
control_box.Add(run_button, 0, wx.EXPAND) |
|
| 132 |
forms.toggle_button( |
|
| 133 |
sizer=control_box, parent=self, |
|
| 134 |
true_label='Stop', false_label='Run', |
|
| 135 |
ps=parent, key=RUNNING_KEY, |
|
| 136 |
) |
|
| 115 | 137 |
#set sizer |
| 116 | 138 |
self.SetSizerAndFit(control_box) |
| 117 | 139 |
|
| ... | ... | |
| 181 | 203 |
self.plotter.set_title(title) |
| 182 | 204 |
self.plotter.enable_point_label(True) |
| 183 | 205 |
self.plotter.enable_grid_lines(False) |
| 184 |
#setup the box with plot and controls |
|
| 185 |
self.control_panel = control_panel(self) |
|
| 186 |
main_box = wx.BoxSizer(wx.HORIZONTAL) |
|
| 187 |
main_box.Add(self.plotter, 1, wx.EXPAND) |
|
| 188 |
main_box.Add(self.control_panel, 0, wx.EXPAND) |
|
| 189 |
self.SetSizerAndFit(main_box) |
|
| 190 | 206 |
#plotter listeners |
| 191 | 207 |
self.subscribe(COLOR_MODE_KEY, self.plotter.set_color_mode) |
| 192 | 208 |
self.subscribe(NUM_LINES_KEY, self.plotter.set_num_lines) |
| 193 | 209 |
#initialize values |
| 194 |
self[AVERAGE_KEY] = self[AVERAGE_KEY] |
|
| 195 |
self[AVG_ALPHA_KEY] = self[AVG_ALPHA_KEY] |
|
| 196 | 210 |
self[DYNAMIC_RANGE_KEY] = dynamic_range |
| 197 | 211 |
self[NUM_LINES_KEY] = num_lines |
| 198 | 212 |
self[Y_DIVS_KEY] = 8 |
| ... | ... | |
| 201 | 215 |
self[BASEBAND_FREQ_KEY] = baseband_freq |
| 202 | 216 |
self[COLOR_MODE_KEY] = COLOR_MODES[0][1] |
| 203 | 217 |
self[RUNNING_KEY] = True |
| 218 |
#setup the box with plot and controls |
|
| 219 |
self.control_panel = control_panel(self) |
|
| 220 |
main_box = wx.BoxSizer(wx.HORIZONTAL) |
|
| 221 |
main_box.Add(self.plotter, 1, wx.EXPAND) |
|
| 222 |
main_box.Add(self.control_panel, 0, wx.EXPAND) |
|
| 223 |
self.SetSizerAndFit(main_box) |
|
| 204 | 224 |
#register events |
| 205 | 225 |
self.subscribe(MSG_KEY, self.handle_msg) |
| 206 | 226 |
for key in ( |
Also available in: Unified diff