Skip to content

Commit 8301ba2

Browse files
committed
Remove sizeScaleField and sizeScaleMethods from renderers
These were unused (since they were moved to data defined properties at the symbol layer level) and were not set anywhere in core QGIS (ie, the only way to set them was by manually calling this api)
1 parent 041ceea commit 8301ba2

16 files changed

+12
-358
lines changed

doc/api_break.dox

+3-1
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,9 @@ in code which previously passed a null pointer to QgsVectorFileWriter.</li>
11231123
<ul>
11241124
<li>New virtual method <code>bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage, QgsStringMap props = QgsStringMap() )</code> accepts an
11251125
optional property map passing down layer level properties to the SLD encoders. If scale based visibility is enabled, it will contain the
1126-
<code>scaleMinDenom</code> and <code>scaleMaxDenom</code> properties.
1126+
<code>scaleMinDenom</code> and <code>scaleMaxDenom</code> properties.</li>
1127+
<li>The RotationField capabitity was removed. This is now handled using data defined rotation at a symbol layer level</li>
1128+
<li>setScaleMethodToSymbol was removed. This is now handled using data defined scaling at a symbol layer level</li>
11271129
</ul>
11281130

11291131

python/core/symbology-ng/qgscategorizedsymbolrenderer.sip

-6
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,6 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
168168
*/
169169
void updateColorRamp( QgsColorRamp* ramp /Transfer/, bool inverted = false );
170170

171-
void setSizeScaleField( const QString& fieldOrExpression );
172-
QString sizeScaleField() const;
173-
174-
void setScaleMethod( QgsSymbol::ScaleMethod scaleMethod );
175-
QgsSymbol::ScaleMethod scaleMethod() const;
176-
177171
//! items of symbology items in legend should be checkable
178172
//! @note added in 2.5
179173
virtual bool legendSymbolItemsCheckable() const;

python/core/symbology-ng/qgsgraduatedsymbolrenderer.sip

-6
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,6 @@ class QgsGraduatedSymbolRenderer : QgsFeatureRenderer
293293
//! @note added in 2.10
294294
void setGraduatedMethod( GraduatedMethod method );
295295

296-
void setSizeScaleField( const QString& fieldOrExpression );
297-
QString sizeScaleField() const;
298-
299-
void setScaleMethod( QgsSymbol::ScaleMethod scaleMethod );
300-
QgsSymbol::ScaleMethod scaleMethod() const;
301-
302296
//! items of symbology items in legend should be checkable
303297
//! @note added in 2.5
304298
virtual bool legendSymbolItemsCheckable() const;

python/core/symbology-ng/qgsrenderer.sip

