Skip to content
Permalink
Browse files

Fix diagrams not initially showing when toggling on/off layers

  • Loading branch information
nyalldawson committed Apr 9, 2015
1 parent e8b06c7 commit 134067716d6d8a6a6da36e0958d85637f94731d2
@@ -427,6 +427,12 @@ class QgsVectorLayer : QgsMapLayer
/** Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned */
QgsRectangle boundingBoxOfSelected();

/** Returns whether the layer contains diagrams which are enabled and should be drawn.
* @return true if layer contains enabled diagrams
* @note added in QGIS 2.9
*/
bool diagramsEnabled() const;

/** Sets diagram rendering object (takes ownership) */
void setDiagramRenderer( QgsDiagramRendererV2* r /Transfer/ );
const QgsDiagramRendererV2* diagramRenderer() const;
@@ -9157,7 +9157,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( it.value() );
if ( !vlayer || !vlayer->isEditable() ||
( !vlayer->diagramRenderer() && vlayer->customProperty( "labeling" ).toString() != QString( "pal" ) ) )
( !vlayer->diagramsEnabled() && vlayer->customProperty( "labeling" ).toString() != QString( "pal" ) ) )
continue;

int colX, colY, colShow, colAng;
@@ -3152,7 +3152,8 @@ bool QgsPalLabeling::staticWillUseLayer( QgsVectorLayer* layer )
// don't do QgsPalLayerSettings::readFromLayer( layer ) if not needed
bool enabled = false;
if ( layer->customProperty( "labeling" ).toString() == QString( "pal" ) )
enabled = layer->customProperty( "labeling/enabled", QVariant( false ) ).toBool();
enabled = layer->customProperty( "labeling/enabled", QVariant( false ) ).toBool()
|| layer->diagramsEnabled();

return enabled;
}
@@ -711,6 +711,11 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected()
return retval;
}

bool QgsVectorLayer::diagramsEnabled() const
{
return mDiagramRenderer && mDiagramLayerSettings;
}

long QgsVectorLayer::featureCount() const
{
if ( !mDataProvider )
@@ -789,6 +789,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned */
QgsRectangle boundingBoxOfSelected();

/** Returns whether the layer contains diagrams which are enabled and should be drawn.
* @return true if layer contains enabled diagrams
* @note added in QGIS 2.9
*/
bool diagramsEnabled() const;

/** Sets diagram rendering object (takes ownership) */
void setDiagramRenderer( QgsDiagramRendererV2* r );
const QgsDiagramRendererV2* diagramRenderer() const { return mDiagramRenderer; }
@@ -489,7 +489,7 @@ void QgsVectorLayerRenderer::prepareDiagrams( QgsVectorLayer* layer, QStringList
if ( !mContext.labelingEngine() )
return;

if ( !layer->diagramRenderer() || !layer->diagramLayerSettings() )
if ( !layer->diagramsEnabled() )
return;

mDiagrams = true;

0 comments on commit 1340677

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