After thinking and looking at the code a little, I definitely didn&#39;t explain that very well...<br><br>As you know, what you see in the main editing canvas is not always what you get in the composer.&nbsp; Likewise,what you see when using the cache preview in the composer is not what you get when you render.<br>


<br>The root of the problem is that QGIS does all of its drawing in canvas units, so when you switch canvases, you change how things look.&nbsp; The map composer uses millimeters - one QGraphicsScene unit is one mm.&nbsp; <br>Printers and PDF output both work with millimeters this way.&nbsp; If I make
a QGraphicsRectItem with a size of 10mm square, it will come out 10mm
square.&nbsp; If the pen width is 1 scene unit (and isn&#39;t scaled), it will come out 1 mm wide.<br>

<br>Note that when the composer map cache pixmap is drawn, the sizes are all in pixels again.&nbsp; Thus, as the resolution of the cache image changes, the line widths and symbol sizes all change.&nbsp; This has caused a lot of confusion, because although the rendered preview matches the rendered output, the cached preview does not.<br>
<br>I&#39;m not completely clear on what the DPI setting in the composer actually does when doing a vector output such as SVG or Postscript.&nbsp; Changing that setting doesn&#39;t seem to affect them, but the vector output code does reference it.&nbsp; I think the SVG generator needs to know something about the size/dpi so that rasterizers/renderers can render them properly.<br>
<br>What I did in the composer redesign branch was add an enum, mScaleType, which tells the renderer what units the size is in.&nbsp; The renderer sets a size scale, which is dependent on the scale type, size, and current mupp (map units per pixel).&nbsp; Also, rather than setting a pointer to a pixmap, it sets a pointer to a symbol renderer which will always render the symbol with a size of 1.&nbsp; QgsVectorLayer&#39;s drawFeature( ) method scales the painter by the size scale and calls the symbolRenderer&#39;s render( ) method.<br>
<br>Since this appears to be much slower than the current code, we probably need to do some context-dependent caching.<br><br>In the rendering context, we would need to include some information about whether we were rendering in screen units or paper units.&nbsp; Perhaps more correctly, we would like to know the output DPI, which will be one (system-dependent) thing for the editing canvas, 25.4 for the composer canvas, and some variable for the composer map cache.&nbsp; Because of the way the physical output is handled, I don&#39;t think we need to know or care what the printer&#39;s DPI is.<br>
<br>This should enable the removal of the symbol/line width/text scale options in the composer.&nbsp; This also allows us to use the QgsMapRender class to render the map, rather than having a bunch of almost-duplicate code.&nbsp; The code currently in composer_redesign uses QgsMapRender, but I haven&#39;t taken the time to remove the scale boxes in the map control pane.<br>
<br>Let me know if this still isn&#39;t clear.&nbsp; I haven&#39;t completely sorted it all out, either. :-)<br><br>Steven<br><br><br><div class="gmail_quote">On Wed, Mar 5, 2008 at 4:09 AM, Marco Hugentobler &lt;<a href="mailto:marco.hugentobler@karto.baug.ethz.ch" target="_blank">marco.hugentobler@karto.baug.ethz.ch</a>&gt; wrote:<br>


<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Steven,<br>
<div><br>
&gt; I would remove symbolScale and widthScale in favor of defining the widths<br>
&gt; in terms of concrete units, whether pixels, millimeters, or map units.<br>
<br>
</div>It would be good for me if you could explain this idea in more detail as I&#39;m<br>
still not sure my understanding is correct.<br>
<br>
Do you mean that QgsSymbol should have its own pen width and stroke width?<br>
They would be specified e.g. in mm instead of pixels and when the symbol is<br>
applied, transformed to pixels according to the ouput device dpi?<br>
<br>
<br>
The idea that i had was to just work on pixel level with one scalefactor<br>
(mResolutionRatio). So if e.g. a printer has a resolution of screen dpi * 2,<br>
then mResolutionRatio would be 2 and all the width values for QPen, QBrush<br>
and also width/height for images would be scaled by factor 2. Caching pixmaps<br>
would only be alloud if mResolutionRatio is 1.<br>
<br>
I think that would be doable without many code changes. But it is not as<br>
generic and clean as working with real units (e.g. mm) in the qgis core.<br>
<br>
Regards,<br>
Marco<br>
<br>
<br>
<br>
<br>
Am Dienstag 04 März 2008 17:26:08 schrieb Steven Bell:<br>
<div><div></div><div>&gt; &gt; So my suggestion is to have the rendering context somehow like this:<br>
&gt; &gt;<br>
&gt; &gt; class QgsMapRenderContext<br>
&gt; &gt; {<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;QgsMapToPixel mMapToPixel;<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;QgsCoordinateTransform mCoordTransform;<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;QgsRect mExtent;<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;bool drawEditingInformation;<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;bool mRenderingStopped;<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;double mResolutionRatio;<br>
&gt; &gt; };<br>
&gt; &gt;<br>
&gt; &gt; The resolution ratio is usually 1, except when drawing to a different<br>
&gt; &gt; paint<br>
&gt; &gt; device (like QPrinter). I hope it will allow to consider for different<br>
&gt; &gt; line<br>
&gt; &gt; width / symbol sizes on these output devices.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;From what I understand, QgsMapToPixel basically holds the information that<br>
&gt;<br>
&gt; mResolutionRatio would contain.<br>
&gt;<br>
&gt; Martin already mentioned this, but the rendering context needs to have some<br>
&gt; way to tell the renderer whether to use maximum-resolution vector ouput or<br>
&gt; cached pixmaps. &nbsp;I would also add something about what the output units<br>
&gt; are, whether pixels or millimeters. &nbsp;Both of the above might be done<br>
&gt; together with an &quot;are we printing to ps/pdf/svg&quot; bool.<br>
&gt;<br>
&gt; I would remove symbolScale and widthScale in favor of defining the widths<br>
&gt; in terms of concrete units, whether pixels, millimeters, or map units.<br>
&gt; This is what I have attempted to do in the current composer_redesign code.<br>
&gt; One of the major problems is that printed millimeters are treated as the<br>
&gt; same as screen pixels, rather than a separate but similar type of<br>
&gt; measurement.<br>
&gt;<br>
&gt; I hope this makes sense. &nbsp;Let me know if I need to clarify anything.<br>
&gt; Steven<br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Dr. Marco Hugentobler<br>
Institute of Cartography<br>
ETH Zurich<br>
Technical Advisor QGIS Project Steering Committee<br>
</font></blockquote></div><br>