Move GLSpectrum to GLSpectrumView and create new GLSpectrum that instances GLSpectrumView and SpectrumMeasurements

This commit is contained in:
Jon Beniston 2022-09-29 13:48:04 +01:00
parent d00862d4f1
commit 7c5249149a
17 changed files with 5374 additions and 5320 deletions

View File

@ -23,7 +23,7 @@
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "gui/glspectrum.h"
#include "gui/glspectrumtop.h"
#include "gui/glspectrumview.h"
#include "gui/glscope.h"
#include "gui/basicchannelsettingsdialog.h"
#include "plugin/pluginapi.h"
@ -193,17 +193,17 @@ void ChannelAnalyzerGUI::setSpectrumDisplay()
qDebug("ChannelAnalyzerGUI::setSpectrumDisplay: m_sinkSampleRate: %d", sinkSampleRate);
if (m_settings.m_ssb)
{
ui->glSpectrumTop->getSpectrum()->setCenterFrequency(sinkSampleRate/4);
ui->glSpectrumTop->getSpectrum()->setSampleRate(sinkSampleRate/2);
ui->glSpectrumTop->getSpectrum()->setSsbSpectrum(true);
ui->glSpectrumTop->getSpectrum()->setLsbDisplay(ui->BW->value() < 0);
ui->glSpectrum->setCenterFrequency(sinkSampleRate/4);
ui->glSpectrum->setSampleRate(sinkSampleRate/2);
ui->glSpectrum->setSsbSpectrum(true);
ui->glSpectrum->setLsbDisplay(ui->BW->value() < 0);
}
else
{
ui->glSpectrumTop->getSpectrum()->setCenterFrequency(0);
ui->glSpectrumTop->getSpectrum()->setSampleRate(sinkSampleRate);
ui->glSpectrumTop->getSpectrum()->setSsbSpectrum(false);
ui->glSpectrumTop->getSpectrum()->setLsbDisplay(false);
ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(sinkSampleRate);
ui->glSpectrum->setSsbSpectrum(false);
ui->glSpectrum->setLsbDisplay(false);
}
}
@ -543,7 +543,7 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
m_basebandSampleRate = m_channelAnalyzer->getChannelSampleRate();
qDebug("ChannelAnalyzerGUI::ChannelAnalyzerGUI: m_basebandSampleRate: %d", m_basebandSampleRate);
m_spectrumVis = m_channelAnalyzer->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrumTop->getSpectrum());
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_scopeVis = m_channelAnalyzer->getScopeVis();
m_scopeVis->setGLScope(ui->glScope);
m_basebandSampleRate = m_channelAnalyzer->getChannelSampleRate();
@ -557,12 +557,12 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
ui->rationalDownSamplerRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
ui->glSpectrumTop->getSpectrum()->setCenterFrequency(m_basebandSampleRate/2);
ui->glSpectrumTop->getSpectrum()->setSampleRate(m_basebandSampleRate);
ui->glSpectrumTop->getSpectrum()->setDisplayWaterfall(true);
ui->glSpectrumTop->getSpectrum()->setDisplayMaxHold(true);
ui->glSpectrumTop->getSpectrum()->setSsbSpectrum(false);
ui->glSpectrumTop->getSpectrum()->setLsbDisplay(false);
ui->glSpectrum->setCenterFrequency(m_basebandSampleRate/2);
ui->glSpectrum->setSampleRate(m_basebandSampleRate);
ui->glSpectrum->setDisplayWaterfall(true);
ui->glSpectrum->setDisplayMaxHold(true);
ui->glSpectrum->setSsbSpectrum(false);
ui->glSpectrum->setLsbDisplay(false);
ui->glScope->connectTimer(MainCore::instance()->getMasterTimer());
connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
@ -579,7 +579,7 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
m_deviceUISet->addChannelMarker(&m_channelMarker);
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrumTop->getSpectrum(), ui->glSpectrumTop);
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
m_settings.setChannelMarker(&m_channelMarker);
@ -695,7 +695,7 @@ void ChannelAnalyzerGUI::setFiltersUIBoundaries()
void ChannelAnalyzerGUI::blockApplySettings(bool block)
{
ui->glScope->blockSignals(block);
ui->glSpectrumTop->getSpectrum()->blockSignals(block);
ui->glSpectrum->blockSignals(block);
m_doApplySettings = !block;
}

View File

@ -899,7 +899,7 @@
<number>2</number>
</property>
<item>
<widget class="GLSpectrumTop" name="glSpectrumTop" native="true">
<widget class="GLSpectrum" name="glSpectrum" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -1018,9 +1018,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumTop</class>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrumtop.h</header>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>

View File

