[Qgis-developer] QgsVertexMarker modified class: Plot moving points over a map at fixed rate

Martin Dobias wonder.sk at gmail.com
Thu Jul 2 07:37:21 EDT 2009


On Thu, Jul 2, 2009 at 11:43 AM, Luca Pascale<pascale.luca.it at gmail.com> wrote:
> [...]
>     case ICON_CUSTOM:
>
>       QPixmap pixmap(QSize(22,22));
>       pixmap.load(mFileName);
>       p->drawPixmap(0,0,pixmap);
>       break;

It would be wiser to load the pixmap just once and keep the QPixmap,
it will save some time when doing updates. Additionally, you don't
have to set pixmap's size before the load() method - the pixmap will
be resized to the required size during the load.

> The problem now is that the icon (png file) is not plotted correctly until I
> refresh the map canvas.
> See the attached images.
> notcorrectvisualization.png is what I obtain on the screen
> and
> correctvisualization.png is waht I obtain after pushed the refresh button.
>
> Any suggestion to solve ??

Yes: you have to update boundingRect() function to return correct
rectangle of the marker. Currently for markers it's something like
(-5,-5)..(5,5) while you probably want a bounding rect e.g.
(0,0)..(22,22). But think also where dou you actually want to put the
pixmap - currently you draw it in a way that the position is at the
upper left corner of the pixmap. Maybe you want it to be in the
center...?

Martin


More information about the Qgis-developer mailing list