mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 05:41:56 -05:00
Removed SpectrumVis from GUI dependency
This commit is contained in:
parent
93c13e449c
commit
6a6b5f8d7e
@ -126,6 +126,7 @@ set(sdrbase_SOURCES
|
||||
dsp/devicesamplesink.cpp
|
||||
dsp/devicesamplemimo.cpp
|
||||
dsp/devicesamplestatic.cpp
|
||||
dsp/spectrumvis.cpp
|
||||
|
||||
device/deviceapi.cpp
|
||||
device/deviceenumerator.cpp
|
||||
@ -268,6 +269,7 @@ set(sdrbase_HEADERS
|
||||
dsp/devicesamplesink.h
|
||||
dsp/devicesamplemimo.h
|
||||
dsp/devicesamplestatic.h
|
||||
dsp/spectrumvis.h
|
||||
|
||||
device/deviceapi.h
|
||||
device/deviceenumerator.h
|
||||
|
32
sdrbase/dsp/glspectruminterface.h
Normal file
32
sdrbase/dsp/glspectruminterface.h
Normal file
@ -0,0 +1,32 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 SDRBASE_DSP_GLSPECTRUMINTERFACE_H_
|
||||
#define SDRBASE_DSP_GLSPECTRUMINTERFACE_H_
|
||||
|
||||
#include <vector>
|
||||
#include "dsptypes.h"
|
||||
|
||||
class GLSpectrumInterface
|
||||
{
|
||||
public:
|
||||
GLSpectrumInterface() {}
|
||||
virtual ~GLSpectrumInterface() {}
|
||||
virtual void newSpectrum(const std::vector<Real>& spectrum, int fftSize) {}
|
||||
};
|
||||
|
||||
#endif // SDRBASE_DSP_GLSPECTRUMINTERFACE_H_
|
@ -1,10 +1,31 @@
|
||||
#include "dsp/spectrumvis.h"
|
||||
#include "gui/glspectrum.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/fftfactory.h"
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015-2020 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// Symbol synchronizer or symbol clock recovery mostly encapsulating //
|
||||
// liquid-dsp's symsync "object" //
|
||||
// //
|
||||
// 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 "glspectruminterface.h"
|
||||
#include "dspcommands.h"
|
||||
#include "dspengine.h"
|
||||
#include "fftfactory.h"
|
||||
#include "util/messagequeue.h"
|
||||
|
||||
#include "spectrumvis.h"
|
||||
|
||||
#define MAX_FFT_SIZE 4096
|
||||
|
||||
#ifndef LINUX
|
||||
@ -19,7 +40,7 @@ MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureScalingFactor, Message)
|
||||
|
||||
const Real SpectrumVis::m_mult = (10.0f / log2f(10.0f));
|
||||
|
||||
SpectrumVis::SpectrumVis(Real scalef, GLSpectrum* glSpectrum) :
|
||||
SpectrumVis::SpectrumVis(Real scalef, GLSpectrumInterface* glSpectrum) :
|
||||
BasebandSampleSink(),
|
||||
m_fft(nullptr),
|
||||
m_fftEngineSequence(0),
|
@ -1,3 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015-2020 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// Symbol synchronizer or symbol clock recovery mostly encapsulating //
|
||||
// liquid-dsp's symsync "object" //
|
||||
// //
|
||||
// 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 INCLUDE_SPECTRUMVIS_H
|
||||
#define INCLUDE_SPECTRUMVIS_H
|
||||
|
||||
@ -11,7 +31,7 @@
|
||||
#include "util/fixedaverage2d.h"
|
||||
#include "util/max2d.h"
|
||||
|
||||
class GLSpectrum;
|
||||
class GLSpectrumInterface;
|
||||
class MessageQueue;
|
||||
|
||||
class SDRGUI_API SpectrumVis : public BasebandSampleSink {
|
||||
@ -77,7 +97,7 @@ public:
|
||||
Real m_scalef;
|
||||
};
|
||||
|
||||
SpectrumVis(Real scalef, GLSpectrum* glSpectrum = 0);
|
||||
SpectrumVis(Real scalef, GLSpectrumInterface* glSpectrum = nullptr);
|
||||
virtual ~SpectrumVis();
|
||||
|
||||
void configure(MessageQueue* msgQueue,
|
||||
@ -111,7 +131,7 @@ private:
|
||||
bool m_needMoreSamples;
|
||||
|
||||
Real m_scalef;
|
||||
GLSpectrum* m_glSpectrum;
|
||||
GLSpectrumInterface* m_glSpectrum;
|
||||
MovingAverage2D<double> m_movingAverage;
|
||||
FixedAverage2D<double> m_fixedAverage;
|
||||
Max2D<double> m_max;
|
@ -56,7 +56,6 @@ set(sdrgui_SOURCES
|
||||
|
||||
dsp/scopevis.cpp
|
||||
dsp/scopevisxy.cpp
|
||||
dsp/spectrumvis.cpp
|
||||
dsp/spectrumscopecombovis.cpp
|
||||
|
||||
device/deviceuiset.cpp
|
||||
@ -129,7 +128,6 @@ set(sdrgui_HEADERS
|
||||
|
||||
dsp/scopevis.h
|
||||
dsp/scopevisxy.h
|
||||
dsp/spectrumvis.h
|
||||
dsp/spectrumscopecombovis.h
|
||||
|
||||
device/deviceuiset.h
|
||||
|
@ -156,17 +156,22 @@ GLSpectrum::~GLSpectrum()
|
||||
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if(m_waterfallBuffer != NULL) {
|
||||
if (m_waterfallBuffer)
|
||||
{
|
||||
delete m_waterfallBuffer;
|
||||
m_waterfallBuffer = NULL;
|
||||
m_waterfallBuffer = nullptr;
|
||||
}
|
||||
if(m_histogramBuffer != NULL) {
|
||||
|
||||
if (m_histogramBuffer)
|
||||
{
|
||||
delete m_histogramBuffer;
|
||||
m_histogramBuffer = NULL;
|
||||
m_histogramBuffer = nullptr;
|
||||
}
|
||||
if(m_histogram != NULL) {
|
||||
|
||||
if (m_histogram)
|
||||
{
|
||||
delete[] m_histogram;
|
||||
m_histogram = NULL;
|
||||
m_histogram = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,23 +309,27 @@ void GLSpectrum::setDisplayGrid(bool display)
|
||||
void GLSpectrum::setDisplayGridIntensity(int intensity)
|
||||
{
|
||||
m_displayGridIntensity = intensity;
|
||||
|
||||
if (m_displayGridIntensity > 100) {
|
||||
m_displayGridIntensity = 100;
|
||||
} else if (m_displayGridIntensity < 0) {
|
||||
m_displayGridIntensity = 0;
|
||||
}
|
||||
update();
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void GLSpectrum::setDisplayTraceIntensity(int intensity)
|
||||
{
|
||||
m_displayTraceIntensity = intensity;
|
||||
|
||||
if (m_displayTraceIntensity > 100) {
|
||||
m_displayTraceIntensity = 100;
|
||||
} else if (m_displayTraceIntensity < 0) {
|
||||
m_displayTraceIntensity = 0;
|
||||
}
|
||||
update();
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void GLSpectrum::setLinear(bool linear)
|
||||
@ -371,12 +380,14 @@ void GLSpectrum::newSpectrum(const std::vector<Real>& spectrum, int fftSize)
|
||||
|
||||
m_displayChanged = true;
|
||||
|
||||
if(m_changesPending) {
|
||||
if (m_changesPending)
|
||||
{
|
||||
m_fftSize = fftSize;
|
||||
return;
|
||||
}
|
||||
|
||||
if(fftSize != m_fftSize) {
|
||||
if (fftSize != m_fftSize)
|
||||
{
|
||||
m_fftSize = fftSize;
|
||||
m_changesPending = true;
|
||||
return;
|
||||
@ -388,15 +399,19 @@ void GLSpectrum::newSpectrum(const std::vector<Real>& spectrum, int fftSize)
|
||||
|
||||
void GLSpectrum::updateWaterfall(const std::vector<Real>& spectrum)
|
||||
{
|
||||
if(m_waterfallBufferPos < m_waterfallBuffer->height()) {
|
||||
if (m_waterfallBufferPos < m_waterfallBuffer->height())
|
||||
{
|
||||
quint32* pix = (quint32*)m_waterfallBuffer->scanLine(m_waterfallBufferPos);
|
||||
|
||||
for(int i = 0; i < m_fftSize; i++) {
|
||||
for (int i = 0; i < m_fftSize; i++)
|
||||
{
|
||||
int v = (int)((spectrum[i] - m_referenceLevel) * 2.4 * 100.0 / m_powerRange + 240.0);
|
||||
if(v > 239)
|
||||
|
||||
if (v > 239) {
|
||||
v = 239;
|
||||
else if(v < 0)
|
||||
} else if (v < 0) {
|
||||
v = 0;
|
||||
}
|
||||
|
||||
*pix++ = m_waterfallPalette[(int)v];
|
||||
}
|
||||
@ -522,7 +537,8 @@ void GLSpectrum::initializeGL()
|
||||
{
|
||||
QOpenGLContext *glCurrentContext = QOpenGLContext::currentContext();
|
||||
|
||||
if (glCurrentContext) {
|
||||
if (glCurrentContext)
|
||||
{
|
||||
if (QOpenGLContext::currentContext()->isValid()) {
|
||||
qDebug() << "GLSpectrum::initializeGL: context:"
|
||||
<< " major: " << (QOpenGLContext::currentContext()->format()).majorVersion()
|
||||
@ -532,7 +548,9 @@ void GLSpectrum::initializeGL()
|
||||
else {
|
||||
qDebug() << "GLSpectrum::initializeGL: current context is invalid";
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "GLSpectrum::initializeGL: no current context";
|
||||
return;
|
||||
}
|
||||
@ -1593,7 +1611,7 @@ void GLSpectrum::applyChanges()
|
||||
|
||||
bool fftSizeChanged = true;
|
||||
|
||||
if(m_waterfallBuffer != NULL) {
|
||||
if (m_waterfallBuffer) {
|
||||
fftSizeChanged = m_waterfallBuffer->width() != m_fftSize;
|
||||
}
|
||||
|
||||
@ -1601,7 +1619,7 @@ void GLSpectrum::applyChanges()
|
||||
|
||||
if (fftSizeChanged || windowSizeChanged)
|
||||
{
|
||||
if(m_waterfallBuffer != 0) {
|
||||
if (m_waterfallBuffer) {
|
||||
delete m_waterfallBuffer;
|
||||
}
|
||||
|
||||
@ -1614,13 +1632,15 @@ void GLSpectrum::applyChanges()
|
||||
|
||||
if(fftSizeChanged)
|
||||
{
|
||||
if(m_histogramBuffer != NULL) {
|
||||
if (m_histogramBuffer)
|
||||
{
|
||||
delete m_histogramBuffer;
|
||||
m_histogramBuffer = NULL;
|
||||
m_histogramBuffer = nullptr;
|
||||
}
|
||||
if(m_histogram != NULL) {
|
||||
|
||||
if (m_histogram) {
|
||||
delete[] m_histogram;
|
||||
m_histogram = NULL;
|
||||
m_histogram = nullptr;
|
||||
}
|
||||
|
||||
m_histogramBuffer = new QImage(m_fftSize, 100, QImage::Format_RGB32);
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QMatrix4x4>
|
||||
#include <QGLWidget>
|
||||
#include "dsp/dsptypes.h"
|
||||
#include "dsp/glspectruminterface.h"
|
||||
#include "gui/scaleengine.h"
|
||||
#include "gui/glshadersimple.h"
|
||||
#include "gui/glshadertextured.h"
|
||||
@ -40,7 +40,7 @@
|
||||
class QOpenGLShaderProgram;
|
||||
class MessageQueue;
|
||||
|
||||
class SDRGUI_API GLSpectrum : public QGLWidget {
|
||||
class SDRGUI_API GLSpectrum : public QGLWidget, public GLSpectrumInterface {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -61,8 +61,8 @@ public:
|
||||
quint32 m_sampleRate;
|
||||
};
|
||||
|
||||
GLSpectrum(QWidget* parent = NULL);
|
||||
~GLSpectrum();
|
||||
GLSpectrum(QWidget* parent = nullptr);
|
||||
virtual ~GLSpectrum();
|
||||
|
||||
void setCenterFrequency(qint64 frequency);
|
||||
void setSampleRate(qint32 sampleRate);
|
||||
@ -89,7 +89,7 @@ public:
|
||||
void removeChannelMarker(ChannelMarker* channelMarker);
|
||||
void setMessageQueueToGUI(MessageQueue* messageQueue) { m_messageQueueToGUI = messageQueue; }
|
||||
|
||||
void newSpectrum(const std::vector<Real>& spectrum, int fftSize);
|
||||
virtual void newSpectrum(const std::vector<Real>& spectrum, int fftSize);
|
||||
void clearSpectrumHistogram();
|
||||
|
||||
Real getWaterfallShare() const { return m_waterfallShare; }
|
||||
|
Loading…
Reference in New Issue
Block a user