@ -51,7 +51,7 @@ set(sdrgui_SOURCES
gui/glshadertvarray.cpp
gui/glspectrum.cpp
gui/glspectrumgui.cpp
gui/glspectrumtop.cpp
gui/glspectrumview.cpp
gui/graphicsdialog.cpp
gui/graphicsviewzoom.cpp
gui/httpdownloadmanagergui.cpp
@ -157,7 +157,7 @@ set(sdrgui_HEADERS
gui/glshadertextured.h
gui/glspectrum.h
gui/glspectrumgui.h
gui/glspectrumtop.h
gui/glspectrumview.h
gui/graphicsdialog.h
gui/graphicsviewzoom.h
gui/httpdownloadmanagergui.h

View File

@ -23,7 +23,7 @@
#include "dsp/dspdevicesourceengine.h"
#include "dsp/dspdevicesinkengine.h"
#include "gui/glspectrum.h"
#include "gui/glspectrumtop.h"
#include "gui/glspectrumview.h"
#include "gui/glspectrumgui.h"
// #include "gui/channelwindow.h"
#include "gui/workspace.h"
@ -43,14 +43,13 @@
DeviceUISet::DeviceUISet(int deviceSetIndex, DeviceSet *deviceSet)
{
m_spectrumTop = new GLSpectrumTop();
m_spectrum = m_spectrumTop->getSpectrum();
m_spectrum = new GLSpectrum();
m_spectrum->setIsDeviceSpectrum(true);
m_spectrumVis = deviceSet->m_spectrumVis;
m_spectrumVis->setGLSpectrum(m_spectrum);
m_spectrumGUI = new GLSpectrumGUI;
m_spectrumGUI->setBuddies(m_spectrumVis, m_spectrum, m_spectrumTop);
m_mainSpectrumGUI = new MainSpectrumGUI(m_spectrumTop, m_spectrum, m_spectrumGUI);
m_spectrumGUI->setBuddies(m_spectrumVis, m_spectrum);
m_mainSpectrumGUI = new MainSpectrumGUI(m_spectrum, m_spectrumGUI);
// m_channelWindow = new ChannelWindow;
m_deviceAPI = nullptr;
m_deviceGUI = nullptr;

View File

@ -54,7 +54,6 @@ class SDRGUI_API DeviceUISet : public QObject
Q_OBJECT
public:
SpectrumVis *m_spectrumVis;
GLSpectrumTop *m_spectrumTop;
GLSpectrum *m_spectrum;
GLSpectrumGUI *m_spectrumGUI;
MainSpectrumGUI *m_mainSpectrumGUI;

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 F4EXB //
// written by Edouard Griffiths //
// //
// OpenGL interface modernization. //
// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html //
// Copyright (C) 2022 Jon Beniston, M7RCE //
// //
// 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 //
@ -19,479 +15,102 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_GLSPECTRUM_H
#define INCLUDE_GLSPECTRUM_H
#ifndef SDRGUI_GLSPECTRUM_H_
#define SDRGUI_GLSPECTRUM_H_
#include <QWidget>
#include <QTimer>
#include <QMutex>
#include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject>
#include <QMatrix4x4>
#include <QPoint>
#include <QOpenGLWidget>
#include <QOpenGLDebugLogger>
#include "gui/scaleengine.h"
#include "gui/glshadersimple.h"
#include "gui/glshadertextured.h"
#include "gui/glshadercolormap.h"
#include "dsp/glspectruminterface.h"
#include "gui/glshaderspectrogram.h"
#include "dsp/spectrummarkers.h"
#include "dsp/channelmarker.h"
#include "dsp/spectrumsettings.h"
#include "export.h"
#include "util/incrementalarray.h"
#include "util/message.h"
#include "util/colormap.h"
#include "glspectrumview.h"
class QOpenGLShaderProgram;
class MessageQueue;
class SpectrumVis;
class QOpenGLDebugLogger;
class QSplitter;
class SpectrumMeasurements;
class SDRGUI_API GLSpectrum : public QOpenGLWidget, public GLSpectrumInterface {
// Combines GLSpectrumView with SpectrumMeasurements in a QSplitter
class SDRGUI_API GLSpectrum : public QWidget, public GLSpectrumInterface {
Q_OBJECT
public:
class MsgReportSampleRate : public Message {
MESSAGE_CLASS_DECLARATION
GLSpectrum(QWidget *parent = nullptr);
GLSpectrumView *getSpectrumView() const { return m_spectrum; }
SpectrumMeasurements *getMeasurements() const { return m_measurements; }
void setMeasurementsVisible(bool visible);
void setMeasurementsPosition(SpectrumSettings::MeasurementsPosition position);
public:
MsgReportSampleRate(quint32 sampleRate) :
Message(),
m_sampleRate(sampleRate)
{}
quint32 getSampleRate() const { return m_sampleRate; }
private:
quint32 m_sampleRate;
};
class MsgReportWaterfallShare : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportWaterfallShare(Real waterfallShare) :
Message(),
m_waterfallShare(waterfallShare)
{}
Real getWaterfallShare() const { return m_waterfallShare; }
private:
Real m_waterfallShare;
};
class MsgReportFFTOverlap : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportFFTOverlap(int overlap) :
Message(),
m_overlap(overlap)
{}
int getOverlap() const { return m_overlap; }
private:
int m_overlap;
};
class MsgReportPowerScale : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportPowerScale(int refLevel, int range) :
Message(),
m_refLevel(refLevel),
m_range(range)
{}
Real getRefLevel() const { return m_refLevel; }
Real getRange() const { return m_range; }
private:
Real m_refLevel;
Real m_range;
};
class MsgReportCalibrationShift : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportCalibrationShift(Real calibrationShiftdB) :
Message(),
m_calibrationShiftdB(calibrationShiftdB)
{}
Real getCalibrationShiftdB() const { return m_calibrationShiftdB; }
private:
Real m_calibrationShiftdB;
};
GLSpectrum(QWidget* parent = nullptr);
virtual ~GLSpectrum();
void setCenterFrequency(qint64 frequency);
qint64 getCenterFrequency() const { return m_centerFrequency; }
float getPowerMax() const;
float getTimeMax() const;
void setSampleRate(qint32 sampleRate);
void setTimingRate(qint32 timingRate);
void setFFTOverlap(int overlap);
void setReferenceLevel(Real referenceLevel);
void setPowerRange(Real powerRange);
void setDecay(int decay);
void setDecayDivisor(int decayDivisor);
void setHistoStroke(int stroke);
void setDisplayWaterfall(bool display);
void setDisplay3DSpectrogram(bool display);
void set3DSpectrogramStyle(SpectrumSettings::SpectrogramStyle style);
void setColorMapName(const QString &colorMapName);
void setSpectrumStyle(SpectrumSettings::SpectrumStyle style);
void setSsbSpectrum(bool ssbSpectrum);
void setLsbDisplay(bool lsbDisplay);
void setInvertedWaterfall(bool inv);
void setDisplayMaxHold(bool display);
void setDisplayCurrent(bool display);
void setDisplayHistogram(bool display);
void setDisplayGrid(bool display);
void setDisplayGridIntensity(int intensity);
void setDisplayTraceIntensity(int intensity);
void setLinear(bool linear);
void setUseCalibration(bool useCalibration);
void setMeasurements(SpectrumMeasurements *measurements) { m_measurements = measurements; }
void setCenterFrequency(qint64 frequency) { m_spectrum->setCenterFrequency(frequency); }
qint64 getCenterFrequency() const { return m_spectrum->getCenterFrequency(); }
float getPowerMax() const { return m_spectrum->getPowerMax(); }
float getTimeMax() const { return m_spectrum->getTimeMax(); }
void setSampleRate(qint32 sampleRate) { m_spectrum->setSampleRate(sampleRate); }
void setTimingRate(qint32 timingRate) { m_spectrum->setTimingRate(timingRate); }
void setFFTOverlap(int overlap) { m_spectrum->setFFTOverlap(overlap); }
void setReferenceLevel(Real referenceLevel) { m_spectrum->setReferenceLevel(referenceLevel); }
void setPowerRange(Real powerRange){ m_spectrum->setPowerRange(powerRange); }
void setDecay(int decay) { m_spectrum->setDecay(decay); }
void setDecayDivisor(int decayDivisor) { m_spectrum->setDecayDivisor(decayDivisor); }
void setHistoStroke(int stroke) { m_spectrum->setHistoStroke(stroke); }
void setDisplayWaterfall(bool display) { m_spectrum->setDisplayWaterfall(display); }
void setDisplay3DSpectrogram(bool display) { m_spectrum->setDisplay3DSpectrogram(display); }
void set3DSpectrogramStyle(SpectrumSettings::SpectrogramStyle style) { m_spectrum->set3DSpectrogramStyle(style); }
void setColorMapName(const QString &colorMapName) { m_spectrum->setColorMapName(colorMapName); }
void setSpectrumStyle(SpectrumSettings::SpectrumStyle style) { m_spectrum->setSpectrumStyle(style); }
void setSsbSpectrum(bool ssbSpectrum) { m_spectrum->setSsbSpectrum(ssbSpectrum); }
void setLsbDisplay(bool lsbDisplay) { m_spectrum->setLsbDisplay(lsbDisplay); }
void setInvertedWaterfall(bool inv) { m_spectrum->setInvertedWaterfall(inv); }
void setDisplayMaxHold(bool display) { m_spectrum->setDisplayMaxHold(display); }
void setDisplayCurrent(bool display) { m_spectrum->setDisplayCurrent(display); }
void setDisplayHistogram(bool display) { m_spectrum->setDisplayHistogram(display); }
void setDisplayGrid(bool display) { m_spectrum->setDisplayGrid(display); }
void setDisplayGridIntensity(int intensity) { m_spectrum->setDisplayGridIntensity(intensity); }
void setDisplayTraceIntensity(int intensity) { m_spectrum->setDisplayTraceIntensity(intensity); }
void setLinear(bool linear) { m_spectrum->setLinear(linear); }
void setUseCalibration(bool useCalibration) { m_spectrum->setUseCalibration(useCalibration); }
void setMeasurementParams(SpectrumSettings::Measurement measurement,
int centerFrequencyOffset, int bandwidth, int chSpacing, int adjChBandwidth,
int harmonics, int peaks, bool highlight, int precision);
qint32 getSampleRate() const { return m_sampleRate; }
void addChannelMarker(ChannelMarker* channelMarker);
void removeChannelMarker(ChannelMarker* channelMarker);
void setMessageQueueToGUI(MessageQueue* messageQueue) { m_messageQueueToGUI = messageQueue; }
virtual void newSpectrum(const Real* spectrum, int nbBins, int fftSize);
void clearSpectrumHistogram();
Real getWaterfallShare() const { return m_waterfallShare; }
void setWaterfallShare(Real waterfallShare);
void setFPSPeriodMs(int fpsPeriodMs);
void setDisplayedStream(bool sourceOrSink, int streamIndex)
int harmonics, int peaks, bool highlight, int precision)
{
m_displaySourceOrSink = sourceOrSink;
m_displayStreamIndex = streamIndex;
m_spectrum->setMeasurementParams(measurement, centerFrequencyOffset, bandwidth, chSpacing, adjChBandwidth, harmonics, peaks, highlight, precision);
}
void setSpectrumVis(SpectrumVis *spectrumVis) { m_spectrumVis = spectrumVis; }
SpectrumVis *getSpectrumVis() { return m_spectrumVis; }
const QList<SpectrumHistogramMarker>& getHistogramMarkers() const { return m_histogramMarkers; }
QList<SpectrumHistogramMarker>& getHistogramMarkers() { return m_histogramMarkers; }
void setHistogramMarkers(const QList<SpectrumHistogramMarker>& histogramMarkers);
const QList<SpectrumWaterfallMarker>& getWaterfallMarkers() const { return m_waterfallMarkers; }
QList<SpectrumWaterfallMarker>& getWaterfallMarkers() { return m_waterfallMarkers; }
void setWaterfallMarkers(const QList<SpectrumWaterfallMarker>& waterfallMarkers);
const QList<SpectrumAnnotationMarker>& getAnnotationMarkers() const { return m_annotationMarkers; }
QList<SpectrumAnnotationMarker>& getAnnotationMarkers() { return m_annotationMarkers; }
void setAnnotationMarkers(const QList<SpectrumAnnotationMarker>& annotationMarkers);
void updateHistogramMarkers();
void updateWaterfallMarkers();
void updateAnnotationMarkers();
void updateMarkersDisplay();
void updateCalibrationPoints();
SpectrumSettings::MarkersDisplay& getMarkersDisplay() { return m_markersDisplay; }
void setMarkersDisplay(SpectrumSettings::MarkersDisplay markersDisplay);
QList<SpectrumCalibrationPoint>& getCalibrationPoints() { return m_calibrationPoints; }
void setCalibrationPoints(const QList<SpectrumCalibrationPoint>& calibrationPoints);
SpectrumSettings::CalibrationInterpolationMode& getCalibrationInterpMode() { return m_calibrationInterpMode; }
void setCalibrationInterpMode(SpectrumSettings::CalibrationInterpolationMode mode);
void setIsDeviceSpectrum(bool isDeviceSpectrum) { m_isDeviceSpectrum = isDeviceSpectrum; }
bool isDeviceSpectrum() const { return m_isDeviceSpectrum; }
qint32 getSampleRate() const { return m_spectrum->getSampleRate(); }
void addChannelMarker(ChannelMarker* channelMarker) { m_spectrum->addChannelMarker(channelMarker); }
void removeChannelMarker(ChannelMarker* channelMarker) { m_spectrum->removeChannelMarker(channelMarker); }
void setMessageQueueToGUI(MessageQueue* messageQueue) { m_spectrum->setMessageQueueToGUI(messageQueue); }
void newSpectrum(const Real* spectrum, int nbBins, int fftSize) { m_spectrum->newSpectrum(spectrum, nbBins, fftSize); }
void clearSpectrumHistogram() { m_spectrum->clearSpectrumHistogram(); }
Real getWaterfallShare() const { return m_spectrum->getWaterfallShare(); }
void setWaterfallShare(Real waterfallShare) { m_spectrum->setWaterfallShare(waterfallShare); }
void setFPSPeriodMs(int fpsPeriodMs) { m_spectrum->setFPSPeriodMs(fpsPeriodMs); }
void setDisplayedStream(bool sourceOrSink, int streamIndex) { m_spectrum->setDisplayedStream(sourceOrSink, streamIndex); }
void setSpectrumVis(SpectrumVis *spectrumVis) { m_spectrum->setSpectrumVis(spectrumVis); }
SpectrumVis *getSpectrumVis() { return m_spectrum->getSpectrumVis(); }
const QList<SpectrumHistogramMarker>& getHistogramMarkers() const { return m_spectrum->getHistogramMarkers(); }
QList<SpectrumHistogramMarker>& getHistogramMarkers() { return m_spectrum->getHistogramMarkers(); }
void setHistogramMarkers(const QList<SpectrumHistogramMarker>& histogramMarkers) { m_spectrum->setHistogramMarkers(histogramMarkers); }
const QList<SpectrumWaterfallMarker>& getWaterfallMarkers() const { return m_spectrum->getWaterfallMarkers(); }
QList<SpectrumWaterfallMarker>& getWaterfallMarkers() { return m_spectrum->getWaterfallMarkers(); }
void setWaterfallMarkers(const QList<SpectrumWaterfallMarker>& waterfallMarkers) { m_spectrum->setWaterfallMarkers(waterfallMarkers); }
const QList<SpectrumAnnotationMarker>& getAnnotationMarkers() const { return m_spectrum->getAnnotationMarkers(); }
QList<SpectrumAnnotationMarker>& getAnnotationMarkers() { return m_spectrum->getAnnotationMarkers(); }
void setAnnotationMarkers(const QList<SpectrumAnnotationMarker>& annotationMarkers) { m_spectrum->setAnnotationMarkers(annotationMarkers); };
void updateHistogramMarkers() { m_spectrum->updateHistogramMarkers(); }
void updateWaterfallMarkers() { m_spectrum->updateWaterfallMarkers(); }
void updateAnnotationMarkers() { m_spectrum->updateAnnotationMarkers();}
void updateMarkersDisplay() { m_spectrum->updateMarkersDisplay(); }
void updateCalibrationPoints() { m_spectrum->updateCalibrationPoints(); }
SpectrumSettings::MarkersDisplay& getMarkersDisplay() { return m_spectrum->getMarkersDisplay(); }
void setMarkersDisplay(SpectrumSettings::MarkersDisplay markersDisplay) { m_spectrum->setMarkersDisplay(markersDisplay); }
QList<SpectrumCalibrationPoint>& getCalibrationPoints() { return m_spectrum->getCalibrationPoints(); }
void setCalibrationPoints(const QList<SpectrumCalibrationPoint>& calibrationPoints) { m_spectrum->setCalibrationPoints(calibrationPoints); }
SpectrumSettings::CalibrationInterpolationMode& getCalibrationInterpMode() { return m_spectrum->getCalibrationInterpMode(); }
void setCalibrationInterpMode(SpectrumSettings::CalibrationInterpolationMode mode) { m_spectrum->setCalibrationInterpMode(mode); }
void setIsDeviceSpectrum(bool isDeviceSpectrum) { m_spectrum->setIsDeviceSpectrum(isDeviceSpectrum); }
bool isDeviceSpectrum() const { return m_spectrum->isDeviceSpectrum(); }
private:
struct ChannelMarkerState {
ChannelMarker* m_channelMarker;
QMatrix4x4 m_glMatrixWaterfall;
QMatrix4x4 m_glMatrixDsbWaterfall;
QMatrix4x4 m_glMatrixFreqScale;
QMatrix4x4 m_glMatrixDsbFreqScale;
QMatrix4x4 m_glMatrixHistogram;
QMatrix4x4 m_glMatrixDsbHistogram;
QRectF m_rect;
ChannelMarkerState(ChannelMarker* channelMarker) :
m_channelMarker(channelMarker)
{ }
};
QList<ChannelMarkerState*> m_channelMarkerStates;
enum CursorState {
CSNormal,
CSSplitter,
CSSplitterMoving,
CSChannel,
CSChannelMoving
};
QList<SpectrumHistogramMarker> m_histogramMarkers;
QList<SpectrumWaterfallMarker> m_waterfallMarkers;
QList<SpectrumAnnotationMarker> m_annotationMarkers;
QList<SpectrumAnnotationMarker*> m_sortedAnnotationMarkers;
QList<SpectrumAnnotationMarker*> m_visibleAnnotationMarkers;
SpectrumSettings::MarkersDisplay m_markersDisplay;
QList<SpectrumCalibrationPoint> m_calibrationPoints;
CursorState m_cursorState;
int m_cursorChannel;
SpectrumVis* m_spectrumVis;
QTimer m_timer;
int m_fpsPeriodMs;
QMutex m_mutex;
bool m_mouseInside;
bool m_changesPending;
qint64 m_centerFrequency;
Real m_referenceLevel;
Real m_powerRange;
bool m_linear;
int m_decay;
quint32 m_sampleRate;
quint32 m_timingRate;
int m_fftOverlap;
int m_fftSize; //!< FFT size in number of bins
int m_nbBins; //!< Number of visible FFT bins (zoom support)
bool m_displayGrid;
int m_displayGridIntensity;
int m_displayTraceIntensity;
bool m_invertedWaterfall;
std::vector<Real> m_maxHold;
bool m_displayMaxHold;
const Real *m_currentSpectrum;
bool m_displayCurrent;
Real m_waterfallShare;
int m_leftMargin;
int m_rightMargin;
int m_topMargin;
int m_frequencyScaleHeight;
int m_infoHeight;
int m_histogramHeight;
int m_waterfallHeight;
int m_bottomMargin;
QFont m_textOverlayFont;
QPixmap m_leftMarginPixmap;
QPixmap m_frequencyPixmap;
QPixmap m_infoPixmap;
ScaleEngine m_timeScale;
ScaleEngine m_powerScale;
ScaleEngine m_frequencyScale;
QRectF m_histogramRect;
QRect m_frequencyScaleRect;
QRectF m_waterfallRect;
QRect m_infoRect;
QMatrix4x4 m_glFrequencyScaleBoxMatrix;
QMatrix4x4 m_glLeftScaleBoxMatrix;
QMatrix4x4 m_glInfoBoxMatrix;
QString m_peakFrequencyMaxStr;
QString m_peakPowerMaxStr;
QString m_peakPowerUnits;
QRgb m_waterfallPalette[240];
QImage* m_waterfallBuffer;
int m_waterfallBufferPos;
int m_waterfallTextureHeight;
int m_waterfallTexturePos;
QMatrix4x4 m_glWaterfallBoxMatrix;
bool m_displayWaterfall;
bool m_ssbSpectrum;
bool m_lsbDisplay;
QImage* m_3DSpectrogramBuffer;
int m_3DSpectrogramBufferPos;
int m_3DSpectrogramTextureHeight;
int m_3DSpectrogramTexturePos;
bool m_display3DSpectrogram;
bool m_rotate3DSpectrogram; //!< Set when mouse is pressed in 3D spectrogram area for rotation when mouse is moved
bool m_pan3DSpectrogram;
bool m_scaleZ3DSpectrogram;
QPointF m_mousePrevLocalPos; //!< Position of the mouse for last event
int m_3DSpectrogramBottom;
QPixmap m_spectrogramTimePixmap;
QPixmap m_spectrogramPowerPixmap;
SpectrumSettings::SpectrogramStyle m_3DSpectrogramStyle;
QString m_colorMapName;
SpectrumSettings::SpectrumStyle m_spectrumStyle;
const float *m_colorMap;
bool m_scrollFrequency;
qint64 m_scrollStartCenterFreq;
QRgb m_histogramPalette[240];
QImage* m_histogramBuffer;
quint8* m_histogram; //!< Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239]
int m_decayDivisor;
int m_decayDivisorCount;
int m_histogramStroke;
QMatrix4x4 m_glHistogramSpectrumMatrix;
QMatrix4x4 m_glHistogramBoxMatrix;
bool m_displayHistogram;
bool m_displayChanged;
bool m_displaySourceOrSink;
int m_displayStreamIndex;
float m_frequencyZoomFactor;
float m_frequencyZoomPos;
static const float m_maxFrequencyZoom;
static const float m_annotationMarkerHeight;
GLShaderSimple m_glShaderSimple;
GLShaderTextured m_glShaderLeftScale;
GLShaderTextured m_glShaderFrequencyScale;
GLShaderTextured m_glShaderWaterfall;
GLShaderTextured m_glShaderHistogram;
GLShaderColorMap m_glShaderColorMap;
GLShaderTextured m_glShaderTextOverlay;
GLShaderTextured m_glShaderInfo;
GLShaderSpectrogram m_glShaderSpectrogram;
GLShaderTextured m_glShaderSpectrogramTimeScale;
GLShaderTextured m_glShaderSpectrogramPowerScale;
int m_matrixLoc;
int m_colorLoc;
bool m_useCalibration;
Real m_calibrationGain;
Real m_calibrationShiftdB;
SpectrumSettings::CalibrationInterpolationMode m_calibrationInterpMode;
IncrementalArray<GLfloat> m_q3TickTime;
IncrementalArray<GLfloat> m_q3TickFrequency;
IncrementalArray<GLfloat> m_q3TickPower;
IncrementalArray<GLfloat> m_q3FFT;
IncrementalArray<GLfloat> m_q3ColorMap;
MessageQueue *m_messageQueueToGUI;
QOpenGLDebugLogger *m_openGLLogger;
bool m_isDeviceSpectrum;
QSplitter *m_splitter;
GLSpectrumView *m_spectrum;
SpectrumMeasurements *m_measurements;
SpectrumSettings::Measurement m_measurement;
int m_measurementCenterFrequencyOffset;
int m_measurementBandwidth;
int m_measurementChSpacing;
int m_measurementAdjChBandwidth;
int m_measurementHarmonics;
int m_measurementPeaks;
bool m_measurementHighlight;
int m_measurementPrecision;
static const QVector4D m_measurementLightMarkerColor;
static const QVector4D m_measurementDarkMarkerColor;
void updateWaterfall(const Real *spectrum);
void update3DSpectrogram(const Real *spectrum);
void updateHistogram(const Real *spectrum);
void initializeGL();
void resizeGL(int width, int height);
void paintGL();
void drawPowerBandMarkers(float max, float min, const QVector4D &color);
void drawBandwidthMarkers(int64_t centerFrequency, int bandwidth, const QVector4D &color);
void drawPeakMarkers(int64_t startFrequency, int64_t endFrequency, const QVector4D &color);
void drawSpectrumMarkers();
void drawAnnotationMarkers();
void measurePeak();
void measurePeaks();
void measureChannelPower();
void measureAdjacentChannelPower();
void measureSNR();
void measureSFDR();
float calcChannelPower(int64_t centerFrequency, int channelBandwidth) const;
float calPower(float power) const;
int findPeakBin(const Real *spectrum) const;
void findPeak(float &power, float &frequency) const;
void peakWidth(const Real *spectrum, int center, int &left, int &right, int maxLeft, int maxRight) const;
int frequencyToBin(int64_t frequency) const;
int64_t binToFrequency(int bin) const;
void stopDrag();
void applyChanges();
void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent*);
void channelMarkerMove(QWheelEvent*, int mul);
void zoom(QWheelEvent*);
void frequencyZoom(float pw);
void frequencyPan(QMouseEvent*);
void timeZoom(bool zoomInElseOut);
void powerZoom(float pw, bool zoomInElseOut);
void resetFrequencyZoom();
void updateFFTLimits();
void setFrequencyScale();
void setPowerScale(int height);
void getFrequencyZoom(int64_t& centerFrequency, int& frequencySpan);
bool pointInWaterfallOrSpectrogram(const QPointF &point) const;
bool pointInHistogram(const QPointF &point) const;
void enterEvent(QEvent* event);
void leaveEvent(QEvent* event);
static QString displayFull(int64_t value);
static QString displayScaled(int64_t value, char type, int precision, bool showMult);
static QString displayScaledF(float value, char type, int precision, bool showMult);
static QString displayPower(float value, char type, int precision);
int getPrecision(int value);
void drawTextRight(const QString &text, const QString &value, const QString &max, const QString &units);
void drawTextsRight(const QStringList &text, const QStringList &value, const QStringList &max, const QStringList &units);
void drawTextOverlayCentered(
const QString& text,
const QColor& color,
const QFont& font,
float shiftX,
float shiftY,
const QRectF& glRect);
void drawTextOverlay( //!< Draws a text overlay
const QString& text,
const QColor& color,
const QFont& font,
float shiftX,
float shiftY,
bool leftHalf,
bool topHalf,
const QRectF& glRect);
void formatTextInfo(QString& info);
void updateSortedAnnotationMarkers();
static bool annotationDisplayLessThan(const SpectrumAnnotationMarker *m1, const SpectrumAnnotationMarker *m2)
{
if (m1->m_bandwidth == m2->m_bandwidth) {
return m1->m_startFrequency < m2->m_startFrequency;
} else {
return m1->m_bandwidth > m2->m_bandwidth; // larger bandwidths should come first for display (lower layer)
}
}
static bool calibrationPointsLessThan(const SpectrumCalibrationPoint& m1, const SpectrumCalibrationPoint& m2)
{
return m1.m_frequency < m2.m_frequency;
}
private slots:
void cleanup();
void tick();
void channelMarkerChanged();
void channelMarkerDestroyed(QObject* object);
void openGLDebug(const QOpenGLDebugMessage &debugMessage);
bool eventFilter(QObject *object, QEvent *event);
signals:
// Emitted when user tries to scroll to frequency currently out of range
void requestCenterFrequency(qint64 frequency);
};
#endif // INCLUDE_GLSPECTRUM_H
#endif // SDRGUI_GLSPECTRUM_H_

