[QGIS Commit] r12900 - in trunk/qgis/src: core plugins/labeling

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Feb 8 06:08:48 EST 2010


Author: wonder
Date: 2010-02-08 06:08:45 -0500 (Mon, 08 Feb 2010)
New Revision: 12900

Modified:
   trunk/qgis/src/core/qgsmaprenderer.h
   trunk/qgis/src/core/qgsvectorlayer.cpp
   trunk/qgis/src/plugins/labeling/pallabeling.cpp
   trunk/qgis/src/plugins/labeling/pallabeling.h
Log:
Uhm... fixing compilation error, take #2.
Hopefully also with better label size scaling in composer (labeling plugin)


Modified: trunk/qgis/src/core/qgsmaprenderer.h
===================================================================
--- trunk/qgis/src/core/qgsmaprenderer.h	2010-02-08 09:33:23 UTC (rev 12899)
+++ trunk/qgis/src/core/qgsmaprenderer.h	2010-02-08 11:08:45 UTC (rev 12900)
@@ -51,7 +51,7 @@
     //! called to find out whether the layer is used for labeling
     virtual bool willUseLayer( QgsVectorLayer* layer ) = 0;
     //! called when starting rendering of a layer
-    virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex ) = 0;
+    virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx ) = 0;
     //! called for every feature
     virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat ) = 0;
     //! called when the map is drawn and labels should be placed

Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp	2010-02-08 09:33:23 UTC (rev 12899)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp	2010-02-08 11:08:45 UTC (rev 12900)
@@ -898,7 +898,7 @@
     if ( rendererContext.labelingEngine() )
     {
       int attrIndex;
-      if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex ) )
+      if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex, rendererContext ) )
       {
         if ( !attributes.contains( attrIndex ) )
           attributes << attrIndex;
@@ -958,7 +958,7 @@
     if ( rendererContext.labelingEngine() )
     {
       int attrIndex;
-      if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex ) )
+      if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex, rendererContext ) )
       {
         if ( !attributes.contains( attrIndex ) )
           attributes << attrIndex;

Modified: trunk/qgis/src/plugins/labeling/pallabeling.cpp
===================================================================
--- trunk/qgis/src/plugins/labeling/pallabeling.cpp	2010-02-08 09:33:23 UTC (rev 12899)
+++ trunk/qgis/src/plugins/labeling/pallabeling.cpp	2010-02-08 11:08:45 UTC (rev 12900)
@@ -28,6 +28,7 @@
 #include <qgsgeometry.h>
 #include <qgsmaprenderer.h>
 
+
 using namespace pal;
 
 
@@ -296,7 +297,7 @@
 }
 
 
-int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex )
+int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx )
 {
   Q_ASSERT( mMapRenderer != NULL );
 
@@ -353,6 +354,10 @@
   // set whether adjacent lines should be merged
   l->setMergeConnectedLines( lyr.mergeLines );
 
+  // set font size from points to output size
+  double size = 0.3527 * lyr.textFont.pointSizeF() * ctx.scaleFactor(); //* ctx.rasterScaleFactor();
+  lyr.textFont.setPixelSize((int)size);
+
   // save the pal layer to our layer context (with some additional info)
   lyr.palLayer = l;
   lyr.fieldIndex = fldIndex;
@@ -620,5 +625,8 @@
 
 QgsLabelingEngineInterface* PalLabeling::clone()
 {
-  return new PalLabeling();
+  PalLabeling* lbl = new PalLabeling();
+  lbl->mShowingAllLabels = mShowingAllLabels;
+  lbl->mShowingCandidates = mShowingCandidates;
+  return lbl;
 }

Modified: trunk/qgis/src/plugins/labeling/pallabeling.h
===================================================================
--- trunk/qgis/src/plugins/labeling/pallabeling.h	2010-02-08 09:33:23 UTC (rev 12899)
+++ trunk/qgis/src/plugins/labeling/pallabeling.h	2010-02-08 11:08:45 UTC (rev 12900)
@@ -126,7 +126,7 @@
     //! called to find out whether the layer is used for labeling
     virtual bool willUseLayer( QgsVectorLayer* layer );
     //! hook called when drawing layer before issuing select()
-    virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex );
+    virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx );
     //! hook called when drawing for every feature in a layer
     virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat );
     //! called when the map is drawn and labels should be placed



More information about the QGIS-commit mailing list