kopia lustrzana https://gitlab.com/eliggett/wfview
Waterfal length may now be adjusted. Let's see what range of length
seems good and limit the control accordingly. Also there may be a memory leak in the prepareWf() function where the colormap is created when the image is resized.merge-requests/5/head
rodzic
d601983beb
commit
b5167a6a97
|
@ -171,7 +171,6 @@ void rigCommander::setup()
|
||||||
setCIVAddr(civAddr);
|
setCIVAddr(civAddr);
|
||||||
spectSeqMax = 0; // this is now set after rig ID determined
|
spectSeqMax = 0; // this is now set after rig ID determined
|
||||||
|
|
||||||
|
|
||||||
payloadSuffix = QByteArray("\xFD");
|
payloadSuffix = QByteArray("\xFD");
|
||||||
|
|
||||||
lookingForRig = false;
|
lookingForRig = false;
|
||||||
|
|
125
wfmain.cpp
125
wfmain.cpp
|
@ -142,7 +142,7 @@ void wfmain::openRig()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start rigctld
|
// Start rigctld
|
||||||
if (prefs.enableRigCtlD) {
|
if (prefs.enableRigCtlD && rigCtl == Q_NULLPTR) {
|
||||||
rigCtl = new rigCtlD(this);
|
rigCtl = new rigCtlD(this);
|
||||||
|
|
||||||
rigCtl->startServer(prefs.rigCtlPort);
|
rigCtl->startServer(prefs.rigCtlPort);
|
||||||
|
@ -525,6 +525,7 @@ void wfmain::setupPlots()
|
||||||
{
|
{
|
||||||
|
|
||||||
// Line 290--
|
// Line 290--
|
||||||
|
spectrumDrawLock = true;
|
||||||
plot = ui->plot; // rename it waterfall.
|
plot = ui->plot; // rename it waterfall.
|
||||||
wf = ui->waterfall;
|
wf = ui->waterfall;
|
||||||
|
|
||||||
|
@ -563,7 +564,7 @@ void wfmain::setupPlots()
|
||||||
connect(wf, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(handleWFClick(QMouseEvent*)));
|
connect(wf, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(handleWFClick(QMouseEvent*)));
|
||||||
connect(wf, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(handleWFScroll(QWheelEvent*)));
|
connect(wf, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(handleWFScroll(QWheelEvent*)));
|
||||||
connect(plot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(handlePlotScroll(QWheelEvent*)));
|
connect(plot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(handlePlotScroll(QWheelEvent*)));
|
||||||
|
spectrumDrawLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfmain::setupMainUI()
|
void wfmain::setupMainUI()
|
||||||
|
@ -1136,7 +1137,7 @@ void wfmain::loadSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->lanEnableBtn->setChecked(prefs.enableLAN);
|
ui->lanEnableBtn->setChecked(prefs.enableLAN);
|
||||||
ui->connectBtn->setEnabled(prefs.enableLAN);
|
ui->connectBtn->setEnabled(true);
|
||||||
|
|
||||||
prefs.enableRigCtlD = settings->value("EnableRigCtlD", defPrefs.enableRigCtlD).toBool();
|
prefs.enableRigCtlD = settings->value("EnableRigCtlD", defPrefs.enableRigCtlD).toBool();
|
||||||
prefs.rigCtlPort = settings->value("RigCtlPort", defPrefs.rigCtlPort).toInt();
|
prefs.rigCtlPort = settings->value("RigCtlPort", defPrefs.rigCtlPort).toInt();
|
||||||
|
@ -1422,35 +1423,66 @@ void wfmain::saveSettings()
|
||||||
settings->sync(); // Automatic, not needed (supposedly)
|
settings->sync(); // Automatic, not needed (supposedly)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wfmain::prepareWf()
|
void wfmain::prepareWf()
|
||||||
|
{
|
||||||
|
prepareWf(160);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wfmain::prepareWf(unsigned int wfLength)
|
||||||
{
|
{
|
||||||
// All this code gets moved in from the constructor of wfmain.
|
// All this code gets moved in from the constructor of wfmain.
|
||||||
|
|
||||||
if(haveRigCaps)
|
if(haveRigCaps)
|
||||||
{
|
{
|
||||||
// do things
|
// TODO: Lock the function that draws on the spectrum while we are updating.
|
||||||
spectWidth = rigCaps.spectLenMax; // was fixed at 475
|
spectrumDrawLock = true;
|
||||||
wfLength = 160; // fixed for now, time-length of waterfall
|
|
||||||
|
spectWidth = rigCaps.spectLenMax;
|
||||||
|
this->wfLength = wfLength; // fixed for now, time-length of waterfall
|
||||||
|
|
||||||
// Initialize before use!
|
// Initialize before use!
|
||||||
|
|
||||||
QByteArray empty((int)spectWidth, '\x01');
|
QByteArray empty((int)spectWidth, '\x01');
|
||||||
spectrumPeaks = QByteArray( (int)spectWidth, '\x01' );
|
spectrumPeaks = QByteArray( (int)spectWidth, '\x01' );
|
||||||
for(quint16 i=0; i<wfLength; i++)
|
|
||||||
|
if((unsigned int)wfimage.size() < wfLength)
|
||||||
{
|
{
|
||||||
wfimage.append(empty);
|
unsigned int i=0;
|
||||||
|
unsigned int oldSize = wfimage.size();
|
||||||
|
// Note: apparently .append() in this case does not add to the initial size.
|
||||||
|
// So if the initial size is 100 and you append 50 times,
|
||||||
|
// the end size is 50.
|
||||||
|
for(i=oldSize; i<(wfLength); i++)
|
||||||
|
{
|
||||||
|
wfimage.append(empty);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wfimage.remove(wfLength, wfimage.size()-wfLength);
|
||||||
}
|
}
|
||||||
|
wfimage.squeeze();
|
||||||
|
colorMap->clearData();
|
||||||
|
colorMap->data()->clear();
|
||||||
|
|
||||||
colorMap->data()->setValueRange(QCPRange(0, wfLength-1));
|
colorMap->data()->setValueRange(QCPRange(0, wfLength-1));
|
||||||
colorMap->data()->setKeyRange(QCPRange(0, spectWidth-1));
|
colorMap->data()->setKeyRange(QCPRange(0, spectWidth-1));
|
||||||
colorMap->setDataRange(QCPRange(0, rigCaps.spectAmpMax));
|
colorMap->setDataRange(QCPRange(0, rigCaps.spectAmpMax));
|
||||||
colorMap->setGradient(QCPColorGradient::gpJet); // TODO: Add preference
|
colorMap->setGradient(QCPColorGradient::gpJet); // TODO: Add preference
|
||||||
colorMapData = new QCPColorMapData(spectWidth, wfLength, QCPRange(0, spectWidth-1), QCPRange(0, wfLength-1));
|
|
||||||
|
if(colorMapData == Q_NULLPTR)
|
||||||
|
{
|
||||||
|
colorMapData = new QCPColorMapData(spectWidth, wfLength, QCPRange(0, spectWidth-1), QCPRange(0, wfLength-1));
|
||||||
|
} else {
|
||||||
|
//delete colorMapData; // TODO: Figure out why it crashes if we delete first.
|
||||||
|
colorMapData = new QCPColorMapData(spectWidth, wfLength, QCPRange(0, spectWidth-1), QCPRange(0, wfLength-1));
|
||||||
|
}
|
||||||
colorMap->setData(colorMapData);
|
colorMap->setData(colorMapData);
|
||||||
spectRowCurrent = 0;
|
|
||||||
wf->yAxis->setRangeReversed(true);
|
wf->yAxis->setRangeReversed(true);
|
||||||
wf->xAxis->setVisible(false);
|
wf->xAxis->setVisible(false);
|
||||||
rigName->setText(rigCaps.modelName);
|
rigName->setText(rigCaps.modelName);
|
||||||
|
|
||||||
|
spectrumDrawLock = false;
|
||||||
} else {
|
} else {
|
||||||
qInfo(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this.";
|
qInfo(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this.";
|
||||||
return;
|
return;
|
||||||
|
@ -2571,42 +2603,44 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//ui->qcp->addGraph();
|
if(!spectrumDrawLock)
|
||||||
plot->graph(0)->setData(x,y);
|
|
||||||
if((freq.MHzDouble < endFreq) && (freq.MHzDouble > startFreq))
|
|
||||||
{
|
{
|
||||||
freqIndicatorLine->start->setCoords(freq.MHzDouble,0);
|
//ui->qcp->addGraph();
|
||||||
freqIndicatorLine->end->setCoords(freq.MHzDouble,160);
|
plot->graph(0)->setData(x,y);
|
||||||
}
|
if((freq.MHzDouble < endFreq) && (freq.MHzDouble > startFreq))
|
||||||
if(drawPeaks)
|
|
||||||
{
|
|
||||||
plot->graph(1)->setData(x,y2); // peaks
|
|
||||||
}
|
|
||||||
plot->yAxis->setRange(0, rigCaps.spectAmpMax+1);
|
|
||||||
plot->xAxis->setRange(startFreq, endFreq);
|
|
||||||
plot->replot();
|
|
||||||
|
|
||||||
if(specLen == spectWidth)
|
|
||||||
{
|
|
||||||
wfimage.prepend(spectrum);
|
|
||||||
if(wfimage.length() > wfLength)
|
|
||||||
{
|
{
|
||||||
wfimage.remove(wfLength);
|
freqIndicatorLine->start->setCoords(freq.MHzDouble,0);
|
||||||
|
freqIndicatorLine->end->setCoords(freq.MHzDouble,160);
|
||||||
}
|
}
|
||||||
|
if(drawPeaks)
|
||||||
// Waterfall:
|
|
||||||
for(int row = 0; row < wfLength; row++)
|
|
||||||
{
|
{
|
||||||
for(int col = 0; col < spectWidth; col++)
|
plot->graph(1)->setData(x,y2); // peaks
|
||||||
|
}
|
||||||
|
plot->yAxis->setRange(0, rigCaps.spectAmpMax+1);
|
||||||
|
plot->xAxis->setRange(startFreq, endFreq);
|
||||||
|
plot->replot();
|
||||||
|
|
||||||
|
if(specLen == spectWidth)
|
||||||
|
{
|
||||||
|
wfimage.prepend(spectrum);
|
||||||
|
if(wfimage.length() > wfLength)
|
||||||
{
|
{
|
||||||
colorMap->data()->setCell( col, row, wfimage.at(row).at(col));
|
wfimage.remove(wfLength);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
wf->yAxis->setRange(0,wfLength - 1);
|
// Waterfall:
|
||||||
wf->xAxis->setRange(0, spectWidth-1);
|
for(int row = 0; row < wfLength; row++)
|
||||||
wf->replot();
|
{
|
||||||
spectRowCurrent = (spectRowCurrent + 1) % wfLength;
|
for(int col = 0; col < spectWidth; col++)
|
||||||
|
{
|
||||||
|
colorMap->data()->setCell( col, row, wfimage.at(row).at(col));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wf->yAxis->setRange(0,wfLength - 1);
|
||||||
|
wf->xAxis->setRange(0, spectWidth-1);
|
||||||
|
wf->replot();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3552,7 +3586,7 @@ void wfmain::on_serialEnableBtn_clicked(bool checked)
|
||||||
prefs.enableLAN = !checked;
|
prefs.enableLAN = !checked;
|
||||||
ui->serialDeviceListCombo->setEnabled(checked);
|
ui->serialDeviceListCombo->setEnabled(checked);
|
||||||
|
|
||||||
ui->connectBtn->setEnabled(!checked);
|
ui->connectBtn->setEnabled(true);
|
||||||
ui->ipAddressTxt->setEnabled(!checked);
|
ui->ipAddressTxt->setEnabled(!checked);
|
||||||
ui->controlPortTxt->setEnabled(!checked);
|
ui->controlPortTxt->setEnabled(!checked);
|
||||||
ui->usernameTxt->setEnabled(!checked);
|
ui->usernameTxt->setEnabled(!checked);
|
||||||
|
@ -3572,7 +3606,7 @@ void wfmain::on_serialEnableBtn_clicked(bool checked)
|
||||||
void wfmain::on_lanEnableBtn_clicked(bool checked)
|
void wfmain::on_lanEnableBtn_clicked(bool checked)
|
||||||
{
|
{
|
||||||
prefs.enableLAN = checked;
|
prefs.enableLAN = checked;
|
||||||
ui->connectBtn->setEnabled(checked);
|
ui->connectBtn->setEnabled(true);
|
||||||
ui->ipAddressTxt->setEnabled(checked);
|
ui->ipAddressTxt->setEnabled(checked);
|
||||||
ui->controlPortTxt->setEnabled(checked);
|
ui->controlPortTxt->setEnabled(checked);
|
||||||
ui->usernameTxt->setEnabled(checked);
|
ui->usernameTxt->setEnabled(checked);
|
||||||
|
@ -4447,10 +4481,15 @@ void wfmain::on_baudRateCombo_activated(int index)
|
||||||
(void)index;
|
(void)index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wfmain::on_wfLengthSlider_valueChanged(int value)
|
||||||
|
{
|
||||||
|
prepareWf(value);
|
||||||
|
}
|
||||||
|
|
||||||
// --- DEBUG FUNCTION ---
|
// --- DEBUG FUNCTION ---
|
||||||
void wfmain::on_debugBtn_clicked()
|
void wfmain::on_debugBtn_clicked()
|
||||||
{
|
{
|
||||||
qInfo(logSystem()) << "Debug button pressed.";
|
qInfo(logSystem()) << "Debug button pressed.";
|
||||||
qInfo(logSystem()) << "getting mode.";
|
prepareWf(160);
|
||||||
emit getRigID();
|
|
||||||
}
|
}
|
||||||
|
|
8
wfmain.h
8
wfmain.h
|
@ -45,7 +45,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Basic to rig:
|
// Basic to rig:
|
||||||
void setCIVAddr(unsigned char);
|
void setCIVAddr(unsigned char newRigCIVAddr);
|
||||||
|
|
||||||
// Power
|
// Power
|
||||||
void sendPowerOn();
|
void sendPowerOn();
|
||||||
|
@ -446,6 +446,8 @@ private slots:
|
||||||
|
|
||||||
void on_baudRateCombo_activated(int);
|
void on_baudRateCombo_activated(int);
|
||||||
|
|
||||||
|
void on_wfLengthSlider_valueChanged(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::wfmain *ui;
|
Ui::wfmain *ui;
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
@ -459,6 +461,7 @@ private:
|
||||||
void setAppTheme(bool isCustom);
|
void setAppTheme(bool isCustom);
|
||||||
void setPlotTheme(QCustomPlot *plot, bool isDark);
|
void setPlotTheme(QCustomPlot *plot, bool isDark);
|
||||||
void prepareWf();
|
void prepareWf();
|
||||||
|
void prepareWf(unsigned int wfLength);
|
||||||
void getInitialRigState();
|
void getInitialRigState();
|
||||||
void setBandButtons();
|
void setBandButtons();
|
||||||
void showButton(QPushButton *btn);
|
void showButton(QPushButton *btn);
|
||||||
|
@ -543,8 +546,7 @@ private:
|
||||||
|
|
||||||
quint16 spectWidth;
|
quint16 spectWidth;
|
||||||
quint16 wfLength;
|
quint16 wfLength;
|
||||||
|
bool spectrumDrawLock;
|
||||||
quint16 spectRowCurrent;
|
|
||||||
|
|
||||||
QByteArray spectrumPeaks;
|
QByteArray spectrumPeaks;
|
||||||
|
|
||||||
|
|
56
wfmain.ui
56
wfmain.ui
|
@ -18,7 +18,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="mainTab">
|
<widget class="QWidget" name="mainTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -767,6 +767,60 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_20">
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="wfLengthSlider">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>70</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>80</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Waterfall Length</string>
|
||||||
|
</property>
|
||||||
|
<property name="accessibleName">
|
||||||
|
<string>Waterfall Length</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1024</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>160</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_35">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>15</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Len</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
|
|
Ładowanie…
Reference in New Issue