mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
Make bar width configurable
This commit is contained in:
parent
04fd6b69b7
commit
55ff09ec3e
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user