From 5f427454a6a8663c3c23f968818a30854ed9f7ed Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 12 Jul 2015 23:45:17 +0200 Subject: [PATCH] Added persistency (serialize/deserialize) of scope display mode (prime, second, both) --- include-gpl/gui/glscopegui.h | 1 + sdrbase/gui/glscopegui.cpp | 48 +++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/include-gpl/gui/glscopegui.h b/include-gpl/gui/glscopegui.h index f7e3d12b7..1cd62b9df 100644 --- a/include-gpl/gui/glscopegui.h +++ b/include-gpl/gui/glscopegui.h @@ -41,6 +41,7 @@ private: qint32 m_displayData; qint32 m_displayOrientation; + qint32 m_displays; qint32 m_timeBase; qint32 m_timeOffset; qint32 m_amplification; diff --git a/sdrbase/gui/glscopegui.cpp b/sdrbase/gui/glscopegui.cpp index 09309215a..d322e196a 100644 --- a/sdrbase/gui/glscopegui.cpp +++ b/sdrbase/gui/glscopegui.cpp @@ -19,6 +19,7 @@ GLScopeGUI::GLScopeGUI(QWidget* parent) : m_sampleRate(1), m_displayData(GLScope::ModeIQ), m_displayOrientation(Qt::Horizontal), + m_displays(GLScope::DisplayBoth), m_timeBase(1), m_timeOffset(0), m_amplification(0), @@ -72,6 +73,7 @@ QByteArray GLScopeGUI::serialize() const s.writeS32(5, m_amplification); s.writeS32(6, m_displayGridIntensity); s.writeS32(7, m_ampOffset); + s.writeS32(8, m_displays); return s.final(); } @@ -95,6 +97,7 @@ bool GLScopeGUI::deserialize(const QByteArray& data) if(m_timeBase < 0) m_timeBase = 1; d.readS32(7, &m_ampOffset, 0); + d.readS32(8, &m_displays, GLScope::DisplayBoth); applySettings(); return true; } else { @@ -106,14 +109,37 @@ bool GLScopeGUI::deserialize(const QByteArray& data) void GLScopeGUI::applySettings() { ui->dataMode->setCurrentIndex(m_displayData); - if(m_displayOrientation == Qt::Horizontal) { - m_glScope->setOrientation(Qt::Horizontal); - ui->horizView->setChecked(true); - ui->vertView->setChecked(false); - } else { - m_glScope->setOrientation(Qt::Vertical); + if (m_displays == GLScope::DisplayBoth) + { + if(m_displayOrientation == Qt::Horizontal) { + m_glScope->setOrientation(Qt::Horizontal); + ui->horizView->setChecked(true); + ui->vertView->setChecked(false); + ui->onlyPrimeView->setChecked(false); + ui->onlySecondView->setChecked(false); + } else { + m_glScope->setOrientation(Qt::Vertical); + ui->horizView->setChecked(false); + ui->vertView->setChecked(true); + ui->onlyPrimeView->setChecked(false); + ui->onlySecondView->setChecked(false); + } + } + else if (m_displays == GLScope::DisplayFirstOnly) + { + m_glScope->setDisplays(GLScope::DisplayFirstOnly); + ui->onlyPrimeView->setChecked(true); ui->horizView->setChecked(false); - ui->vertView->setChecked(true); + ui->vertView->setChecked(false); + ui->onlySecondView->setChecked(false); + } + else if (m_displays == GLScope::DisplaySecondOnly) + { + m_glScope->setDisplays(GLScope::DisplaySecondOnly); + ui->onlySecondView->setChecked(true); + ui->onlyPrimeView->setChecked(false); + ui->horizView->setChecked(false); + ui->vertView->setChecked(false); } ui->time->setValue(m_timeBase); ui->timeOfs->setValue(m_timeOffset); @@ -248,8 +274,8 @@ void GLScopeGUI::on_dataMode_currentIndexChanged(int index) void GLScopeGUI::on_horizView_clicked() { - std::cerr << "GLScopeGUI::on_horizView_clicked" << std::endl; m_displayOrientation = Qt::Horizontal; + m_displays = GLScope::DisplayBoth; if(ui->horizView->isChecked()) { ui->vertView->setChecked(false); ui->onlyPrimeView->setChecked(false); @@ -265,8 +291,8 @@ void GLScopeGUI::on_horizView_clicked() void GLScopeGUI::on_vertView_clicked() { - std::cerr << "GLScopeGUI::on_vertView_clicked" << std::endl; m_displayOrientation = Qt::Vertical; + m_displays = GLScope::DisplayBoth; if(ui->vertView->isChecked()) { ui->horizView->setChecked(false); ui->onlyPrimeView->setChecked(false); @@ -282,7 +308,7 @@ void GLScopeGUI::on_vertView_clicked() void GLScopeGUI::on_onlyPrimeView_clicked() { - std::cerr << "GLScopeGUI::on_onlyPrimeView_clicked" << std::endl; + m_displays = GLScope::DisplayFirstOnly; if(ui->onlyPrimeView->isChecked()) { ui->horizView->setChecked(false); ui->vertView->setChecked(false); @@ -296,7 +322,7 @@ void GLScopeGUI::on_onlyPrimeView_clicked() void GLScopeGUI::on_onlySecondView_clicked() { - std::cerr << "GLScopeGUI::on_onlySecondView_clicked" << std::endl; + m_displays = GLScope::DisplaySecondOnly; if(ui->onlySecondView->isChecked()) { ui->horizView->setChecked(false); ui->vertView->setChecked(false);