mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Fix new labeling to work with render caching.
git-svn-id: http://svn.osgeo.org/qgis/trunk@12540 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
f2c040c38d
commit
a81156fa78
@ -14,6 +14,8 @@ public:
|
|||||||
|
|
||||||
//! called when we're going to start with rendering
|
//! called when we're going to start with rendering
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
|
//! called to find out whether the layer is used for labeling
|
||||||
|
virtual bool willUseLayer( QgsVectorLayer* layer ) = 0;
|
||||||
//! called when starting rendering of a layer
|
//! called when starting rendering of a layer
|
||||||
virtual int prepareLayer(QgsVectorLayer* layer, int& attrIndex) = 0;
|
virtual int prepareLayer(QgsVectorLayer* layer, int& attrIndex) = 0;
|
||||||
//! called for every feature
|
//! called for every feature
|
||||||
|
@ -180,9 +180,9 @@ void QgsMapRenderer::adjustExtentToSize()
|
|||||||
dymax = mExtent.yMaximum() + whitespace;
|
dymax = mExtent.yMaximum() + whitespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsDebugMsg( QString("Map units per pixel (x,y) : %1, %2\n" ).arg( mapUnitsPerPixelX ).arg( mapUnitsPerPixelY ) );
|
QgsDebugMsg( QString( "Map units per pixel (x,y) : %1, %2\n" ).arg( mapUnitsPerPixelX ).arg( mapUnitsPerPixelY ) );
|
||||||
QgsDebugMsg( QString("Pixmap dimensions (x,y) : %1, %2\n" ).arg( myWidth ).arg( myHeight ) );
|
QgsDebugMsg( QString( "Pixmap dimensions (x,y) : %1, %2\n" ).arg( myWidth ).arg( myHeight ) );
|
||||||
QgsDebugMsg( QString("Extent dimensions (x,y) : %1, %2\n" ).arg( mExtent.width() ).arg( mExtent.height() ) );
|
QgsDebugMsg( QString( "Extent dimensions (x,y) : %1, %2\n" ).arg( mExtent.width() ).arg( mExtent.height() ) );
|
||||||
QgsDebugMsg( mExtent.toString() );
|
QgsDebugMsg( mExtent.toString() );
|
||||||
|
|
||||||
// update extent
|
// update extent
|
||||||
@ -194,7 +194,7 @@ void QgsMapRenderer::adjustExtentToSize()
|
|||||||
// update the scale
|
// update the scale
|
||||||
updateScale();
|
updateScale();
|
||||||
|
|
||||||
QgsDebugMsg( QString("Scale (assuming meters as map units) = 1:%1").arg( mScale ) );
|
QgsDebugMsg( QString( "Scale (assuming meters as map units) = 1:%1" ).arg( mScale ) );
|
||||||
|
|
||||||
newCoordXForm.setParameters( mMapUnitsPerPixel, dxmin, dymin, myHeight );
|
newCoordXForm.setParameters( mMapUnitsPerPixel, dxmin, dymin, myHeight );
|
||||||
mRenderContext.setMapToPixel( newCoordXForm );
|
mRenderContext.setMapToPixel( newCoordXForm );
|
||||||
@ -406,10 +406,12 @@ void QgsMapRenderer::render( QPainter* painter )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Force render of layers that are being edited
|
// Force render of layers that are being edited
|
||||||
|
// or if there's a labeling engine that needs the layer to register features
|
||||||
if ( ml->type() == QgsMapLayer::VectorLayer )
|
if ( ml->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( ml );
|
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( ml );
|
||||||
if ( vl->isEditable() )
|
if ( vl->isEditable() ||
|
||||||
|
( mRenderContext.labelingEngine() && mRenderContext.labelingEngine()->willUseLayer( vl ) ) )
|
||||||
{
|
{
|
||||||
ml->setCacheImage( 0 );
|
ml->setCacheImage( 0 );
|
||||||
}
|
}
|
||||||
@ -576,7 +578,7 @@ void QgsMapRenderer::render( QPainter* painter )
|
|||||||
{
|
{
|
||||||
// set correct extent
|
// set correct extent
|
||||||
mRenderContext.setExtent( mExtent );
|
mRenderContext.setExtent( mExtent );
|
||||||
mRenderContext.setCoordinateTransform(NULL);
|
mRenderContext.setCoordinateTransform( NULL );
|
||||||
|
|
||||||
mLabelingEngine->drawLabeling( mRenderContext );
|
mLabelingEngine->drawLabeling( mRenderContext );
|
||||||
mLabelingEngine->exit();
|
mLabelingEngine->exit();
|
||||||
@ -813,7 +815,7 @@ void QgsMapRenderer::updateFullExtent()
|
|||||||
QgsMapLayer * lyr = registry->mapLayer( *it );
|
QgsMapLayer * lyr = registry->mapLayer( *it );
|
||||||
if ( lyr == NULL )
|
if ( lyr == NULL )
|
||||||
{
|
{
|
||||||
QgsDebugMsg( QString("WARNING: layer '%1' not found in map layer registry!").arg( *it ) );
|
QgsDebugMsg( QString( "WARNING: layer '%1' not found in map layer registry!" ).arg( *it ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,8 @@ class QgsLabelingEngineInterface
|
|||||||
|
|
||||||
//! called when we're going to start with rendering
|
//! called when we're going to start with rendering
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
|
//! called to find out whether the layer is used for labeling
|
||||||
|
virtual bool willUseLayer( QgsVectorLayer* layer ) = 0;
|
||||||
//! called when starting rendering of a layer
|
//! called when starting rendering of a layer
|
||||||
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex ) = 0;
|
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex ) = 0;
|
||||||
//! called for every feature
|
//! called for every feature
|
||||||
|
@ -288,6 +288,14 @@ PalLabeling::~PalLabeling()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PalLabeling::willUseLayer( QgsVectorLayer* layer )
|
||||||
|
{
|
||||||
|
LayerSettings lyrTmp;
|
||||||
|
lyrTmp.readFromLayer( layer );
|
||||||
|
return lyrTmp.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex )
|
int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex )
|
||||||
{
|
{
|
||||||
// start with a temporary settings class, find out labeling info
|
// start with a temporary settings class, find out labeling info
|
||||||
@ -298,7 +306,7 @@ int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex )
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// find out which field will be needed
|
// find out which field will be needed
|
||||||
int fldIndex = layer->dataProvider()->fieldNameIndex( lyrTmp.fieldName );
|
int fldIndex = layer->fieldNameIndex( lyrTmp.fieldName );
|
||||||
if ( fldIndex == -1 )
|
if ( fldIndex == -1 )
|
||||||
return 0;
|
return 0;
|
||||||
attrIndex = fldIndex;
|
attrIndex = fldIndex;
|
||||||
|
@ -123,6 +123,8 @@ class PalLabeling : public QgsLabelingEngineInterface
|
|||||||
|
|
||||||
//! called when we're going to start with rendering
|
//! called when we're going to start with rendering
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
//! called to find out whether the layer is used for labeling
|
||||||
|
virtual bool willUseLayer( QgsVectorLayer* layer );
|
||||||
//! hook called when drawing layer before issuing select()
|
//! hook called when drawing layer before issuing select()
|
||||||
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex );
|
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex );
|
||||||
//! hook called when drawing for every feature in a layer
|
//! hook called when drawing for every feature in a layer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user