Skip to content
Permalink
Browse files

Fixed scale method (area/diameter) for graduated and categorized markers

  • Loading branch information
m-kuhn committed Aug 15, 2012
1 parent a9008d0 commit e323df97ee709d0bbb8bcb98362920eb7b885b72
@@ -122,6 +122,7 @@ QgsCategorizedSymbolRendererV2::QgsCategorizedSymbolRendererV2( QString attrName
mCategories( categories ),
mSourceSymbol( NULL ),
mSourceColorRamp( NULL ),
mScaleMethod( QgsSymbolV2::ScaleArea ),
mRotationFieldIdx( -1 ),
mSizeScaleFieldIdx( -1 )
{
@@ -216,6 +217,7 @@ QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& featu
markerSymbol->setAngle( rotation );
if ( mSizeScaleFieldIdx != -1 )
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
markerSymbol->setScaleMethod( mScaleMethod );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
@@ -374,6 +376,7 @@ QgsFeatureRendererV2* QgsCategorizedSymbolRendererV2::clone()
r->setUsingSymbolLevels( usingSymbolLevels() );
r->setRotationField( rotationField() );
r->setSizeScaleField( sizeScaleField() );
r->setScaleMethod( scaleMethod() );
return r;
}

@@ -140,6 +140,7 @@ QgsGraduatedSymbolRendererV2::QgsGraduatedSymbolRendererV2( QString attrName, Qg
mMode( Custom ),
mSourceSymbol( NULL ),
mSourceColorRamp( NULL ),
mScaleMethod( QgsSymbolV2::ScaleArea ),
mRotationFieldIdx( -1 ),
mSizeScaleFieldIdx( -1 )
{
@@ -201,6 +202,7 @@ QgsSymbolV2* QgsGraduatedSymbolRendererV2::symbolForFeature( QgsFeature& feature
markerSymbol->setAngle( rotation );
if ( mSizeScaleFieldIdx != -1 )
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
markerSymbol->setScaleMethod( mScaleMethod );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
@@ -332,6 +334,7 @@ QgsFeatureRendererV2* QgsGraduatedSymbolRendererV2::clone()
r->setUsingSymbolLevels( usingSymbolLevels() );
r->setRotationField( rotationField() );
r->setSizeScaleField( sizeScaleField() );
r->setScaleMethod( scaleMethod() );
return r;
}

@@ -107,6 +107,7 @@ QgsCategorizedSymbolRendererV2Widget::QgsCategorizedSymbolRendererV2Widget( QgsV
mRenderer->rotationField(), mRenderer->sizeScaleField(), mRenderer->scaleMethod() );
connect( mDataDefinedMenus, SIGNAL( rotationFieldChanged( QString ) ), this, SLOT( rotationFieldChanged( QString ) ) );
connect( mDataDefinedMenus, SIGNAL( sizeScaleFieldChanged( QString ) ), this, SLOT( sizeScaleFieldChanged( QString ) ) );
connect( mDataDefinedMenus, SIGNAL( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ), this, SLOT( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ) );
btnAdvanced->setMenu( advMenu );
}

@@ -366,10 +367,14 @@ void QgsCategorizedSymbolRendererV2Widget::addCategories()
*/

// recreate renderer
QgsCategorizedSymbolRendererV2 *r = new QgsCategorizedSymbolRendererV2( attrName, cats );
r->setSourceSymbol( mCategorizedSymbol->clone() );
r->setSourceColorRamp( ramp->clone() );
r->setScaleMethod( mRenderer->scaleMethod() );
r->setSizeScaleField( mRenderer->sizeScaleField() );
r->setRotationField( mRenderer->rotationField() );
delete mRenderer;
mRenderer = new QgsCategorizedSymbolRendererV2( attrName, cats );
mRenderer->setSourceSymbol( mCategorizedSymbol->clone() );
mRenderer->setSourceColorRamp( ramp->clone() );
mRenderer = r;

populateCategories();
}
@@ -452,6 +457,11 @@ void QgsCategorizedSymbolRendererV2Widget::sizeScaleFieldChanged( QString fldNam
mRenderer->setSizeScaleField( fldName );
}

void QgsCategorizedSymbolRendererV2Widget::scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod )
{
mRenderer->setScaleMethod( scaleMethod );
}

QList<QgsSymbolV2*> QgsCategorizedSymbolRendererV2Widget::selectedSymbols()
{
QList<QgsSymbolV2*> selectedSymbols;
@@ -48,6 +48,7 @@ class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widg

void rotationFieldChanged( QString fldName );
void sizeScaleFieldChanged( QString fldName );
void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );

void showSymbolLevels();

@@ -106,6 +106,7 @@ QgsGraduatedSymbolRendererV2Widget::QgsGraduatedSymbolRendererV2Widget( QgsVecto
mRenderer->rotationField(), mRenderer->sizeScaleField(), mRenderer->scaleMethod() );
connect( mDataDefinedMenus, SIGNAL( rotationFieldChanged( QString ) ), this, SLOT( rotationFieldChanged( QString ) ) );
connect( mDataDefinedMenus, SIGNAL( sizeScaleFieldChanged( QString ) ), this, SLOT( sizeScaleFieldChanged( QString ) ) );
connect( mDataDefinedMenus, SIGNAL( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ), this, SLOT( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ) );
btnAdvanced->setMenu( advMenu );
}

@@ -216,6 +217,10 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
return;
}

r->setSizeScaleField( mRenderer->sizeScaleField() );
r->setRotationField( mRenderer->rotationField() );
r->setScaleMethod( mRenderer->scaleMethod() );

delete mRenderer;
mRenderer = r;

@@ -383,6 +388,11 @@ void QgsGraduatedSymbolRendererV2Widget::sizeScaleFieldChanged( QString fldName
mRenderer->setSizeScaleField( fldName );
}

void QgsGraduatedSymbolRendererV2Widget::scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod )
{
mRenderer->setScaleMethod( scaleMethod );
}

QList<QgsSymbolV2*> QgsGraduatedSymbolRendererV2Widget::selectedSymbols()
{
QList<QgsSymbolV2*> selectedSymbols;
@@ -51,6 +51,7 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget

void rotationFieldChanged( QString fldName );
void sizeScaleFieldChanged( QString fldName );
void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );

void showSymbolLevels();

0 comments on commit e323df9

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