Skip to content
Permalink
Browse files

Merge branch 'diagram-additional-fix'

  • Loading branch information
m-kuhn committed Aug 29, 2012
2 parents c8a3321 + b97f2fc commit 0eab9697c09d950c076206ac16ae9023296155d0
Showing with 17 additions and 4 deletions.
  1. +0 −1 src/app/qgsdiagramproperties.cpp
  2. +13 −2 src/core/diagram/qgspiediagram.cpp
  3. +4 −1 src/core/qgsdiagramrendererv2.cpp
@@ -511,7 +511,6 @@ void QgsDiagramProperties::apply()

ds.backgroundColor = mBackgroundColorButton->color();
ds.penColor = mDiagramPenColorButton->color();
ds.penColor.setAlpha( 255 - ds.transparency );
ds.penWidth = mPenWidthSpinBox->value();
if ( mVisibilityGroupBox->isChecked() )
{
@@ -89,13 +89,15 @@ void QgsPieDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext&
QList<double> values;
double currentVal = 0;
double valSum = 0;
int valCount = 0;

QList<int>::const_iterator catIt = s.categoryIndices.constBegin();
for ( ; catIt != s.categoryIndices.constEnd(); ++catIt )
{
currentVal = att[*catIt].toDouble();
values.push_back( currentVal );
valSum += currentVal;
if ( currentVal ) valCount++;
}

//draw the slices
@@ -114,7 +116,7 @@ void QgsPieDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext&
setPenWidth( mPen, s, c );
p->setPen( mPen );

// draw empty circle if no values are defined at all
// there are some values > 0 available
if ( valSum > 0 )
{
QList<double>::const_iterator valIt = values.constBegin();
@@ -124,12 +126,21 @@ void QgsPieDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext&
currentAngle = *valIt / valSum * 360 * 16;
mCategoryBrush.setColor( *colIt );
p->setBrush( mCategoryBrush );
p->drawPie( baseX, baseY, w, h, totalAngle, currentAngle );
// if only 1 value is > 0, draw a circle
if ( valCount == 1 )
{
p->drawEllipse( baseX, baseY, w, h );
}
else
{
p->drawPie( baseX, baseY, w, h, totalAngle, currentAngle );
}
totalAngle += currentAngle;
}
}
else // valSum > 0
{
// draw empty circle if no values are defined at all
mCategoryBrush.setColor( Qt::transparent );
p->setBrush( mCategoryBrush );
p->drawEllipse( baseX, baseY, w, h );
@@ -54,8 +54,10 @@ void QgsDiagramSettings::readXML( const QDomElement& elem )
size.setHeight( elem.attribute( "height" ).toDouble() );
transparency = elem.attribute( "transparency", "0" ).toInt();
penColor.setNamedColor( elem.attribute( "penColor" ) );
penColor.setAlpha( 255 - transparency );
int penAlpha = elem.attribute( "penAlpha", "255" ).toInt();
penColor.setAlpha( penAlpha );
penWidth = elem.attribute( "penWidth" ).toDouble();

minScaleDenominator = elem.attribute( "minScaleDenominator", "-1" ).toDouble();
maxScaleDenominator = elem.attribute( "maxScaleDenominator", "-1" ).toDouble();

@@ -141,6 +143,7 @@ void QgsDiagramSettings::writeXML( QDomElement& rendererElem, QDomDocument& doc
categoryElem.setAttribute( "width", QString::number( size.width() ) );
categoryElem.setAttribute( "height", QString::number( size.height() ) );
categoryElem.setAttribute( "penColor", penColor.name() );
categoryElem.setAttribute( "penAlpha", penColor.alpha() );
categoryElem.setAttribute( "penWidth", QString::number( penWidth ) );
categoryElem.setAttribute( "minScaleDenominator", QString::number( minScaleDenominator ) );
categoryElem.setAttribute( "maxScaleDenominator", QString::number( maxScaleDenominator ) );

0 comments on commit 0eab969

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