2012-05-22 13:09:48 -04:00
|
|
|
#include "widegraph.h"
|
|
|
|
#include "ui_widegraph.h"
|
2012-10-10 20:51:16 -04:00
|
|
|
#include "commons.h"
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-07-30 16:36:14 -04:00
|
|
|
#define MAX_SCREENSIZE 2048
|
|
|
|
|
2013-08-10 11:29:55 -04:00
|
|
|
WideGraph::WideGraph(QSettings * settings, QWidget *parent) :
|
2012-05-22 13:09:48 -04:00
|
|
|
QDialog(parent),
|
2013-08-10 11:29:55 -04:00
|
|
|
ui(new Ui::WideGraph),
|
|
|
|
m_settings (settings)
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
2013-08-10 21:30:05 -04:00
|
|
|
ui->setupUi(this);
|
2013-08-10 11:29:55 -04:00
|
|
|
|
|
|
|
setWindowTitle ("Wide Graph");
|
|
|
|
setWindowFlags (Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
|
|
|
|
setMaximumWidth (MAX_SCREENSIZE);
|
|
|
|
setMaximumHeight (880);
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->widePlot->setCursor(Qt::CrossCursor);
|
|
|
|
ui->widePlot->setMaximumHeight(800);
|
2012-10-10 20:51:16 -04:00
|
|
|
ui->widePlot->m_bCurrent=false;
|
2012-05-22 13:09:48 -04:00
|
|
|
|
|
|
|
connect(ui->widePlot, SIGNAL(freezeDecode1(int)),this,
|
|
|
|
SLOT(wideFreezeDecode(int)));
|
|
|
|
|
2013-07-08 09:17:22 -04:00
|
|
|
connect(ui->widePlot, SIGNAL(setFreq1(int,int)),this,
|
|
|
|
SLOT(setFreq2(int,int)));
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
//Restore user's settings
|
2013-08-10 11:29:55 -04:00
|
|
|
m_settings->beginGroup("WideGraph");
|
|
|
|
restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ());
|
|
|
|
ui->widePlot->setPlotZero(m_settings->value("PlotZero", 0).toInt());
|
|
|
|
ui->widePlot->setPlotGain(m_settings->value("PlotGain", 0).toInt());
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->zeroSpinBox->setValue(ui->widePlot->getPlotZero());
|
|
|
|
ui->gainSpinBox->setValue(ui->widePlot->getPlotGain());
|
2013-08-10 11:29:55 -04:00
|
|
|
int n = m_settings->value("FreqSpan",2).toInt();
|
|
|
|
int w = m_settings->value("PlotWidth",1000).toInt();
|
2012-10-29 13:58:33 -04:00
|
|
|
ui->widePlot->m_w=w;
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->freqSpanSpinBox->setValue(n);
|
2012-09-24 19:36:38 -04:00
|
|
|
ui->widePlot->setNSpan(n);
|
2013-08-10 11:29:55 -04:00
|
|
|
m_waterfallAvg = m_settings->value("WaterfallAvg",5).toInt();
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->waterfallAvgSpinBox->setValue(m_waterfallAvg);
|
2013-08-10 11:29:55 -04:00
|
|
|
ui->widePlot->m_bCurrent=m_settings->value("Current",false).toBool();
|
|
|
|
ui->widePlot->m_bCumulative=m_settings->value("Cumulative",true).toBool();
|
2013-03-06 11:37:28 -05:00
|
|
|
if(ui->widePlot->m_bCurrent) ui->spec2dComboBox->setCurrentIndex(0);
|
|
|
|
if(ui->widePlot->m_bCumulative) ui->spec2dComboBox->setCurrentIndex(1);
|
2013-08-10 11:29:55 -04:00
|
|
|
int nbpp=m_settings->value("BinsPerPixel",2).toInt();
|
2012-10-11 18:59:36 -04:00
|
|
|
ui->widePlot->setBinsPerPixel(nbpp);
|
2013-08-10 11:29:55 -04:00
|
|
|
m_slope=m_settings->value("Slope",0.0).toDouble();
|
2013-07-08 09:17:22 -04:00
|
|
|
ui->slopeSpinBox->setValue(m_slope);
|
2013-08-10 11:29:55 -04:00
|
|
|
ui->widePlot->setStartFreq(m_settings->value("StartFreq",0).toInt());
|
2013-07-25 12:48:10 -04:00
|
|
|
ui->fStartSpinBox->setValue(ui->widePlot->startFreq());
|
2013-08-10 11:29:55 -04:00
|
|
|
m_waterfallPalette=m_settings->value("WaterfallPalette","Default").toString();
|
|
|
|
int m_fMin = m_settings->value ("fMin", 2500).toInt ();
|
|
|
|
ui->fMinSpinBox->setValue (m_fMin);
|
|
|
|
setRxRange (m_fMin);
|
|
|
|
m_settings->endGroup();
|
2013-08-07 14:59:11 -04:00
|
|
|
|
|
|
|
QDir recoredDir("Palettes");
|
|
|
|
QStringList allFiles = recoredDir.entryList(QDir::NoDotAndDotDot |
|
|
|
|
QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files,
|
|
|
|
QDir::DirsFirst);
|
|
|
|
int index=0;
|
|
|
|
foreach(QString file, allFiles) {
|
|
|
|
QString t=file.mid(0,file.length()-4);
|
|
|
|
ui->paletteComboBox->addItem(t);
|
|
|
|
if(t==m_waterfallPalette) {
|
|
|
|
ui->paletteComboBox->setCurrentIndex(index);
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
// ui->paletteComboBox->lineEdit()->setAlignment(Qt::AlignHCenter);
|
2013-08-07 10:49:45 -04:00
|
|
|
readPalette("Palettes/" + m_waterfallPalette + ".pal");
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
2013-08-10 11:29:55 -04:00
|
|
|
WideGraph::~WideGraph ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::closeEvent (QCloseEvent * e)
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
2013-08-10 11:29:55 -04:00
|
|
|
saveSettings ();
|
|
|
|
QDialog::closeEvent (e);
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::saveSettings()
|
|
|
|
{
|
2013-08-10 11:29:55 -04:00
|
|
|
m_settings->beginGroup ("WideGraph");
|
|
|
|
m_settings->setValue ("geometry", saveGeometry ());
|
|
|
|
m_settings->setValue ("PlotZero", ui->widePlot->m_plotZero);
|
|
|
|
m_settings->setValue ("PlotGain", ui->widePlot->m_plotGain);
|
|
|
|
m_settings->setValue ("PlotWidth", ui->widePlot->plotWidth ());
|
|
|
|
m_settings->setValue ("FreqSpan", ui->freqSpanSpinBox->value ());
|
|
|
|
m_settings->setValue ("WaterfallAvg", ui->waterfallAvgSpinBox->value ());
|
|
|
|
m_settings->setValue ("Current", ui->widePlot->m_bCurrent);
|
|
|
|
m_settings->setValue ("Cumulative", ui->widePlot->m_bCumulative);
|
|
|
|
m_settings->setValue ("BinsPerPixel", ui->widePlot->binsPerPixel ());
|
|
|
|
m_settings->setValue ("Slope", m_slope);
|
|
|
|
m_settings->setValue ("StartFreq", ui->widePlot->startFreq ());
|
|
|
|
m_settings->setValue ("WaterfallPalette", m_waterfallPalette);
|
|
|
|
m_settings->setValue ("Fmin", m_fMin);
|
|
|
|
m_settings->endGroup ();
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
2013-07-08 09:17:22 -04:00
|
|
|
void WideGraph::dataSink2(float s[], float df3, int ihsym,
|
2013-05-20 10:09:02 -04:00
|
|
|
int ndiskdata)
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
2012-09-25 20:48:49 -04:00
|
|
|
static float splot[NSMAX];
|
2013-07-30 16:36:14 -04:00
|
|
|
static float swide[MAX_SCREENSIZE];
|
2012-05-22 13:09:48 -04:00
|
|
|
int nbpp = ui->widePlot->binsPerPixel();
|
|
|
|
static int n=0;
|
|
|
|
|
|
|
|
//Average spectra over specified number, m_waterfallAvg
|
|
|
|
if (n==0) {
|
2012-09-25 20:48:49 -04:00
|
|
|
for (int i=0; i<NSMAX; i++)
|
2012-05-22 13:09:48 -04:00
|
|
|
splot[i]=s[i];
|
|
|
|
} else {
|
2012-09-25 20:48:49 -04:00
|
|
|
for (int i=0; i<NSMAX; i++)
|
2012-05-22 13:09:48 -04:00
|
|
|
splot[i] += s[i];
|
|
|
|
}
|
|
|
|
n++;
|
|
|
|
|
|
|
|
if (n>=m_waterfallAvg) {
|
2012-09-25 20:48:49 -04:00
|
|
|
for (int i=0; i<NSMAX; i++)
|
2012-05-22 13:09:48 -04:00
|
|
|
splot[i] /= n; //Normalize the average
|
|
|
|
n=0;
|
2013-07-25 12:48:10 -04:00
|
|
|
int i=int(ui->widePlot->startFreq()/df3 + 0.5);
|
2013-07-08 09:17:22 -04:00
|
|
|
int jz=5000.0/(nbpp*df3);
|
2013-07-30 16:36:14 -04:00
|
|
|
if(jz>MAX_SCREENSIZE) jz=MAX_SCREENSIZE;
|
2012-10-03 22:05:14 -04:00
|
|
|
for (int j=0; j<jz; j++) {
|
2012-09-28 19:59:50 -04:00
|
|
|
float sum=0;
|
|
|
|
for (int k=0; k<nbpp; k++) {
|
2013-07-25 12:48:10 -04:00
|
|
|
sum += splot[i++];
|
2012-09-28 19:59:50 -04:00
|
|
|
}
|
2012-10-03 22:05:14 -04:00
|
|
|
swide[j]=sum;
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Time according to this computer
|
|
|
|
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
|
2012-09-24 19:36:38 -04:00
|
|
|
int ntr = (ms/1000) % m_TRperiod;
|
2012-10-26 12:01:57 -04:00
|
|
|
if((ndiskdata && ihsym <= m_waterfallAvg) || (!ndiskdata && ntr<m_ntr0)) {
|
2012-05-22 13:09:48 -04:00
|
|
|
for (int i=0; i<2048; i++) {
|
|
|
|
swide[i] = 1.e30;
|
|
|
|
}
|
|
|
|
}
|
2012-10-26 12:01:57 -04:00
|
|
|
m_ntr0=ntr;
|
2013-07-25 12:48:10 -04:00
|
|
|
ui->widePlot->draw(swide);
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
2012-09-24 19:36:38 -04:00
|
|
|
}
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
void WideGraph::on_freqSpanSpinBox_valueChanged(int n)
|
|
|
|
{
|
2012-09-29 13:09:05 -04:00
|
|
|
ui->widePlot->setBinsPerPixel(n);
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::on_waterfallAvgSpinBox_valueChanged(int n)
|
|
|
|
{
|
|
|
|
m_waterfallAvg = n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::on_zeroSpinBox_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->widePlot->setPlotZero(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::on_gainSpinBox_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->widePlot->setPlotGain(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::keyPressEvent(QKeyEvent *e)
|
|
|
|
{
|
|
|
|
switch(e->key())
|
|
|
|
{
|
2012-11-23 11:05:50 -05:00
|
|
|
int n;
|
2012-05-22 13:09:48 -04:00
|
|
|
case Qt::Key_F11:
|
2012-11-23 11:05:50 -05:00
|
|
|
n=11;
|
|
|
|
if(e->modifiers() & Qt::ControlModifier) n+=100;
|
|
|
|
emit f11f12(n);
|
2012-05-22 13:09:48 -04:00
|
|
|
break;
|
|
|
|
case Qt::Key_F12:
|
2012-11-23 11:05:50 -05:00
|
|
|
n=12;
|
|
|
|
if(e->modifiers() & Qt::ControlModifier) n+=100;
|
|
|
|
emit f11f12(n);
|
2012-05-22 13:09:48 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
e->ignore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-08 09:17:22 -04:00
|
|
|
void WideGraph::setRxFreq(int n)
|
2012-10-19 15:26:07 -04:00
|
|
|
{
|
2013-07-08 09:17:22 -04:00
|
|
|
m_rxFreq=n;
|
|
|
|
ui->widePlot->setRxFreq(m_rxFreq,true);
|
|
|
|
if(m_lockTxFreq) setTxFreq(m_rxFreq);
|
2012-10-19 15:26:07 -04:00
|
|
|
}
|
|
|
|
|
2013-07-08 09:17:22 -04:00
|
|
|
int WideGraph::rxFreq()
|
2012-09-24 19:36:38 -04:00
|
|
|
{
|
2013-07-08 09:17:22 -04:00
|
|
|
return ui->widePlot->rxFreq();
|
2012-09-24 19:36:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int WideGraph::nSpan()
|
|
|
|
{
|
|
|
|
return ui->widePlot->m_nSpan;
|
|
|
|
}
|
|
|
|
|
|
|
|
float WideGraph::fSpan()
|
|
|
|
{
|
|
|
|
return ui->widePlot->m_fSpan;
|
|
|
|
}
|
|
|
|
|
|
|
|
int WideGraph::nStartFreq()
|
|
|
|
{
|
|
|
|
return ui->widePlot->startFreq();
|
|
|
|
}
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
void WideGraph::wideFreezeDecode(int n)
|
|
|
|
{
|
|
|
|
emit freezeDecode2(n);
|
|
|
|
}
|
|
|
|
|
2013-07-08 09:17:22 -04:00
|
|
|
void WideGraph::setRxRange(int fMin)
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
2013-07-08 09:17:22 -04:00
|
|
|
ui->widePlot->setRxRange(fMin);
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->widePlot->DrawOverlay();
|
|
|
|
ui->widePlot->update();
|
|
|
|
}
|
|
|
|
|
2013-04-10 10:41:16 -04:00
|
|
|
int WideGraph::getFmin()
|
|
|
|
{
|
|
|
|
return m_fMin;
|
|
|
|
}
|
|
|
|
|
|
|
|
int WideGraph::getFmax()
|
|
|
|
{
|
2013-07-08 09:17:22 -04:00
|
|
|
int n=ui->widePlot->getFmax();
|
|
|
|
if(n>5000) n=5000;
|
|
|
|
return n;
|
2013-04-05 12:48:10 -04:00
|
|
|
}
|
|
|
|
|
2012-11-24 10:18:17 -05:00
|
|
|
double WideGraph::fGreen()
|
2012-09-24 15:11:31 -04:00
|
|
|
{
|
2012-11-24 10:18:17 -05:00
|
|
|
return ui->widePlot->fGreen();
|
2012-09-24 15:11:31 -04:00
|
|
|
}
|
|
|
|
|
2012-09-25 20:48:49 -04:00
|
|
|
void WideGraph::setPeriod(int ntrperiod, int nsps)
|
2012-09-24 19:36:38 -04:00
|
|
|
{
|
2012-09-25 20:48:49 -04:00
|
|
|
m_TRperiod=ntrperiod;
|
|
|
|
m_nsps=nsps;
|
2012-11-14 10:30:21 -05:00
|
|
|
ui->widePlot->setNsps(ntrperiod, nsps);
|
2012-09-24 19:36:38 -04:00
|
|
|
}
|
2012-10-10 20:51:16 -04:00
|
|
|
|
2013-03-06 11:37:28 -05:00
|
|
|
void WideGraph::setTxFreq(int n)
|
2012-10-10 20:51:16 -04:00
|
|
|
{
|
2013-07-08 09:17:22 -04:00
|
|
|
emit setXIT2(n);
|
2013-03-06 11:37:28 -05:00
|
|
|
ui->widePlot->setTxFreq(n);
|
2012-10-15 13:43:49 -04:00
|
|
|
}
|
|
|
|
|
2013-07-08 09:17:22 -04:00
|
|
|
void WideGraph::setMode(QString mode)
|
|
|
|
{
|
|
|
|
m_mode=mode;
|
|
|
|
ui->fMinSpinBox->setEnabled(m_mode=="JT9+JT65");
|
|
|
|
ui->widePlot->setMode(mode);
|
|
|
|
ui->widePlot->DrawOverlay();
|
|
|
|
ui->widePlot->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::setModeTx(QString modeTx)
|
|
|
|
{
|
|
|
|
m_modeTx=modeTx;
|
|
|
|
ui->widePlot->setModeTx(modeTx);
|
|
|
|
ui->widePlot->DrawOverlay();
|
|
|
|
ui->widePlot->update();
|
|
|
|
}
|
|
|
|
|
2013-03-06 11:37:28 -05:00
|
|
|
void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1)
|
2012-10-15 13:43:49 -04:00
|
|
|
{
|
|
|
|
ui->widePlot->m_bCurrent=false;
|
|
|
|
ui->widePlot->m_bCumulative=false;
|
2013-03-06 11:37:28 -05:00
|
|
|
if(arg1=="Current") ui->widePlot->m_bCurrent=true;
|
|
|
|
if(arg1=="Cumulative") ui->widePlot->m_bCumulative=true;
|
2012-11-23 11:05:50 -05:00
|
|
|
}
|
2013-04-05 12:48:10 -04:00
|
|
|
|
|
|
|
void WideGraph::on_fMinSpinBox_valueChanged(int n)
|
|
|
|
{
|
|
|
|
m_fMin=n;
|
2013-07-08 09:17:22 -04:00
|
|
|
setRxRange(m_fMin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::on_slopeSpinBox_valueChanged(double d)
|
|
|
|
{
|
|
|
|
m_slope=d;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::setSlope(double d)
|
|
|
|
{
|
|
|
|
m_slope=d;
|
|
|
|
ui->slopeSpinBox->setValue(d);
|
2013-04-05 12:48:10 -04:00
|
|
|
}
|
|
|
|
|
2013-07-08 09:17:22 -04:00
|
|
|
void WideGraph::setLockTxFreq(bool b)
|
|
|
|
{
|
|
|
|
m_lockTxFreq=b;
|
|
|
|
ui->widePlot->m_lockTxFreq=b;
|
|
|
|
}
|
|
|
|
double WideGraph::getSlope()
|
2013-04-05 12:48:10 -04:00
|
|
|
{
|
2013-07-08 09:17:22 -04:00
|
|
|
return m_slope;
|
2013-04-05 12:48:10 -04:00
|
|
|
}
|
|
|
|
|
2013-07-08 09:17:22 -04:00
|
|
|
void WideGraph::setFreq2(int rxFreq, int txFreq)
|
|
|
|
{
|
|
|
|
m_rxFreq=rxFreq;
|
|
|
|
m_txFreq=txFreq;
|
|
|
|
emit setFreq3(rxFreq,txFreq);
|
|
|
|
}
|
2013-07-12 09:45:28 -04:00
|
|
|
|
|
|
|
void WideGraph::setDialFreq(double d)
|
|
|
|
{
|
|
|
|
m_dialFreq=d;
|
|
|
|
ui->widePlot->setDialFreq(d);
|
|
|
|
}
|
2013-07-25 12:48:10 -04:00
|
|
|
|
|
|
|
void WideGraph::on_fStartSpinBox_valueChanged(int n)
|
|
|
|
{
|
|
|
|
ui->widePlot->setStartFreq(n);
|
|
|
|
}
|
2013-08-07 10:49:45 -04:00
|
|
|
|
|
|
|
void WideGraph::readPalette(QString fileName)
|
|
|
|
{
|
|
|
|
QFile f;
|
|
|
|
f.setFileName(fileName);
|
|
|
|
if(f.open(QIODevice::ReadOnly)) {
|
|
|
|
QTextStream in(&f);
|
|
|
|
int r[9],g[9],b[9];
|
|
|
|
QString t;
|
|
|
|
for(int i=0; i<9; i++) {
|
|
|
|
t=in.readLine();
|
|
|
|
r[i]=t.mid(0,3).toInt();
|
|
|
|
g[i]=t.mid(4,3).toInt();
|
|
|
|
b[i]=t.mid(8,3).toInt();
|
|
|
|
}
|
|
|
|
f.close();
|
|
|
|
for(int i=0; i<256; i++) {
|
|
|
|
int j0=i/32;
|
|
|
|
int j1=j0+1;
|
|
|
|
int k=i-32*j0;
|
|
|
|
int rr=r[j0] + int((k*(r[j1]-r[j0]))/31 + 0.5);
|
|
|
|
int gg=g[j0] + int((k*(g[j1]-g[j0]))/31 + 0.5);
|
|
|
|
int bb=b[j0] + int((k*(b[j1]-b[j0]))/31 + 0.5);
|
|
|
|
ui->widePlot->m_ColorTbl[i].setRgb(rr,gg,bb);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
QMessageBox msgBox0;
|
|
|
|
QString t="Error: Cannot find requested palette file " + fileName;
|
|
|
|
msgBox0.setText(t);
|
|
|
|
msgBox0.exec();
|
|
|
|
}
|
|
|
|
}
|
2013-08-07 14:59:11 -04:00
|
|
|
|
|
|
|
void WideGraph::on_paletteComboBox_activated(const QString &palette)
|
|
|
|
{
|
2013-08-07 20:16:13 -04:00
|
|
|
m_waterfallPalette=palette;
|
2013-08-07 14:59:11 -04:00
|
|
|
readPalette("Palettes/" + palette + ".pal");
|
|
|
|
}
|