Skip to content
Permalink
Browse files
Add scale method to data defined size label, related to #8887
  • Loading branch information
blazek committed Jan 28, 2014
1 parent 8cf9936 commit 3256c92604fc208240d241774a6bd41a8eeecd19
@@ -1157,9 +1157,9 @@ void QgsGraduatedSymbolRendererV2::updateSymbols( QgsSymbolV2 *sym )
void QgsGraduatedSymbolRendererV2::setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod )
{
mScaleMethod = scaleMethod;
foreach ( QgsRendererRangeV2 range, mRanges )
for ( QgsRangeList::iterator it = mRanges.begin(); it != mRanges.end(); ++it )
{
setScaleMethodToSymbol( range.symbol(), scaleMethod );
setScaleMethodToSymbol( it->symbol(), scaleMethod );
}
}

@@ -107,6 +107,12 @@ void QgsSingleSymbolRendererV2Widget::sizeScaleFieldChanged( QString fldName )
void QgsSingleSymbolRendererV2Widget::scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod )
{
mRenderer->setScaleMethod( scaleMethod );
// Set also on the symbol clone
QgsMarkerSymbolV2 *markerSymbol = dynamic_cast<QgsMarkerSymbolV2 *>( mSingleSymbol );
if ( markerSymbol )
{
markerSymbol->setScaleMethod( scaleMethod );
}
}

void QgsSingleSymbolRendererV2Widget::showSymbolLevels()
@@ -43,7 +43,28 @@
#include <QStandardItemModel>
#include <QSvgRenderer>


QString QgsSymbolLayerV2Widget::dataDefinedPropertyLabel( const QString &entryName )
{
QString label = entryName;
if ( entryName == "size" )
{
label = tr( "Size" );
QgsMarkerSymbolLayerV2 * layer = dynamic_cast<QgsMarkerSymbolLayerV2 *>( symbolLayer() );
if ( layer )
{
switch ( layer->scaleMethod() )
{
case QgsSymbolV2::ScaleArea:
label += " (" + tr( "area" ) + ")";
break;
case QgsSymbolV2::ScaleDiameter:
label += " (" + tr( "diameter" ) + ")";
break;
}
}
}
return label;
}

QgsSimpleLineSymbolLayerV2Widget::QgsSimpleLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
@@ -455,7 +476,7 @@ void QgsSimpleMarkerSymbolLayerV2Widget::on_mDataDefinedPropertiesButton_clicked
QgsDataDefinedSymbolDialog::colorHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline_width", tr( "Outline width" ), mLayer->dataDefinedPropertyString( "outline_width" ),
QgsDataDefinedSymbolDialog::doubleHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "size", tr( "Size" ), mLayer->dataDefinedPropertyString( "size" ),
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "size", dataDefinedPropertyLabel( "size" ), mLayer->dataDefinedPropertyString( "size" ),
QgsDataDefinedSymbolDialog::doubleHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "angle", tr( "Angle" ), mLayer->dataDefinedPropertyString( "angle" ),
QgsDataDefinedSymbolDialog::doubleHelpText() );
@@ -1556,7 +1577,7 @@ void QgsSvgMarkerSymbolLayerV2Widget::on_mDataDefinedPropertiesButton_clicked()
}

QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "size", tr( "Size" ), mLayer->dataDefinedPropertyString( "size" ),
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "size", dataDefinedPropertyLabel( "size" ), mLayer->dataDefinedPropertyString( "size" ),
QgsDataDefinedSymbolDialog::doubleHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline-width", tr( "Border width" ), mLayer->dataDefinedPropertyString( "outline-width" ),
QgsDataDefinedSymbolDialog::doubleHelpText() );
@@ -36,6 +36,10 @@ class GUI_EXPORT QgsSymbolLayerV2Widget : public QWidget

protected:
const QgsVectorLayer* mVectorLayer;
/** Get label for data defined entry.
* Implemented only for 'size' of marker symbols
* @added in 2.1 */
virtual QString dataDefinedPropertyLabel( const QString &entryName );

signals:
void changed();

0 comments on commit 3256c92

Please sign in to comment.