Skip to content

Commit 573efab

Browse files
committed
Fix calculation of heatmap raster size (fix #8194) - merged for further testing
1 parent 8d75f8e commit 573efab

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/plugins/heatmap/heatmapgui.cpp

+14-9
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ void HeatmapGui::blockAllSignals( bool b )
124124
radiusFieldCombo->blockSignals( b );
125125
advancedGroupBox->blockSignals( b );
126126
kernelShapeCombo->blockSignals( b );
127+
rowsSpinBox->blockSignals( b );
128+
columnsSpinBox->blockSignals( b );
129+
cellXLineEdit->blockSignals( b );
130+
cellYLineEdit->blockSignals( b );
127131
}
128132

129133
/*
@@ -285,15 +289,15 @@ void HeatmapGui::on_rowsSpinBox_valueChanged()
285289
mRows = rowsSpinBox->value();
286290
mYcellsize = mBBox.height() / mRows;
287291
mXcellsize = mYcellsize;
288-
mColumns = max( qRound( mBBox.width() / mXcellsize ), 1 );
292+
mColumns = max( qRound( mBBox.width() / mXcellsize ) + 1, 1 );
289293

290294
updateSize();
291295
}
292296

293297
void HeatmapGui::on_columnsSpinBox_valueChanged()
294298
{
295299
mColumns = columnsSpinBox->value();
296-
mXcellsize = mBBox.width() / mColumns;
300+
mXcellsize = mBBox.width() / ( mColumns - 1 );
297301
mYcellsize = mXcellsize;
298302
mRows = max( qRound( mBBox.height() / mYcellsize ), 1 );
299303

@@ -304,8 +308,8 @@ void HeatmapGui::on_cellXLineEdit_editingFinished()
304308
{
305309
mXcellsize = cellXLineEdit->text().toDouble();
306310
mYcellsize = mXcellsize;
307-
mRows = max( qRound( mBBox.height() / mYcellsize ), 1 );
308-
mColumns = max( qRound( mBBox.width() / mXcellsize ), 1 );
311+
mRows = max( qRound( mBBox.height() / mYcellsize ) + 1, 1 );
312+
mColumns = max( qRound( mBBox.width() / mXcellsize ) + 1, 1 );
309313

310314
updateSize();
311315
}
@@ -314,8 +318,8 @@ void HeatmapGui::on_cellYLineEdit_editingFinished()
314318
{
315319
mYcellsize = cellYLineEdit->text().toDouble();
316320
mXcellsize = mYcellsize;
317-
mRows = max( qRound( mBBox.height() / mYcellsize ), 1 );
318-
mColumns = max( qRound( mBBox.width() / mXcellsize ), 1 );
321+
mRows = max( qRound( mBBox.height() / mYcellsize ) + 1, 1 );
322+
mColumns = max( qRound( mBBox.width() / mXcellsize ) + 1, 1 );
319323

320324
updateSize();
321325
}
@@ -447,10 +451,12 @@ void HeatmapGui::populateFields()
447451

448452
void HeatmapGui::updateSize()
449453
{
454+
blockAllSignals( true );
450455
rowsSpinBox->setValue( mRows );
451456
columnsSpinBox->setValue( mColumns );
452457
cellXLineEdit->setText( QString::number( mXcellsize ) );
453458
cellYLineEdit->setText( QString::number( mYcellsize ) );
459+
blockAllSignals( false );
454460
}
455461

456462
void HeatmapGui::updateBBox()
@@ -496,10 +502,9 @@ void HeatmapGui::updateBBox()
496502
mBBox.setYMaximum( mBBox.yMaximum() + radiusInMapUnits );
497503

498504
// Leave number of rows the same, and calculate new corresponding cell size and number of columns
499-
mYcellsize = mBBox.height() / mRows;
505+
mYcellsize = mBBox.height() / ( mRows - 1 );
500506
mXcellsize = mYcellsize;
501-
mColumns = max( mBBox.width() / mXcellsize, 1 );
502-
507+
mColumns = max( mBBox.width() / mXcellsize + 1, 1 );
503508
updateSize();
504509
}
505510

0 commit comments

Comments
 (0)