[Qgis-developer] qgis pre-refresh rendering ?

Sandro Santilli strk at keybit.net
Sat Dec 13 08:40:10 PST 2014

On Sat, Dec 13, 2014 at 10:40:44PM +0700, Martin Dobias wrote:

> The Qt framework uses pos() and boundingRect() to understand where the
> items are located in the scene (QGraphicsScene). These are all screen
> coordinates - one can tell from the use of QPointF instead of QgsPoint
> (always used for map / layer coordinates).
> The rect() and setRect() is just our added convenience functionality in
> QgsMapCanvasItem. The idea was that you just use setRect() to specify the
> item's position+size in map coordinates - and the pos() and boundingRect()
> will be set according to that. In addition, calls to updatePosition() from
> map canvas make sure that pos() and boundingRect() are kept in sync with
> changes to the canvas.

The problem with that, as you can see, is that it is assumed that
a single rectangle can fully express a map configuration, but that's
only true when there's no rotation.

This lack of information makes it impossible for updatePosition to
keep a rotated map position/size in sync with canvas changes.

> Some canvas items use that functionality (e.g. QgsRubberBand or
> QgsMapCanvasMap) and don't worry about the screen coordinates. For some
> items this default behavior is not useful, so they do not use setRect() and
> provide their own implementation of updatePosition() and boundingRect().
> For example QgsVertexMarker, which is centered on a map coordinate, but its
> bounding box is independent from map coordinates / scale.

Maybe the object passed via setRect (via QgsMapCanvasMap::setContent)
could possibly be syntetized as a rectangle having the map coordinate
corresponding to device position (0,0) as its upper-left corner and
width and height being the output device width and height scaled by the
current map resolution.  But we'd still be in the "workaround" side.


 ()  ASCII ribbon campaign  --  Keep it simple !
 /\  http://strk.keybit.net/rants/ascii_mails.txt  

More information about the Qgis-developer mailing list