diff --git a/widegraph.cpp b/widegraph.cpp index 1468896..361728e 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -402,9 +402,13 @@ void WideGraph::setFilter(int a, int b){ high = low + m_filterMinWidth; } + int width = high - low; + int center = low + width / 2; + // update the filter history m_filterMinimum = low; m_filterMaximum = high; + m_filterCenter = center; // update the spinner UI bool blocked = false; @@ -420,10 +424,15 @@ void WideGraph::setFilter(int a, int b){ } ui->filterMaxSpinBox->blockSignals(blocked); + blocked = ui->filterCenterSpinBox->blockSignals(true); + { + ui->filterCenterSpinBox->setValue(center); + } + ui->filterCenterSpinBox->blockSignals(blocked); + // update the wide plot UI - int width = high - low; - ui->widePlot->setFilterCenter(low + width/2); - ui->widePlot->setFilterWidth(high - low); + ui->widePlot->setFilterCenter(center); + ui->widePlot->setFilterWidth(width); } void WideGraph::setFilterMinimumBandwidth(int width){ @@ -437,6 +446,7 @@ void WideGraph::setFilterEnabled(bool enabled){ // update the filter spinner ui->filterMinSpinBox->setEnabled(enabled); ui->filterMaxSpinBox->setEnabled(enabled); + ui->filterCenterSpinBox->setEnabled(enabled); // update the checkbox ui bool blocked = ui->filterCheckBox->blockSignals(true); @@ -722,6 +732,11 @@ void WideGraph::on_filterMaxSpinBox_valueChanged(int n){ setFilter(m_filterMinimum, n); } +void WideGraph::on_filterCenterSpinBox_valueChanged(int n){ + int delta = n - m_filterCenter; + setFilter(m_filterMinimum + delta, m_filterMaximum + delta); +} + void WideGraph::on_filterCheckBox_toggled(bool b){ setFilterEnabled(b); } diff --git a/widegraph.h b/widegraph.h index a300d93..fd0392c 100644 --- a/widegraph.h +++ b/widegraph.h @@ -99,6 +99,7 @@ private slots: void on_sbPercent2dPlot_valueChanged(int n); void on_filterMinSpinBox_valueChanged(int n); void on_filterMaxSpinBox_valueChanged(int n); + void on_filterCenterSpinBox_valueChanged(int n); void on_filterCheckBox_toggled(bool b); void on_filterOpacitySpinBox_valueChanged(int n); @@ -126,6 +127,7 @@ private: qint32 m_filterMinWidth; qint32 m_filterMinimum; qint32 m_filterMaximum; + qint32 m_filterCenter; qint32 m_waterfallAvg; qint32 m_TRperiod; qint32 m_nsps;