View File

@ -28,7 +28,7 @@
#include "dsp/fftwindow.h"
#include "dsp/spectrumvis.h"
#include "gui/glspectrum.h"
#include "gui/glspectrumtop.h"
#include "gui/glspectrumview.h"
#include "gui/crightclickenabler.h"
#include "gui/wsspectrumsettingsdialog.h"
#include "gui/spectrummarkersdialog.h"
@ -48,7 +48,6 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
ui(new Ui::GLSpectrumGUI),
m_spectrumVis(nullptr),
m_glSpectrum(nullptr),
m_glSpectrumTop(nullptr),
m_doApplySettings(true),
m_calibrationShiftdB(0.0)
{
@ -103,14 +102,13 @@ GLSpectrumGUI::~GLSpectrumGUI()
delete ui;
}
void GLSpectrumGUI::setBuddies(SpectrumVis* spectrumVis, GLSpectrum* glSpectrum, GLSpectrumTop *glSpectrumTop)
void GLSpectrumGUI::setBuddies(SpectrumVis* spectrumVis, GLSpectrum* glSpectrum)
{
m_spectrumVis = spectrumVis;
m_glSpectrum = glSpectrum;
m_glSpectrum->setSpectrumVis(spectrumVis);
m_glSpectrum->setMessageQueueToGUI(&m_messageQueue);
m_spectrumVis->setMessageQueueToGUI(&m_messageQueue);
m_glSpectrumTop = glSpectrumTop;
}
void GLSpectrumGUI::resetToDefaults()
@ -849,7 +847,7 @@ void GLSpectrumGUI::setMaximumOverlap()
bool GLSpectrumGUI::handleMessage(const Message& message)
{
if (GLSpectrum::MsgReportSampleRate::match(message))
if (GLSpectrumView::MsgReportSampleRate::match(message))
{
setAveragingToolitp();
setFFTSizeToolitp();
@ -875,24 +873,24 @@ bool GLSpectrumGUI::handleMessage(const Message& message)
ui->wsSpectrum->blockSignals(false);
return true;
}
else if (GLSpectrum::MsgReportWaterfallShare::match(message))
else if (GLSpectrumView::MsgReportWaterfallShare::match(message))
{
const GLSpectrum::MsgReportWaterfallShare& report = (const GLSpectrum::MsgReportWaterfallShare&) message;
const GLSpectrumView::MsgReportWaterfallShare& report = (const GLSpectrumView::MsgReportWaterfallShare&) message;
m_settings.m_waterfallShare = report.getWaterfallShare();
return true;
}
else if (GLSpectrum::MsgReportFFTOverlap::match(message))
else if (GLSpectrumView::MsgReportFFTOverlap::match(message))
{
const GLSpectrum::MsgReportFFTOverlap& report = (const GLSpectrum::MsgReportFFTOverlap&) message;
const GLSpectrumView::MsgReportFFTOverlap& report = (const GLSpectrumView::MsgReportFFTOverlap&) message;
m_settings.m_fftOverlap = report.getOverlap();
ui->fftOverlap->blockSignals(true);
ui->fftOverlap->setValue(m_settings.m_fftOverlap);
ui->fftOverlap->blockSignals(false);
return true;
}
else if (GLSpectrum::MsgReportPowerScale::match(message))
else if (GLSpectrumView::MsgReportPowerScale::match(message))
{
const GLSpectrum::MsgReportPowerScale& report = (const GLSpectrum::MsgReportPowerScale&) message;
const GLSpectrumView::MsgReportPowerScale& report = (const GLSpectrumView::MsgReportPowerScale&) message;
m_settings.m_refLevel = report.getRefLevel();
m_settings.m_powerRange = report.getRange();
ui->refLevel->blockSignals(true);
@ -903,9 +901,9 @@ bool GLSpectrumGUI::handleMessage(const Message& message)
ui->refLevel->blockSignals(false);
return true;
}
else if (GLSpectrum::MsgReportCalibrationShift::match(message))
else if (GLSpectrumView::MsgReportCalibrationShift::match(message))
{
const GLSpectrum::MsgReportCalibrationShift& report = (GLSpectrum::MsgReportCalibrationShift&) message;
const GLSpectrumView::MsgReportCalibrationShift& report = (GLSpectrumView::MsgReportCalibrationShift&) message;
m_calibrationShiftdB = report.getCalibrationShiftdB();
ui->refLevel->blockSignals(true);
ui->refLevel->setValue(m_settings.m_refLevel + m_calibrationShiftdB);
@ -1019,7 +1017,7 @@ void GLSpectrumGUI::updateCalibrationPoints()
void GLSpectrumGUI::on_measure_clicked(bool checked)
{
SpectrumMeasurementsDialog measurementsDialog(
m_glSpectrumTop,
m_glSpectrum,
&m_settings,
this
);
@ -1031,14 +1029,10 @@ void GLSpectrumGUI::on_measure_clicked(bool checked)
void GLSpectrumGUI::updateMeasurements()
{
if (m_glSpectrumTop)
{
m_glSpectrumTop->setMeasurementsVisible(m_settings.m_measurement != SpectrumSettings::MeasurementNone);
m_glSpectrumTop->setMeasurementsPosition(m_settings.m_measurementsPosition);
}
if (m_glSpectrum)
{
m_glSpectrum->setMeasurementsVisible(m_settings.m_measurement != SpectrumSettings::MeasurementNone);
m_glSpectrum->setMeasurementsPosition(m_settings.m_measurementsPosition);
m_glSpectrum->setMeasurementParams(
m_settings.m_measurement,
m_settings.m_measurementCenterFrequencyOffset,

View File

@ -36,7 +36,6 @@ namespace Ui {
class SpectrumVis;
class GLSpectrum;
class GLSpectrumTop;
class SDRGUI_API GLSpectrumGUI : public QWidget, public Serializable {
Q_OBJECT
@ -53,7 +52,7 @@ public:
explicit GLSpectrumGUI(QWidget* parent = NULL);
~GLSpectrumGUI();
void setBuddies(SpectrumVis* spectrumVis, GLSpectrum* glSpectrum, GLSpectrumTop *glSpectrumTop = nullptr);
void setBuddies(SpectrumVis* spectrumVis, GLSpectrum* glSpectrum);
void setFFTSize(int log2FFTSize);
void resetToDefaults();
@ -68,7 +67,6 @@ private:
SpectrumVis* m_spectrumVis;
GLSpectrum* m_glSpectrum;
GLSpectrumTop* m_glSpectrumTop;
MessageQueue m_messageQueue;
SpectrumSettings m_settings;
bool m_doApplySettings;

View File

@ -1,70 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2022 Jon Beniston, M7RCE //
// //
// 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 <QSplitter>
#include <QVBoxLayout>
#include <QLabel>
#include "gui/glspectrum.h"
#include "gui/glspectrumtop.h"
#include "gui/spectrummeasurements.h"
GLSpectrumTop::GLSpectrumTop(QWidget *parent) :
QWidget(parent)
{
m_splitter = new QSplitter(Qt::Vertical);
m_spectrum = new GLSpectrum();
m_measurements = new SpectrumMeasurements();
m_spectrum->setMeasurements(m_measurements);
m_splitter->addWidget(m_spectrum);
m_splitter->addWidget(m_measurements);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_splitter);
setLayout(layout);
m_measurements->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
void GLSpectrumTop::setMeasurementsVisible(bool visible)
{
m_measurements->setVisible(visible);
}
void GLSpectrumTop::setMeasurementsPosition(SpectrumSettings::MeasurementsPosition position)
{
switch (position)
{
case SpectrumSettings::PositionAbove:
m_splitter->setOrientation(Qt::Vertical);
m_splitter->insertWidget(0, m_measurements);
break;
case SpectrumSettings::PositionBelow:
m_splitter->setOrientation(Qt::Vertical);
m_splitter->insertWidget(0, m_spectrum);
break;
case SpectrumSettings::PositionLeft:
m_splitter->setOrientation(Qt::Horizontal);
m_splitter->insertWidget(0, m_measurements);
break;
case SpectrumSettings::PositionRight:
m_splitter->setOrientation(Qt::Horizontal);
m_splitter->insertWidget(0, m_spectrum);
break;
}
}

View File

@ -1,47 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2022 Jon Beniston, M7RCE //
// //
// 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 SDRGUI_GLSPECTRUMTOP_H_
#define SDRGUI_GLSPECTRUMTOP_H_
#include <QWidget>
#include "export.h"
class QSplitter;
class GLSpectrum;
class SpectrumMeasurements;
// Combines GLSpectrum in a QMainWindow with SpectrumMeasurements in a QDockWidget
class SDRGUI_API GLSpectrumTop : public QWidget {
Q_OBJECT
public:
GLSpectrumTop(QWidget *parent = nullptr);
GLSpectrum *getSpectrum() const { return m_spectrum; }
SpectrumMeasurements *getMeasurements() const { return m_measurements; }
void setMeasurementsVisible(bool visible);
void setMeasurementsPosition(SpectrumSettings::MeasurementsPosition position);
private:
QSplitter *m_splitter;
GLSpectrum *m_spectrum;
SpectrumMeasurements *m_measurements;
};
#endif // SDRGUI_GLSPECTRUMTOP_H_

File diff suppressed because it is too large Load Diff

497
sdrgui/gui/glspectrumview.h Normal file
View File

@ -0,0 +1,497 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 F4EXB //
// written by Edouard Griffiths //
// //
// OpenGL interface modernization. //
// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html //
// //
// 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_GLSPECTRUMVIEW_H
#define INCLUDE_GLSPECTRUMVIEW_H
#include <QTimer>
#include <QMutex>
#include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject>
#include <QMatrix4x4>
#include <QPoint>
#include <QOpenGLWidget>
#include <QOpenGLDebugLogger>
#include "gui/scaleengine.h"
#include "gui/glshadersimple.h"
#include "gui/glshadertextured.h"
#include "gui/glshadercolormap.h"
#include "dsp/glspectruminterface.h"
#include "gui/glshaderspectrogram.h"
#include "dsp/spectrummarkers.h"
#include "dsp/channelmarker.h"
#include "dsp/spectrumsettings.h"
#include "export.h"
#include "util/incrementalarray.h"
#include "util/message.h"
#include "util/colormap.h"
class QOpenGLShaderProgram;
class MessageQueue;
class SpectrumVis;
class QOpenGLDebugLogger;
class SpectrumMeasurements;
class SDRGUI_API GLSpectrumView : public QOpenGLWidget, public GLSpectrumInterface {
Q_OBJECT
public:
class MsgReportSampleRate : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportSampleRate(quint32 sampleRate) :
Message(),
m_sampleRate(sampleRate)
{}
quint32 getSampleRate() const { return m_sampleRate; }
private:
quint32 m_sampleRate;
};
class MsgReportWaterfallShare : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportWaterfallShare(Real waterfallShare) :
Message(),
m_waterfallShare(waterfallShare)
{}
Real getWaterfallShare() const { return m_waterfallShare; }
private:
Real m_waterfallShare;
};
class MsgReportFFTOverlap : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportFFTOverlap(int overlap) :
Message(),
m_overlap(overlap)
{}
int getOverlap() const { return m_overlap; }
private:
int m_overlap;
};
class MsgReportPowerScale : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportPowerScale(int refLevel, int range) :
Message(),
m_refLevel(refLevel),
m_range(range)
{}
Real getRefLevel() const { return m_refLevel; }
Real getRange() const { return m_range; }
private:
Real m_refLevel;
Real m_range;
};
class MsgReportCalibrationShift : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportCalibrationShift(Real calibrationShiftdB) :
Message(),
m_calibrationShiftdB(calibrationShiftdB)
{}
Real getCalibrationShiftdB() const { return m_calibrationShiftdB; }
private:
Real m_calibrationShiftdB;
};
GLSpectrumView(QWidget* parent = nullptr);
virtual ~GLSpectrumView();
void setCenterFrequency(qint64 frequency);
qint64 getCenterFrequency() const { return m_centerFrequency; }
float getPowerMax() const;
float getTimeMax() const;
void setSampleRate(qint32 sampleRate);
void setTimingRate(qint32 timingRate);
void setFFTOverlap(int overlap);
void setReferenceLevel(Real referenceLevel);
void setPowerRange(Real powerRange);
void setDecay(int decay);
void setDecayDivisor(int decayDivisor);
void setHistoStroke(int stroke);
void setDisplayWaterfall(bool display);
void setDisplay3DSpectrogram(bool display);
void set3DSpectrogramStyle(SpectrumSettings::SpectrogramStyle style);
void setColorMapName(const QString &colorMapName);
void setSpectrumStyle(SpectrumSettings::SpectrumStyle style);
void setSsbSpectrum(bool ssbSpectrum);
void setLsbDisplay(bool lsbDisplay);
void setInvertedWaterfall(bool inv);
void setDisplayMaxHold(bool display);
void setDisplayCurrent(bool display);
void setDisplayHistogram(bool display);
void setDisplayGrid(bool display);
void setDisplayGridIntensity(int intensity);
void setDisplayTraceIntensity(int intensity);
void setLinear(bool linear);
void setUseCalibration(bool useCalibration);
void setMeasurements(SpectrumMeasurements *measurements) { m_measurements = measurements; }
void setMeasurementParams(SpectrumSettings::Measurement measurement,
int centerFrequencyOffset, int bandwidth, int chSpacing, int adjChBandwidth,
int harmonics, int peaks, bool highlight, int precision);
qint32 getSampleRate() const { return m_sampleRate; }
void addChannelMarker(ChannelMarker* channelMarker);
void removeChannelMarker(ChannelMarker* channelMarker);
void setMessageQueueToGUI(MessageQueue* messageQueue) { m_messageQueueToGUI = messageQueue; }
virtual void newSpectrum(const Real* spectrum, int nbBins, int fftSize);
void clearSpectrumHistogram();
Real getWaterfallShare() const { return m_waterfallShare; }
void setWaterfallShare(Real waterfallShare);
void setFPSPeriodMs(int fpsPeriodMs);
void setDisplayedStream(bool sourceOrSink, int streamIndex)
{
m_displaySourceOrSink = sourceOrSink;
m_displayStreamIndex = streamIndex;
}
void setSpectrumVis(SpectrumVis *spectrumVis) { m_spectrumVis = spectrumVis; }
SpectrumVis *getSpectrumVis() { return m_spectrumVis; }
const QList<SpectrumHistogramMarker>& getHistogramMarkers() const { return m_histogramMarkers; }
QList<SpectrumHistogramMarker>& getHistogramMarkers() { return m_histogramMarkers; }
void setHistogramMarkers(const QList<SpectrumHistogramMarker>& histogramMarkers);
const QList<SpectrumWaterfallMarker>& getWaterfallMarkers() const { return m_waterfallMarkers; }
QList<SpectrumWaterfallMarker>& getWaterfallMarkers() { return m_waterfallMarkers; }
void setWaterfallMarkers(const QList<SpectrumWaterfallMarker>& waterfallMarkers);
const QList<SpectrumAnnotationMarker>& getAnnotationMarkers() const { return m_annotationMarkers; }
QList<SpectrumAnnotationMarker>& getAnnotationMarkers() { return m_annotationMarkers; }
void setAnnotationMarkers(const QList<SpectrumAnnotationMarker>& annotationMarkers);
void updateHistogramMarkers();
void updateWaterfallMarkers();
void updateAnnotationMarkers();
void updateMarkersDisplay();
void updateCalibrationPoints();
SpectrumSettings::MarkersDisplay& getMarkersDisplay() { return m_markersDisplay; }
void setMarkersDisplay(SpectrumSettings::MarkersDisplay markersDisplay);
QList<SpectrumCalibrationPoint>& getCalibrationPoints() { return m_calibrationPoints; }
void setCalibrationPoints(const QList<SpectrumCalibrationPoint>& calibrationPoints);
SpectrumSettings::CalibrationInterpolationMode& getCalibrationInterpMode() { return m_calibrationInterpMode; }
void setCalibrationInterpMode(SpectrumSettings::CalibrationInterpolationMode mode);
void setIsDeviceSpectrum(bool isDeviceSpectrum) { m_isDeviceSpectrum = isDeviceSpectrum; }
bool isDeviceSpectrum() const { return m_isDeviceSpectrum; }
private:
struct ChannelMarkerState {
ChannelMarker* m_channelMarker;
QMatrix4x4 m_glMatrixWaterfall;
QMatrix4x4 m_glMatrixDsbWaterfall;
QMatrix4x4 m_glMatrixFreqScale;
QMatrix4x4 m_glMatrixDsbFreqScale;
QMatrix4x4 m_glMatrixHistogram;
QMatrix4x4 m_glMatrixDsbHistogram;
QRectF m_rect;
ChannelMarkerState(ChannelMarker* channelMarker) :
m_channelMarker(channelMarker)
{ }
};
QList<ChannelMarkerState*> m_channelMarkerStates;
enum CursorState {
CSNormal,
CSSplitter,
CSSplitterMoving,
CSChannel,
CSChannelMoving
};
QList<SpectrumHistogramMarker> m_histogramMarkers;
QList<SpectrumWaterfallMarker> m_waterfallMarkers;
QList<SpectrumAnnotationMarker> m_annotationMarkers;
QList<SpectrumAnnotationMarker*> m_sortedAnnotationMarkers;
QList<SpectrumAnnotationMarker*> m_visibleAnnotationMarkers;
SpectrumSettings::MarkersDisplay m_markersDisplay;
QList<SpectrumCalibrationPoint> m_calibrationPoints;
CursorState m_cursorState;
int m_cursorChannel;
SpectrumVis* m_spectrumVis;
QTimer m_timer;
int m_fpsPeriodMs;
QMutex m_mutex;
bool m_mouseInside;
bool m_changesPending;
qint64 m_centerFrequency;
Real m_referenceLevel;
Real m_powerRange;
bool m_linear;
int m_decay;
quint32 m_sampleRate;
quint32 m_timingRate;
int m_fftOverlap;
int m_fftSize; //!< FFT size in number of bins
int m_nbBins; //!< Number of visible FFT bins (zoom support)
bool m_displayGrid;
int m_displayGridIntensity;
int m_displayTraceIntensity;
bool m_invertedWaterfall;
std::vector<Real> m_maxHold;
bool m_displayMaxHold;
const Real *m_currentSpectrum;
bool m_displayCurrent;
Real m_waterfallShare;
int m_leftMargin;
int m_rightMargin;
int m_topMargin;
int m_frequencyScaleHeight;
int m_infoHeight;
int m_histogramHeight;
int m_waterfallHeight;
int m_bottomMargin;
QFont m_textOverlayFont;
QPixmap m_leftMarginPixmap;
QPixmap m_frequencyPixmap;
QPixmap m_infoPixmap;
ScaleEngine m_timeScale;
ScaleEngine m_powerScale;
ScaleEngine m_frequencyScale;
QRectF m_histogramRect;
QRect m_frequencyScaleRect;
QRectF m_waterfallRect;
QRect m_infoRect;
QMatrix4x4 m_glFrequencyScaleBoxMatrix;
QMatrix4x4 m_glLeftScaleBoxMatrix;
QMatrix4x4 m_glInfoBoxMatrix;
QString m_peakFrequencyMaxStr;
QString m_peakPowerMaxStr;
QString m_peakPowerUnits;
QRgb m_waterfallPalette[240];
QImage* m_waterfallBuffer;
int m_waterfallBufferPos;
int m_waterfallTextureHeight;
int m_waterfallTexturePos;
QMatrix4x4 m_glWaterfallBoxMatrix;
bool m_displayWaterfall;
bool m_ssbSpectrum;
bool m_lsbDisplay;
QImage* m_3DSpectrogramBuffer;
int m_3DSpectrogramBufferPos;
int m_3DSpectrogramTextureHeight;
int m_3DSpectrogramTexturePos;
bool m_display3DSpectrogram;
bool m_rotate3DSpectrogram; //!< Set when mouse is pressed in 3D spectrogram area for rotation when mouse is moved
bool m_pan3DSpectrogram;
bool m_scaleZ3DSpectrogram;
QPointF m_mousePrevLocalPos; //!< Position of the mouse for last event
int m_3DSpectrogramBottom;
QPixmap m_spectrogramTimePixmap;
QPixmap m_spectrogramPowerPixmap;
SpectrumSettings::SpectrogramStyle m_3DSpectrogramStyle;
QString m_colorMapName;
SpectrumSettings::SpectrumStyle m_spectrumStyle;
const float *m_colorMap;
bool m_scrollFrequency;
qint64 m_scrollStartCenterFreq;
QRgb m_histogramPalette[240];
QImage* m_histogramBuffer;
quint8* m_histogram; //!< Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239]
int m_decayDivisor;
int m_decayDivisorCount;
int m_histogramStroke;
QMatrix4x4 m_glHistogramSpectrumMatrix;
QMatrix4x4 m_glHistogramBoxMatrix;
bool m_displayHistogram;
bool m_displayChanged;
bool m_displaySourceOrSink;
int m_displayStreamIndex;
float m_frequencyZoomFactor;
float m_frequencyZoomPos;
static const float m_maxFrequencyZoom;
static const float m_annotationMarkerHeight;
GLShaderSimple m_glShaderSimple;
GLShaderTextured m_glShaderLeftScale;
GLShaderTextured m_glShaderFrequencyScale;
GLShaderTextured m_glShaderWaterfall;
GLShaderTextured m_glShaderHistogram;
GLShaderColorMap m_glShaderColorMap;
GLShaderTextured m_glShaderTextOverlay;
GLShaderTextured m_glShaderInfo;
GLShaderSpectrogram m_glShaderSpectrogram;
GLShaderTextured m_glShaderSpectrogramTimeScale;
GLShaderTextured m_glShaderSpectrogramPowerScale;
int m_matrixLoc;
int m_colorLoc;
bool m_useCalibration;
Real m_calibrationGain;
Real m_calibrationShiftdB;
SpectrumSettings::CalibrationInterpolationMode m_calibrationInterpMode;
IncrementalArray<GLfloat> m_q3TickTime;
IncrementalArray<GLfloat> m_q3TickFrequency;
IncrementalArray<GLfloat> m_q3TickPower;
IncrementalArray<GLfloat> m_q3FFT;
IncrementalArray<GLfloat> m_q3ColorMap;
MessageQueue *m_messageQueueToGUI;
QOpenGLDebugLogger *m_openGLLogger;
bool m_isDeviceSpectrum;
SpectrumMeasurements *m_measurements;
SpectrumSettings::Measurement m_measurement;
int m_measurementCenterFrequencyOffset;
int m_measurementBandwidth;
int m_measurementChSpacing;
int m_measurementAdjChBandwidth;
int m_measurementHarmonics;
int m_measurementPeaks;
bool m_measurementHighlight;
int m_measurementPrecision;
static const QVector4D m_measurementLightMarkerColor;
static const QVector4D m_measurementDarkMarkerColor;
void updateWaterfall(const Real *spectrum);
void update3DSpectrogram(const Real *spectrum);
void updateHistogram(const Real *spectrum);
void initializeGL();
void resizeGL(int width, int height);
void paintGL();
void drawPowerBandMarkers(float max, float min, const QVector4D &color);
void drawBandwidthMarkers(int64_t centerFrequency, int bandwidth, const QVector4D &color);
void drawPeakMarkers(int64_t startFrequency, int64_t endFrequency, const QVector4D &color);
void drawSpectrumMarkers();
void drawAnnotationMarkers();
void measurePeak();
void measurePeaks();
void measureChannelPower();
void measureAdjacentChannelPower();
void measureSNR();
void measureSFDR();
float calcChannelPower(int64_t centerFrequency, int channelBandwidth) const;
float calPower(float power) const;
int findPeakBin(const Real *spectrum) const;
void findPeak(float &power, float &frequency) const;
void peakWidth(const Real *spectrum, int center, int &left, int &right, int maxLeft, int maxRight) const;
int frequencyToBin(int64_t frequency) const;
int64_t binToFrequency(int bin) const;
void stopDrag();
void applyChanges();
void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent*);
void channelMarkerMove(QWheelEvent*, int mul);
void zoom(QWheelEvent*);
void frequencyZoom(float pw);
void frequencyPan(QMouseEvent*);
void timeZoom(bool zoomInElseOut);
void powerZoom(float pw, bool zoomInElseOut);
void resetFrequencyZoom();
void updateFFTLimits();
void setFrequencyScale();
void setPowerScale(int height);
void getFrequencyZoom(int64_t& centerFrequency, int& frequencySpan);
bool pointInWaterfallOrSpectrogram(const QPointF &point) const;
bool pointInHistogram(const QPointF &point) const;
void enterEvent(QEvent* event);
void leaveEvent(QEvent* event);
static QString displayFull(int64_t value);
static QString displayScaled(int64_t value, char type, int precision, bool showMult);
static QString displayScaledF(float value, char type, int precision, bool showMult);
static QString displayPower(float value, char type, int precision);
int getPrecision(int value);
void drawTextRight(const QString &text, const QString &value, const QString &max, const QString &units);
void drawTextsRight(const QStringList &text, const QStringList &value, const QStringList &max, const QStringList &units);
void drawTextOverlayCentered(
const QString& text,
const QColor& color,
const QFont& font,
float shiftX,
float shiftY,
const QRectF& glRect);
void drawTextOverlay( //!< Draws a text overlay
const QString& text,
const QColor& color,
const QFont& font,
float shiftX,
float shiftY,
bool leftHalf,
bool topHalf,
const QRectF& glRect);
void formatTextInfo(QString& info);
void updateSortedAnnotationMarkers();
static bool annotationDisplayLessThan(const SpectrumAnnotationMarker *m1, const SpectrumAnnotationMarker *m2)
{
if (m1->m_bandwidth == m2->m_bandwidth) {
return m1->m_startFrequency < m2->m_startFrequency;
} else {
return m1->m_bandwidth > m2->m_bandwidth; // larger bandwidths should come first for display (lower layer)
}
}
static bool calibrationPointsLessThan(const SpectrumCalibrationPoint& m1, const SpectrumCalibrationPoint& m2)
{
return m1.m_frequency < m2.m_frequency;
}
private slots:
void cleanup();
void tick();
void channelMarkerChanged();
void channelMarkerDestroyed(QObject* object);
void openGLDebug(const QOpenGLDebugMessage &debugMessage);
bool eventFilter(QObject *object, QEvent *event);
signals:
// Emitted when user tries to scroll to frequency currently out of range
void requestCenterFrequency(qint64 frequency);
};
#endif // INCLUDE_GLSPECTRUMVIEW_H

View File

@ -23,14 +23,14 @@
#include "util/csv.h"
#include "spectrummeasurementsdialog.h"
#include "spectrummeasurements.h"
#include "glspectrumtop.h"
#include "glspectrum.h"
#include "ui_spectrummeasurementsdialog.h"
SpectrumMeasurementsDialog::SpectrumMeasurementsDialog(GLSpectrumTop *glSpectrumTop, SpectrumSettings *settings, QWidget *parent) :
SpectrumMeasurementsDialog::SpectrumMeasurementsDialog(GLSpectrum *glSpectrum, SpectrumSettings *settings, QWidget *parent) :
QDialog(parent),
ui(new Ui::SpectrumMeasurementsDialog),
m_glSpectrumTop(glSpectrumTop),
m_glSpectrum(glSpectrum),
m_settings(settings)
{
ui->setupUi(this);
@ -131,8 +131,8 @@ void SpectrumMeasurementsDialog::on_resetMeasurements_clicked(bool checked)
{
(void) checked;
if (m_glSpectrumTop) {
m_glSpectrumTop->getMeasurements()->reset();
if (m_glSpectrum) {
m_glSpectrum->getMeasurements()->reset();
}
}

View File

@ -27,20 +27,20 @@ namespace Ui {
class SpectrumMeasurementsDialog;
}
class GLSpectrumTop;
class GLSpectrum;
class SDRGUI_API SpectrumMeasurementsDialog : public QDialog {
Q_OBJECT
public:
explicit SpectrumMeasurementsDialog(GLSpectrumTop *glSpectrumTop, SpectrumSettings *settings, QWidget *parent = nullptr);
explicit SpectrumMeasurementsDialog(GLSpectrum *glSpectrum, SpectrumSettings *settings, QWidget *parent = nullptr);
~SpectrumMeasurementsDialog();
private:
void displaySettings();
Ui::SpectrumMeasurementsDialog *ui;
GLSpectrumTop *m_glSpectrumTop;
GLSpectrum *m_glSpectrum;
SpectrumSettings *m_settings;
private slots:

View File

@ -26,15 +26,13 @@
#include "mainwindow.h"
#include "gui/glspectrum.h"
#include "gui/glspectrumtop.h"
#include "gui/glspectrumgui.h"
#include "gui/workspaceselectiondialog.h"
#include "dsp/spectrumvis.h"
#include "mainspectrumgui.h"
MainSpectrumGUI::MainSpectrumGUI(GLSpectrumTop *spectrumTop, GLSpectrum *spectrum, GLSpectrumGUI *spectrumGUI, QWidget *parent) :
MainSpectrumGUI::MainSpectrumGUI(GLSpectrum *spectrum, GLSpectrumGUI *spectrumGUI, QWidget *parent) :
QMdiSubWindow(parent),
m_spectrumTop(spectrumTop),
m_spectrum(spectrum),
m_spectrumGUI(spectrumGUI),
m_deviceType(DeviceRx),
@ -115,7 +113,7 @@ MainSpectrumGUI::MainSpectrumGUI(GLSpectrumTop *spectrumTop, GLSpectrum *spectru
m_topLayout->addWidget(m_hideButton);
m_spectrumLayout = new QHBoxLayout();
m_spectrumLayout->addWidget(spectrumTop);
m_spectrumLayout->addWidget(spectrum);
spectrum->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
m_spectrumGUILayout = new QHBoxLayout();
m_spectrumGUILayout->addWidget(spectrumGUI);
@ -143,7 +141,7 @@ MainSpectrumGUI::MainSpectrumGUI(GLSpectrumTop *spectrumTop, GLSpectrum *spectru
connect(this, SIGNAL(forceShrink()), this, SLOT(shrinkWindow()));
connect(m_hideButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(spectrum, &GLSpectrum::requestCenterFrequency, this, &MainSpectrumGUI::onRequestCenterFrequency);
connect(spectrum->getSpectrumView(), &GLSpectrumView::requestCenterFrequency, this, &MainSpectrumGUI::onRequestCenterFrequency);
connect(spectrumGUI, &GLSpectrumGUI::requestCenterFrequency, this, &MainSpectrumGUI::onRequestCenterFrequency);
m_resizer.enableChildMouseTracking();
@ -153,7 +151,7 @@ MainSpectrumGUI::MainSpectrumGUI(GLSpectrumTop *spectrumTop, GLSpectrum *spectru
MainSpectrumGUI::~MainSpectrumGUI()
{
qDebug("MainSpectrumGUI::~MainSpectrumGUI");
m_spectrumLayout->removeWidget(m_spectrumTop);
m_spectrumLayout->removeWidget(m_spectrum);
m_spectrumGUILayout->removeWidget(m_spectrumGUI);
delete m_sizeGripBottomRight;
delete m_bottomLayout;

View File

@ -26,7 +26,6 @@
#include "export.h"
class GLSpectrum;
class GLSpectrumTop;
class GLSpectrumGUI;
class QLabel;
class QPushButton;
@ -45,7 +44,7 @@ public:
DeviceMIMO
};
MainSpectrumGUI(GLSpectrumTop *spectrumTop, GLSpectrum *spectrum, GLSpectrumGUI *spectrumGUI, QWidget *parent = nullptr);
MainSpectrumGUI(GLSpectrum *spectrum, GLSpectrumGUI *spectrumGUI, QWidget *parent = nullptr);
virtual ~MainSpectrumGUI();
void setDeviceType(DeviceType type);
@ -61,7 +60,6 @@ public:
const QByteArray& getGeometryBytes() const { return m_geometryBytes; }
private:
GLSpectrumTop *m_spectrumTop;
GLSpectrum *m_spectrum;
GLSpectrumGUI *m_spectrumGUI;
int m_workspaceIndex;