Skip to content
Permalink
Browse files
Fix data defined size for simple marker. Propagate scale method to sy…
…mbol layers
  • Loading branch information
mhugent committed Mar 29, 2013
1 parent f13fc31 commit de473aa7c0c26d5d062612a1741a381f36869c41
@@ -680,3 +680,13 @@ void QgsCategorizedSymbolRendererV2::updateSymbols( QgsSymbolV2 * sym )
++i;
}
}

void QgsCategorizedSymbolRendererV2::setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod )
{
mScaleMethod = scaleMethod;
QgsCategoryList::const_iterator catIt = mCategories.constBegin();
for ( ; catIt != mCategories.constEnd(); ++catIt )
{
setScaleMethodToSymbol( catIt->symbol(), scaleMethod );
}
}
@@ -144,7 +144,7 @@ class CORE_EXPORT QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2
QString sizeScaleField() const { return mSizeScaleField; }

//! @note added in 2.0
void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod ) { mScaleMethod = scaleMethod; }
void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
//! @note added in 2.0
QgsSymbolV2::ScaleMethod scaleMethod() const { return mScaleMethod; }

@@ -195,8 +195,8 @@ QgsSymbolV2* QgsGraduatedSymbolRendererV2::symbolForFeature( QgsFeature& feature
// Null values should not be categorized
if ( attrs[mAttrNum].isNull() )
return NULL;
// find the right category

// find the right category
QgsSymbolV2* symbol = symbolForValue( attrs[mAttrNum].toDouble() );
if ( symbol == NULL )
return NULL;
@@ -806,7 +806,7 @@ QgsGraduatedSymbolRendererV2* QgsGraduatedSymbolRendererV2::createRenderer(
lst.append( attrNum );

QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( lst ) );

// create list of non-null attribute values
while ( fit.nextFeature( f ) )
if ( !f.attribute( attrNum ).isNull() )
@@ -1131,6 +1131,15 @@ void QgsGraduatedSymbolRendererV2::updateSymbols( QgsSymbolV2 *sym )
this->setSourceSymbol( sym->clone() );
}

void QgsGraduatedSymbolRendererV2::setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod )
{
mScaleMethod = scaleMethod;
foreach ( QgsRendererRangeV2 range, mRanges )
{
setScaleMethodToSymbol( range.symbol(), scaleMethod );
}
}

void QgsGraduatedSymbolRendererV2::addClass( QgsSymbolV2* symbol )
{
QgsSymbolV2* newSymbol = symbol->clone();
@@ -163,7 +163,7 @@ class CORE_EXPORT QgsGraduatedSymbolRendererV2 : public QgsFeatureRendererV2
QString sizeScaleField() const { return mSizeScaleField; }

//! @note added in 2.0
void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod ) { mScaleMethod = scaleMethod; }
void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
//! @note added in 2.0
QgsSymbolV2::ScaleMethod scaleMethod() const { return mScaleMethod; }

@@ -149,7 +149,7 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex
mSelPen.setWidthF( context.outputLineWidth( mPen.widthF() ) );

bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation;
bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale;
bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale || mSizeExpression;

// use caching only when:
// - size, rotation, shape, color, border color is not data-defined
@@ -183,6 +183,21 @@ unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygon
return wkb;
}

void QgsFeatureRendererV2::setScaleMethodToSymbol( QgsSymbolV2* symbol, int scaleMethod )
{
if ( symbol )
{
if ( symbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* ms = static_cast<QgsMarkerSymbolV2*>( symbol );
if ( ms )
{
ms->setScaleMethod(( QgsSymbolV2::ScaleMethod )scaleMethod );
}
}
}
}


QgsFeatureRendererV2::QgsFeatureRendererV2( QString type )
: mType( type ), mUsingSymbolLevels( false ),
@@ -194,6 +194,8 @@ class CORE_EXPORT QgsFeatureRendererV2
static unsigned char* _getLineString( QPolygonF& pts, QgsRenderContext& context, unsigned char* wkb );
static unsigned char* _getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, unsigned char* wkb );

void setScaleMethodToSymbol( QgsSymbolV2* symbol, int scaleMethod );

QString mType;

bool mUsingSymbolLevels;
@@ -166,6 +166,12 @@ void QgsSingleSymbolRendererV2::setSymbol( QgsSymbolV2* s )
mSymbol = s;
}

void QgsSingleSymbolRendererV2::setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod )
{
mScaleMethod = scaleMethod;
setScaleMethodToSymbol( mSymbol, scaleMethod );
}

QString QgsSingleSymbolRendererV2::dump()
{
if ( mSymbol )
@@ -49,7 +49,7 @@ class CORE_EXPORT QgsSingleSymbolRendererV2 : public QgsFeatureRendererV2
QString sizeScaleField() const { return mSizeScaleField; }

//! @note added in 2.0
void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod ) { mScaleMethod = scaleMethod; }
void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
//! @note added in 2.0
QgsSymbolV2::ScaleMethod scaleMethod() const { return mScaleMethod; }

0 comments on commit de473aa

Please sign in to comment.