2018-10-31 22:45:21 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 08:43:33 -04:00
|
|
|
// (at your option) any later version. //
|
2018-10-31 22:45:21 -04:00
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "ui_intervalrangegui.h"
|
|
|
|
#include "intervalrangegui.h"
|
|
|
|
|
|
|
|
IntervalRangeGUI::IntervalRangeGUI(QWidget* parent) :
|
2018-11-01 05:06:27 -04:00
|
|
|
ItemSettingGUI(parent),
|
2018-10-31 22:45:21 -04:00
|
|
|
ui(new Ui::IntervalRangeGUI),
|
|
|
|
m_nbDigits(7)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->value->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
|
|
|
}
|
|
|
|
|
|
|
|
IntervalRangeGUI::~IntervalRangeGUI()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntervalRangeGUI::setLabel(const QString& text)
|
|
|
|
{
|
|
|
|
ui->rangeLabel->setText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntervalRangeGUI::setUnits(const QString& units)
|
|
|
|
{
|
|
|
|
ui->rangeUnits->setText(units);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntervalRangeGUI::addInterval(double minimum, double maximum)
|
|
|
|
{
|
|
|
|
ui->rangeInterval->blockSignals(true);
|
|
|
|
ui->rangeInterval->addItem(QString("%1").arg(m_minima.size()));
|
|
|
|
ui->rangeInterval->blockSignals(false);
|
|
|
|
m_minima.push_back(minimum);
|
|
|
|
m_maxima.push_back(maximum);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntervalRangeGUI::reset()
|
|
|
|
{
|
|
|
|
if (m_minima.size() > 0)
|
|
|
|
{
|
|
|
|
double maxLog = 0.0;
|
|
|
|
|
|
|
|
for (const auto &it : m_maxima)
|
|
|
|
{
|
|
|
|
if (log10(it) > maxLog) {
|
|
|
|
maxLog = log10(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_nbDigits = maxLog;
|
|
|
|
m_nbDigits++;
|
|
|
|
ui->rangeInterval->blockSignals(true);
|
|
|
|
ui->rangeInterval->setCurrentIndex(0);
|
|
|
|
ui->rangeInterval->blockSignals(false);
|
2018-11-06 02:32:47 -05:00
|
|
|
ui->value->setValueRange(m_minima[0] >= 0, m_nbDigits, m_minima[0], m_maxima[0]);
|
2018-10-31 22:45:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_minima.size() == 1) {
|
|
|
|
ui->rangeInterval->setDisabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double IntervalRangeGUI::getCurrentValue()
|
|
|
|
{
|
2018-11-11 03:57:28 -05:00
|
|
|
return ui->value->getValueNew();
|
2018-10-31 22:45:21 -04:00
|
|
|
}
|
|
|
|
|
2018-11-01 05:06:27 -04:00
|
|
|
void IntervalRangeGUI::setValue(double value)
|
|
|
|
{
|
|
|
|
ui->value->setValue(value);
|
|
|
|
}
|
|
|
|
|
2018-11-06 02:32:47 -05:00
|
|
|
void IntervalRangeGUI::on_value_changed(qint64 value)
|
2018-10-31 22:45:21 -04:00
|
|
|
{
|
2018-11-01 05:06:27 -04:00
|
|
|
emit ItemSettingGUI::valueChanged(value);
|
2018-10-31 22:45:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void IntervalRangeGUI::on_rangeInterval_currentIndexChanged(int index)
|
|
|
|
{
|
2018-11-06 02:32:47 -05:00
|
|
|
ui->value->setValueRange(m_minima[index] >= 0, m_nbDigits, m_minima[index], m_maxima[index]);
|
2018-11-04 20:40:02 -05:00
|
|
|
emit ItemSettingGUI::valueChanged(ui->value->getValueNew());
|
2018-10-31 22:45:21 -04:00
|
|
|
}
|
|
|
|
|