1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-29 19:28:47 -05:00

SoapySDR support: GUI component to deal with interval ranges

This commit is contained in:
f4exb 2018-11-01 03:45:21 +01:00
parent cc08f42ea6
commit d5ce833668
5 changed files with 258 additions and 1 deletions

View File

@ -9,6 +9,7 @@ set(soapysdrinput_SOURCES
soapysdrinputsettings.cpp
soapysdrinputthread.cpp
discreterangegui.cpp
intervalrangegui.cpp
)
set(soapysdrinput_HEADERS
@ -18,11 +19,13 @@ set(soapysdrinput_HEADERS
soapysdrinputsettings.h
soapysdrinputthread.h
discreterangegui.h
intervalrangegui.h
)
set(soapysdrinput_FORMS
soapysdrinputgui.ui
discreterangegui.ui
intervalrangegui.ui
)
if (BUILD_DEBIAN)

View File

@ -0,0 +1,95 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 //
// //
// 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) :
QWidget(parent),
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);
ui->value->setValueRange(m_nbDigits, m_minima[0], m_maxima[0]);
}
if (m_minima.size() == 1) {
ui->rangeInterval->setDisabled(true);
}
}
double IntervalRangeGUI::getCurrentValue()
{
return ui->value->getValue();
}
void IntervalRangeGUI::on_value_changed(quint64 value)
{
emit valueChanged(value);
}
void IntervalRangeGUI::on_rangeInterval_currentIndexChanged(int index)
{
ui->value->setValueRange(m_nbDigits, m_minima[index], m_maxima[index]);
}

View File

@ -0,0 +1,55 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_INTERVALRANGEGUI_H_
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_INTERVALRANGEGUI_H_
#include <QWidget>
#include <QString>
namespace Ui {
class IntervalRangeGUI;
}
class IntervalRangeGUI : public QWidget
{
Q_OBJECT
public:
explicit IntervalRangeGUI(QWidget* parent = 0);
~IntervalRangeGUI();
void setLabel(const QString& text);
void setUnits(const QString& units);
void addInterval(double minimum, double maximum);
void reset();
double getCurrentValue();
signals:
void valueChanged(double value);
private slots:
void on_value_changed(quint64 value);
void on_rangeInterval_currentIndexChanged(int index);
private:
Ui::IntervalRangeGUI* ui;
std::vector<double> m_minima;
std::vector<double> m_maxima;
int m_nbDigits;
};
#endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_INTERVALRANGEGUI_H_ */

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>IntervalRangeGUI</class>
<widget class="QWidget" name="IntervalRangeGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>263</width>
<height>30</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>262</width>
<height>29</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="rangeLabel">
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item>
<widget class="ValueDial" name="value" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rangeUnits">
<property name="text">
<string>Unit</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="rangeInterval">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Range select</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -22,6 +22,7 @@
#include "ui_soapysdrinputgui.h"
#include "discreterangegui.h"
#include "intervalrangegui.h"
#include "soapysdrinputgui.h"
SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
@ -43,7 +44,7 @@ SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_sampleSource->getFrequencyRange(f_min, f_max);
ui->centerFrequency->setValueRange(7, f_min/1000, f_max/1000);
createRangesControl(m_sampleSource->getRateRanges(), "Sample Rate", "kS/s");
createRangesControl(m_sampleSource->getRateRanges(), "SR", "kS/s");
}
SoapySDRInputGui::~SoapySDRInputGui()
@ -109,6 +110,18 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
// //window->setStyleSheet("background-color:black;");
// window->setLayout(layout);
}
else if (rangeInterval)
{
IntervalRangeGUI *rangeGUI = new IntervalRangeGUI(ui->scrollAreaWidgetContents);
rangeGUI->setLabel(text);
rangeGUI->setUnits(unit);
for (const auto &it : rangeList) {
rangeGUI->addInterval(it.minimum(), it.maximum());
}
rangeGUI->reset();
}
}
void SoapySDRInputGui::setName(const QString& name)