Skip to content
Permalink
Browse files

Don't reset output size on radius change (fix #8090)

Prevent input of invalid output size by changing to spin boxes for rows and columns
  • Loading branch information
nyalldawson committed Jun 26, 2013
1 parent 5e760dd commit 65aa1d5ae06e0f28fbbd75355a3c339dc7eb58b4
Showing with 42 additions and 29 deletions.
  1. +20 −21 src/plugins/heatmap/heatmapgui.cpp
  2. +2 −2 src/plugins/heatmap/heatmapgui.h
  3. +20 −6 src/plugins/heatmap/heatmapguibase.ui
@@ -37,7 +37,8 @@
//standard includes

HeatmapGui::HeatmapGui( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
: QDialog( parent, fl ),
mRows( 500 )
{
setupUi( this );

@@ -79,6 +80,8 @@ HeatmapGui::HeatmapGui( QWidget* parent, Qt::WFlags fl )
mFormatCombo->setCurrentIndex( myTiffIndex );

updateBBox();
updateSize();

//finally set right the ok button
enableOrDisableOkButton();
}
@@ -149,22 +152,22 @@ void HeatmapGui::on_advancedGroupBox_toggled( bool enabled )
}
}

void HeatmapGui::on_rowLineEdit_editingFinished()
void HeatmapGui::on_mRowsSpinBox_editingFinished()
{
mRows = rowLineEdit->text().toInt();
mRows = mRowsSpinBox->value();
mYcellsize = mBBox.height() / mRows;
mXcellsize = mYcellsize;
mColumns = mBBox.width() / mXcellsize + 1;
mColumns = max( mBBox.width() / mXcellsize, 1 );

updateSize();
}

void HeatmapGui::on_columnLineEdit_editingFinished()
void HeatmapGui::on_mColumnsSpinBox_editingFinished()
{
mColumns = columnLineEdit->text().toInt();
mColumns = mColumnsSpinBox->value();
mXcellsize = mBBox.width() / mColumns;
mYcellsize = mXcellsize;
mRows = mBBox.height() / mYcellsize + 1;
mRows = max( mBBox.height() / mYcellsize, 1 );

updateSize();
}
@@ -173,8 +176,8 @@ void HeatmapGui::on_cellXLineEdit_editingFinished()
{
mXcellsize = cellXLineEdit->text().toDouble();
mYcellsize = mXcellsize;
mRows = mBBox.height() / mYcellsize + 1;
mColumns = mBBox.width() / mXcellsize + 1;
mRows = max( mBBox.height() / mYcellsize, 1 );
mColumns = max( mBBox.width() / mXcellsize, 1 );

updateSize();
}
@@ -183,8 +186,8 @@ void HeatmapGui::on_cellYLineEdit_editingFinished()
{
mYcellsize = cellYLineEdit->text().toDouble();
mXcellsize = mYcellsize;
mRows = mBBox.height() / mYcellsize + 1;
mColumns = mBBox.width() / mXcellsize + 1;
mRows = max( mBBox.height() / mYcellsize, 1 );
mColumns = max( mBBox.width() / mXcellsize, 1 );

updateSize();
}
@@ -316,8 +319,8 @@ void HeatmapGui::populateFields()

void HeatmapGui::updateSize()
{
rowLineEdit->setText( QString::number( mRows ) );
columnLineEdit->setText( QString::number( mColumns ) );
mRowsSpinBox->setValue( mRows );
mColumnsSpinBox->setValue( mColumns );
cellXLineEdit->setText( QString::number( mXcellsize ) );
cellYLineEdit->setText( QString::number( mYcellsize ) );
}
@@ -363,17 +366,13 @@ void HeatmapGui::updateBBox()
mBBox.setYMinimum( mBBox.yMinimum() - radiusInMapUnits );
mBBox.setXMaximum( mBBox.xMaximum() + radiusInMapUnits );
mBBox.setYMaximum( mBBox.yMaximum() + radiusInMapUnits );
mRows = 500;

// Leave number of rows the same, and calculate new corresponding cell size and number of columns
mYcellsize = mBBox.height() / mRows;
mXcellsize = mYcellsize;
// +1 should be added wherever a fractional part of cell might occur
mColumns = mBBox.width() / mXcellsize + 1;
mRows += 1;
mColumns = max( mBBox.width() / mXcellsize, 1 );

if ( advancedGroupBox->isChecked() )
{
updateSize();
}
updateSize();
}

double HeatmapGui::mapUnitsOf( double meters, QgsCoordinateReferenceSystem layerCrs )
@@ -114,8 +114,8 @@ class HeatmapGui : public QDialog, private Ui::HeatmapGuiBase
void on_mBrowseButton_clicked();
void on_mOutputRasterLineEdit_editingFinished();
void on_advancedGroupBox_toggled( bool enabled );
void on_rowLineEdit_editingFinished();
void on_columnLineEdit_editingFinished();
void on_mRowsSpinBox_editingFinished();
void on_mColumnsSpinBox_editingFinished();
void on_cellXLineEdit_editingFinished();
void on_cellYLineEdit_editingFinished();
void on_radiusFieldCombo_currentIndexChanged( int index );
@@ -130,7 +130,7 @@
<string>Rows</string>
</property>
<property name="buddy">
<cstring>rowLineEdit</cstring>
<cstring>mRowsSpinBox</cstring>
</property>
</widget>
</item>
@@ -150,7 +150,7 @@
<string>Columns</string>
</property>
<property name="buddy">
<cstring>columnLineEdit</cstring>
<cstring>mColumnsSpinBox</cstring>
</property>
</widget>
</item>
@@ -165,10 +165,24 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="rowLineEdit"/>
<widget class="QSpinBox" name="mRowsSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="columnLineEdit"/>
<widget class="QSpinBox" name="mColumnsSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="cellXLineEdit"/>
@@ -292,8 +306,8 @@
<tabstop>mBufferLineEdit</tabstop>
<tabstop>mRadiusUnitCombo</tabstop>
<tabstop>advancedGroupBox</tabstop>
<tabstop>rowLineEdit</tabstop>
<tabstop>columnLineEdit</tabstop>
<tabstop>mRowsSpinBox</tabstop>
<tabstop>mColumnsSpinBox</tabstop>
<tabstop>cellXLineEdit</tabstop>
<tabstop>cellYLineEdit</tabstop>
<tabstop>kernelShapeCombo</tabstop>

0 comments on commit 65aa1d5

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