[Qgis-developer] qgis pre-refresh rendering ?

Sandro Santilli strk at keybit.net
Sat Dec 13 06:15:50 PST 2014


On Sat, Dec 13, 2014 at 08:42:40PM +0700, Martin Dobias wrote:
> On Sat, Dec 13, 2014 at 8:17 PM, Sandro Santilli <strk at keybit.net> wrote:
> 
> > I see how it is modified when map rendering has finished
> > [ by QgsMapCanvas::rendererJobFinished() ]
> > but what modifies it for the temporary result seems to be
> > QgsMapCanvas::updateCanvasItemPositions which is called
> > by QgsMapCanvas::setExtent. So the QgsMapCanvasMap extent
> > is also modified due to that call, isn't it ?
> >
> > Debugging prints tell me indeed that the "boundingRect"
> > of QgsMapCanvasItem grows as I zoom in (with rendering turned off)
> > and shrinks as I zoom out.
> 
> The extent of canvas items (in map units) stays the same, just the position
> and bounding rect (both in screen coordinates) change accordingly when
> zooming/panning.

What's exactly the "bounding rect" ? How's it different from rect" ?
Documentation doesn't say:
http://qgis.org/api/classQgsMapCanvasItem.html#a8be640ba5958ed63df3a17a9c9b9792a
http://qgis.org/api/classQgsMapCanvasItem.html#ad0cd631ace28e2feb63166d28b704364

>From QT documentation I understand "bounding rect" is the outer bounds
of the item: http://qt-project.org/doc/qt-4.8/qgraphicsitem.html#boundingRect

>From QGIS code I see that the parameter passed to setRect() is in
map units and is used to set a mItemSize member which is then used to
compute the output from boundingRect(), thus effectively "setRect()"
involves changing the "bounding rect" too. But "rect()" returns a
different value than "boundingRect".

I'm confused. Probably due to the lack of documentation about what
"setRect" is expected to be called with.
Docs only say "sets canvas item rectangle".
Right now QgsMapCanvas::rendererJobFinished passes it the so-called
"visibleExtent", which is the extent of the visible pointset of the map,
in map (geographical) units.

> > Once rotation enters the picture a simple QgsRectangle is not enough
> > anymore to express what area is shown in the canvas item. That is,
> > the canvas item output rectangle is not a rectangle in map coordinate
> > space. Could the "rect" concept be changed to something different then ?
> > Like a triplet: center,resolution,rotation ?
> 
> I don't think such triplet would work here well - we need to know the exact
> bounds of canvas items (in screen coordinates) so that the underlying Qt
> framework knows when it needs to repaint the individual items.

Only the visible bounds or the full item bounds ?
In other words, are these "bounds" independent of canvas size in pixels ?

> Why should canvas items keep rotation? Lots of canvas items do not care
> about the rotation - and should not care, e.g. a cross marker should always
> have the same appearance regardless of any map rotation.
> 
> It is also worth noting that not all canvas items do need to have the
> position + bounding box calculated automatically from map coordinates. For
> example, annotations only have one point fixed to a map coordinate, the
> rest of the bounding rect is defined in screen coordinates (independent
> from map).

Good point. So then why do we have this function at all:

  void QgsMapCanvasItem::setRect( const QgsRectangle& rect )

Which seems to take the "rect" in map coordinates ?
(according to the internal use of toCanvasCoordinates method)

> > PS: should we discuss this on the mailing lit instead ?
> >
> 
> Yeah why not...
> 
> The map rotation functionality in the end is probably more complex than it
> seemed to be. QEP explaining all the implications would be quite useful.

Indeed, I greatly understimated it.
I'll try to draft a QEP.

--strk;

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


More information about the Qgis-developer mailing list