wfview/spectrumscope.h

280 wiersze
8.6 KiB
C
Czysty Zwykły widok Historia

2023-06-01 16:57:44 +00:00
#ifndef SPECTRUMSCOPE_H
#define SPECTRUMSCOPE_H
#include <QWidget>
#include <QMutex>
#include <QMutexLocker>
#include <QSplitter>
2023-06-05 08:27:37 +00:00
#include <QComboBox>
#include <QLabel>
#include <QCheckBox>
#include <QPushButton>
2023-09-23 21:06:28 +00:00
#include <QSlider>
2023-06-05 08:27:37 +00:00
#include <QSpacerItem>
#include <QElapsedTimer>
2023-06-01 16:57:44 +00:00
#include <qcustomplot.h>
2023-09-26 18:09:01 +00:00
#include "freqctrl.h"
2023-06-05 20:08:01 +00:00
#include "cluster.h"
2023-06-01 16:57:44 +00:00
#include "wfviewtypes.h"
#include "colorprefs.h"
2023-06-05 08:27:37 +00:00
#include "rigidentities.h"
#include "cachingqueue.h"
2023-06-01 16:57:44 +00:00
enum scopeTypes {
scopeSpectrum=0,
scopeWaterfall,
scopeNone
};
2023-06-05 08:27:37 +00:00
class spectrumScope : public QGroupBox
2023-06-01 16:57:44 +00:00
{
Q_OBJECT
public:
explicit spectrumScope(uchar receiver = 0, uchar vfo = 1, QWidget *parent = nullptr);
2023-06-01 16:57:44 +00:00
bool prepareWf(uint wfLength);
void prepareScope(uint ampMap, uint spectWidth);
2024-01-27 22:13:47 +00:00
bool updateScope(scopeData spectrum);
2023-06-01 16:57:44 +00:00
void setRange(int floor, int ceiling);
void wfInterpolate(bool en) { colorMap->setInterpolate(en); }
void wfAntiAliased(bool en) { colorMap->setAntialiased(en); }
2023-07-16 09:08:28 +00:00
void wfTheme(int num);
2023-06-01 16:57:44 +00:00
void setUnderlayMode(underlay_t un) { underlayMode = un; clearPeaks();}
void overflow(bool en) {ovfIndicator->setVisible(en);}
void resizePlasmaBuffer(int size);
void colorPreset(colorPrefsType *p);
2023-06-05 08:27:37 +00:00
2023-06-01 16:57:44 +00:00
void setCenterFreq (double hz) { passbandCenterFrequency = hz;}
double getCenterFreq () { return passbandCenterFrequency;}
2023-06-05 08:27:37 +00:00
void setPassbandWidth(double hz) { passbandWidth = hz;}
2023-09-25 13:55:27 +00:00
double getPassbandWidth() { configFilterWidth->setValue(passbandWidth*1E6); return passbandWidth;}
2023-06-05 08:27:37 +00:00
void setIdentity(QString name) {this->setTitle(name);}
bool getVfo() { return receiver;}
2023-06-05 08:27:37 +00:00
2023-06-08 07:20:50 +00:00
void setTuningFloorZeros(bool tf) {this->tuningFloorZeros = tf;}
void setClickDragTuning(bool cg) { this->clickDragTuning = cg;}
void setScrollSpeedXY(int clicksX, int clicksY) { this->scrollXperClick = clicksX; this->scrollYperClick = clicksY;}
2023-06-08 07:20:50 +00:00
2023-06-11 21:31:32 +00:00
void enableScope(bool en);
2023-06-05 08:27:37 +00:00
void receiveCwPitch(uchar p);
quint16 getCwPitch() { return cwPitch;}
void receivePassband(quint16 pass);
double getPBTInner () { return PBTInner;}
2024-02-10 12:11:10 +00:00
void setPBTInner (uchar val);
2023-06-05 08:27:37 +00:00
double getPBTOuter () { return PBTOuter;}
2024-02-10 12:11:10 +00:00
void setPBTOuter (uchar val);
2023-06-05 08:27:37 +00:00
quint16 getStepSize () { return stepSize;}
void setStepSize (quint16 hz) { stepSize = hz;}
2023-06-01 16:57:44 +00:00
freqt getFrequency () { return freq;}
void setFrequency (freqt f,uchar vfo=0);
2023-06-01 16:57:44 +00:00
uchar getNumVFO () { return numVFO;}
void receiveMode (modeInfo m, uchar vfo=0);
modeInfo currentMode() {return mode;}
2023-06-05 08:27:37 +00:00
void clearSpans() { spanCombo->clear();}
void clearMode() { modeCombo->clear();}
void clearData() { dataCombo->clear();}
void clearFilter() { filterCombo->clear();}
void addSpan(QString text, QVariant data) {spanCombo->blockSignals(true); spanCombo->addItem(text,data); spanCombo->blockSignals(false);}
void addMode(QString text, QVariant data) {modeCombo->blockSignals(true); modeCombo->addItem(text,data); modeCombo->blockSignals(false);}
void addData(QString text, QVariant data) {dataCombo->blockSignals(true); dataCombo->addItem(text,data); dataCombo->blockSignals(false);}
void addFilter(QString text, QVariant data) {filterCombo->blockSignals(true); filterCombo->addItem(text,data); filterCombo->blockSignals(false);}
void selected(bool);
2024-02-10 19:54:39 +00:00
bool isSelected() {return isActive;}
void setHold(bool h);
void setSpeed(uchar s);
2023-09-26 17:46:04 +00:00
void displaySettings(int NumDigits, qint64 Minf, qint64 Maxf, int MinStep,FctlUnit unit,std::vector<bandType>* bands = Q_NULLPTR);
void setUnit(FctlUnit unit);
2023-09-27 11:28:43 +00:00
void setRefLimits(int lower, int upper);
void setRef(int ref);
2023-09-30 10:08:20 +00:00
unsigned char getDataMode() { return static_cast<unsigned char>(dataCombo->currentIndex()); }
2023-06-05 08:27:37 +00:00
public slots: // Can be called directly or updated via signal/slot
void selectScopeMode(spectrumMode_t m);
void selectSpan(centerSpanData s);
void receiveSpots(uchar receiver, QList<spotData> spots);
2023-06-05 08:27:37 +00:00
signals:
void frequencyRange(uchar receiver, double start, double end);
2023-06-05 08:27:37 +00:00
void updateScopeMode(spectrumMode_t index);
void updateSpan(centerSpanData s);
2023-06-08 07:20:50 +00:00
void showStatusBarText(QString text);
void updateSettings(uchar receiver, int value, quint16 len, int floor, int ceiling);
void elapsedTime(uchar receiver, qint64 ns);
void dataChanged(modeInfo m);
2023-06-01 16:57:44 +00:00
2023-06-05 08:27:37 +00:00
private slots:
void detachScope(bool state);
2023-06-05 08:27:37 +00:00
void updatedScopeMode(int index);
void updatedSpan(int index);
void updatedEdge(int index);
void updatedMode(int index);
void holdPressed(bool en);
2023-06-05 08:27:37 +00:00
void toFixedPressed();
void customSpanPressed();
2023-07-16 09:08:28 +00:00
void configPressed();
2023-06-01 16:57:44 +00:00
2023-06-05 08:27:37 +00:00
// Mouse interaction with scope/waterfall
void scopeClick(QMouseEvent *);
void scopeMouseRelease(QMouseEvent *);
void scopeMouseMove(QMouseEvent *);
2023-06-05 20:08:01 +00:00
void doubleClick(QMouseEvent *); // used for both scope and wf
2023-06-05 08:27:37 +00:00
void waterfallClick(QMouseEvent *);
void scroll(QWheelEvent *);
2023-06-01 16:57:44 +00:00
void clearPeaks();
2024-03-30 21:26:39 +00:00
void newFrequency(qint64 freq,uchar i=0);
2023-09-26 17:46:04 +00:00
2023-06-05 20:08:01 +00:00
private:
2023-06-01 16:57:44 +00:00
void clearPlasma();
void computePlasma();
2023-06-05 08:27:37 +00:00
void showHideControls(spectrumMode_t mode);
quint64 roundFrequency(quint64 frequency, unsigned int tsHz);
quint64 roundFrequency(quint64 frequency, int steps, unsigned int tsHz);
2023-06-01 16:57:44 +00:00
2023-09-25 13:55:27 +00:00
QString defaultStyleSheet;
2023-06-01 16:57:44 +00:00
QMutex mutex;
QWidget* originalParent = Q_NULLPTR;
QLabel* windowLabel = Q_NULLPTR;
2023-06-01 16:57:44 +00:00
QCustomPlot* spectrum = Q_NULLPTR;
QCustomPlot* waterfall = Q_NULLPTR;
freqCtrl* freqDisplay[2];
2023-09-26 17:46:04 +00:00
QSpacerItem* displaySpacer;
2023-06-05 08:27:37 +00:00
QGroupBox* group;
2023-06-01 16:57:44 +00:00
QSplitter* splitter;
2023-09-24 23:11:37 +00:00
QHBoxLayout* mainLayout;
2023-06-01 16:57:44 +00:00
QVBoxLayout* layout;
2023-09-25 13:55:27 +00:00
QVBoxLayout* rhsLayout;
2023-09-26 17:46:04 +00:00
QHBoxLayout* displayLayout;
2023-06-05 08:27:37 +00:00
QHBoxLayout* controlLayout;
QPushButton* detachButton;
2023-06-05 08:27:37 +00:00
QLabel* scopeModeLabel;
QComboBox* scopeModeCombo;
QLabel* spanLabel;
QComboBox* spanCombo;
QLabel* edgeLabel;
QComboBox* edgeCombo;
QPushButton* edgeButton;
QPushButton* toFixedButton;
QPushButton* clearPeaksButton;
QLabel* themeLabel;
QComboBox* modeCombo;
QComboBox* dataCombo;
QComboBox* filterCombo;
QComboBox* antennaCombo;
QPushButton* holdButton;
2023-09-23 21:06:28 +00:00
QSlider* dummySlider;
2023-09-24 23:11:37 +00:00
// Config screen
2023-09-25 13:55:27 +00:00
QSpacerItem* rhsTopSpacer;
QSpacerItem* rhsBottomSpacer;
2023-09-24 23:11:37 +00:00
QGroupBox* configGroup;
QFormLayout* configLayout;
QSlider* configRef;
QSlider* configLength;
QSlider* configBottom;
QSlider* configTop;
QComboBox* configSpeed;
QComboBox* configTheme;
QSlider* configPbtInner;
QSlider* configPbtOuter;
QSlider* configIfShift;
QSlider* configFilterWidth;
2023-09-25 17:03:31 +00:00
// These parameters relate to scroll wheel response:
int scrollYperClick = 24;
int scrollXperClick = 24;
float scrollWheelOffsetAccumulated=0;
2023-06-05 08:27:37 +00:00
QCheckBox* rxCheckBox;
2023-07-16 09:08:28 +00:00
2023-09-25 18:21:31 +00:00
QPushButton* confButton;
2023-06-05 08:27:37 +00:00
QSpacerItem* controlSpacer;
QSpacerItem* midSpacer;
2023-07-16 09:46:30 +00:00
QCPColorGradient::GradientPreset currentTheme = QCPColorGradient::gpSpectrum;
2023-07-16 09:08:28 +00:00
int currentRef = 0;
uchar currentSpeed = 0;
2023-06-01 16:57:44 +00:00
colorPrefsType colors;
freqt freq;
2023-06-05 08:27:37 +00:00
modeInfo mode;
bool lock = false;
2023-06-01 16:57:44 +00:00
bool scopePrepared=false;
quint16 spectWidth=689;
quint16 maxAmp=200;
quint16 wfLength;
quint16 wfLengthMax;
double lowerFreq=0.0;
double upperFreq=0.0;
// Spectrum items;
QCPItemLine * freqIndicatorLine;
QCPItemRect* passbandIndicator;
QCPItemRect* pbtIndicator;
QCPItemText* oorIndicator;
QCPItemText* ovfIndicator;
2024-01-22 12:19:31 +00:00
QCPItemText* redrawSpeed;
2023-06-01 16:57:44 +00:00
QByteArray spectrumPeaks;
QVector <double> spectrumPlasmaLine;
QVector <QByteArray> spectrumPlasma;
unsigned int spectrumPlasmaSizeCurrent = 64;
unsigned int spectrumPlasmaSizeMax = 128;
unsigned int spectrumPlasmaPosition = 0;
2023-06-01 16:57:44 +00:00
underlay_t underlayMode = underlayNone;
QMutex plasmaMutex;
double plotFloor = 0;
double plotCeiling = 160;
double wfFloor = 0;
double wfCeiling = 160;
double oldPlotFloor = -1;
double oldPlotCeiling = 999;
double mousePressFreq = 0.0;
double mouseReleaseFreq = 0.0;
passbandActions passbandAction = passbandStatic;
double PBTInner = 0.0;
double PBTOuter = 0.0;
double passbandWidth = 0.0;
double passbandCenterFrequency = 0.0;
double pbtDefault = 0.0;
quint16 cwPitch = 600;
2023-06-05 08:27:37 +00:00
quint16 stepSize = 100;
2023-09-27 11:28:43 +00:00
int refLower=0;
int refUpper=0;
2023-06-01 16:57:44 +00:00
// Waterfall items;
QCPColorMap * colorMap = Q_NULLPTR;
QCPColorMapData * colorMapData = Q_NULLPTR;
QCPColorScale * colorScale = Q_NULLPTR;
QVector <QByteArray> wfimage;
2023-06-05 08:27:37 +00:00
cachingQueue* queue;
uchar receiver=0;
2023-06-05 20:08:01 +00:00
double startFrequency;
QMap<QString, spotData*> clusterSpots;
2023-06-08 07:20:50 +00:00
// Assorted settings
bool tuningFloorZeros=false;
bool clickDragTuning=false;
2024-02-10 19:54:39 +00:00
bool isActive;
uchar numVFO=1;
2023-06-01 16:57:44 +00:00
};
#endif // SPECTRUMSCOPE_H