[Qgis-developer] Qpainter.rotate() question - qgis

Martin Dobias wonder.sk at gmail.com
Mon May 11 18:22:07 EDT 2009


Hi,

from your mail it's not clear what are you actually doing. Are you
developing a custom map canvas item? Or are you doing some post-render
drawing to the rendered map image?

And how does the position of the line change when trying to rotate it?
If you're using rotation of painter, the rotation is done with center
at point [0,0] so that might be the reason why it changes position.

Martin

On Sat, May 9, 2009 at 7:29 PM, ashjas <ashjas at gmail.com> wrote:
> Hi,
>
> I am customising QuantumGIS that uses Qt's Qpainter to draw and paint...
>
> I am trying to draw a polyline on the canvas that is coming as a update
> through message queues..the draw is very fine...but in the polyline or
> polygon objects that i get as an update also include an angle field that is
> to be used for rotation of an object. The problem is that when i try to
> rotate the line just before the polyline is drawn by the qpainter using
> painter.rotate() method,the line is rotated fine but the position of the
> line drawn changes..and it changes at every zoom and pan of the Qgis
> canvas.. Before setting painter.rotate() i am saving the painter state and
> after drawing- again restoring its state which i believe is analogous to
> OpenGL's push/popMatrix functions. Does the Qpainter's save restore
> functions work similar to push/popMatrix functions of opengl??
>
> Any Ideas how rotation can be achieved??
>
> here is a code snippet:
>
> p->save();
>
>   //p->rotate(45);
>
>   p->scale( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor );
>
>   p->drawPolyline( pa );
>
>   p->restore();
>
> Help is appreciated. Thanks.
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>


More information about the Qgis-developer mailing list