Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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/qgis@12900 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Feb 8, 2010
1 parent db878e0 commit f6ee8f4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsmaprenderer.h
Expand Up @@ -51,7 +51,7 @@ class QgsLabelingEngineInterface
//! 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
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -898,7 +898,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
if ( rendererContext.labelingEngine() )
{
int attrIndex;
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex ) )
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex, rendererContext ) )
{
if ( !attributes.contains( attrIndex ) )
attributes << attrIndex;
Expand Down Expand Up @@ -958,7 +958,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
if ( rendererContext.labelingEngine() )
{
int attrIndex;
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex ) )
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex, rendererContext ) )
{
if ( !attributes.contains( attrIndex ) )
attributes << attrIndex;
Expand Down
12 changes: 10 additions & 2 deletions src/plugins/labeling/pallabeling.cpp
Expand Up @@ -28,6 +28,7 @@
#include <qgsgeometry.h>
#include <qgsmaprenderer.h>


using namespace pal;


Expand Down Expand Up @@ -296,7 +297,7 @@ bool PalLabeling::willUseLayer( QgsVectorLayer* layer )
}


int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex )
int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx )
{
Q_ASSERT( mMapRenderer != NULL );

Expand Down Expand Up @@ -353,6 +354,10 @@ int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex )
// 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;
Expand Down Expand Up @@ -620,5 +625,8 @@ void PalLabeling::drawLabelBuffer( QPainter* p, QString text, const QFont& font,

QgsLabelingEngineInterface* PalLabeling::clone()
{
return new PalLabeling();
PalLabeling* lbl = new PalLabeling();
lbl->mShowingAllLabels = mShowingAllLabels;
lbl->mShowingCandidates = mShowingCandidates;
return lbl;
}
2 changes: 1 addition & 1 deletion src/plugins/labeling/pallabeling.h
Expand Up @@ -126,7 +126,7 @@ class PalLabeling : public QgsLabelingEngineInterface
//! 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
Expand Down

0 comments on commit f6ee8f4

Please sign in to comment.