Skip to content

Commit

Permalink
[Diagrams] UI-Improvements
Browse files Browse the repository at this point in the history
 * Do not allow "fixed size" histograms (makes no sense)
 * Rewire slots and signals for the fixed size
 * Default pie dimensions set to 50 mm
  • Loading branch information
m-kuhn committed May 1, 2013
1 parent 9e870c7 commit 3c68312
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
30 changes: 22 additions & 8 deletions src/app/qgsdiagramproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,10 @@ void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( int inde
mBarWidthLabel->show();
mBarWidthSpinBox->show();
mOrientationFrame->show();
mLinearlyScalingLabel->setText( tr( "Multiplicator for attribute values:" ) );
mAttributeBasedScalingOptions->hide();
mFixedSizeCheckBox->setChecked( false );
mFixedSizeCheckBox->setVisible( false );
mDiagramSizeSpinBox->setVisible( false );
mLinearlyScalingLabel->setText( tr( "Bar length: Scale linearly, such as the following value matches the specified size." ) );
}
else
{
Expand All @@ -335,6 +337,8 @@ void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( int inde
mOrientationFrame->hide();
mLinearlyScalingLabel->setText( tr( "Scale linearly between 0 and the following attribute value / diagram size:" ) );
mAttributeBasedScalingOptions->show();
mFixedSizeCheckBox->setVisible( true );
mDiagramSizeSpinBox->setVisible( true );
}

if ( DIAGRAM_NAME_HISTOGRAM == diagramType || DIAGRAM_NAME_TEXT == diagramType )
Expand Down Expand Up @@ -469,23 +473,33 @@ void QgsDiagramProperties::apply()
}
else
{
QgsDiagram* diagram = 0;
int index = mDiagramTypeComboBox->currentIndex();
QString diagramType = mDiagramTypeComboBox->itemData( index ).toString();

if ( 0 == mDiagramAttributesTreeWidget->topLevelItemCount() )
{
QMessageBox::warning( this, tr( "No attributes added." ),
tr( "You did not add any attributes to this diagram layer. Please specify the attributes to visualize on the diagrams or disable diagrams." ), QMessageBox::Ok );
}

bool scaleAttributeValueIsNumeric;
mValueLineEdit->text().toDouble( &scaleAttributeValueIsNumeric );
if ( !mFixedSizeCheckBox->isChecked() && !scaleAttributeValueIsNumeric )
bool scaleAttributeValueOk = false;
if ( diagramType == DIAGRAM_NAME_HISTOGRAM )
{
// We don't need a scale attribute, the field is used as a multiplicator
scaleAttributeValueOk = true;
}
else
{
// Check if a (usable) scale attribute value is inserted
mValueLineEdit->text().toDouble( &scaleAttributeValueOk );
}
if ( !mFixedSizeCheckBox->isChecked() && !scaleAttributeValueOk )
{
QMessageBox::warning( this, tr( "No attribute value specified" ),
tr( "You did not specify a maximum value for the diagram size. Please specify the attribute and a reference value as a base for scaling in the Tab Diagram / Size." ), QMessageBox::Ok );
}

QgsDiagram* diagram = 0;
int index = mDiagramTypeComboBox->currentIndex();
QString diagramType = mDiagramTypeComboBox->itemData( index ).toString();
if ( diagramType == DIAGRAM_NAME_TEXT )
{
diagram = new QgsTextDiagram();
Expand Down
2 changes: 1 addition & 1 deletion src/core/diagram/qgshistogramdiagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributes& attributes, const
{
case QgsDiagramSettings::Up:
case QgsDiagramSettings::Down:
mScaleFactor = (( is.upperSize.width() - is.lowerSize.height() ) / ( is.upperValue - is.lowerValue ) );
mScaleFactor = ( ( is.upperSize.width() - is.lowerSize.height() ) / ( is.upperValue - is.lowerValue ) );
size.scale( s.barWidth * attributes.size(), maxValue * mScaleFactor, Qt::IgnoreAspectRatio );
break;

Expand Down
40 changes: 38 additions & 2 deletions src/ui/qgsdiagrampropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="mLinearlyScalingLabel">
<property name="text">
Expand Down Expand Up @@ -441,7 +444,7 @@
<number>10000000</number>
</property>
<property name="value">
<number>100</number>
<number>50</number>
</property>
</widget>
</item>
Expand Down Expand Up @@ -952,7 +955,40 @@
<resources>
<include location="../../images/images.qrc"/>
</resources>
<connections/>
<connections>
<connection>
<sender>mFixedSizeCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>mDiagramSizeSpinBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>48</x>
<y>122</y>
</hint>
<hint type="destinationlabel">
<x>78</x>
<y>122</y>
</hint>
</hints>
</connection>
<connection>
<sender>mFixedSizeCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>mLinearScaleFrame</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>48</x>
<y>122</y>
</hint>
<hint type="destinationlabel">
<x>77</x>
<y>132</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="mOrientationButtonGroup"/>
</buttongroups>
Expand Down

0 comments on commit 3c68312

Please sign in to comment.