2014-05-18 11:52:39 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2016-03-04 12:51:03 -05:00
|
|
|
// Copyright (C) 2016 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// OpenGL interface modernization. //
|
|
|
|
// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html //
|
2014-05-18 11:52:39 -04:00
|
|
|
// //
|
|
|
|
// 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 INCLUDE_GLSPECTRUM_H
|
|
|
|
#define INCLUDE_GLSPECTRUM_H
|
|
|
|
|
2016-03-05 10:44:29 -05:00
|
|
|
#include <QOpenGLWidget>
|
2014-05-18 11:52:39 -04:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QMutex>
|
2016-03-01 21:09:50 -05:00
|
|
|
#include <QOpenGLBuffer>
|
|
|
|
#include <QOpenGLVertexArrayObject>
|
2016-03-02 16:50:05 -05:00
|
|
|
#include <QMatrix4x4>
|
2016-03-05 15:54:24 -05:00
|
|
|
#include <QGLWidget>
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "dsp/dsptypes.h"
|
|
|
|
#include "gui/scaleengine.h"
|
2016-03-02 19:09:55 -05:00
|
|
|
#include "gui/glshadersimple.h"
|
2016-03-05 00:45:05 -05:00
|
|
|
#include "gui/glshadertextured.h"
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "dsp/channelmarker.h"
|
|
|
|
#include "util/export.h"
|
|
|
|
|
2016-03-01 21:09:50 -05:00
|
|
|
class QOpenGLShaderProgram;
|
|
|
|
|
2016-03-05 15:54:24 -05:00
|
|
|
class SDRANGEL_API GLSpectrum : public QGLWidget {
|
2014-05-18 11:52:39 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
GLSpectrum(QWidget* parent = NULL);
|
|
|
|
~GLSpectrum();
|
|
|
|
|
|
|
|
void setCenterFrequency(quint64 frequency);
|
|
|
|
void setSampleRate(qint32 sampleRate);
|
|
|
|
void setReferenceLevel(Real referenceLevel);
|
|
|
|
void setPowerRange(Real powerRange);
|
|
|
|
void setDecay(int decay);
|
2015-07-15 22:55:14 -04:00
|
|
|
void setHistoLateHoldoff(int lateHoldoff);
|
|
|
|
void setHistoStroke(int stroke);
|
2014-05-18 11:52:39 -04:00
|
|
|
void setDisplayWaterfall(bool display);
|
2015-06-11 20:49:29 -04:00
|
|
|
void setSsbSpectrum(bool ssbSpectrum);
|
2014-05-18 11:52:39 -04:00
|
|
|
void setInvertedWaterfall(bool inv);
|
|
|
|
void setDisplayMaxHold(bool display);
|
2015-07-15 22:55:14 -04:00
|
|
|
void setDisplayCurrent(bool display);
|
2014-05-18 11:52:39 -04:00
|
|
|
void setDisplayHistogram(bool display);
|
|
|
|
void setDisplayGrid(bool display);
|
2015-05-12 09:49:03 -04:00
|
|
|
void setDisplayGridIntensity(int intensity);
|
2015-07-18 11:53:57 -04:00
|
|
|
void setDisplayTraceIntensity(int intensity);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
void addChannelMarker(ChannelMarker* channelMarker);
|
|
|
|
void removeChannelMarker(ChannelMarker* channelMarker);
|
|
|
|
|
|
|
|
void newSpectrum(const std::vector<Real>& spectrum, int fftSize);
|
2015-07-23 19:09:03 -04:00
|
|
|
void clearSpectrumHistogram();
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-07-23 19:30:00 -04:00
|
|
|
Real getWaterfallShare() const { return m_waterfallShare; }
|
|
|
|
void setWaterfallShare(Real waterfallShare);
|
2015-07-31 21:33:07 -04:00
|
|
|
void connectTimer(const QTimer& timer);
|
2015-07-23 19:30:00 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
private:
|
|
|
|
struct ChannelMarkerState {
|
|
|
|
ChannelMarker* m_channelMarker;
|
2016-03-03 19:30:29 -05:00
|
|
|
QMatrix4x4 m_glMatrixWaterfall;
|
|
|
|
QMatrix4x4 m_glMatrixDsbWaterfall;
|
2016-03-03 20:24:08 -05:00
|
|
|
QMatrix4x4 m_glMatrixFreqScale;
|
2016-03-03 21:45:34 -05:00
|
|
|
QMatrix4x4 m_glMatrixDsbFreqScale;
|
|
|
|
QMatrix4x4 m_glMatrixHistogram;
|
|
|
|
QMatrix4x4 m_glMatrixDsbHistogram;
|
2014-05-18 11:52:39 -04:00
|
|
|
QRect m_rect;
|
|
|
|
|
|
|
|
ChannelMarkerState(ChannelMarker* channelMarker) :
|
2016-03-05 01:02:06 -05:00
|
|
|
m_channelMarker(channelMarker)
|
2014-05-18 11:52:39 -04:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
QList<ChannelMarkerState*> m_channelMarkerStates;
|
|
|
|
|
|
|
|
enum CursorState {
|
|
|
|
CSNormal,
|
|
|
|
CSSplitter,
|
|
|
|
CSSplitterMoving,
|
|
|
|
CSChannel,
|
|
|
|
CSChannelMoving
|
|
|
|
};
|
|
|
|
|
|
|
|
CursorState m_cursorState;
|
|
|
|
int m_cursorChannel;
|
|
|
|
|
|
|
|
QTimer m_timer;
|
|
|
|
QMutex m_mutex;
|
|
|
|
bool m_mouseInside;
|
|
|
|
bool m_changesPending;
|
|
|
|
|
|
|
|
qint64 m_centerFrequency;
|
|
|
|
Real m_referenceLevel;
|
|
|
|
Real m_powerRange;
|
|
|
|
int m_decay;
|
|
|
|
quint32 m_sampleRate;
|
|
|
|
|
|
|
|
int m_fftSize;
|
|
|
|
|
|
|
|
bool m_displayGrid;
|
2015-05-12 09:49:03 -04:00
|
|
|
int m_displayGridIntensity;
|
2015-07-18 11:53:57 -04:00
|
|
|
int m_displayTraceIntensity;
|
2014-05-18 11:52:39 -04:00
|
|
|
bool m_invertedWaterfall;
|
|
|
|
|
|
|
|
std::vector<Real> m_maxHold;
|
|
|
|
bool m_displayMaxHold;
|
2015-07-16 02:38:33 -04:00
|
|
|
const std::vector<Real> *m_currentSpectrum;
|
2015-07-15 22:55:14 -04:00
|
|
|
bool m_displayCurrent;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
Real m_waterfallShare;
|
|
|
|
|
|
|
|
QPixmap m_leftMarginPixmap;
|
2016-03-05 02:53:56 -05:00
|
|
|
QPixmap m_frequencyPixmap;
|
2014-05-18 11:52:39 -04:00
|
|
|
ScaleEngine m_timeScale;
|
|
|
|
ScaleEngine m_powerScale;
|
|
|
|
ScaleEngine m_frequencyScale;
|
|
|
|
QRect m_frequencyScaleRect;
|
2016-03-03 13:56:54 -05:00
|
|
|
QMatrix4x4 m_glFrequencyScaleBoxMatrix;
|
|
|
|
QMatrix4x4 m_glLeftScaleBoxMatrix;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
QRgb m_waterfallPalette[240];
|
|
|
|
QImage* m_waterfallBuffer;
|
|
|
|
int m_waterfallBufferPos;
|
|
|
|
int m_waterfallTextureHeight;
|
|
|
|
int m_waterfallTexturePos;
|
2016-03-03 13:56:54 -05:00
|
|
|
QMatrix4x4 m_glWaterfallBoxMatrix;
|
2014-05-18 11:52:39 -04:00
|
|
|
bool m_displayWaterfall;
|
2015-06-11 20:49:29 -04:00
|
|
|
bool m_ssbSpectrum;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
QRgb m_histogramPalette[240];
|
|
|
|
QImage* m_histogramBuffer;
|
|
|
|
quint8* m_histogram;
|
|
|
|
quint8* m_histogramHoldoff;
|
|
|
|
int m_histogramHoldoffBase;
|
|
|
|
int m_histogramHoldoffCount;
|
|
|
|
int m_histogramLateHoldoff;
|
2015-07-15 02:48:02 -04:00
|
|
|
int m_histogramStroke;
|
2016-03-02 19:41:30 -05:00
|
|
|
QMatrix4x4 m_glHistogramSpectrumMatrix;
|
|
|
|
QMatrix4x4 m_glHistogramBoxMatrix;
|
2014-05-18 11:52:39 -04:00
|
|
|
bool m_displayHistogram;
|
|
|
|
|
|
|
|
bool m_displayChanged;
|
|
|
|
|
2016-03-03 13:56:54 -05:00
|
|
|
GLShaderSimple m_glShaderSimple;
|
2016-03-05 00:45:05 -05:00
|
|
|
GLShaderTextured m_glShaderLeftScale;
|
2016-03-05 02:53:56 -05:00
|
|
|
GLShaderTextured m_glShaderFrequencyScale;
|
2016-03-05 05:57:53 -05:00
|
|
|
GLShaderTextured m_glShaderWaterfall;
|
2016-03-05 08:28:55 -05:00
|
|
|
GLShaderTextured m_glShaderHistogram;
|
2016-03-01 21:09:50 -05:00
|
|
|
int m_matrixLoc;
|
|
|
|
int m_colorLoc;
|
|
|
|
|
2016-03-05 05:57:53 -05:00
|
|
|
static const int m_waterfallBufferHeight = 256;
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
void updateWaterfall(const std::vector<Real>& spectrum);
|
|
|
|
void updateHistogram(const std::vector<Real>& spectrum);
|
|
|
|
|
|
|
|
void initializeGL();
|
|
|
|
void resizeGL(int width, int height);
|
|
|
|
void paintGL();
|
|
|
|
|
|
|
|
void stopDrag();
|
|
|
|
void applyChanges();
|
|
|
|
|
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
|
|
|
|
|
|
|
void enterEvent(QEvent* event);
|
|
|
|
void leaveEvent(QEvent* event);
|
|
|
|
|
|
|
|
private slots:
|
2016-03-06 03:33:10 -05:00
|
|
|
void cleanup();
|
2014-05-18 11:52:39 -04:00
|
|
|
void tick();
|
|
|
|
void channelMarkerChanged();
|
|
|
|
void channelMarkerDestroyed(QObject* object);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_GLSPECTRUM_H
|