point label transpareny, horizontal offset, and toggle on/off capability
authorJosh Blum <josh@joshknows.com>
Fri, 9 Oct 2009 03:12:34 +0000 (20:12 -0700)
committerJosh Blum <josh@joshknows.com>
Fri, 9 Oct 2009 03:12:34 +0000 (20:12 -0700)
gr-wxgui/src/python/plotter/common.py
gr-wxgui/src/python/plotter/grid_plotter_base.py

index 7699986aad1e65d61c8637980d323c8702771bc9..4c50cd7872e1750cf61180eb651dd1661e02d85e 100644 (file)
@@ -102,6 +102,7 @@ class point_label_thread(threading.Thread, mutex):
                #bind plotter mouse events
                self._plotter.Bind(wx.EVT_MOTION, lambda evt: self.enqueue(evt.GetPosition()))
                self._plotter.Bind(wx.EVT_LEAVE_WINDOW, lambda evt: self.enqueue(None))
+               self._plotter.Bind(wx.EVT_RIGHT_DOWN, lambda evt: plotter.enable_point_label(not plotter.enable_point_label()))
                #start the thread
                threading.Thread.__init__(self)
                self.start()
index 39bed181111140abb52b9ca01ddfd134cacc8726..a9bd02731479ac3be8780eb8631a3792a7316772 100644 (file)
@@ -36,8 +36,9 @@ AXIS_LABEL_PADDING = 5
 TICK_LABEL_PADDING = 5
 TITLE_LABEL_PADDING = 7
 POINT_LABEL_FONT_SIZE = 8
-POINT_LABEL_COLOR_SPEC = (1, 1, .5)
+POINT_LABEL_COLOR_SPEC = (1, 1, 0.5, 0.75)
 POINT_LABEL_PADDING = 3
+POINT_LABEL_OFFSET = 10
 GRID_LINE_DASH_LEN = 4
 
 ##################################################
@@ -395,8 +396,12 @@ class grid_plotter_base(plotter_base):
                if not label_str: return
                txt = gltext.Text(label_str, font_size=POINT_LABEL_FONT_SIZE)
                w, h = txt.get_size()
+               #enable transparency
+               GL.glEnable(GL.GL_BLEND)
+               GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
                #draw rect + text
-               GL.glColor3f(*POINT_LABEL_COLOR_SPEC)
-               if x > self.width/2: x -= w+2*POINT_LABEL_PADDING
+               GL.glColor4f(*POINT_LABEL_COLOR_SPEC)
+               if x > self.width/2: x -= w+2*POINT_LABEL_PADDING + POINT_LABEL_OFFSET
+               else: x += POINT_LABEL_OFFSET
                self._draw_rect(x, y-h-2*POINT_LABEL_PADDING, w+2*POINT_LABEL_PADDING, h+2*POINT_LABEL_PADDING)
                txt.draw_text(wx.Point(x+POINT_LABEL_PADDING, y-h-POINT_LABEL_PADDING))