SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
intervalrangegui.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include <math.h>
19 
20 #include "ui_intervalrangegui.h"
21 #include "intervalrangegui.h"
22 
24  ItemSettingGUI(parent),
25  ui(new Ui::IntervalRangeGUI),
26  m_nbDigits(7)
27 {
28  ui->setupUi(this);
29  ui->value->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
30 }
31 
33 {
34  delete ui;
35 }
36 
37 void IntervalRangeGUI::setLabel(const QString& text)
38 {
39  ui->rangeLabel->setText(text);
40 }
41 
42 void IntervalRangeGUI::setUnits(const QString& units)
43 {
44  ui->rangeUnits->setText(units);
45 }
46 
47 void IntervalRangeGUI::addInterval(double minimum, double maximum)
48 {
49  ui->rangeInterval->blockSignals(true);
50  ui->rangeInterval->addItem(QString("%1").arg(m_minima.size()));
51  ui->rangeInterval->blockSignals(false);
52  m_minima.push_back(minimum);
53  m_maxima.push_back(maximum);
54 }
55 
57 {
58  if (m_minima.size() > 0)
59  {
60  double maxLog = 0.0;
61 
62  for (const auto &it : m_maxima)
63  {
64  if (log10(it) > maxLog) {
65  maxLog = log10(it);
66  }
67  }
68 
69  m_nbDigits = maxLog;
70  m_nbDigits++;
71  ui->rangeInterval->blockSignals(true);
72  ui->rangeInterval->setCurrentIndex(0);
73  ui->rangeInterval->blockSignals(false);
74  ui->value->setValueRange(m_minima[0] >= 0, m_nbDigits, m_minima[0], m_maxima[0]);
75  }
76 
77  if (m_minima.size() == 1) {
78  ui->rangeInterval->setDisabled(true);
79  }
80 }
81 
83 {
84  return ui->value->getValueNew();
85 }
86 
87 void IntervalRangeGUI::setValue(double value)
88 {
89  ui->value->setValue(value);
90 }
91 
93 {
94  emit ItemSettingGUI::valueChanged(value);
95 }
96 
98 {
99  ui->value->setValueRange(m_minima[index] >= 0, m_nbDigits, m_minima[index], m_maxima[index]);
100  emit ItemSettingGUI::valueChanged(ui->value->getValueNew());
101 }
102 
void on_value_changed(qint64 value)
std::vector< double > m_maxima
void valueChanged(double value)
void on_rangeInterval_currentIndexChanged(int index)
virtual double getCurrentValue()
std::vector< double > m_minima
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
virtual void setValue(double value)
Ui::IntervalRangeGUI * ui
void setLabel(const QString &text)
virtual ~IntervalRangeGUI()
IntervalRangeGUI(QWidget *parent=0)
void addInterval(double minimum, double maximum)
void setUnits(const QString &units)