plotting directly using the renderer

Hello everyone,
Hello John,

I'm thinking about this fastplot-routine for a while now. Before hacking all
the I wanted to ask you about your thoughts. Just to repeate a

I changed the previously sent (I'll call it 'plot_points()' from
now on) a bit: Now it is possible to draw multiple markers with one call.
But all at all it looks like the version sent before.

What you John asked for, was a unification with Taking for example
triangle_down in one can read:

  def _draw_triangle_down(self, renderer, gc, xt, yt):
      offset = 0.5*renderer.points_to_pixels(self._markersize)
      rgbFace = self._get_rgb_face()
      if self._newstyle:
          path = agg.path_storage()
          path.move_to(-offset, offset)
          path.line_to(offset, offset)
          path.line_to(0, -offset)
          renderer.draw_markers(gc, path, rgbFace, xt, yt, self._transform)
          for (x,y) in zip(xt, yt):
              verts = ( (x-offset, y+offset),
                        (x+offset, y+offset),
                        (x, y-offset))
              renderer.draw_polygon(gc, rgbFace, verts)

I would like to ask you (right before I'll mess everything up :wink: if all this
at least could work:
What I would try for unification is writing the dictionary 'markerd' in (I'd prefer it right in front of 'class Line2D' as global - but
there it isn't readable for a program later, isn't it?) and change the
functions a bit like:
    def _make_triangle_down(size):
        return reshape([[0, -size, size],
                        [1, size, size],
                        [1, 0, -size]], (3,3))
    def _make_x(size):
        return reshape([[0, -size, -size],
                        [1, size, size],
                        [0, 0, 0],
                        [1, size, -size],
                        [1, -size, size],
                        [0, 0, 0]], (6,3))
and so on ...

Then I would try to let the newstyle & oldstyle ploting-method use those
functions by writing a (for all markers usable) function:

def _draw_marker(self, marker, renderer, gc, xt, yt):
    func = markerd[marker]
    verts = func(1.0*renderer.points_to_pixels(int(msize)))
    rgbFace = self._get_rgb_face()
    if self._newstyle:
        path = agg.path_storage()
        for v in verts.tolist():
            if v[0]:
                path.line_to(v[1], v[2])
            if else:
                path.move_to(v[1], v[2])
        renderer.draw_markers(gc, path, rgbFace, xt, yt, self._transform)
        for (x,y) in zip(xt, yt):
            vertices = []
            for v in verts:
                vertices.append((x+v[1], y+v[2]))
            renderer.draw_polygon(gc, rgbFace, tuple(vertices))
           # notice: some markers are partially drawn double (e.g x)

Then the plot_points-routine would contain a differing line:
  verts = func(1.0*renderer.points_to_pixels(int(msize)))[:,1:3]

All this I already tried a bit but somehow failed (I quess mainly due to
variables not beeing defined). A way out of this would be knitting those
functions into the class Line2D (it would be pretty easy to define
everything there). But than I could have used Line2D from the beginning,
couldn't I? So - to cut the long story short - where would you (if ever) add
those new lines to the code?
Another question would be: Are those new for-loops in _draw_marker() too
annoying (in the sense of speed)? (I quess they are vital for the
_make_triangle_down()-like functions to keep their simple form so that they
can be used by plot and plot_points together.)

Best regards,


Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen f�r GMX Partner: