Merged r10463:10658 from jblum/gui_guts into trunk. Trunk passes distcheck.
[debian/gnuradio] / gr-wxgui / src / python / const_window.py
index cb7236b4924255af1a8db273e9d7d5a76155f718..8e0e61ac3da523bbf4efffc010545883d16c0760 100644 (file)
@@ -62,32 +62,31 @@ class control_panel(wx.Panel):
                @param parent the wx parent window
                """
                self.parent = parent
-               wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)
+               wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
                control_box = wx.BoxSizer(wx.VERTICAL)
                self.marker_index = 2
                #begin control box
-               control_box.AddStretchSpacer()
                control_box.Add(common.LabelText(self, 'Options'), 0, wx.ALIGN_CENTER)
-               #marker
-               control_box.AddStretchSpacer()
-               self.marker_chooser = common.DropDownController(self, 'Marker', MARKER_TYPES, parent, MARKER_KEY)
-               control_box.Add(self.marker_chooser, 0, wx.EXPAND)
                #alpha
                control_box.AddStretchSpacer()
-               self.alpha_slider = common.LogSliderController(
+               alpha_slider = common.LogSliderController(
                        self, 'Alpha',
                        ALPHA_MIN_EXP, ALPHA_MAX_EXP, SLIDER_STEPS,
-                       parent.ext_controller, parent.alpha_key,
+                       parent, ALPHA_KEY,
                )
-               control_box.Add(self.alpha_slider, 0, wx.EXPAND)
+               control_box.Add(alpha_slider, 0, wx.EXPAND)
                #gain_mu
                control_box.AddStretchSpacer()
-               self.gain_mu_slider = common.LogSliderController(
+               gain_mu_slider = common.LogSliderController(
                        self, 'Gain Mu',
                        GAIN_MU_MIN_EXP, GAIN_MU_MAX_EXP, SLIDER_STEPS,
-                       parent.ext_controller, parent.gain_mu_key,
+                       parent, GAIN_MU_KEY,
                )
-               control_box.Add(self.gain_mu_slider, 0, wx.EXPAND)
+               control_box.Add(gain_mu_slider, 0, wx.EXPAND)
+               #marker
+               control_box.AddStretchSpacer()
+               marker_chooser = common.DropDownController(self, MARKER_TYPES, parent, MARKER_KEY)
+               control_box.Add(common.LabelBox(self, 'Marker', marker_chooser), 0, wx.EXPAND)
                #run/stop
                control_box.AddStretchSpacer()
                self.run_button = common.ToggleButtonController(self, parent, RUNNING_KEY, 'Stop', 'Run')
@@ -98,7 +97,7 @@ class control_panel(wx.Panel):
 ##################################################
 # Constellation window with plotter and control panel
 ##################################################
-class const_window(wx.Panel, pubsub.pubsub, common.prop_setter):
+class const_window(wx.Panel, pubsub.pubsub):
        def __init__(
                self,
                parent,
@@ -110,22 +109,27 @@ class const_window(wx.Panel, pubsub.pubsub, common.prop_setter):
                beta_key,
                gain_mu_key,
                gain_omega_key,
+               omega_key,
+               sample_rate_key,
        ):
                pubsub.pubsub.__init__(self)
-               #setup
-               self.ext_controller = controller
-               self.alpha_key = alpha_key
-               self.beta_key = beta_key
-               self.gain_mu_key = gain_mu_key
-               self.gain_omega_key = gain_omega_key
+               #proxy the keys
+               self.proxy(MSG_KEY, controller, msg_key)
+               self.proxy(ALPHA_KEY, controller, alpha_key)
+               self.proxy(BETA_KEY, controller, beta_key)
+               self.proxy(GAIN_MU_KEY, controller, gain_mu_key)
+               self.proxy(GAIN_OMEGA_KEY, controller, gain_omega_key)
+               self.proxy(OMEGA_KEY, controller, omega_key)
+               self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
                #init panel and plot
-               wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
+               wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
                self.plotter = plotter.channel_plotter(self)
                self.plotter.SetSize(wx.Size(*size))
                self.plotter.set_title(title)
                self.plotter.set_x_label('Inphase')
                self.plotter.set_y_label('Quadrature')
                self.plotter.enable_point_label(True)
+               self.plotter.enable_grid_lines(True)
                #setup the box with plot and controls
                self.control_panel = control_panel(self)
                main_box = wx.BoxSizer(wx.HORIZONTAL)
@@ -133,22 +137,21 @@ class const_window(wx.Panel, pubsub.pubsub, common.prop_setter):
                main_box.Add(self.control_panel, 0, wx.EXPAND)
                self.SetSizerAndFit(main_box)
                #alpha and gain mu 2nd orders
-               def set_beta(alpha): self.ext_controller[self.beta_key] = .25*alpha**2
-               self.ext_controller.subscribe(self.alpha_key, set_beta)
-               def set_gain_omega(gain_mu): self.ext_controller[self.gain_omega_key] = .25*gain_mu**2
-               self.ext_controller.subscribe(self.gain_mu_key, set_gain_omega)
-               #initial setup
-               self.ext_controller[self.alpha_key] = self.ext_controller[self.alpha_key]
-               self.ext_controller[self.gain_mu_key] = self.ext_controller[self.gain_mu_key]
-               self._register_set_prop(self, RUNNING_KEY, True)
-               self._register_set_prop(self, X_DIVS_KEY, 8)
-               self._register_set_prop(self, Y_DIVS_KEY, 8)
-               self._register_set_prop(self, MARKER_KEY, DEFAULT_MARKER_TYPE)
+               def set_beta(alpha): self[BETA_KEY] = .25*alpha**2
+               self.subscribe(ALPHA_KEY, set_beta)
+               def set_gain_omega(gain_mu): self[GAIN_OMEGA_KEY] = .25*gain_mu**2
+               self.subscribe(GAIN_MU_KEY, set_gain_omega)
+               #initialize values
+               self[ALPHA_KEY] = self[ALPHA_KEY]
+               self[GAIN_MU_KEY] = self[GAIN_MU_KEY]
+               self[RUNNING_KEY] = True
+               self[X_DIVS_KEY] = 8
+               self[Y_DIVS_KEY] = 8
+               self[MARKER_KEY] = DEFAULT_MARKER_TYPE
                #register events
-               self.ext_controller.subscribe(msg_key, self.handle_msg)
-               for key in (
-                       X_DIVS_KEY, Y_DIVS_KEY,
-               ): self.subscribe(key, self.update_grid)
+               self.subscribe(MSG_KEY, self.handle_msg)
+               self.subscribe(X_DIVS_KEY, self.update_grid)
+               self.subscribe(Y_DIVS_KEY, self.update_grid)
                #initial update
                self.update_grid()
 
@@ -173,15 +176,12 @@ class const_window(wx.Panel, pubsub.pubsub, common.prop_setter):
                self.plotter.update()
 
        def update_grid(self):
-               #grid parameters
-               x_divs = self[X_DIVS_KEY]
-               y_divs = self[Y_DIVS_KEY]
                #update the x axis
                x_max = 2.0
-               self.plotter.set_x_grid(-x_max, x_max, common.get_clean_num(2.0*x_max/x_divs))
+               self.plotter.set_x_grid(-x_max, x_max, common.get_clean_num(2.0*x_max/self[X_DIVS_KEY]))
                #update the y axis
                y_max = 2.0
-               self.plotter.set_y_grid(-y_max, y_max, common.get_clean_num(2.0*y_max/y_divs))
+               self.plotter.set_y_grid(-y_max, y_max, common.get_clean_num(2.0*y_max/self[Y_DIVS_KEY]))
                #update plotter
                self.plotter.update()