commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10525 - in gnuradio/branches/developers/jblum/gui_gut


From: jblum
Subject: [Commit-gnuradio] r10525 - in gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python: . plotter
Date: Wed, 25 Feb 2009 23:25:56 -0700 (MST)

Author: jblum
Date: 2009-02-25 23:25:55 -0700 (Wed, 25 Feb 2009)
New Revision: 10525

Modified:
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/plotter_base.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
Log:
trigger position indicator, dashed lines for plotter grid

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/plotter_base.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/plotter_base.py
     2009-02-26 04:44:02 UTC (rev 10524)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/plotter_base.py
     2009-02-26 06:25:55 UTC (rev 10525)
@@ -29,7 +29,8 @@
 import time
 
 BACKGROUND_COLOR_SPEC = (1, 0.976, 1, 1) #creamy white
-GRID_LINE_COLOR_SPEC = (0, 0, 0) #black
+GRID_LINE_COLOR_SPEC = (.7, .7, .7) #gray
+GRID_BORDER_COLOR_SPEC = (0, 0, 0) #black
 TICK_TEXT_FONT_SIZE = 9
 TITLE_TEXT_FONT_SIZE = 13
 UNITS_TEXT_FONT_SIZE = 9
@@ -241,26 +242,16 @@
                Draw the border, grid, title, and units.
                """
                ##################################################
-               # Draw Border
+               # Draw Grid X
                ##################################################
                glColor3f(*GRID_LINE_COLOR_SPEC)
-               self._draw_rect(
-                       self.padding_left,
-                       self.padding_top,
-                       self.width - self.padding_right - self.padding_left,
-                       self.height - self.padding_top - self.padding_bottom,
-                       fill=False,
-               )
-               ##################################################
-               # Draw Grid X
-               ##################################################
                for tick in self._get_ticks(self.x_min, self.x_max, 
self.x_step, self.x_scalar):
                        scaled_tick = 
(self.width-self.padding_left-self.padding_right)*\
                                
(tick/self.x_scalar-self.x_min)/(self.x_max-self.x_min) + self.padding_left
                        glColor3f(*GRID_LINE_COLOR_SPEC)
-                       self._draw_line(
-                               (scaled_tick, self.padding_top, 0),
-                               (scaled_tick, self.height-self.padding_bottom, 
0),
+                       self._draw_dashed_line(
+                               (scaled_tick, self.padding_top),
+                               (scaled_tick, self.height-self.padding_bottom),
                        )
                        txt = self._get_tick_label(tick)
                        w, h = txt.get_size()
@@ -268,18 +259,30 @@
                ##################################################
                # Draw Grid Y
                ##################################################
+               glColor3f(*GRID_LINE_COLOR_SPEC)
                for tick in self._get_ticks(self.y_min, self.y_max, 
self.y_step, self.y_scalar):
                        scaled_tick = 
(self.height-self.padding_top-self.padding_bottom)*\
                                (1 - 
(tick/self.y_scalar-self.y_min)/(self.y_max-self.y_min)) + self.padding_top
                        glColor3f(*GRID_LINE_COLOR_SPEC)
-                       self._draw_line(
-                               (self.padding_left, scaled_tick, 0),
-                               (self.width-self.padding_right, scaled_tick, 0),
+                       self._draw_dashed_line(
+                               (self.padding_left, scaled_tick),
+                               (self.width-self.padding_right, scaled_tick),
                        )
                        txt = self._get_tick_label(tick)
                        w, h = txt.get_size()
                        
txt.draw_text(wx.Point(self.padding_left-w-TICK_LABEL_PADDING, scaled_tick-h/2))
                ##################################################
+               # Draw Border
+               ##################################################
+               glColor3f(*GRID_BORDER_COLOR_SPEC)
+               self._draw_rect(
+                       self.padding_left,
+                       self.padding_top,
+                       self.width - self.padding_right - self.padding_left,
+                       self.height - self.padding_top - self.padding_bottom,
+                       fill=False,
+               )
+               ##################################################
                # Draw Title
                ##################################################
                #draw x units
@@ -336,16 +339,19 @@
                stop = int(math.floor(max/step))
                return [i*step*scalar for i in range(start, stop+1)]
 
-       def _draw_line(self, coor1, coor2):
+       def _draw_dashed_line(self, coor1, coor2):
                """
