mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
SoapySDR support: interface for all generic GUI elements
This commit is contained in:
parent
d5ce833668
commit
f79e6bc3ab
@ -8,6 +8,7 @@ set(soapysdrinput_SOURCES
|
|||||||
soapysdrinputplugin.cpp
|
soapysdrinputplugin.cpp
|
||||||
soapysdrinputsettings.cpp
|
soapysdrinputsettings.cpp
|
||||||
soapysdrinputthread.cpp
|
soapysdrinputthread.cpp
|
||||||
|
itemsettinggui.cpp
|
||||||
discreterangegui.cpp
|
discreterangegui.cpp
|
||||||
intervalrangegui.cpp
|
intervalrangegui.cpp
|
||||||
)
|
)
|
||||||
@ -18,6 +19,7 @@ set(soapysdrinput_HEADERS
|
|||||||
soapysdrinputplugin.h
|
soapysdrinputplugin.h
|
||||||
soapysdrinputsettings.h
|
soapysdrinputsettings.h
|
||||||
soapysdrinputthread.h
|
soapysdrinputthread.h
|
||||||
|
itemsettinggui.h
|
||||||
discreterangegui.h
|
discreterangegui.h
|
||||||
intervalrangegui.h
|
intervalrangegui.h
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "discreterangegui.h"
|
#include "discreterangegui.h"
|
||||||
|
|
||||||
DiscreteRangeGUI::DiscreteRangeGUI(QWidget* parent) :
|
DiscreteRangeGUI::DiscreteRangeGUI(QWidget* parent) :
|
||||||
QWidget(parent),
|
ItemSettingGUI(parent),
|
||||||
ui(new Ui::DiscreteRangeGUI)
|
ui(new Ui::DiscreteRangeGUI)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -52,8 +52,26 @@ double DiscreteRangeGUI::getCurrentValue()
|
|||||||
return itemValues[ui->rangeCombo->currentIndex()];
|
return itemValues[ui->rangeCombo->currentIndex()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiscreteRangeGUI::setValue(double value)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
for (const auto &it : itemValues)
|
||||||
|
{
|
||||||
|
if (it >= value)
|
||||||
|
{
|
||||||
|
ui->rangeCombo->blockSignals(true);
|
||||||
|
ui->rangeCombo->setCurrentIndex(index);
|
||||||
|
ui->rangeCombo->blockSignals(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DiscreteRangeGUI::on_rangeCombo_currentIndexChanged(int index)
|
void DiscreteRangeGUI::on_rangeCombo_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
double newRange = itemValues[index];
|
double newRange = itemValues[index];
|
||||||
emit rangeChanged(newRange);
|
emit ItemSettingGUI::valueChanged(newRange);
|
||||||
}
|
}
|
||||||
|
@ -20,24 +20,24 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include "itemsettinggui.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DiscreteRangeGUI;
|
class DiscreteRangeGUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DiscreteRangeGUI : public QWidget
|
class DiscreteRangeGUI : public ItemSettingGUI
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DiscreteRangeGUI(QWidget* parent = 0);
|
explicit DiscreteRangeGUI(QWidget* parent = 0);
|
||||||
~DiscreteRangeGUI();
|
virtual ~DiscreteRangeGUI();
|
||||||
|
|
||||||
void setLabel(const QString& text);
|
void setLabel(const QString& text);
|
||||||
void setUnits(const QString& units);
|
void setUnits(const QString& units);
|
||||||
void addItem(const QString& itemStr, double itemValue);
|
void addItem(const QString& itemStr, double itemValue);
|
||||||
double getCurrentValue();
|
virtual double getCurrentValue();
|
||||||
|
virtual void setValue(double value);
|
||||||
signals:
|
|
||||||
void rangeChanged(double value);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_rangeCombo_currentIndexChanged(int index);
|
void on_rangeCombo_currentIndexChanged(int index);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "intervalrangegui.h"
|
#include "intervalrangegui.h"
|
||||||
|
|
||||||
IntervalRangeGUI::IntervalRangeGUI(QWidget* parent) :
|
IntervalRangeGUI::IntervalRangeGUI(QWidget* parent) :
|
||||||
QWidget(parent),
|
ItemSettingGUI(parent),
|
||||||
ui(new Ui::IntervalRangeGUI),
|
ui(new Ui::IntervalRangeGUI),
|
||||||
m_nbDigits(7)
|
m_nbDigits(7)
|
||||||
{
|
{
|
||||||
@ -83,9 +83,14 @@ double IntervalRangeGUI::getCurrentValue()
|
|||||||
return ui->value->getValue();
|
return ui->value->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IntervalRangeGUI::setValue(double value)
|
||||||
|
{
|
||||||
|
ui->value->setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
void IntervalRangeGUI::on_value_changed(quint64 value)
|
void IntervalRangeGUI::on_value_changed(quint64 value)
|
||||||
{
|
{
|
||||||
emit valueChanged(value);
|
emit ItemSettingGUI::valueChanged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntervalRangeGUI::on_rangeInterval_currentIndexChanged(int index)
|
void IntervalRangeGUI::on_rangeInterval_currentIndexChanged(int index)
|
||||||
|
@ -21,25 +21,25 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include "itemsettinggui.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class IntervalRangeGUI;
|
class IntervalRangeGUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
class IntervalRangeGUI : public QWidget
|
class IntervalRangeGUI : public ItemSettingGUI
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit IntervalRangeGUI(QWidget* parent = 0);
|
explicit IntervalRangeGUI(QWidget* parent = 0);
|
||||||
~IntervalRangeGUI();
|
virtual ~IntervalRangeGUI();
|
||||||
|
|
||||||
void setLabel(const QString& text);
|
void setLabel(const QString& text);
|
||||||
void setUnits(const QString& units);
|
void setUnits(const QString& units);
|
||||||
void addInterval(double minimum, double maximum);
|
void addInterval(double minimum, double maximum);
|
||||||
void reset();
|
void reset();
|
||||||
double getCurrentValue();
|
virtual double getCurrentValue();
|
||||||
|
virtual void setValue(double value);
|
||||||
signals:
|
|
||||||
void valueChanged(double value);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_value_changed(quint64 value);
|
void on_value_changed(quint64 value);
|
||||||
|
11
plugins/samplesource/soapysdrinput/itemsettinggui.cpp
Normal file
11
plugins/samplesource/soapysdrinput/itemsettinggui.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* itemsettinggui.cpp
|
||||||
|
*
|
||||||
|
* Created on: Nov 1, 2018
|
||||||
|
* Author: f4exb
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "itemsettinggui.h"
|
||||||
|
|
||||||
|
ItemSettingGUI::ItemSettingGUI(QWidget *parent) : QWidget(parent) {}
|
||||||
|
|
39
plugins/samplesource/soapysdrinput/itemsettinggui.h
Normal file
39
plugins/samplesource/soapysdrinput/itemsettinggui.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This is an interface to an elementary GUI item used to get/set setting from the GUI
|
||||||
|
|
||||||
|
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_ITEMSETTINGGUI_H_
|
||||||
|
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_ITEMSETTINGGUI_H_
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class ItemSettingGUI : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ItemSettingGUI(QWidget *parent = 0);
|
||||||
|
virtual ~ItemSettingGUI() {}
|
||||||
|
virtual double getCurrentValue() = 0;
|
||||||
|
virtual void setValue(double value) = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void valueChanged(double value);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_ITEMSETTINGGUI_H_ */
|
@ -34,7 +34,8 @@ SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
|||||||
m_sampleSource(0),
|
m_sampleSource(0),
|
||||||
m_sampleRate(0),
|
m_sampleRate(0),
|
||||||
m_deviceCenterFrequency(0),
|
m_deviceCenterFrequency(0),
|
||||||
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
|
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
|
||||||
|
m_sampleRateGUI(0)
|
||||||
{
|
{
|
||||||
m_sampleSource = (SoapySDRInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
|
m_sampleSource = (SoapySDRInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -85,6 +86,8 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
|
|||||||
rangeGUI->addItem(QString("%1").arg(QString::number(it.minimum()/1000.0, 'f', 0)), it.minimum());
|
rangeGUI->addItem(QString("%1").arg(QString::number(it.minimum()/1000.0, 'f', 0)), it.minimum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_sampleRateGUI = rangeGUI;
|
||||||
|
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
|
||||||
// QHBoxLayout *layout = new QHBoxLayout();
|
// QHBoxLayout *layout = new QHBoxLayout();
|
||||||
// QLabel *rangeLabel = new QLabel();
|
// QLabel *rangeLabel = new QLabel();
|
||||||
// rangeLabel->setText(text);
|
// rangeLabel->setText(text);
|
||||||
@ -121,6 +124,9 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rangeGUI->reset();
|
rangeGUI->reset();
|
||||||
|
|
||||||
|
m_sampleRateGUI = rangeGUI;
|
||||||
|
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,4 +170,7 @@ bool SoapySDRInputGui::handleMessage(const Message& message __attribute__((unuse
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoapySDRInputGui::sampleRateChanged(double sampleRate)
|
||||||
|
{
|
||||||
|
qDebug("SoapySDRInputGui::sampleRateChanged: %lf", sampleRate);
|
||||||
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "soapysdrinput.h"
|
#include "soapysdrinput.h"
|
||||||
|
|
||||||
class DeviceUISet;
|
class DeviceUISet;
|
||||||
|
class ItemSettingGUI;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class SoapySDRInputGui;
|
class SoapySDRInputGui;
|
||||||
@ -66,6 +67,11 @@ private:
|
|||||||
quint64 m_deviceCenterFrequency; //!< Center frequency in device
|
quint64 m_deviceCenterFrequency; //!< Center frequency in device
|
||||||
int m_lastEngineState;
|
int m_lastEngineState;
|
||||||
MessageQueue m_inputMessageQueue;
|
MessageQueue m_inputMessageQueue;
|
||||||
|
|
||||||
|
ItemSettingGUI *m_sampleRateGUI;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void sampleRateChanged(double sampleRate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user