1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
|
#ifndef RECEIVERWIDGET_H
#define RECEIVERWIDGET_H
#include <QWidget>
#include <QMutex>
#include <QMutexLocker>
#include <QSplitter>
#include <QComboBox>
#include <QLabel>
#include <QCheckBox>
#include <QPushButton>
#include <QSlider>
#include <QSpacerItem>
#include <QElapsedTimer>
#include <QTimer>
#include <qcustomplot.h>
#include "freqctrl.h"
#include "cluster.h"
#include "wfviewtypes.h"
#include "colorprefs.h"
#include "rigidentities.h"
#include "cachingqueue.h"
enum scopeTypes {
scopeSpectrum=0,
scopeWaterfall,
scopeNone
};
struct bandIndicator {
QCPItemLine* line;
QCPItemText* text;
};
class receiverWidget : public QGroupBox
{
Q_OBJECT
public:
explicit receiverWidget(bool scope, uchar receiver = 0, uchar vfo = 1, QWidget *parent = nullptr);
~receiverWidget();
bool prepareWf(uint wfLength);
void prepareScope(uint ampMap, uint spectWidth);
void changeWfLength(uint wf);
bool updateScope(scopeData spectrum);
void setRange(int floor, int ceiling);
void wfInterpolate(bool en) { colorMap->setInterpolate(en); }
void wfAntiAliased(bool en) { colorMap->setAntialiased(en); }
void wfTheme(int num);
void setUnderlayMode(underlay_t un) { underlayMode = un; clearPeaks(); }
void overflow(bool en) {ovfIndicator->setVisible(en); }
void resizePlasmaBuffer(int size );
void colorPreset(colorPrefsType *p );
void setCenterFreq (double hz) { passbandCenterFrequency = hz; }
double getCenterFreq () { return passbandCenterFrequency; }
void setPassbandWidth(double hz) { passbandWidth = hz;}
double getPassbandWidth() { configFilterWidth->setValue(passbandWidth*1E6); return passbandWidth; }
void setIdentity(QString name) {this->setTitle(name); }
uchar getReceiver() { return receiver; }
void setTuningFloorZeros(bool tf) {this->tuningFloorZeros = tf; }
void setClickDragTuning(bool cg) { this->clickDragTuning = cg; }
void setSatMode(bool sm) { this->satMode = sm; satelliteButton->blockSignals(true); satelliteButton->setChecked(sm); satelliteButton->blockSignals(false); }
void setScrollSpeedXY(int clicksX, int clicksY) { this->scrollXperClick = clicksX; this->scrollYperClick = clicksY;}
void displayScope(bool en);
void receiveCwPitch(quint16 p);
quint16 getCwPitch() { return cwPitch;}
void receivePassband(quint16 pass);
double getPBTInner () { return PBTInner;}
void setPBTInner (uchar val);
double getPBTOuter () { return PBTOuter;}
void setPBTOuter (uchar val);
void setIFShift (uchar val);
quint16 getStepSize () { return stepSize;}
void setStepSize (quint64 hz) { stepSize = hz;}
freqt getFrequency () { return freq;}
void setFrequencyLocally (freqt f,uchar vfo=0);
void setFrequency (freqt f,uchar vfo=0);
void updateInfo();
uchar getNumVFO () { return numVFO;}
void receiveMode (modeInfo m, uchar vfo=0);
void setEdge(uchar index);
void setHold(bool h);
void setSpeed(uchar s);
void setSpan(centerSpanData s);
void setScopeMode(spectrumMode_t m);
void setSplit(bool en) { splitButton->blockSignals(true);splitButton->setChecked(en); splitButton->blockSignals(false);}
void setTracking(bool en) { tracking=en; }
void setRef(int ref);
void setRefLimits(int lower, int upper);
void setFreqLock( bool en) { freqLock = en; }
void setRoofing(uchar val);
void setFilterShape(uchar val);
void setBandIndicators(bool show, QString region, std::vector<bandType>* bands);
void setUnit(FctlUnit unit);
void setSeparators(QChar group, QChar decimal);
modeInfo currentMode() {return mode;}
uchar currentFilter() {return filterCombo->currentData().toInt();}
void clearSpans() { spanCombo->clear();}
void clearMode() { modeCombo->clear();}
void clearData() { dataCombo->clear();}
void clearFilter() { filterCombo->clear();}
void clearRoofing() { roofingCombo->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 addRoofing(QString text, QVariant data) {roofingCombo->blockSignals(true); roofingCombo->addItem(text,data); roofingCombo->blockSignals(false);}
void selected(bool);
bool isSelected() {return isActive;}
void showScope(bool en) { this->splitter->setVisible(en); }
void displaySettings(int NumDigits, qint64 Minf, qint64 Maxf, int MinStep,FctlUnit unit,std::vector<bandType>* bands = Q_NULLPTR);
quint8 getDataMode() { return static_cast<quint8>(dataCombo->currentIndex()); }
void changeSpan(qint8 val);
void updateBSR(std::vector<bandType>* bands);
QImage getSpectrumImage();
QImage getWaterfallImage();
bandType getCurrentBand();
public slots: // Can be called directly or updated via signal/slot
void receiveSpots(uchar receiver, QList<spotData> spots);
void memoryMode(bool en);
signals:
void frequencyRange(uchar receiver, double start, double end);
void updateScopeMode(spectrumMode_t index);
void updateSpan(centerSpanData s);
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);
void bandChanged(uchar receiver, bandType b);
void spectrumTime(double time);
void waterfallTime(double time);
void sendScopeImage(uchar receiver);
void sendTrack(int f);
private slots:
void detachScope(bool state);
void updatedMode(int index);
void toFixedPressed();
void customSpanPressed();
void configPressed();
void freqNoteLockTimerSlot();
// Mouse interaction with scope/waterfall
void scopeClick(QMouseEvent *);
void scopeMouseRelease(QMouseEvent *);
void scopeMouseMove(QMouseEvent *);
void doubleClick(QMouseEvent *); // used for both scope and wf
void waterfallClick(QMouseEvent *);
void scroll(QWheelEvent *);
void clearPeaks();
void newFrequency(qint64 freq,uchar i=0);
void receiveTrack(int f);
private:
void clearPlasma();
void computePlasma();
void showHideControls(spectrumMode_t mode);
void showBandIndicators(bool en);
void vfoSwap();
quint64 roundFrequency(quint64 frequency, unsigned int tsHz);
quint64 roundFrequency(quint64 frequency, int steps, unsigned int tsHz);
QString defaultStyleSheet;
QMutex mutex;
QWidget* originalParent = Q_NULLPTR;
QLabel* windowLabel = Q_NULLPTR;
QCustomPlot* spectrum = Q_NULLPTR;
QCustomPlot* waterfall = Q_NULLPTR;
QLinearGradient spectrumGradient;
QLinearGradient underlayGradient;
QList <freqCtrl*> freqDisplay;
QSpacerItem* displayLSpacer;
QPushButton* vfoSelectButton;
QSpacerItem* displayCSpacer;
QPushButton* vfoSwapButton;
QPushButton* vfoEqualsButton;
QPushButton* vfoMemoryButton;
QPushButton* satelliteButton;
QSpacerItem* displayMSpacer;
QPushButton* splitButton;
QSpacerItem* displayRSpacer;
QGroupBox* group;
QSplitter* splitter;
QHBoxLayout* mainLayout;
QVBoxLayout* layout;
QVBoxLayout* rhsLayout;
QHBoxLayout* displayLayout;
QHBoxLayout* controlLayout;
QPushButton* detachButton;
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* filterShapeCombo;
QComboBox* roofingCombo;
QComboBox* antennaCombo;
QPushButton* holdButton;
QSlider* dummySlider;
// Config screen
QSpacerItem* rhsTopSpacer;
QSpacerItem* rhsBottomSpacer;
QGroupBox* configGroup;
QFormLayout* configLayout;
QHBoxLayout* configIfLayout;
QSlider* configRef;
QSlider* configLength;
QSlider* configBottom;
QSlider* configTop;
QComboBox* configSpeed;
QComboBox* configTheme;
QSlider* configPbtInner;
QSlider* configPbtOuter;
QSlider* configIfShift;
QPushButton* configResetIf;
QSlider* configFilterWidth;
QCheckBox* configScopeEnabled;
// These parameters relate to scroll wheel response:
int scrollYperClick = 24;
int scrollXperClick = 24;
qreal scrollWheelOffsetAccumulated=0;
QTimer *frequencyNotificationLockoutTimer = NULL;
bool allowAcceptFreqData = true;
void tempLockAcceptFreqData();
QCheckBox* rxCheckBox;
QPushButton* confButton;
QSpacerItem* controlSpacer;
QSpacerItem* midSpacer;
QCPColorGradient::GradientPreset currentTheme = QCPColorGradient::gpSpectrum;
int currentRef = 0;
uchar currentSpeed = 0;
colorPrefsType colors;
freqt freq;
modeInfo mode;
modeInfo unselectedMode;
freqt unselectedFreq;
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;
QCPItemText* redrawSpeed;
QByteArray spectrumPeaks;
QVector <double> spectrumPlasmaLine;
QVector <QByteArray> spectrumPlasma;
QVector<bandIndicator> bandIndicators;
unsigned int spectrumPlasmaSizeCurrent = 64;
unsigned int spectrumPlasmaSizeMax = 128;
unsigned int spectrumPlasmaPosition = 0;
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 = 1.0; // Invalid value to start.
double PBTOuter = 1.0; // Invalid value to start.
double passbandWidth = 0.0;
double passbandCenterFrequency = 0.0;
double pbtDefault = 0.0;
quint16 cwPitch = 600;
quint64 stepSize = 100;
uchar ifShift = 0;
int refLower=0;
int refUpper=0;
// Waterfall items;
QCPColorMap * colorMap = Q_NULLPTR;
QCPColorMapData * colorMapData = Q_NULLPTR;
QCPColorScale * colorScale = Q_NULLPTR;
QVector <QByteArray> wfimage;
cachingQueue* queue;
uchar receiver=0;
uchar rxcmd=0;
double startFrequency;
QMap<QString, spotData*> clusterSpots;
// Assorted settings
bool tuningFloorZeros=false;
bool clickDragTuning=false;
bool isActive;
uchar numVFO=1;
uchar selectedVFO=0;
bool hasScope=true;
QString currentRegion="1";
spectrumMode_t currentScopeMode=spectrumMode_t::spectModeUnknown;
bool bandIndicatorsVisible=false;
rigCapabilities* rigCaps=Q_NULLPTR;
bandType currentBand;
QElapsedTimer lastData;
bool satMode = false;
bool memMode = false;
bool tracking = false;
qint64 freqOffset = 0;
double minFreqMhz = 0.0;
double maxFreqMhz = 0.0;
bool freqLock = false;
};
#endif // RECEIVERWIDGET_H
|