Skip to content
Permalink
Browse files
symbology-ng: fix data defined properties of centroid fill markers (f…
…ixes #8318)
  • Loading branch information
jef-n committed Jul 22, 2013
1 parent 4e4bf8e commit 1d5712c485999950b2403f4dbf4e43d16239948f
@@ -1718,6 +1718,18 @@ bool QgsCentroidFillSymbolLayerV2::setSubSymbol( QgsSymbolV2* symbol )
return true;
}

QSet<QString> QgsCentroidFillSymbolLayerV2::usedAttributes() const
{
QSet<QString> attributes;

attributes.unite( QgsSymbolLayerV2::usedAttributes() );

if ( mMarker )
attributes.unite( mMarker->usedAttributes() );

return attributes;
}

QgsSymbolV2::OutputUnit QgsCentroidFillSymbolLayerV2::outputUnit() const
{
if ( mMarker )
@@ -384,6 +384,8 @@ class CORE_EXPORT QgsCentroidFillSymbolLayerV2 : public QgsFillSymbolLayerV2
void setOutputUnit( QgsSymbolV2::OutputUnit unit ) { Q_UNUSED( unit ); }
QgsSymbolV2::OutputUnit outputUnit() const;

virtual QSet<QString> usedAttributes() const;

protected:
QgsMarkerSymbolV2* mMarker;
};
@@ -413,8 +413,7 @@ bool QgsSimpleMarkerSymbolLayerV2::preparePath( QString name )

void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
QgsRenderContext& rc = context.renderContext();
QPainter* p = rc.painter();
QPainter *p = context.renderContext().painter();
if ( !p )
{
return;
@@ -460,42 +459,20 @@ void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV
{
QMatrix transform;


bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation || angleExpression;
QgsExpression* sizeExpression = expression( "size" );
bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale || sizeExpression;

// move to the desired position
transform.translate( point.x() + off.x(), point.y() + off.y() );

// resize if necessary
if ( hasDataDefinedSize )
{
double scaledSize = mSize;
if ( sizeExpression )
{
scaledSize = sizeExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
}
scaledSize *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mSizeUnit );

switch ( mScaleMethod )
{
case QgsSymbolV2::ScaleArea:
scaledSize = sqrt( scaledSize );
break;
case QgsSymbolV2::ScaleDiameter:
break;
}

double half = scaledSize / 2.0;
transform.scale( half, half );
}
double size = mSize;
QgsExpression* sizeExpression = expression( "size" );

// rotate if necessary
if ( angle != 0 && hasDataDefinedRotation )
if ( sizeExpression )
{
transform.rotate( angle );
size = sizeExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
}
size *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mSizeUnit );

double half = size / 2.0;
transform.scale( half, half );

QgsExpression* colorExpression = expression( "color" );
QgsExpression* colorBorderExpression = expression( "color_border" );
@@ -835,11 +812,9 @@ void QgsSvgMarkerSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )

void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
QPainter* p = context.renderContext().painter();
QPainter *p = context.renderContext().painter();
if ( !p )
{
return;
}

double size = mSize;
QgsExpression* sizeExpression = expression( "size" );
@@ -1167,13 +1142,15 @@ void QgsFontMarkerSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )

void QgsFontMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
QPainter* p = context.renderContext().painter();
QPainter *p = context.renderContext().painter();
if ( !p )
return;

QColor penColor = context.selected() ? context.renderContext().selectionColor() : mColor;
penColor.setAlphaF( mColor.alphaF() * context.alpha() );
p->setPen( penColor );
p->setFont( mFont );


p->save();
double offsetX = mOffset.x() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
double offsetY = mOffset.y() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
@@ -96,7 +96,6 @@ void QgsSymbolLayerV2::prepareExpressions( const QgsVectorLayer* vl )

QSet<QString> QgsSymbolLayerV2::usedAttributes() const
{
QSet<QString> attributes;
QStringList columns;

QMap< QString, QgsExpression* >::const_iterator ddIt = mDataDefinedProperties.constBegin();
@@ -108,11 +107,13 @@ QSet<QString> QgsSymbolLayerV2::usedAttributes() const
}
}

QSet<QString> attributes;
QStringList::const_iterator it = columns.constBegin();
for ( ; it != columns.constEnd(); ++it )
{
attributes.insert( *it );
}

return attributes;
}

@@ -131,9 +132,8 @@ void QgsSymbolLayerV2::saveDataDefinedProperties( QgsStringMap& stringMap ) cons
void QgsSymbolLayerV2::copyDataDefinedProperties( QgsSymbolLayerV2* destLayer ) const
{
if ( !destLayer )
{
return;
}

destLayer->removeDataDefinedProperties();

QMap< QString, QgsExpression* >::const_iterator ddIt = mDataDefinedProperties.constBegin();

0 comments on commit 1d5712c

Please sign in to comment.