[Qgis-developer] Rotation status and PSC meeting

Mathieu Pellerin nirvn.asia at gmail.com
Thu Jan 15 21:48:53 PST 2015


Sandro, Nyall,

Discussing this with Martin earlier today, he came up with a test patch to
see what would happen if the code was "blindly" modified to use
QgsMapSettings' setRotation() function. The result is interesting, it
actually _mostly_ works (see attached patch):
- before the patch, rotating the map composer of 45 degrees looked like
this: http://i.imgur.com/8e88VZf.png
- applying the patch, rotating the map composer of 45 degrees now looks
like this: http://i.imgur.com/VudbYrn.png

The map rotation without the patch shows the current limitations, namely
undesired rotated label, undesired rotated symbology, etc.

With the patch applied, the label is horizontal, and my centroid triangle
symbology's orientation is respected. There is however an issue with the
calculation of the rotated map extend leading to a slightly misplaced map
overview polygon on the larger map as well as a slight misalignment of the
grid.

Regarding the map overview issue, this got me to think that instead of
having a map visibility extend calculation code in the composer map item,
the QgsMapSettings object should have a function that returns a visible
extend polygon (in WKT string, or whatever). That would simplify and
bulletproof the code in many places beyond the composer map item.

Food for thoughts.

Math

On Fri, Jan 16, 2015 at 9:00 AM, Mathieu Pellerin <nirvn.asia at gmail.com>
wrote:

> Sandro,
>
> The last few weeks has been a nice leap forward when it comes to your
> rotation feature, congratulation on that.
>
> IMO, based on the improvements, it's worth considering _removing the
> activation option altogether_ from the preference window. I can't see
> any stability and usability issue that would warrant disabling it.
>
> That said, in my view, a basic composer support (i.e. map item's
> rotation feature) should be moved at the top of your priority list.
> Right now, the benefits of your rotation work _cannot_ be exported
> outside of the QGIS canvas, which IMO is a serious limitation. In most
> of my QGIS workflows, the final cartographic products are exported
> through the composer to obtain an high resolution file that can be
> printed out (i.e. I can't just go save the canvas as an image :) ).
> Not having map items make use of your rotation feature is a
> significant restriction.
>
> Cheers, and thanks again for the work,
>
> Math
>
>
> On Thu, Jan 15, 2015 at 9:59 PM, Sandro Santilli <strk at keybit.net> wrote:
> > I've spent more time on rotation (only partially funded), fixing:
> >
> >  - Label pre-rotation (#11814)
> >  - North Arrow Decoration (#11818)
> >  - Grid decoration (#11817)
> >
> > Leftover issues (open for funding):
> >
> >  - Plugin layers (#11900) -- needs feedback
> >  - Overview map (#11862) -- minor, IMHO
> >  - Composer support (#11912) -- wish ?
> >  - Atlas doesn't consider map rotation when setting scale (#11954)
> >
> > Please report any other issue that might arise with rotation enabled
> > and properly tag it with the "rotation" label.
> >
> > I'd like to partecipate to the PSC meeting tomorrow but it is only
> > possible for me before 18:00 CET. I hadn't found the schedule here:
> > http://hub.qgis.org/wiki/17/PSC_Meeting_16_January_2015
> > At what time do you plan to meet ?
> >
> > --strk;
> >
> >   ()   Free GIS & Flash consultant/developer
> >   /\   http://strk.keybit.net/services.html
> > _______________________________________________
> > Qgis-developer mailing list
> > Qgis-developer at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150116/aa3eb215/attachment.html>
-------------- next part --------------
diff --git a/src/core/composer/qgscomposermap.cpp b/src/core/composer/qgscomposermap.cpp
index 3f0a29f..a811a02 100644
--- a/src/core/composer/qgscomposermap.cpp
+++ b/src/core/composer/qgscomposermap.cpp
@@ -202,6 +202,7 @@ QgsMapSettings QgsComposerMap::mapSettings( const QgsRectangle& extent, const QS
   jobMapSettings.setMapUnits( ms.mapUnits() );
   jobMapSettings.setBackgroundColor( Qt::transparent );
   jobMapSettings.setOutputImageFormat( ms.outputImageFormat() );
+  jobMapSettings.setRotation( mEvaluatedMapRotation );
 
   //set layers to render
   QStringList theLayerSet = layersToRender();
@@ -362,9 +363,9 @@ void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* i
     painter->save();
 
     painter->translate( mXOffset, mYOffset );
-    painter->translate( xTopLeftShift, yTopLeftShift );
-    painter->rotate( mEvaluatedMapRotation );
-    painter->translate( xShiftMM, -yShiftMM );
+    //painter->translate( xTopLeftShift, yTopLeftShift );
+    //painter->rotate( mEvaluatedMapRotation );
+    //painter->translate( xShiftMM, -yShiftMM );
     painter->scale( scale, scale );
     painter->drawImage( 0, 0, mCacheImage );
 
@@ -413,9 +414,9 @@ void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* i
     double yTopLeftShift = ( cExtent.yMaximum() - rotationPoint.y() ) * mapUnitsToMM();
     painter->save();
     painter->translate( mXOffset, mYOffset );
-    painter->translate( xTopLeftShift, yTopLeftShift );
-    painter->rotate( mEvaluatedMapRotation );
-    painter->translate( xShiftMM, -yShiftMM );
+    //painter->translate( xTopLeftShift, yTopLeftShift );
+    //painter->rotate( mEvaluatedMapRotation );
+    //painter->translate( xShiftMM, -yShiftMM );
 
     double dotsPerMM = thePaintDevice->logicalDpiX() / 25.4;
     theSize *= dotsPerMM; // output size will be in dots (pixels)


More information about the Qgis-developer mailing list