[Qgis-developer] Custom raster drawing

Martin Dobias wonder.sk at gmail.com
Tue Jun 12 13:01:16 EDT 2007

On 6/12/07, Barry Rowlingson <b.rowlingson at lancaster.ac.uk> wrote:
>   What I wanted to do was to override the 3-arg method with my new
> drawing code - it just has to paint on a QImage and return. But my
> Python class method got called with 5-args. When I just called the
> parent 5-arg method from my Python method it never called it again with
> 3-args. You can only have one method per name in a Python class, so
> maybe there's some trick with SIP to get this to work. I couldn't. The
> simple solution here would be to rename the 3-arg draw method in the C++
> code, then I could override that and have it called. Let's call this
> solution #1.

Thinking about this once again, this is probably doable. The reason of
this behaviour is that the 5-args method is virtual, while the 3-args
one isn't. My guess is that if you set also the 3-args method virtual
(in both header file and SIP file), you should be able to override it.

But... well, I don't like this hack either.

>   Solution #3 is to rewrite the raster drawing code to use renderers. I
> think this is outside my timeframe though - I'd like to get this done in
> a matter of weeks.

Yeah, this one would be nice. When refactaring, there will be probably
need of two main stages:
1. break raster layer into renderers
2. design a good raster data provider interface and move gdal specific
stuff there

Um, quite a lot of work :-)


More information about the Qgis-developer mailing list