Skip to content
Permalink
Browse files

Make bar width configurable

  • Loading branch information
m-kuhn committed Aug 9, 2012
1 parent 04fd6b6 commit 55ff09ec3e72b05722ab1bc8f5df64fc79a0bab1
@@ -900,6 +900,8 @@ void QgsVectorLayerProperties::apply()
ds.diagramOrientation = QgsDiagramSettings::Left;
}

ds.barWidth = mBarWidthSpinBox->value();

if ( mFixedSizeCheckBox->isChecked() )
{
QgsSingleCategoryDiagramRenderer* dr = new QgsSingleCategoryDiagramRenderer();
@@ -1748,9 +1750,10 @@ void QgsVectorLayerProperties::initDiagramTab()
case QgsDiagramSettings::Down:
mOrientationDownButton->setChecked( true );
break;

}

mBarWidthSpinBox->setValue( settingList.at( 0 ).barWidth );

mIncreaseSmallDiagramsCheckBox->setChecked( settingList.at( 0 ).minimumSize != 0 );
mIncreaseMinimumSizeSpinBox->setValue( settingList.at( 0 ).minimumSize );

@@ -351,7 +351,8 @@ void QgsHistogramDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderCo
values.push_back( currentVal );
}

double currentOffset = 0;
double currentOffset = 0 - ( values.size() * s.barWidth ) / 2;
double scaledWidth = sizePainterUnits( s.barWidth, s, c );

double baseX = position.x();
double baseY = position.y();
@@ -360,8 +361,6 @@ void QgsHistogramDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderCo
setPenWidth( mPen, s, c );
p->setPen( mPen );

p->drawPoint( baseX, baseY );

QList<double>::const_iterator valIt = values.constBegin();
QList< QColor >::const_iterator colIt = s.categoryColors.constBegin();
for ( ; valIt != values.constEnd(); ++valIt, ++colIt )
@@ -374,22 +373,22 @@ void QgsHistogramDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderCo
switch ( s.diagramOrientation )
{
case QgsDiagramSettings::Up:
p->drawRect( baseX + currentOffset, baseY, 10, 0 - length );
p->drawRect( baseX + currentOffset, baseY, scaledWidth, 0 - length );
break;

case QgsDiagramSettings::Down:
p->drawRect( baseX + currentOffset, baseY, 10, length );
p->drawRect( baseX + currentOffset, baseY, scaledWidth, length );
break;

case QgsDiagramSettings::Right:
p->drawRect( baseX, baseY + currentOffset, 0 - length, 10 );
p->drawRect( baseX, baseY + currentOffset, 0 - length, scaledWidth );
break;

case QgsDiagramSettings::Left:
p->drawRect( baseX, baseY + currentOffset, length, 10 );
p->drawRect( baseX, baseY + currentOffset, length, scaledWidth );
break;
}

currentOffset += 10;
currentOffset += scaledWidth;
}
}
@@ -93,6 +93,8 @@ void QgsDiagramSettings::readXML( const QDomElement& elem )
diagramOrientation = Up;
}

barWidth = elem.attribute( "barWidth" ).toDouble();

minimumSize = elem.attribute( "minimumSize" ).toDouble();

//colors
@@ -170,6 +172,7 @@ void QgsDiagramSettings::writeXML( QDomElement& rendererElem, QDomDocument& doc
break;
}

categoryElem.setAttribute( "barWidth", QString::number( barWidth ) );
categoryElem.setAttribute( "minimumSize", QString::number( minimumSize ) );

QString colors;
@@ -123,6 +123,7 @@ struct CORE_EXPORT QgsDiagramSettings
double penWidth;
LabelPlacementMethod labelPlacementMethod;
DiagramOrientation diagramOrientation;
double barWidth;

//scale range (-1 if no lower / upper bound )
double minScaleDenominator;
@@ -1353,6 +1353,20 @@
</property>
</spacer>
</item>
<item row="6" column="0" colspan="3">
<layout class="QHBoxLayout" name="mBarWidthLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Bar width</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="mBarWidthSpinBox"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>

0 comments on commit 55ff09e

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