1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

New scope: deserialize traces

This commit is contained in:
f4exb 2017-02-20 22:19:50 +01:00
parent f5aff6b34f
commit f9ba5696c5
3 changed files with 195 additions and 104 deletions

View File

@ -79,6 +79,10 @@ void ScopeVisNG::configure(uint32_t traceSize, uint32_t timeOfsProMill, uint32_t
void ScopeVisNG::addTrace(const TraceData& traceData)
{
qDebug() << "ScopeVisNG::addTrace:"
<< " m_amp: " << traceData.m_amp
<< " m_ofs: " << traceData.m_ofs
<< " m_traceDelay: " << traceData.m_traceDelay;
Message* cmd = MsgScopeVisNGAddTrace::create(traceData);
getInputMessageQueue()->push(cmd);
}
@ -96,6 +100,8 @@ void ScopeVisNG::changeTrace(const TraceData& traceData, uint32_t traceIndex)
void ScopeVisNG::removeTrace(uint32_t traceIndex)
{
qDebug() << "ScopeVisNG::removeTrace:"
<< " trace: " << traceIndex;
Message* cmd = MsgScopeVisNGRemoveTrace::create(traceIndex);
getInputMessageQueue()->push(cmd);
}

View File

@ -199,9 +199,17 @@ bool GLScopeNGGUI::deserialize(const QByteArray& data)
if(d.getVersion() == 1)
{
MainUIBlocker mainUIBlocker(ui);
TraceUIBlocker traceUIBlocker(ui);
int intValue;
uint32_t uintValue;
ui->onlyX->setEnabled(false);
ui->onlyY->setEnabled(false);
ui->horizontalXY->setEnabled(false);
ui->verticalXY->setEnabled(false);
ui->polar->setEnabled(false);
ui->traceMode->setCurrentIndex(intValue);
d.readS32(1, &intValue, (int) GLScopeNG::DisplayX);
m_glScope->setDisplayMode((GLScopeNG::DisplayMode) intValue);
@ -242,6 +250,74 @@ bool GLScopeNGGUI::deserialize(const QByteArray& data)
d.readS32(6, &intValue, 1);
ui->traceLen->setValue(intValue);
// trace stuff
uint32_t nbTracesSaved;
d.readU32(10, &nbTracesSaved, 1);
const std::vector<ScopeVisNG::TraceData>& tracesData = m_scopeVis->getTracesData();
int iTrace = tracesData.size();
qDebug("GLScopeNGGUI::deserialize: nbTracesSaved: %u tracesData.size(): %lu", nbTracesSaved, tracesData.size());
while (iTrace > nbTracesSaved) // remove possible traces in excess
{
m_scopeVis->removeTrace(iTrace - 1);
iTrace--;
}
for (iTrace = 0; iTrace < nbTracesSaved; iTrace++)
{
ScopeVisNG::TraceData traceData;
float r, g, b;
d.readS32(20 + 16*iTrace, &intValue, 0);
ui->traceMode->setCurrentIndex(intValue);
d.readU32(21 + 16*iTrace, &uintValue, 0);
ui->amp->setValue(uintValue);
d.readS32(22 + 16*iTrace, &intValue, 0);
ui->ofsCoarse->setValue(intValue);
d.readS32(23 + 16*iTrace, &intValue, 0);
ui->ofsFine->setValue(intValue);
d.readS32(24 + 16*iTrace, &intValue, 0);
ui->traceDelayCoarse->setValue(intValue);
d.readS32(25 + 16*iTrace, &intValue, 0);
ui->traceDelayFine->setValue(intValue);
d.readFloat(26 + 16*iTrace, &r, 1.0f);
d.readFloat(27 + 16*iTrace, &g, 1.0f);
d.readFloat(28 + 16*iTrace, &b, 1.0f);
m_focusedTraceColor.setRgbF(r, g, b);
fillTraceData(traceData);
if (iTrace < tracesData.size()) // change existing traces
{
m_scopeVis->changeTrace(traceData, iTrace);
}
else // add new traces
{
m_scopeVis->addTrace(traceData);
}
}
ui->trace->setMaximum(nbTracesSaved-1);
ui->trace->setValue(nbTracesSaved-1);
int r,g,b,a;
m_focusedTraceColor.getRgb(&r, &g, &b, &a);
ui->traceColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b));
setTraceIndexDisplay();
setAmpScaleDisplay();
setAmpOfsDisplay();
setTraceDelayDisplay();
ui->onlyX->setEnabled(true);
ui->onlyY->setEnabled(nbTracesSaved > 1);
ui->horizontalXY->setEnabled(nbTracesSaved > 1);
ui->verticalXY->setEnabled(nbTracesSaved > 1);
ui->polar->setEnabled(nbTracesSaved > 1);
return true;
}
else
@ -630,7 +706,7 @@ void GLScopeNGGUI::on_freerun_toggled(bool checked)
void GLScopeNGGUI::setTraceIndexDisplay()
{
ui->traceText->setText(tr("%1").arg(ui->trace->value()));
ui->traceText->setText(ui->trace->value() == 0 ? "X" : "Y");
}
void GLScopeNGGUI::setTrigCountDisplay()
@ -1053,6 +1129,9 @@ void GLScopeNGGUI::TrigUIBlocker::unBlock()
GLScopeNGGUI::TraceUIBlocker::TraceUIBlocker(Ui::GLScopeNGGUI* ui) :
m_ui(ui)
{
m_oldStateTrace = m_ui->trace->blockSignals(true);
m_oldStateTraceAdd = m_ui->traceAdd->blockSignals(true);
m_oldStateTraceDel = m_ui->traceDel->blockSignals(true);
m_oldStateTraceMode = m_ui->traceMode->blockSignals(true);
m_oldStateAmp = m_ui->amp->blockSignals(true);
m_oldStateOfsCoarse = m_ui->ofsCoarse->blockSignals(true);
@ -1071,6 +1150,9 @@ GLScopeNGGUI::TraceUIBlocker::~TraceUIBlocker()
void GLScopeNGGUI::TraceUIBlocker::unBlock()
{
m_ui->trace->blockSignals(m_oldStateTrace);
m_ui->traceAdd->blockSignals(m_oldStateTraceAdd);
m_ui->traceDel->blockSignals(m_oldStateTraceDel);
m_ui->traceMode->blockSignals(m_oldStateTraceMode);
m_ui->amp->blockSignals(m_oldStateAmp);
m_ui->ofsCoarse->blockSignals(m_oldStateOfsCoarse);

View File

@ -81,6 +81,9 @@ private:
private:
Ui::GLScopeNGGUI *m_ui;
bool m_oldStateTrace;
bool m_oldStateTraceAdd;
bool m_oldStateTraceDel;
bool m_oldStateTraceMode;
bool m_oldStateAmp;
bool m_oldStateOfsCoarse;