[Qgis-developer] Fwd: QGIS Multi-threaded Rendering

Martin Dobias wonder.sk at gmail.com
Thu Feb 27 00:51:51 PST 2014


Hi Nyall

(cc-ing back to qgis-dev)

On Thu, Feb 27, 2014 at 1:29 PM, Nyall Dawson <nyall.dawson at gmail.com> wrote:
>
> On 12/12/2013 10:14 pm, "Martin Dobias" <wonder.sk at gmail.com> wrote:
>
>>
>> - update to scale factors. I have always found the "scale" and "raster
>> scale" factors from QgsRenderContext confusing and did not properly
>> understand their real meaning because in various contexts (composer vs
>> canvas) they had different meaning and value. There were also various
>> rendering bugs due to wrong or no usage of these factors. By scaling
>> of painter before rendering and setup of correct DPI, these factors
>> are now always equal to one. In the future, we will be able to remove
>> them altogether.
>>
>
> Hi Martin,
>
> I'm just trying to understand this change a bit more. Am I to understand
> that QgsRenderContext::setScale and setRasterScaleFactor now have no effect?

Uh, sorry, I got it a bit wrong, let me put it correct it what are the
main rules now when rendering map:

1. QPainer's coordinate system is always in paint device's raw pixels.
That means, in canvas a line with width 1 will be one pixel wide, in
composer it will be one dot wide. (In 2.2 the coordinate system would
be either in pixels or milimeters)

2. the "raster scale factor" is always equal to one - and thus does
not need to be used anymore because it will not make any difference
(in 2.2 it has to be used for proper scaling, especiall in composer
output)

3. the "scale factor" is always equal to number of device's raw pixels
per millimeter. To draw a line with width 2 mm you would use "2 *
scaleFactor". (In 2.2 the scale factor did not have a clear physical
meaning

4. there is just one true DPI - painter's DPI is equal to map settings
DPI (In 2.2 these are DPIs are not always the same - especially not in
composer output)

5. there is no forced scale in composer anymore - the scale calculator
is set up properly (In 2.2 the map scale is forced by composer as the
scale was calculated from different values)


> If so, I'm hoping this change will make issues like #8210 easier to solve.
> Currently QgsComposerMap::drawGridLine uses setScale and
> setRasterScaleFactor before drawing the grid lines, and obviously this is
> broken in some way.
>
> Is the code in qgscomposermap.cpp lines 382 & 384 the correct way to
> approach this scaling now?

If you intend to do drawing with symbols, then yes, it makes sense to
scale the painter from millimeters to dots and then setup the raster
scale factor (=1) and scale factor (=DPI/25.4) as noted above and
things should just work..

Let me know if you have any problems.

Regards
Martin


More information about the Qgis-developer mailing list