[QGIS Commit] r13419 - trunk/qgis/src/core/symbology-ng

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue May 4 04:51:43 EDT 2010


Author: wonder
Date: 2010-05-04 04:51:43 -0400 (Tue, 04 May 2010)
New Revision: 13419

Modified:
   trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
   trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.h
Log:
SimpleMarker symbol layer: do not cache marker symbol if the vector output is enforced, fixed scaling


Modified: trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp	2010-05-04 08:48:43 UTC (rev 13418)
+++ trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp	2010-05-04 08:51:43 UTC (rev 13419)
@@ -77,6 +77,11 @@
   bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation;
   bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale;
 
+  // use caching only when:
+  // - the size and rotation is not data-defined
+  // - drawing to screen (not printer)
+  mUsingCache = !hasDataDefinedRotation && !hasDataDefinedSize && !context.renderContext().forceVectorOutput();
+
   // use either QPolygonF or QPainterPath for drawing
   // TODO: find out whether drawing directly doesn't bring overhead - if not, use it for all shapes
   if ( !prepareShape() ) // drawing as a polygon
@@ -101,7 +106,9 @@
   // scale the shape (if the size is not going to be modified)
   if ( !hasDataDefinedSize )
   {
-    double scaledSize = context.outputPixelSize( mSize );
+    double scaledSize = context.outputLineWidth( mSize );
+    if ( mUsingCache )
+      scaledSize *= context.renderContext().rasterScaleFactor();
     double half = scaledSize / 2.0;
     transform.scale( half, half );
   }
@@ -117,10 +124,8 @@
   else
     mPath = transform.map( mPath );
 
-  if ( !hasDataDefinedRotation && !hasDataDefinedSize )
+  if ( mUsingCache )
   {
-    // we can use the cached marker
-    // TODO: use caching only when drawing to screen (not printer)
     prepareCache( context );
   }
   else
@@ -324,10 +329,7 @@
     return;
   }
 
-  bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation;
-  bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale;
-
-  if ( !hasDataDefinedRotation && !hasDataDefinedSize )
+  if ( mUsingCache )
   {
     // we will use cached image
     QImage &img = context.selected() ? mSelCache : mCache;
@@ -340,6 +342,9 @@
   {
     QMatrix transform;
 
+    bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation;
+    bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale;
+
     // move to the desired position
     transform.translate( point.x() + context.outputLineWidth( mOffset.x() ),
                          point.y() + context.outputLineWidth( mOffset.y() ) );
@@ -347,7 +352,7 @@
     // resize if necessary
     if ( hasDataDefinedSize )
     {
-      double scaledSize = context.outputPixelSize( mSize );
+      double scaledSize = context.outputLineWidth( mSize );
       double half = scaledSize / 2.0;
       transform.scale( half, half );
     }
@@ -655,9 +660,8 @@
 
 void QgsFontMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
 {
-  double pixelSize = context.outputPixelSize( mSize );
   mFont = QFont( mFontFamily );
-  mFont.setPixelSize( pixelSize / context.renderContext().rasterScaleFactor() );
+  mFont.setPixelSize( context.outputLineWidth( mSize ) );
   QFontMetrics fm( mFont );
   mChrOffset = QPointF( fm.width( mChr ) / 2, -fm.ascent() / 2 );
 

Modified: trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.h	2010-05-04 08:48:43 UTC (rev 13418)
+++ trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.h	2010-05-04 08:51:43 UTC (rev 13419)
@@ -68,6 +68,7 @@
     QPen mSelPen;
     QBrush mSelBrush;
     QImage mSelCache;
+    bool mUsingCache;
 };
 
 //////////



More information about the QGIS-commit mailing list