Skip to content

Commit a0fa234

Browse files
author
wonder
committedFeb 8, 2010
Uhm... fixing compilation error, take #2.
Hopefully also with better label size scaling in composer (labeling plugin) git-svn-id: http://svn.osgeo.org/qgis/trunk@12900 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 757c42e commit a0fa234

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed
 

‎src/core/qgsmaprenderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class QgsLabelingEngineInterface
5151
//! called to find out whether the layer is used for labeling
5252
virtual bool willUseLayer( QgsVectorLayer* layer ) = 0;
5353
//! called when starting rendering of a layer
54-
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex ) = 0;
54+
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx ) = 0;
5555
//! called for every feature
5656
virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat ) = 0;
5757
//! called when the map is drawn and labels should be placed

‎src/core/qgsvectorlayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
898898
if ( rendererContext.labelingEngine() )
899899
{
900900
int attrIndex;
901-
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex ) )
901+
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex, rendererContext ) )
902902
{
903903
if ( !attributes.contains( attrIndex ) )
904904
attributes << attrIndex;
@@ -958,7 +958,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
958958
if ( rendererContext.labelingEngine() )
959959
{
960960
int attrIndex;
961-
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex ) )
961+
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex, rendererContext ) )
962962
{
963963
if ( !attributes.contains( attrIndex ) )
964964
attributes << attrIndex;

‎src/plugins/labeling/pallabeling.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <qgsgeometry.h>
2929
#include <qgsmaprenderer.h>
3030

31+
3132
using namespace pal;
3233

3334

@@ -296,7 +297,7 @@ bool PalLabeling::willUseLayer( QgsVectorLayer* layer )
296297
}
297298

298299

299-
int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex )
300+
int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx )
300301
{
301302
Q_ASSERT( mMapRenderer != NULL );
302303

@@ -353,6 +354,10 @@ int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex )
353354
// set whether adjacent lines should be merged
354355
l->setMergeConnectedLines( lyr.mergeLines );
355356

357+
// set font size from points to output size
358+
double size = 0.3527 * lyr.textFont.pointSizeF() * ctx.scaleFactor(); //* ctx.rasterScaleFactor();
359+
lyr.textFont.setPixelSize((int)size);
360+
356361
// save the pal layer to our layer context (with some additional info)
357362
lyr.palLayer = l;
358363
lyr.fieldIndex = fldIndex;
@@ -620,5 +625,8 @@ void PalLabeling::drawLabelBuffer( QPainter* p, QString text, const QFont& font,
620625

621626
QgsLabelingEngineInterface* PalLabeling::clone()
622627
{
623-
return new PalLabeling();
628+
PalLabeling* lbl = new PalLabeling();
629+
lbl->mShowingAllLabels = mShowingAllLabels;
630+
lbl->mShowingCandidates = mShowingCandidates;
631+
return lbl;
624632
}

‎src/plugins/labeling/pallabeling.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class PalLabeling : public QgsLabelingEngineInterface
126126
//! called to find out whether the layer is used for labeling
127127
virtual bool willUseLayer( QgsVectorLayer* layer );
128128
//! hook called when drawing layer before issuing select()
129-
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex );
129+
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx );
130130
//! hook called when drawing for every feature in a layer
131131
virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat );
132132
//! called when the map is drawn and labels should be placed

0 commit comments

Comments
 (0)
Please sign in to comment.