-               Draw a line from coor1 to coor2.
-               @param corr1 a tuple of x, y, z
-               @param corr2 a tuple of x, y, z
+               Draw a dashed line from coor1 to coor2.
+               @param corr1 a tuple of x, y
+               @param corr2 a tuple of x, y
                """
+               glEnable(GL_LINE_STIPPLE)
+               glLineStipple(1, int("1110" + "0000" + "1110" + "0000", 2))
                glBegin(GL_LINES)
-               glVertex3f(*coor1)
-               glVertex3f(*coor2)
+               glVertex2f(*coor1)
+               glVertex2f(*coor2)
                glEnd()
+               glDisable(GL_LINE_STIPPLE)
 
        def _draw_rect(self, x, y, width, height, fill=True):
                """

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py 
    2009-02-26 04:44:02 UTC (rev 10524)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py 
    2009-02-26 06:25:55 UTC (rev 10525)
@@ -128,7 +128,7 @@
                hbox.Add(wx.StaticText(self, -1, ' T Offset '), 1, 
wx.ALIGN_CENTER_VERTICAL)
                #t axis control
                t_off_slider = wx.Slider(self, size=SIZE, 
style=wx.SL_HORIZONTAL)
-               t_off_slider.SetRange(0, SIZE[0])
+               t_off_slider.SetRange(0, 1000)
                def t_off_slider_changed(evt): parent[T_FRAC_OFF_KEY] = 
float(t_off_slider.GetValue())/t_off_slider.GetMax()
                t_off_slider.Bind(wx.EVT_SLIDER, t_off_slider_changed)
                parent.subscribe(T_FRAC_OFF_KEY, lambda x: 
t_off_slider.SetValue(int(round(x*t_off_slider.GetMax()))))
@@ -356,7 +356,7 @@
                self[SCOPE_TRIGGER_CHANNEL_KEY] = 0
                self[SCOPE_TRIGGER_MODE_KEY] = gr.gr_TRIG_MODE_AUTO
                self[SCOPE_TRIGGER_SLOPE_KEY] = gr.gr_TRIG_SLOPE_POS
-               self[T_FRAC_OFF_KEY] = 0
+               self[T_FRAC_OFF_KEY] = 0.5
                #register events for trigger
                for key in (
                        SCOPE_TRIGGER_LEVEL_KEY, SCOPE_TRIGGER_MODE_KEY,
@@ -410,6 +410,7 @@
                """
                Redraw the trigger line with current settings.
                """
+               if not self.sampleses: return
                #keep trigger level within range
                if self[SCOPE_TRIGGER_LEVEL_KEY] > self.get_y_max():
                        self[SCOPE_TRIGGER_LEVEL_KEY] = self.get_y_max()
@@ -422,11 +423,12 @@
                        self.plotter.clear_waveform(channel='Trig')
                else: #show trigger channel
                        trigger_level = self[SCOPE_TRIGGER_LEVEL_KEY]
+                       trigger_point = 
(len(self.sampleses[0])-1)/self.get_actual_rate()/2.0
                        self.plotter.set_waveform(
                                channel='Trig',
                                samples=(
-                                       [self.get_t_min(), self.get_t_max()],
-                                       [trigger_level, trigger_level]
+                                       [self.get_t_min(), trigger_point, 
trigger_point, trigger_point, trigger_point, self.get_t_max()],
+                                       [trigger_level, trigger_level, 
self.get_y_max(), self.get_y_min(), trigger_level, trigger_level]
                                ),
                                color_spec=TRIGGER_COLOR_SPEC,
                        )
@@ -483,7 +485,7 @@
                                if y_off != self[Y_OFF_KEY]: self[Y_OFF_KEY] = 
y_off; return
                                self.autorange_ts = time.time()
                        #number of samples to scale to the screen
-                       actual_rate = self[SAMPLE_RATE_KEY]/self[DECIMATION_KEY]
+                       actual_rate = self.get_actual_rate()
                        time_span = self[T_PER_DIV_KEY]*self[T_DIVS_KEY]
                        num_samps = int(round(time_span*actual_rate))
                        #handle the time offset
@@ -513,6 +515,7 @@
                #update the plotter
                self.plotter.update()
 
+       def get_actual_rate(self): return 
1.0*self[SAMPLE_RATE_KEY]/self[DECIMATION_KEY]
        def get_t_min(self): return self[T_OFF_KEY]
        def get_t_max(self): return self[T_PER_DIV_KEY]*self[T_DIVS_KEY] + 
self[T_OFF_KEY]
        def get_x_min(self): return -1*self[X_PER_DIV_KEY]*self[X_DIVS_KEY]/2.0 
+ self[X_OFF_KEY]





reply via email to

[Prev in Thread] Current Thread [Next in Thread]