Skip to content
Permalink
Browse files

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
wonder committed Feb 8, 2010
1 parent db878e0 commit f6ee8f4e09fe339bf4969668b02885560b21a14e
@@ -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
@@ -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;
@@ -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;
@@ -28,6 +28,7 @@
#include <qgsgeometry.h>
#include <qgsmaprenderer.h>


using namespace pal;


@@ -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 );

@@ -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;
@@ -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;
}
@@ -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

0 comments on commit f6ee8f4

Please sign in to comment.
You can’t perform that action at this time.