0

I create a widget that plots data and allows users a selections:
https://gobblin.se/u/kellogs/m/bildschirmfoto-vom-2013-11-12-13-23-54/

Sadly, in this screenshot should appear multiple selections (here red), but rendering n of this models doesn't work for some reason. I made sure, that the data is available and the rendering is called and works fine (right position and dimensions)

So my widget just creates a cairo surface that is used in a iteration of the following method to render the selections on top of the plotted data line:

def render_to(self, cairosurface):
    '''external trigger to redraw widget on channel widget surface (only within plotarea!)'''
    cr = cairosurface
    pos_x=self.__getXPos()
    w = self.__getWidth()
    h = self.__getHeight()
    eogclass=self.eogclassification.eogclass
    #background
    r,g,b=eogclass.color
    alpha=0.9
    color=(r,g,b,alpha)
    cr.set_source_rgba(*color)
    cr.rectangle(pos_x, 0, w, h)
    cr.fill()
    #label
    label=eogclass.name
    cr.set_source_rgb(*eogclass.text_color)
    cr.set_font_size(13)
    (x, y, width, height, dx, dy) = cr.text_extents(label)
    cr.move_to(pos_x+w/2 - width/2, h/2) #center within our block
    cr.text_path(label)
    cr.clip()
    cr.stroke()
    cr.paint()

Can anybody give me a tip what might be the problem? I'm not sure, but can this be a problem with compositing?

MaM
  • 2,043
  • 10
  • 20
  • Uhm, this function draws some text on some background (and seems to erase the whole background?). That doesn't really match anything that I see in the screenshot. Also, you have a clip() call that isn't undone and thus more drawing in the future will still be clipped by this path. – Uli Schlachter Nov 23 '13 at 10:13
  • I don't know exactly why, but I can't remove the clip() as otherwise everything gets just grey. A workaround is to encapsulate this stufff with cr.save() and cr.restore(). Anyway thank you :) – MaM Nov 23 '13 at 12:57
  • I can tell you why. Instead of clip() stroke() paint(), I think you want to stroke_preserve(), fill() instead (although the results would be slightly different than before, because stroke() draws on both sides of the path, with the clip half of that got clipped away). – Uli Schlachter Nov 23 '13 at 16:52

0 Answers0