2012-05-22 13:09:48 -04:00
|
|
|
#include "widegraph.h"
|
|
|
|
#include "ui_widegraph.h"
|
|
|
|
|
2012-09-29 09:02:19 -04:00
|
|
|
#define NSMAX 10000
|
2012-05-22 13:09:48 -04:00
|
|
|
|
|
|
|
WideGraph::WideGraph(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::WideGraph)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
this->setWindowFlags(Qt::Dialog);
|
|
|
|
this->installEventFilter(parent); //Installing the filter
|
|
|
|
ui->widePlot->setCursor(Qt::CrossCursor);
|
|
|
|
this->setMaximumWidth(2048);
|
|
|
|
this->setMaximumHeight(880);
|
|
|
|
ui->widePlot->setMaximumHeight(800);
|
|
|
|
|
|
|
|
connect(ui->widePlot, SIGNAL(freezeDecode1(int)),this,
|
|
|
|
SLOT(wideFreezeDecode(int)));
|
|
|
|
|
|
|
|
//Restore user's settings
|
|
|
|
QString inifile(QApplication::applicationDirPath());
|
|
|
|
inifile += "/map65.ini";
|
|
|
|
QSettings settings(inifile, QSettings::IniFormat);
|
|
|
|
|
|
|
|
settings.beginGroup("WideGraph");
|
|
|
|
ui->widePlot->setPlotZero(settings.value("PlotZero", 20).toInt());
|
|
|
|
ui->widePlot->setPlotGain(settings.value("PlotGain", 0).toInt());
|
|
|
|
ui->zeroSpinBox->setValue(ui->widePlot->getPlotZero());
|
|
|
|
ui->gainSpinBox->setValue(ui->widePlot->getPlotGain());
|
2012-09-24 19:36:38 -04:00
|
|
|
int n = settings.value("FreqSpan",60).toInt();
|
|
|
|
int w = settings.value("PlotWidth",1000).toInt();
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->freqSpanSpinBox->setValue(n);
|
2012-09-24 19:36:38 -04:00
|
|
|
ui->widePlot->setNSpan(n);
|
|
|
|
int nbpp = n * 32768.0/(w*96.0) + 0.5;
|
|
|
|
ui->widePlot->setBinsPerPixel(nbpp);
|
|
|
|
m_waterfallAvg = settings.value("WaterfallAvg",10).toInt();
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->waterfallAvgSpinBox->setValue(m_waterfallAvg);
|
2012-09-25 12:04:38 -04:00
|
|
|
m_dForceCenterFreq=settings.value("ForceCenterFreqMHz",473.000).toDouble();
|
2012-09-24 19:36:38 -04:00
|
|
|
// ui->cbFcenter->setChecked(m_bForceCenterFreq);
|
|
|
|
ui->fCenterLineEdit->setText(QString::number(m_dForceCenterFreq));
|
2012-05-22 13:09:48 -04:00
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
2012-09-24 19:36:38 -04:00
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
WideGraph::~WideGraph()
|
|
|
|
{
|
|
|
|
saveSettings();
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::saveSettings()
|
|
|
|
{
|
|
|
|
//Save user's settings
|
|
|
|
QString inifile(QApplication::applicationDirPath());
|
|
|
|
inifile += "/map65.ini";
|
|
|
|
QSettings settings(inifile, QSettings::IniFormat);
|
|
|
|
|
|
|
|
settings.beginGroup("WideGraph");
|
|
|
|
settings.setValue("PlotZero",ui->widePlot->m_plotZero);
|
|
|
|
settings.setValue("PlotGain",ui->widePlot->m_plotGain);
|
|
|
|
settings.setValue("PlotWidth",ui->widePlot->plotWidth());
|
|
|
|
settings.setValue("FreqSpan",ui->freqSpanSpinBox->value());
|
|
|
|
settings.setValue("WaterfallAvg",ui->waterfallAvgSpinBox->value());
|
2012-09-24 19:36:38 -04:00
|
|
|
settings.setValue("ForceCenterFreqMHz",m_dForceCenterFreq);
|
2012-05-22 13:09:48 -04:00
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
2012-09-24 19:36:38 -04:00
|
|
|
void WideGraph::dataSink2(float s[], int nkhz, int ihsym, int ndiskdata,
|
|
|
|
uchar lstrong[])
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
2012-09-25 20:48:49 -04:00
|
|
|
static float splot[NSMAX];
|
2012-05-22 13:09:48 -04:00
|
|
|
float swide[2048];
|
|
|
|
float smax;
|
|
|
|
double df;
|
|
|
|
int nbpp = ui->widePlot->binsPerPixel();
|
|
|
|
static int n=0;
|
|
|
|
static int nkhz0=-999;
|
2012-09-26 11:20:43 -04:00
|
|
|
static int ntr0=0;
|
2012-07-07 11:49:41 -04:00
|
|
|
|
2012-09-25 20:48:49 -04:00
|
|
|
df = 12000.0/m_nsps;
|
2012-05-22 13:09:48 -04:00
|
|
|
if(nkhz != nkhz0) {
|
|
|
|
ui->widePlot->setNkhz(nkhz); //Why do we need both?
|
|
|
|
ui->widePlot->SetCenterFreq(nkhz); //Why do we need both?
|
|
|
|
ui->widePlot->setFQSO(nkhz,true);
|
|
|
|
nkhz0 = nkhz;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Average spectra over specified number, m_waterfallAvg
|
2012-09-29 13:09:05 -04:00
|
|
|
// qDebug() << "C" << ihsym << NSMAX << df << nbpp;
|
2012-05-22 13:09:48 -04:00
|
|
|
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;
|
|
|
|
|
|
|
|
int w=ui->widePlot->plotWidth();
|
2012-09-26 13:39:43 -04:00
|
|
|
// if(sf != ui->widePlot->startFreq()) ui->widePlot->SetStartFreq(sf);
|
2012-09-26 14:45:10 -04:00
|
|
|
// int i0=16384.0+(ui->widePlot->startFreq()-nkhz+1.27046+0.001*m_fCal) *
|
|
|
|
// 1000.0/df + 0.5;
|
2012-09-28 19:59:50 -04:00
|
|
|
|
2012-09-26 14:45:10 -04:00
|
|
|
int i0=0; //###
|
2012-09-29 13:09:05 -04:00
|
|
|
// nbpp=1; //###
|
2012-09-28 19:59:50 -04:00
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
int i=i0;
|
|
|
|
for (int j=0; j<2048; j++) {
|
2012-09-28 19:59:50 -04:00
|
|
|
smax=0;
|
|
|
|
for (int k=0; k<nbpp; k++) {
|
|
|
|
if(splot[i]>smax) smax=splot[i];
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
swide[j]=smax;
|
|
|
|
/*
|
|
|
|
float sum=0;
|
|
|
|
for (int k=0; k<nbpp; k++) {
|
|
|
|
i++;
|
|
|
|
sum += splot[i];
|
|
|
|
}
|
|
|
|
swide[j]=sum;
|
|
|
|
*/
|
|
|
|
if(lstrong[1 + i/32]!=0) swide[j]=-smax; //Tag strong signals
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
2012-09-28 19:59:50 -04:00
|
|
|
// qDebug() << "B" << ihsym << swide[1000] << splot[1000];
|
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-05-22 13:09:48 -04:00
|
|
|
|
2012-09-26 11:20:43 -04:00
|
|
|
if((ndiskdata && ihsym <= m_waterfallAvg) || (!ndiskdata && ntr<ntr0)) {
|
2012-05-22 13:09:48 -04:00
|
|
|
for (int i=0; i<2048; i++) {
|
|
|
|
swide[i] = 1.e30;
|
|
|
|
}
|
|
|
|
for (int i=0; i<32768; i++) {
|
|
|
|
splot[i] = 1.e30;
|
|
|
|
}
|
|
|
|
}
|
2012-09-26 11:20:43 -04:00
|
|
|
ntr0=ntr;
|
2012-05-22 13:09:48 -04:00
|
|
|
ui->widePlot->draw(swide,i0,splot);
|
|
|
|
}
|
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())
|
|
|
|
{
|
|
|
|
case Qt::Key_F11:
|
|
|
|
emit f11f12(11);
|
|
|
|
break;
|
|
|
|
case Qt::Key_F12:
|
|
|
|
emit f11f12(12);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
e->ignore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-24 19:36:38 -04:00
|
|
|
int WideGraph::QSOfreq()
|
|
|
|
{
|
|
|
|
return ui->widePlot->fQSO();
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::setTol(int n)
|
|
|
|
{
|
|
|
|
ui->widePlot->m_tol=n;
|
|
|
|
ui->widePlot->DrawOverlay();
|
|
|
|
ui->widePlot->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
int WideGraph::Tol()
|
|
|
|
{
|
|
|
|
return ui->widePlot->m_tol;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::setDF(int n)
|
|
|
|
{
|
|
|
|
ui->widePlot->m_DF=n;
|
|
|
|
ui->widePlot->DrawOverlay();
|
|
|
|
ui->widePlot->update();
|
|
|
|
}
|
|
|
|
|
2012-09-24 19:36:38 -04:00
|
|
|
void WideGraph::setFcal(int n)
|
|
|
|
{
|
|
|
|
m_fCal=n;
|
|
|
|
ui->widePlot->setFcal(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
int WideGraph::DF()
|
|
|
|
{
|
|
|
|
return ui->widePlot->m_DF;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::on_autoZeroPushButton_clicked()
|
|
|
|
{
|
|
|
|
int nzero=ui->widePlot->autoZero();
|
|
|
|
ui->zeroSpinBox->setValue(nzero);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::setPalette(QString palette)
|
|
|
|
{
|
|
|
|
ui->widePlot->setPalette(palette);
|
|
|
|
}
|
2012-09-24 19:36:38 -04:00
|
|
|
|
|
|
|
void WideGraph::on_fCenterLineEdit_editingFinished()
|
|
|
|
{
|
|
|
|
m_dForceCenterFreq=ui->fCenterLineEdit->text().toDouble();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WideGraph::initIQplus()
|
2012-09-24 15:11:31 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-24 19:36:38 -04:00
|
|
|
double WideGraph::fGreen()
|
|
|
|
{
|
|
|
|
return ui->widePlot->fGreen();
|
|
|
|
}
|
|
|
|
|
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-09-29 13:09:05 -04:00
|
|
|
ui->widePlot->setNsps(nsps);
|
2012-09-24 19:36:38 -04:00
|
|
|
}
|