-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ class QgsFeatureRenderer
149149
enum Capability
150150
{
151151
SymbolLevels, // rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
152-
RotationField, // rotate symbols by attribute value
153152
MoreSymbolsPerFeature, // may use more than one symbol to render a feature: symbolsForFeature() will return them
154153
Filter, // features may be filtered, i.e. some features may not be rendered (categorized, rule based ...)
155154
ScaleDependent // depends on scale if feature will be rendered (rule based )
@@ -360,8 +359,6 @@ class QgsFeatureRenderer
360359
*/
361360
static QPointF _getPoint( QgsRenderContext& context, const QgsPointV2& point );
362361

363-
void setScaleMethodToSymbol( QgsSymbol* symbol, int scaleMethod );
364-
365362
/**
366363
* Clones generic renderer data to another renderer.
367364
* Currently clones

python/core/symbology-ng/qgssinglesymbolrenderer.sip

-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ class QgsSingleSymbolRenderer : QgsFeatureRenderer
2424
QgsSymbol* symbol() const;
2525
void setSymbol( QgsSymbol* s /Transfer/ );
2626

27-
void setSizeScaleField( const QString& fieldOrExpression );
28-
QString sizeScaleField() const;
29-
30-
void setScaleMethod( QgsSymbol::ScaleMethod scaleMethod );
31-
QgsSymbol::ScaleMethod scaleMethod() const;
32-
3327
virtual QString dump() const;
3428

3529
virtual QgsSingleSymbolRenderer* clone() const /Factory/;

src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp

+1-82
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ QgsCategorizedSymbolRenderer::QgsCategorizedSymbolRenderer( const QString& attrN
153153
: QgsFeatureRenderer( "categorizedSymbol" )
154154
, mAttrName( attrName )
155155
, mInvertedColorRamp( false )
156-
, mScaleMethod( DEFAULT_SCALE_METHOD )
157156
, mAttrNum( -1 )
158157
, mCounting( false )
159158
{
@@ -216,38 +215,9 @@ QgsSymbol* QgsCategorizedSymbolRenderer::symbolForValue( const QVariant& value )
216215

217216
QgsSymbol* QgsCategorizedSymbolRenderer::symbolForFeature( QgsFeature& feature, QgsRenderContext &context )
218217
{
219-
QgsSymbol* symbol = originalSymbolForFeature( feature, context );
220-
if ( !symbol )
221-
return nullptr;
222-
223-
if ( !mRotation.data() && !mSizeScale.data() )
224-
return symbol; // no data-defined rotation/scaling - just return the symbol
225-
226-
// find out rotation, size scale
227-
const double rotation = mRotation.data() ? mRotation->evaluate( &context.expressionContext() ).toDouble() : 0;
228-
const double sizeScale = mSizeScale.data() ? mSizeScale->evaluate( &context.expressionContext() ).toDouble() : 1.;
229-
230-
// take a temporary symbol (or create it if doesn't exist)
231-
QgsSymbol* tempSymbol = mTempSymbols[symbol];
232-
233-
// modify the temporary symbol and return it
234-
if ( tempSymbol->type() == QgsSymbol::Marker )
235-
{
236-
QgsMarkerSymbol* markerSymbol = static_cast<QgsMarkerSymbol*>( tempSymbol );
237-
if ( mRotation.data() ) markerSymbol->setAngle( rotation );
238-
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbol*>( symbol )->size() );
239-
markerSymbol->setScaleMethod( mScaleMethod );
240-
}
241-
else if ( tempSymbol->type() == QgsSymbol::Line )
242-
{
243-
QgsLineSymbol* lineSymbol = static_cast<QgsLineSymbol*>( tempSymbol );
244-
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbol*>( symbol )->width() );
245-
}
246-
247-
return tempSymbol;
218+
return originalSymbolForFeature( feature, context );
248219
}
249220

250-
251221
QVariant QgsCategorizedSymbolRenderer::valueForFeature( QgsFeature& feature, QgsRenderContext &context ) const
252222
{
253223
QgsAttributes attrs = feature.attributes();
@@ -435,15 +405,6 @@ void QgsCategorizedSymbolRenderer::startRender( QgsRenderContext& context, const
435405
Q_FOREACH ( const QgsRendererCategory& cat, mCategories )
436406
{
437407
cat.symbol()->startRender( context, fields );
438-
439-
if ( mRotation.data() || mSizeScale.data() )
440-
{
441-
QgsSymbol* tempSymbol = cat.symbol()->clone();
442-
tempSymbol->setRenderHints(( mRotation.data() ? QgsSymbol::DataDefinedRotation : 0 ) |
443-
( mSizeScale.data() ? QgsSymbol::DataDefinedSizeScale : 0 ) );
444-
tempSymbol->startRender( context, fields );
445-
mTempSymbols[ cat.symbol()] = tempSymbol;
446-
}
447408
}
448409
return;
449410
}
@@ -454,15 +415,6 @@ void QgsCategorizedSymbolRenderer::stopRender( QgsRenderContext& context )
454415
{
455416
cat.symbol()->stopRender( context );
456417
}
457-
458-
// cleanup mTempSymbols
459-
QHash<QgsSymbol*, QgsSymbol*>::const_iterator it2 = mTempSymbols.constBegin();
460-
for ( ; it2 != mTempSymbols.constEnd(); ++it2 )
461-
{
462-
it2.value()->stopRender( context );
463-
delete it2.value();
464-
}
465-
mTempSymbols.clear();
466418
mExpression.reset();
467419
}
468420

@@ -480,9 +432,6 @@ QList<QString> QgsCategorizedSymbolRenderer::usedAttributes()
480432
if ( !testExpr.hasParserError() )
481433
attributes.unite( testExpr.referencedColumns().toSet() );
482434

483-
if ( mRotation.data() ) attributes.unite( mRotation->referencedColumns().toSet() );
484-
if ( mSizeScale.data() ) attributes.unite( mSizeScale->referencedColumns().toSet() );
485-
486435
QgsCategoryList::const_iterator catIt = mCategories.constBegin();
487436
for ( ; catIt != mCategories.constEnd(); ++catIt )
488437
{
@@ -514,7 +463,6 @@ QgsCategorizedSymbolRenderer* QgsCategorizedSymbolRenderer::clone() const
514463
r->setInvertedColorRamp( mInvertedColorRamp );
515464
}
516465
r->setUsingSymbolLevels( usingSymbolLevels() );
517-
r->setSizeScaleField( sizeScaleField() );
518466

519467
copyRendererData( r );
520468
return r;
@@ -523,10 +471,6 @@ QgsCategorizedSymbolRenderer* QgsCategorizedSymbolRenderer::clone() const
523471
void QgsCategorizedSymbolRenderer::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
524472
{
525473
props[ "attribute" ] = mAttrName;
526-
if ( mRotation.data() )
527-
props[ "angle" ] = mRotation->expression();
528-
if ( mSizeScale.data() )
529-
props[ "scale" ] = mSizeScale->expression();
530474

531475
// create a Rule for each range
532476
for ( QgsCategoryList::const_iterator it = mCategories.constBegin(); it != mCategories.constEnd(); ++it )
@@ -770,14 +714,9 @@ QDomElement QgsCategorizedSymbolRenderer::save( QDomDocument& doc )
770714
}
771715

772716
QDomElement rotationElem = doc.createElement( "rotation" );
773-
if ( mRotation.data() )
774-
rotationElem.setAttribute( "field", QgsSymbolLayerUtils::fieldOrExpressionFromExpression( mRotation.data() ) );
775717
rendererElem.appendChild( rotationElem );
776718

777719
QDomElement sizeScaleElem = doc.createElement( "sizescale" );
778-
if ( mSizeScale.data() )
779-
sizeScaleElem.setAttribute( "field", QgsSymbolLayerUtils::fieldOrExpressionFromExpression( mSizeScale.data() ) );
780-
sizeScaleElem.setAttribute( "scalemethod", QgsSymbolLayerUtils::encodeScaleMethod( mScaleMethod ) );
781720
rendererElem.appendChild( sizeScaleElem );
782721

783722
if ( mPaintEffect && !QgsPaintEffectRegistry::isDefaultStack( mPaintEffect ) )
@@ -936,16 +875,6 @@ void QgsCategorizedSymbolRenderer::updateColorRamp( QgsColorRamp* ramp, bool inv
936875
}
937876
}
938877

939-
void QgsCategorizedSymbolRenderer::setSizeScaleField( const QString& fieldOrExpression )
940-
{
941-
mSizeScale.reset( QgsSymbolLayerUtils::fieldOrExpressionToExpression( fieldOrExpression ) );
942-
}
943-
944-
QString QgsCategorizedSymbolRenderer::sizeScaleField() const
945-
{
946-
return mSizeScale.data() ? QgsSymbolLayerUtils::fieldOrExpressionFromExpression( mSizeScale.data() ) : QString();
947-
}
948-
949878
void QgsCategorizedSymbolRenderer::updateSymbols( QgsSymbol * sym )
950879
{
951880
int i = 0;
@@ -959,16 +888,6 @@ void QgsCategorizedSymbolRenderer::updateSymbols( QgsSymbol * sym )
959888
setSourceSymbol( sym->clone() );
960889
}
961890

962-
void QgsCategorizedSymbolRenderer::setScaleMethod( QgsSymbol::ScaleMethod scaleMethod )
963-
{
964-
mScaleMethod = scaleMethod;
965-
QgsCategoryList::const_iterator catIt = mCategories.constBegin();
966-
for ( ; catIt != mCategories.constEnd(); ++catIt )
967-
{
968-
setScaleMethodToSymbol( catIt->symbol(), scaleMethod );
969-
}
970-
}
971-
972891
bool QgsCategorizedSymbolRenderer::legendSymbolItemsCheckable() const
973892
{
974893
return true;

src/core/symbology-ng/qgscategorizedsymbolrenderer.h

+1-13
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
9090
virtual QString dump() const override;
9191
virtual QgsCategorizedSymbolRenderer* clone() const override;
9292
virtual void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props = QgsStringMap() ) const override;
93-
virtual Capabilities capabilities() override { return SymbolLevels | RotationField | Filter; }
93+
virtual Capabilities capabilities() override { return SymbolLevels | Filter; }
9494
virtual QString filter( const QgsFields& fields = QgsFields() ) override;
9595
virtual QgsSymbolList symbols( QgsRenderContext& context ) override;
9696

@@ -178,12 +178,6 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
178178
*/
179179
void updateColorRamp( QgsColorRamp* ramp, bool inverted = false );
180180

181-
void setSizeScaleField( const QString& fieldOrExpression );
182-
QString sizeScaleField() const;
183-
184-
void setScaleMethod( QgsSymbol::ScaleMethod scaleMethod );
185-
QgsSymbol::ScaleMethod scaleMethod() const { return mScaleMethod; }
186-
187181
virtual bool legendSymbolItemsCheckable() const override;
188182
virtual bool legendSymbolItemChecked( const QString& key ) override;
189183
virtual void setLegendSymbolItem( const QString& key, QgsSymbol* symbol ) override;
@@ -201,9 +195,6 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
201195
QScopedPointer<QgsSymbol> mSourceSymbol;
202196
QScopedPointer<QgsColorRamp> mSourceColorRamp;
203197
bool mInvertedColorRamp;
204-
QScopedPointer<QgsExpression> mRotation;
205-
QScopedPointer<QgsExpression> mSizeScale;
206-
QgsSymbol::ScaleMethod mScaleMethod;
207198
QScopedPointer<QgsExpression> mExpression;
208199

209200
//! attribute index (derived from attribute name in startRender)
@@ -213,9 +204,6 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
213204
QHash<QString, QgsSymbol*> mSymbolHash;
214205
bool mCounting;
215206

216-
//! temporary symbols, used for data-defined rotation and scaling
217-
QHash<QgsSymbol*, QgsSymbol*> mTempSymbols;
218-
219207
void rebuildHash();
220208

221209
QgsSymbol* skipRender();

0 commit comments

Comments
 (0)