1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-23 16:38:37 -05:00
sdrangel/sdrgui/gui/glscopegui.cpp

1877 lines
62 KiB
C++
Raw Normal View History

2017-01-29 13:51:45 -05:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// Copyright (C) 2017-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2022-2023 Jon Beniston, M7RCE <jon@beniston.com> //
2017-01-29 13:51:45 -05:00
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
2017-01-29 13:51:45 -05:00
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QColorDialog>
2018-10-14 20:47:26 -04:00
#include <QFileDialog>
#include <QMessageBox>
2018-08-12 10:56:03 -04:00
#include "glscopegui.h"
2018-08-12 11:06:55 -04:00
#include "glscope.h"
2018-08-12 12:47:50 -04:00
#include "ui_glscopegui.h"
2022-12-20 06:21:54 -05:00
#include "gui/dialpopup.h"
2021-06-26 19:52:42 -04:00
#include "util/db.h"
2017-02-04 22:41:32 -05:00
2018-08-12 10:48:03 -04:00
GLScopeGUI::GLScopeGUI(QWidget* parent) :
2017-01-29 13:51:45 -05:00
QWidget(parent),
ui(new Ui::GLScopeGUI),
m_messageQueue(nullptr),
m_scopeVis(nullptr),
m_glScope(nullptr),
2017-02-04 22:41:32 -05:00
m_sampleRate(0),
m_timeBase(1),
2017-05-25 14:13:34 -04:00
m_timeOffset(0),
m_ctlTraceIndex(0),
m_ctlTriggerIndex(0)
2017-01-29 13:51:45 -05:00
{
2018-08-12 10:48:03 -04:00
qDebug("GLScopeGUI::GLScopeGUI");
2017-02-04 22:41:32 -05:00
setEnabled(false);
2017-02-05 07:26:07 -05:00
ui->setupUi(this);
ui->trigDelayFine->setMaximum(GLScopeSettings::m_traceChunkDefaultSize / 10.0);
ui->traceColor->setStyleSheet("QLabel { background-color : rgb(255,255,64); }");
m_focusedTraceColor.setRgb(255,255,64);
ui->trigColor->setStyleSheet("QLabel { background-color : rgb(0,255,0); }");
m_focusedTriggerColor.setRgb(0,255,0);
2017-02-26 19:11:12 -05:00
ui->traceText->setText("X");
ui->mem->setMaximum(GLScopeSettings::m_nbTraceMemories - 1);
2022-12-20 06:21:54 -05:00
DialPopup::addPopupsToChildDials(this);
2017-01-29 13:51:45 -05:00
}
2018-08-12 10:48:03 -04:00
GLScopeGUI::~GLScopeGUI()
2017-01-29 13:51:45 -05:00
{
delete ui;
}
2018-08-12 11:18:58 -04:00
void GLScopeGUI::setBuddies(MessageQueue* messageQueue, ScopeVis* scopeVis, GLScope* glScope)
2017-01-29 13:51:45 -05:00
{
2018-08-12 10:48:03 -04:00
qDebug("GLScopeGUI::setBuddies");
2017-02-05 07:26:07 -05:00
2017-01-29 13:51:45 -05:00
m_messageQueue = messageQueue;
m_scopeVis = scopeVis;
m_glScope = glScope;
2017-02-04 22:41:32 -05:00
// initialize display combo
ui->onlyY->setEnabled(false);
ui->horizontalXY->setEnabled(false);
ui->verticalXY->setEnabled(false);
ui->polar->setEnabled(false);
2018-08-12 11:01:56 -04:00
m_glScope->setDisplayMode(GLScope::DisplayX);
2017-02-04 22:41:32 -05:00
// initialize trigger combo
ui->trigPos->setChecked(true);
ui->trigNeg->setChecked(false);
ui->trigBoth->setChecked(false);
ui->trigOneShot->setChecked(false);
ui->trigOneShot->setEnabled(false);
2017-02-04 22:41:32 -05:00
ui->freerun->setChecked(true);
// Add a trigger
GLScopeSettings::TriggerData triggerData;
2017-02-04 22:41:32 -05:00
fillTriggerData(triggerData);
ScopeVis::MsgScopeVisAddTrigger *msgAddTrigger = ScopeVis::MsgScopeVisAddTrigger::create(triggerData);
m_scopeVis->getInputMessageQueue()->push(msgAddTrigger);
settingsTriggerAdd(triggerData);
2017-02-04 22:41:32 -05:00
2017-02-11 04:36:10 -05:00
// Add a trace
2021-05-28 18:55:04 -04:00
GLScopeSettings::TraceData traceData;
2017-02-11 04:36:10 -05:00
fillTraceData(traceData);
ScopeVis::MsgScopeVisAddTrace *msgAddTrace = ScopeVis::MsgScopeVisAddTrace::create(traceData);
m_scopeVis->getInputMessageQueue()->push(msgAddTrace);
settingsTraceAdd(traceData);
2017-02-11 04:36:10 -05:00
2017-02-04 22:41:32 -05:00
setEnabled(true);
connect(m_glScope, SIGNAL(sampleRateChanged(int)), this, SLOT(onScopeSampleRateChanged(int)));
connect(m_glScope, SIGNAL(traceSizeChanged(uint32_t)), this, SLOT(onScopeTraceSizeChanged(uint32_t)));
connect(m_glScope, SIGNAL(preTriggerChanged(uint32_t)), this, SLOT(onScopePreTriggerChanged(uint32_t)));
2017-02-04 22:41:32 -05:00
2017-02-05 07:26:07 -05:00
ui->traceMode->clear();
fillProjectionCombo(ui->traceMode);
ui->trigMode->clear();
fillProjectionCombo(ui->trigMode);
m_scopeVis->configure(
2*m_settings.m_traceLenMult*m_scopeVis->getTraceChunkSize(),
m_timeBase,
m_timeOffset*10,
(uint32_t) (m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f)),
ui->freerun->isChecked()
);
m_scopeVis->configure(
m_settings.m_traceLenMult*m_scopeVis->getTraceChunkSize(),
m_timeBase,
m_timeOffset*10,
(uint32_t) (m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f)),
ui->freerun->isChecked()
);
2017-02-04 22:41:32 -05:00
setTraceLenDisplay();
setTimeScaleDisplay();
setTimeOfsDisplay();
2017-02-05 07:26:07 -05:00
setAmpScaleDisplay();
2017-02-06 18:25:40 -05:00
setAmpOfsDisplay();
2017-02-16 19:54:55 -05:00
setTraceDelayDisplay();
2017-01-29 13:51:45 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setSampleRate(int sampleRate)
2017-01-29 13:51:45 -05:00
{
onScopeSampleRateChanged(sampleRate);
2017-01-29 13:51:45 -05:00
}
void GLScopeGUI::onScopeSampleRateChanged(int sampleRate)
2017-01-29 16:52:38 -05:00
{
//m_sampleRate = m_glScope->getSampleRate();
m_sampleRate = sampleRate;
ui->sampleRateText->setText(tr("%1\nkS/s").arg(m_sampleRate / 1000.0f, 0, 'f', 2));
2017-02-04 22:41:32 -05:00
setTraceLenDisplay();
setTimeScaleDisplay();
setTimeOfsDisplay();
2017-02-16 19:54:55 -05:00
setTraceDelayDisplay();
setTrigPreDisplay();
setTrigDelayDisplay();
2017-01-29 16:52:38 -05:00
}
void GLScopeGUI::onScopeTraceSizeChanged(uint32_t traceNbSamples)
{
qDebug("GLScopeGUI::onScopeTraceSizeChanged: %u", traceNbSamples);
m_settings.m_traceLenMult = traceNbSamples / m_scopeVis->getTraceChunkSize();
ui->traceLen->setValue(m_settings.m_traceLenMult);
setTraceLenDisplay();
}
void GLScopeGUI::onScopePreTriggerChanged(uint32_t preTriggerNbSamples)
{
qDebug("GLScopeGUI::onScopePreTriggerChanged: %u", preTriggerNbSamples);
ui->trigPre->setValue(preTriggerNbSamples*100 / m_glScope->getTraceSize()); // slider position is a percentage value of the trace size
setTrigPreDisplay();
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::resetToDefaults()
2017-01-29 13:51:45 -05:00
{
m_settings.resetToDefaults();
2017-01-29 13:51:45 -05:00
}
2018-08-12 10:48:03 -04:00
QByteArray GLScopeGUI::serialize() const
2017-01-29 13:51:45 -05:00
{
return m_settings.serialize();
}
bool GLScopeGUI::deserialize(const QByteArray& data)
{
bool ret;
if (m_settings.deserialize(data))
{
displaySettings();
ret = true;
}
else
{
resetToDefaults();
ret = false;
}
// trace stuff
2017-01-29 13:51:45 -05:00
const std::vector<GLScopeSettings::TraceData>& tracesData = m_scopeVis->getTracesData();
uint32_t iTrace = tracesData.size();
uint32_t nbTracesSaved = m_settings.m_tracesData.size();
ui->trace->setMaximum(nbTracesSaved-1);
2017-01-29 13:51:45 -05:00
while (iTrace > nbTracesSaved) // remove possible traces in excess
{
ScopeVis::MsgScopeVisRemoveTrace *msg = ScopeVis::MsgScopeVisRemoveTrace::create(iTrace - 1);
m_scopeVis->getInputMessageQueue()->push(msg);
iTrace--;
2017-01-29 13:51:45 -05:00
}
for (iTrace = 0; iTrace < nbTracesSaved; iTrace++)
{
GLScopeSettings::TraceData& traceData = m_settings.m_tracesData[iTrace];
if (iTrace < tracesData.size()) // change existing traces
2017-02-20 16:19:50 -05:00
{
ScopeVis::MsgScopeVisChangeTrace *msg = ScopeVis::MsgScopeVisChangeTrace::create(traceData, iTrace);
m_scopeVis->getInputMessageQueue()->push(msg);
2017-02-20 16:19:50 -05:00
}
else // add new traces
2017-02-20 16:19:50 -05:00
{
ScopeVis::MsgScopeVisAddTrace *msg = ScopeVis::MsgScopeVisAddTrace::create(traceData);
m_scopeVis->getInputMessageQueue()->push(msg);
2017-02-20 16:19:50 -05:00
}
}
2017-02-20 16:19:50 -05:00
setTraceIndexDisplay();
setAmpScaleDisplay();
setAmpOfsDisplay();
setTraceDelayDisplay();
setDisplayMode(m_settings.m_displayMode);
2017-02-20 16:19:50 -05:00
// trigger stuff
2017-02-20 17:58:03 -05:00
uint32_t nbTriggersSaved = m_settings.m_triggersData.size();
uint32_t nbTriggers = m_scopeVis->getNbTriggers();
uint32_t iTrigger = nbTriggers;
ui->trig->setMaximum(nbTriggersSaved-1);
2017-02-20 17:58:03 -05:00
while (iTrigger > nbTriggersSaved) // remove possible triggers in excess
{
ScopeVis::MsgScopeVisRemoveTrigger *msg = ScopeVis::MsgScopeVisRemoveTrigger::create(iTrigger - 1);
m_scopeVis->getInputMessageQueue()->push(msg);
iTrigger--;
}
2017-02-20 17:58:03 -05:00
for (iTrigger = 0; iTrigger < nbTriggersSaved; iTrigger++)
{
GLScopeSettings::TriggerData& triggerData = m_settings.m_triggersData[iTrigger];
2017-02-20 17:58:03 -05:00
if (iTrigger < nbTriggers) // change existing triggers
2017-02-20 17:58:03 -05:00
{
ScopeVis::MsgScopeVisChangeTrigger *msg = ScopeVis::MsgScopeVisChangeTrigger::create(triggerData, iTrigger);
m_scopeVis->getInputMessageQueue()->push(msg);
2017-02-20 17:58:03 -05:00
}
2024-07-10 16:59:13 -04:00
else // add new triggers
2017-02-20 17:58:03 -05:00
{
ScopeVis::MsgScopeVisAddTrigger *msg = ScopeVis::MsgScopeVisAddTrigger::create(triggerData);
m_scopeVis->getInputMessageQueue()->push(msg);
2017-02-20 17:58:03 -05:00
}
}
2017-02-20 17:58:03 -05:00
setTrigCountDisplay();
setTrigDelayDisplay();
setTrigIndexDisplay();
setTrigLevelDisplay();
setTrigPreDisplay();
2017-02-20 17:58:03 -05:00
displaySettings();
2017-02-20 17:58:03 -05:00
return ret;
2017-01-29 13:51:45 -05:00
}
void GLScopeGUI::formatTo(SWGSDRangel::SWGObject *swgObject) const
{
m_settings.formatTo(swgObject);
}
void GLScopeGUI::updateFrom(const QStringList& keys, const SWGSDRangel::SWGObject *swgObject)
{
m_settings.updateFrom(keys, swgObject);
}
void GLScopeGUI::updateSettings()
{
displaySettings();
applySettings(m_settings); /// FIXME
}
void GLScopeGUI::setNbStreams(unsigned int nbStreams)
{
QStringList streamNames;
for (unsigned int s = 0; s < nbStreams; s++) {
streamNames.append(tr("%1").arg(s));
}
setStreams(streamNames);
}
void GLScopeGUI::setStreams(const QStringList& streamNames)
{
int traceStreamIndex = ui->traceStream->currentIndex();
int triggerStreamIndex = ui->trigStream->currentIndex();
ui->traceStream->blockSignals(true);
ui->trigStream->blockSignals(true);
ui->traceStream->clear();
ui->trigStream->clear();
for (QString s : streamNames)
{
ui->traceStream->addItem(s);
ui->trigStream->addItem(s);
}
int newTraceStreamIndex = traceStreamIndex < streamNames.size() ? traceStreamIndex : streamNames.size() - 1;
int newTriggerStreamIndex = triggerStreamIndex < streamNames.size() ? triggerStreamIndex: streamNames.size() - 1;
ui->traceStream->setCurrentIndex(newTraceStreamIndex);
if (newTraceStreamIndex != traceStreamIndex) {
changeCurrentTrace();
}
ui->trigStream->setCurrentIndex(newTriggerStreamIndex);
if (newTriggerStreamIndex != triggerStreamIndex) {
changeCurrentTrigger();
}
ui->traceStream->blockSignals(false);
ui->trigStream->blockSignals(false);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_onlyX_toggled(bool checked)
2017-02-03 02:27:03 -05:00
{
if (checked)
{
m_glScope->setDisplayMode(GLScope::DisplayX);
ui->onlyX->setEnabled(false);
ui->onlyY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->horizontalXY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->verticalXY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->polar->setEnabled(m_scopeVis->getNbTraces() > 1);
2017-02-03 02:27:03 -05:00
ui->onlyY->setChecked(false);
ui->horizontalXY->setChecked(false);
ui->verticalXY->setChecked(false);
ui->polar->setChecked(false);
2021-06-10 18:21:42 -04:00
m_settings.m_displayMode = GLScopeSettings::DisplayX;
m_scopeVis->configure(
m_settings.m_displayMode,
m_settings.m_traceIntensity,
m_settings.m_gridIntensity
);
}
2017-02-03 02:27:03 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_onlyY_toggled(bool checked)
2017-02-03 02:27:03 -05:00
{
if (checked)
{
m_glScope->setDisplayMode(GLScope::DisplayY);
ui->onlyX->setEnabled(true);
ui->onlyY->setEnabled(false);
ui->horizontalXY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->verticalXY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->polar->setEnabled(m_scopeVis->getNbTraces() > 1);
2017-02-03 02:27:03 -05:00
ui->onlyX->setChecked(false);
ui->horizontalXY->setChecked(false);
ui->verticalXY->setChecked(false);
ui->polar->setChecked(false);
2021-06-10 18:21:42 -04:00
m_settings.m_displayMode = GLScopeSettings::DisplayY;
m_scopeVis->configure(
m_settings.m_displayMode,
m_settings.m_traceIntensity,
m_settings.m_gridIntensity
);
}
2017-02-03 02:27:03 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_horizontalXY_toggled(bool checked)
2017-02-03 02:27:03 -05:00
{
if (checked)
{
m_glScope->setDisplayMode(GLScope::DisplayXYH);
ui->onlyX->setEnabled(true);
ui->onlyY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->horizontalXY->setEnabled(false);
ui->verticalXY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->polar->setEnabled(m_scopeVis->getNbTraces() > 1);
2017-02-03 02:27:03 -05:00
ui->onlyX->setChecked(false);
ui->onlyY->setChecked(false);
ui->verticalXY->setChecked(false);
ui->polar->setChecked(false);
2021-06-10 18:21:42 -04:00
m_settings.m_displayMode = GLScopeSettings::DisplayXYH;
m_scopeVis->configure(
m_settings.m_displayMode,
m_settings.m_traceIntensity,
m_settings.m_gridIntensity
);
}
2017-02-03 02:27:03 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_verticalXY_toggled(bool checked)
2017-02-03 02:27:03 -05:00
{
2017-02-04 22:41:32 -05:00
if (checked)
{
m_glScope->setDisplayMode(GLScope::DisplayXYV);
ui->onlyX->setEnabled(true);
ui->onlyY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->horizontalXY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->verticalXY->setEnabled(false);
ui->polar->setEnabled(m_scopeVis->getNbTraces() > 1);
2017-02-04 22:41:32 -05:00
ui->onlyX->setChecked(false);
ui->onlyY->setChecked(false);
ui->horizontalXY->setChecked(false);
ui->polar->setChecked(false);
2021-06-10 18:21:42 -04:00
m_settings.m_displayMode = GLScopeSettings::DisplayXYV;
m_scopeVis->configure(
m_settings.m_displayMode,
m_settings.m_traceIntensity,
m_settings.m_gridIntensity
);
}
2017-02-03 02:27:03 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_polar_toggled(bool checked)
2017-02-03 02:27:03 -05:00
{
2017-02-04 22:41:32 -05:00
if (checked)
{
m_glScope->setDisplayMode(GLScope::DisplayPol);
ui->onlyX->setEnabled(true);
ui->onlyY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->horizontalXY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->verticalXY->setEnabled(m_scopeVis->getNbTraces() > 1);
ui->polar->setEnabled(false);
2017-02-04 22:41:32 -05:00
ui->onlyX->setChecked(false);
ui->onlyY->setChecked(false);
ui->horizontalXY->setChecked(false);
ui->verticalXY->setChecked(false);
2021-06-10 18:21:42 -04:00
m_settings.m_displayMode = GLScopeSettings::DisplayPol;
m_scopeVis->configure(
m_settings.m_displayMode,
m_settings.m_traceIntensity,
m_settings.m_gridIntensity
);
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_polarPoints_toggled(bool checked)
{
m_glScope->setDisplayXYPoints(checked);
2017-02-03 02:27:03 -05:00
}
void GLScopeGUI::on_polarGrid_toggled(bool checked)
{
m_glScope->setDisplayXYPolarGrid(checked);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_traceIntensity_valueChanged(int value)
2017-02-03 02:27:03 -05:00
{
2017-02-04 22:41:32 -05:00
ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(value));
m_glScope->setDisplayTraceIntensity(value);
2021-06-10 18:21:42 -04:00
m_settings.m_traceIntensity = value;
m_scopeVis->configure(
m_settings.m_displayMode,
m_settings.m_traceIntensity,
m_settings.m_gridIntensity
);
2017-02-03 02:27:03 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_gridIntensity_valueChanged(int value)
2017-02-03 02:27:03 -05:00
{
2017-02-04 22:41:32 -05:00
ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(value));
m_glScope->setDisplayGridIntensity(value);
2021-06-10 18:21:42 -04:00
m_settings.m_gridIntensity = value;
m_scopeVis->configure(
m_settings.m_displayMode,
m_settings.m_traceIntensity,
m_settings.m_gridIntensity
);
2017-02-03 02:27:03 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_time_valueChanged(int value)
2017-02-03 02:27:03 -05:00
{
2017-02-04 22:41:32 -05:00
m_timeBase = value;
2021-06-12 04:16:33 -04:00
m_settings.m_time = value;
2017-02-04 22:41:32 -05:00
setTimeScaleDisplay();
2017-02-16 19:54:55 -05:00
setTraceDelayDisplay();
m_scopeVis->configure(
m_settings.m_traceLenMult*m_scopeVis->getTraceChunkSize(),
m_timeBase,
m_timeOffset*10,
(uint32_t) (m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f)),
ui->freerun->isChecked()
);
2017-02-03 02:27:03 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_timeOfs_valueChanged(int value)
2017-02-03 02:27:03 -05:00
{
2017-02-04 22:41:32 -05:00
if ((value < 0) || (value > 100)) {
return;
}
2017-02-03 02:27:03 -05:00
2017-02-04 22:41:32 -05:00
m_timeOffset = value;
2021-06-12 04:16:33 -04:00
m_settings.m_timeOfs = value;
2017-02-04 22:41:32 -05:00
setTimeOfsDisplay();
m_scopeVis->configure(
m_settings.m_traceLenMult*m_scopeVis->getTraceChunkSize(),
m_timeBase,
m_timeOffset*10,
(uint32_t) (m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f)),
ui->freerun->isChecked()
);
if ((value > 0) && (ui->mem->value() == 0)) // switch from live to memory trace
{
ui->mem->setValue(1);
ui->memText->setText("01");
}
2017-02-03 02:27:03 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_traceLen_valueChanged(int value)
2017-02-03 02:27:03 -05:00
{
2017-02-04 22:41:32 -05:00
if ((value < 1) || (value > 100)) {
return;
}
m_settings.m_traceLenMult = value;
m_scopeVis->configure(
m_settings.m_traceLenMult*m_scopeVis->getTraceChunkSize(),
m_timeBase,
m_timeOffset*10,
(uint32_t) (m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f)),
ui->freerun->isChecked()
);
2017-02-04 22:41:32 -05:00
setTraceLenDisplay();
setTimeScaleDisplay();
setTimeOfsDisplay();
setTrigDelayDisplay();
setTrigPreDisplay();
2017-02-04 22:41:32 -05:00
}
2017-02-03 02:27:03 -05:00
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_trace_valueChanged(int value)
{
2017-02-26 14:14:54 -05:00
ui->traceText->setText(value == 0 ? "X" : QString("Y%1").arg(ui->trace->value()));
m_ctlTraceIndex = value;
2021-05-28 18:55:04 -04:00
GLScopeSettings::TraceData traceData;
m_scopeVis->getTraceData(traceData, value);
2018-08-12 10:48:03 -04:00
qDebug() << "GLScopeGUI::on_trace_valueChanged:"
<< " m_projectionType: " << (int) traceData.m_projectionType
<< " m_amp" << traceData.m_amp
<< " m_ofs" << traceData.m_ofs
<< " m_traceDelay" << traceData.m_traceDelay;
setTraceUI(traceData);
ScopeVis::MsgScopeVisFocusOnTrace *msg = ScopeVis::MsgScopeVisFocusOnTrace::create(value);
m_scopeVis->getInputMessageQueue()->push(msg);
}
void GLScopeGUI::on_traceAdd_clicked(bool checked)
{
(void) checked;
2021-05-28 18:55:04 -04:00
GLScopeSettings::TraceData traceData;
fillTraceData(traceData);
addTrace(traceData);
}
void GLScopeGUI::on_traceDel_clicked(bool checked)
{
(void) checked;
2017-02-26 05:26:23 -05:00
if (ui->trace->value() > 0) // not the X trace
{
ui->trace->setMaximum(ui->trace->maximum() - 1);
2021-06-12 04:16:33 -04:00
if (ui->trace->maximum() == 0)
{
2021-06-12 04:16:33 -04:00
setDisplayMode(GLScopeSettings::DisplayX);
2018-08-12 11:01:56 -04:00
m_glScope->setDisplayMode(GLScope::DisplayX);
}
ScopeVis::MsgScopeVisRemoveTrace *msg = ScopeVis::MsgScopeVisRemoveTrace::create(ui->trace->value());
m_scopeVis->getInputMessageQueue()->push(msg);
2021-06-12 04:16:33 -04:00
settingsTraceDel(ui->trace->value());
changeCurrentTrace();
}
}
void GLScopeGUI::on_traceUp_clicked(bool checked)
2017-02-26 05:26:23 -05:00
{
(void) checked;
2017-02-26 05:26:23 -05:00
if (ui->trace->maximum() > 0) // more than one trace
{
int newTraceIndex = (ui->trace->value() + 1) % (ui->trace->maximum()+1);
ScopeVis::MsgScopeVisMoveTrace *msgMoveTrace = ScopeVis::MsgScopeVisMoveTrace::create(ui->trace->value(), true);
m_scopeVis->getInputMessageQueue()->push(msgMoveTrace);
2021-06-12 04:16:33 -04:00
settingsTraceMove(ui->trace->value(), true);
2017-02-26 05:26:23 -05:00
ui->trace->setValue(newTraceIndex); // follow trace
2021-05-28 18:55:04 -04:00
GLScopeSettings::TraceData traceData;
2017-02-26 05:26:23 -05:00
m_scopeVis->getTraceData(traceData, ui->trace->value());
setTraceUI(traceData);
ScopeVis::MsgScopeVisFocusOnTrace *msgFocusOnTrace = ScopeVis::MsgScopeVisFocusOnTrace::create(ui->trace->value());
m_scopeVis->getInputMessageQueue()->push(msgFocusOnTrace);
2017-02-26 05:26:23 -05:00
}
}
void GLScopeGUI::on_traceDown_clicked(bool checked)
2017-02-26 05:26:23 -05:00
{
(void) checked;
2017-02-26 05:26:23 -05:00
if (ui->trace->value() > 0) // not the X (lowest) trace
{
int newTraceIndex = (ui->trace->value() - 1) % (ui->trace->maximum()+1);
ScopeVis::MsgScopeVisMoveTrace *msgMoveTrace = ScopeVis::MsgScopeVisMoveTrace::create(ui->trace->value(), false);
m_scopeVis->getInputMessageQueue()->push(msgMoveTrace);
2021-06-12 04:16:33 -04:00
settingsTraceMove(ui->trace->value(), false);
2017-02-26 05:26:23 -05:00
ui->trace->setValue(newTraceIndex); // follow trace
2021-05-28 18:55:04 -04:00
GLScopeSettings::TraceData traceData;
2017-02-26 05:26:23 -05:00
m_scopeVis->getTraceData(traceData, ui->trace->value());
setTraceUI(traceData);
ScopeVis::MsgScopeVisFocusOnTrace *msgFocusOnTrace = ScopeVis::MsgScopeVisFocusOnTrace::create(ui->trace->value());
m_scopeVis->getInputMessageQueue()->push(msgFocusOnTrace);
2017-02-26 05:26:23 -05:00
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_trig_valueChanged(int value)
{
ui->trigText->setText(tr("%1").arg(value));
m_ctlTriggerIndex = value;
GLScopeSettings::TriggerData triggerData;
m_scopeVis->getTriggerData(triggerData, value);
2018-08-12 10:48:03 -04:00
qDebug() << "GLScopeGUI::on_trig_valueChanged:"
<< " m_projectionType: " << (int) triggerData.m_projectionType
<< " m_triggerRepeat" << triggerData.m_triggerRepeat
<< " m_triggerPositiveEdge" << triggerData.m_triggerPositiveEdge
<< " m_triggerBothEdges" << triggerData.m_triggerBothEdges
<< " m_triggerLevel" << triggerData.m_triggerLevel;
setTriggerUI(triggerData);
ScopeVis::MsgScopeVisFocusOnTrigger *msg = ScopeVis::MsgScopeVisFocusOnTrigger::create(value);
m_scopeVis->getInputMessageQueue()->push(msg);
}
void GLScopeGUI::on_trigAdd_clicked(bool checked)
{
(void) checked;
GLScopeSettings::TriggerData triggerData;
fillTriggerData(triggerData);
addTrigger(triggerData);
}
void GLScopeGUI::on_trigDel_clicked(bool checked)
{
(void) checked;
if (ui->trig->value() > 0)
{
ScopeVis::MsgScopeVisRemoveTrigger *msg = ScopeVis::MsgScopeVisRemoveTrigger::create(ui->trig->value());
m_scopeVis->getInputMessageQueue()->push(msg);
2021-06-12 04:16:33 -04:00
settingsTriggerDel(ui->trig->value());
ui->trig->setMaximum(ui->trig->maximum() - 1);
}
}
void GLScopeGUI::on_trigUp_clicked(bool checked)
2017-02-26 13:14:27 -05:00
{
(void) checked;
2017-02-26 13:14:27 -05:00
if (ui->trig->maximum() > 0) // more than one trigger
{
int newTriggerIndex = (ui->trig->value() + 1) % (ui->trig->maximum()+1);
ScopeVis::MsgScopeVisMoveTrigger *msgMoveTrigger = ScopeVis::MsgScopeVisMoveTrigger::create(ui->trace->value(), true);
m_scopeVis->getInputMessageQueue()->push(msgMoveTrigger);
2021-06-12 04:16:33 -04:00
settingsTriggerMove(ui->trace->value(), true);
2017-02-26 13:14:27 -05:00
ui->trig->setValue(newTriggerIndex); // follow trigger
GLScopeSettings::TriggerData triggerData;
2017-02-26 13:14:27 -05:00
m_scopeVis->getTriggerData(triggerData, ui->trig->value());
setTriggerUI(triggerData);
ScopeVis::MsgScopeVisFocusOnTrigger *msgFocusOnTrigger = ScopeVis::MsgScopeVisFocusOnTrigger::create(ui->trig->value());
m_scopeVis->getInputMessageQueue()->push(msgFocusOnTrigger);
2017-02-26 13:14:27 -05:00
}
}
void GLScopeGUI::on_trigDown_clicked(bool checked)
2017-02-26 13:14:27 -05:00
{
(void) checked;
2017-02-26 13:14:27 -05:00
if (ui->trig->value() > 0) // not the 0 (lowest) trigger
{
int newTriggerIndex = (ui->trig->value() - 1) % (ui->trig->maximum()+1);
ScopeVis::MsgScopeVisMoveTrigger *msgMoveTrigger = ScopeVis::MsgScopeVisMoveTrigger::create(ui->trace->value(), false);
m_scopeVis->getInputMessageQueue()->push(msgMoveTrigger);
2021-06-12 04:16:33 -04:00
settingsTriggerMove(ui->trace->value(), false);
2017-02-26 13:14:27 -05:00
ui->trig->setValue(newTriggerIndex); // follow trigger
GLScopeSettings::TriggerData triggerData;
2017-02-26 13:14:27 -05:00
m_scopeVis->getTriggerData(triggerData, ui->trig->value());
setTriggerUI(triggerData);
ScopeVis::MsgScopeVisFocusOnTrigger *msgFocusOnTrigger = ScopeVis::MsgScopeVisFocusOnTrigger::create(ui->trig->value());
m_scopeVis->getInputMessageQueue()->push(msgFocusOnTrigger);
2017-02-26 13:14:27 -05:00
}
}
void GLScopeGUI::on_traceStream_currentIndexChanged(int index)
{
(void) index;
changeCurrentTrace();
}
void GLScopeGUI::on_traceMode_currentIndexChanged(int index)
2017-02-05 07:26:07 -05:00
{
(void) index;
2017-02-05 07:26:07 -05:00
setAmpScaleDisplay();
2017-02-06 18:25:40 -05:00
setAmpOfsDisplay();
2017-02-05 07:26:07 -05:00
changeCurrentTrace();
}
void GLScopeGUI::on_ampReset_clicked(bool checked)
{
(void) checked;
ui->amp->setValue(0);
ui->ampCoarse->setValue(1);
ui->ampExp->setValue(0);
setAmpScaleDisplay();
changeCurrentTrace();
}
void GLScopeGUI::on_amp_valueChanged(int value)
2017-02-05 07:26:07 -05:00
{
(void) value;
2017-02-05 07:26:07 -05:00
setAmpScaleDisplay();
changeCurrentTrace();
}
2021-06-26 19:52:42 -04:00
void GLScopeGUI::on_ampCoarse_valueChanged(int value)
{
(void) value;
setAmpScaleDisplay();
changeCurrentTrace();
}
void GLScopeGUI::on_ampExp_valueChanged(int value)
{
(void) value;
setAmpScaleDisplay();
changeCurrentTrace();
}
void GLScopeGUI::on_ofsReset_clicked(bool checked)
{
(void) checked;
ui->ofsFine->setValue(0);
ui->ofsCoarse->setValue(0);
ui->ofsExp->setValue(0);
setAmpOfsDisplay();
changeCurrentTrace();
}
void GLScopeGUI::on_ofsCoarse_valueChanged(int value)
{
(void) value;
2017-02-20 16:19:50 -05:00
setAmpOfsDisplay();
changeCurrentTrace();
}
void GLScopeGUI::on_ofsFine_valueChanged(int value)
{
(void) value;
2017-02-20 16:19:50 -05:00
setAmpOfsDisplay();
changeCurrentTrace();
}
2021-06-27 04:10:28 -04:00
void GLScopeGUI::on_ofsExp_valueChanged(int value)
{
(void) value;
setAmpOfsDisplay();
changeCurrentTrace();
}
void GLScopeGUI::on_traceDelayCoarse_valueChanged(int value)
{
(void) value;
2017-02-20 16:19:50 -05:00
setTraceDelayDisplay();
changeCurrentTrace();
2017-02-16 19:54:55 -05:00
}
void GLScopeGUI::on_traceDelayFine_valueChanged(int value)
2017-02-16 19:54:55 -05:00
{
(void) value;
2017-02-16 19:54:55 -05:00
setTraceDelayDisplay();
changeCurrentTrace();
}
void GLScopeGUI::on_traceView_toggled(bool checked)
{
(void) checked;
changeCurrentTrace();
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_traceColor_clicked()
{
QColor newColor = QColorDialog::getColor(m_focusedTraceColor, this, tr("Select Color for trace"), QColorDialog::DontUseNativeDialog);
if (newColor.isValid()) // user clicked OK and selected a color
{
m_focusedTraceColor = newColor;
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));
changeCurrentTrace();
}
}
void GLScopeGUI::on_memorySave_clicked(bool checked)
2018-10-14 20:47:26 -04:00
{
(void) checked;
2018-10-14 20:47:26 -04:00
QString fileName = QFileDialog::getSaveFileName(this,
tr("Create trace memory file"), ".", tr("Trace memory files (*.trcm)"), 0, QFileDialog::DontUseNativeDialog);
2018-10-14 20:47:26 -04:00
if (fileName != "")
{
QFileInfo fileInfo(fileName);
if (fileInfo.suffix() != "trcm") {
fileName += ".trcm";
}
QFile exportFile(fileName);
if (exportFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
QString base64Str = m_scopeVis->serializeMemory().toBase64();
QTextStream outstream(&exportFile);
outstream << base64Str;
exportFile.close();
qDebug("GLScopeGUI::on_memorySave_clicked: saved to %s", qPrintable(fileName));
}
else
{
QMessageBox::information(this, tr("Message"), tr("Cannot open %1 file for writing").arg(fileName));
}
2018-10-14 20:47:26 -04:00
}
}
void GLScopeGUI::on_memoryLoad_clicked(bool checked)
2018-10-14 20:47:26 -04:00
{
(void) checked;
2018-10-14 20:47:26 -04:00
qDebug("GLScopeGUI::on_memoryLoad_clicked");
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open trace memory file"), ".", tr("Trace memory files (*.trcm)"), 0, QFileDialog::DontUseNativeDialog);
if (fileName != "")
{
QFile exportFile(fileName);
if (exportFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
QByteArray base64Str;
QTextStream instream(&exportFile);
instream >> base64Str;
exportFile.close();
m_scopeVis->deserializeMemory(QByteArray::fromBase64(base64Str));
qDebug("GLScopeGUI::on_memoryLoad_clicked: loaded from %s", qPrintable(fileName));
}
else
{
QMessageBox::information(this, tr("Message"), tr("Cannot open file %1 for reading").arg(fileName));
}
2018-10-14 20:47:26 -04:00
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_mem_valueChanged(int value)
{
2020-11-04 02:59:16 -05:00
QString text = QStringLiteral("%1").arg(value, 2, 10, QLatin1Char('0'));
ui->memText->setText(text);
2018-10-14 20:47:26 -04:00
disableLiveMode(value > 0); // live / memory mode toggle
m_scopeVis->setMemoryIndex(value);
}
void GLScopeGUI::on_trigStream_currentIndexChanged(int index)
{
(void) index;
changeCurrentTrigger();
}
void GLScopeGUI::on_trigMode_currentIndexChanged(int index)
{
(void) index;
2017-02-20 16:19:50 -05:00
setTrigLevelDisplay();
changeCurrentTrigger();
}
void GLScopeGUI::on_trigCount_valueChanged(int value)
{
(void) value;
setTrigCountDisplay();
changeCurrentTrigger();
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_trigPos_toggled(bool checked)
{
if (checked)
{
2017-02-20 16:19:50 -05:00
ui->trigNeg->setChecked(false);
ui->trigBoth->setChecked(false);
}
2017-02-20 16:19:50 -05:00
changeCurrentTrigger();
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_trigNeg_toggled(bool checked)
{
if (checked)
{
2017-02-20 16:19:50 -05:00
ui->trigPos->setChecked(false);
ui->trigBoth->setChecked(false);
}
2017-02-20 16:19:50 -05:00
changeCurrentTrigger();
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_trigBoth_toggled(bool checked)
{
if (checked)
{
2017-02-20 16:19:50 -05:00
ui->trigNeg->setChecked(false);
ui->trigPos->setChecked(false);
}
2017-02-20 16:19:50 -05:00
changeCurrentTrigger();
}
2018-10-27 19:38:58 -04:00
void GLScopeGUI::on_trigHoldoff_valueChanged(int value)
{
ui->trigHoldoffText->setText(tr("%1").arg(value));
changeCurrentTrigger();
}
void GLScopeGUI::on_trigLevelCoarse_valueChanged(int value)
{
(void) value;
2017-02-20 16:19:50 -05:00
setTrigLevelDisplay();
changeCurrentTrigger();
}
void GLScopeGUI::on_trigLevelFine_valueChanged(int value)
{
(void) value;
2017-02-20 16:19:50 -05:00
setTrigLevelDisplay();
changeCurrentTrigger();
}
void GLScopeGUI::on_trigDelayCoarse_valueChanged(int value)
{
(void) value;
2017-02-20 16:19:50 -05:00
setTrigDelayDisplay();
changeCurrentTrigger();
}
void GLScopeGUI::on_trigDelayFine_valueChanged(int value)
{
(void) value;
setTrigDelayDisplay();
changeCurrentTrigger();
}
void GLScopeGUI::on_trigPre_valueChanged(int value)
{
(void) value;
2017-02-20 16:19:50 -05:00
setTrigPreDisplay();
m_scopeVis->configure(
m_settings.m_traceLenMult*m_scopeVis->getTraceChunkSize(),
m_timeBase,
m_timeOffset*10,
(uint32_t) (m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f)),
ui->freerun->isChecked()
);
2021-06-12 04:16:33 -04:00
m_settings.m_trigPre = (uint32_t) (m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f));
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_trigColor_clicked()
{
QColor newColor = QColorDialog::getColor(m_focusedTriggerColor, this, tr("Select Color for trigger line"), QColorDialog::DontUseNativeDialog);
if (newColor.isValid()) // user clicked "OK"
{
m_focusedTriggerColor = newColor;
int r,g,b,a;
m_focusedTriggerColor.getRgb(&r, &g, &b, &a);
ui->trigColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b));
changeCurrentTrigger();
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_trigOneShot_toggled(bool checked)
{
2017-02-21 19:18:50 -05:00
m_scopeVis->setOneShot(checked);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::on_freerun_toggled(bool checked)
2017-02-05 20:40:31 -05:00
{
2017-02-20 16:19:50 -05:00
if (checked)
{
ui->trigOneShot->setChecked(false);
ui->trigOneShot->setEnabled(false);
2017-02-20 16:19:50 -05:00
}
else
{
ui->trigOneShot->setEnabled(true);
2017-02-20 16:19:50 -05:00
}
m_scopeVis->configure(
m_settings.m_traceLenMult*m_scopeVis->getTraceChunkSize(),
m_timeBase,
m_timeOffset*10,
(uint32_t) (m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f)),
ui->freerun->isChecked()
);
m_settings.m_freerun = checked;
2017-02-05 20:40:31 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTraceIndexDisplay()
{
2017-02-26 14:14:54 -05:00
ui->traceText->setText(ui->trace->value() == 0 ? "X" : QString("Y%1").arg(ui->trace->value()));
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTrigCountDisplay()
{
2020-11-04 02:59:16 -05:00
QString text = QStringLiteral("%1").arg(ui->trigCount->value(), 2, 10, QLatin1Char('0'));
ui->trigCountText->setText(text);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTimeScaleDisplay()
2017-02-04 22:41:32 -05:00
{
m_sampleRate = m_glScope->getSampleRate();
2017-02-21 20:52:38 -05:00
unsigned int n_samples = (m_glScope->getTraceSize() * 1.0) / (double) m_timeBase;
2017-02-04 22:41:32 -05:00
double t = (m_glScope->getTraceSize() * 1.0 / m_sampleRate) / (double) m_timeBase;
2017-02-21 20:52:38 -05:00
if (n_samples < 1000) {
ui->timeText->setToolTip(tr("%1 S").arg(n_samples));
} else if (n_samples < 1000000) {
ui->timeText->setToolTip(tr("%1 kS").arg(n_samples/1000.0));
} else {
ui->timeText->setToolTip(tr("%1 MS").arg(n_samples/1000000.0));
}
2017-02-04 22:41:32 -05:00
if(t < 0.000001)
{
t = round(t * 100000000000.0) / 100.0;
ui->timeText->setText(tr("%1\nns").arg(t));
}
else if(t < 0.001)
{
t = round(t * 100000000.0) / 100.0;
ui->timeText->setText(tr("%1\nµs").arg(t));
}
else if(t < 1.0)
{
t = round(t * 100000.0) / 100.0;
ui->timeText->setText(tr("%1\nms").arg(t));
}
else
{
t = round(t * 100.0) / 100.0;
ui->timeText->setText(tr("%1\ns").arg(t));
}
2017-02-03 02:27:03 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTraceLenDisplay()
2017-02-04 22:41:32 -05:00
{
unsigned int n_samples = m_settings.m_traceLenMult * m_scopeVis->getTraceChunkSize();
2017-02-04 22:41:32 -05:00
if (n_samples < 1000) {
2017-02-21 20:52:38 -05:00
ui->traceLenText->setToolTip(tr("%1 S").arg(n_samples));
2017-02-04 22:41:32 -05:00
} else if (n_samples < 1000000) {
2017-02-21 20:52:38 -05:00
ui->traceLenText->setToolTip(tr("%1 kS").arg(n_samples/1000.0));
2017-02-04 22:41:32 -05:00
} else {
2017-02-21 20:52:38 -05:00
ui->traceLenText->setToolTip(tr("%1 MS").arg(n_samples/1000000.0));
2017-02-04 22:41:32 -05:00
}
m_sampleRate = m_glScope->getSampleRate();
double t = (m_glScope->getTraceSize() * 1.0 / m_sampleRate);
2017-02-04 22:41:32 -05:00
if(t < 0.000001)
ui->traceLenText->setText(tr("%1\nns").arg(t * 1000000000.0, 0, 'f', 2));
2017-02-04 22:41:32 -05:00
else if(t < 0.001)
ui->traceLenText->setText(tr("%1\nµs").arg(t * 1000000.0, 0, 'f', 2));
2017-02-04 22:41:32 -05:00
else if(t < 1.0)
ui->traceLenText->setText(tr("%1\nms").arg(t * 1000.0, 0, 'f', 2));
2017-02-04 22:41:32 -05:00
else
ui->traceLenText->setText(tr("%1\ns").arg(t * 1.0, 0, 'f', 2));
2017-02-04 22:41:32 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTimeOfsDisplay()
2017-02-04 22:41:32 -05:00
{
2017-02-21 20:52:38 -05:00
unsigned int n_samples = m_glScope->getTraceSize() * (m_timeOffset/100.0);
double dt = m_glScope->getTraceSize() * (m_timeOffset/100.0) / m_sampleRate;
2017-02-04 22:41:32 -05:00
2017-02-21 20:52:38 -05:00
if (n_samples < 1000) {
ui->timeOfsText->setToolTip(tr("%1 S").arg(n_samples));
} else if (n_samples < 1000000) {
ui->timeOfsText->setToolTip(tr("%1 kS").arg(n_samples/1000.0));
} else {
ui->timeOfsText->setToolTip(tr("%1 MS").arg(n_samples/1000000.0));
}
2017-02-04 22:41:32 -05:00
if(dt < 0.000001)
2017-02-21 20:52:38 -05:00
ui->timeOfsText->setText(tr("%1\nns").arg(dt * 1000000000.0, 0, 'f', 2));
2017-02-04 22:41:32 -05:00
else if(dt < 0.001)
2017-02-21 20:52:38 -05:00
ui->timeOfsText->setText(tr("%1\nµs").arg(dt * 1000000.0, 0, 'f', 2));
2017-02-04 22:41:32 -05:00
else if(dt < 1.0)
2017-02-21 20:52:38 -05:00
ui->timeOfsText->setText(tr("%1\nms").arg(dt * 1000.0, 0, 'f', 2));
2017-02-04 22:41:32 -05:00
else
2017-02-21 20:52:38 -05:00
ui->timeOfsText->setText(tr("%1\ns").arg(dt * 1.0, 0, 'f', 2));
2017-02-04 22:41:32 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setAmpScaleDisplay()
2017-02-05 07:26:07 -05:00
{
Projector::ProjectionType projectionType = (Projector::ProjectionType) ui->traceMode->currentIndex();
2021-06-26 19:52:42 -04:00
double amp = (ui->amp->value() / 1000.0) + ui->ampCoarse->value();
int ampExp = ui->ampExp->value();
double ampValue = amp * pow(10.0, ampExp);
ui->ampText->setText(tr("%1").arg(amp, 0, 'f', 3));
2017-02-05 07:26:07 -05:00
if (projectionType == Projector::ProjectionMagDB)
2017-02-05 07:26:07 -05:00
{
2021-06-26 19:52:42 -04:00
ui->ampExpText->setText(tr("e%1%2").arg(ampExp+2 < 0 ? "" : "+").arg(ampExp+2));
ui->ampMultiplierText->setText("-");
2017-02-05 07:26:07 -05:00
}
else
{
2021-06-26 19:52:42 -04:00
ui->ampExpText->setText(tr("e%1%2").arg(ampExp < 0 ? "" : "+").arg(ampExp));
double ampValue2 = 2.0 * ampValue;
if (ampValue2 < 1e-9) {
ui->ampMultiplierText->setText("p");
} else if (ampValue2 < 1e-6) {
ui->ampMultiplierText->setText("n");
} else if (ampValue2 < 1e-3) {
ui->ampMultiplierText->setText("µ");
} else if (ampValue2 < 1e0) {
ui->ampMultiplierText->setText("m");
} else if (ampValue2 <= 1e3) {
ui->ampMultiplierText->setText("-");
} else if (ampValue2 <= 1e6) {
ui->ampMultiplierText->setText("k");
} else if (ampValue2 <= 1e9) {
ui->ampMultiplierText->setText("M");
} else {
ui->ampMultiplierText->setText("G");
}
2017-02-05 07:26:07 -05:00
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setAmpOfsDisplay()
{
Projector::ProjectionType projectionType = (Projector::ProjectionType) ui->traceMode->currentIndex();
2021-06-27 04:10:28 -04:00
double ofs = (ui->ofsFine->value() / 1000.0) + ui->ofsCoarse->value();
int ofsExp = ui->ofsExp->value();
ui->ofsText->setText(tr("%1").arg(ofs, 0, 'f', 3));
2021-06-27 04:10:28 -04:00
if (projectionType == Projector::ProjectionMagDB) {
ui->ofsExpText->setText(tr("e%1%2").arg(ofsExp+2 < 0 ? "" : "+").arg(ofsExp+2));
} else {
ui->ofsExpText->setText(tr("e%1%2").arg(ofsExp < 0 ? "" : "+").arg(ofsExp));
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTraceDelayDisplay()
2017-02-16 19:54:55 -05:00
{
if (m_sampleRate > 0)
{
int n_samples = ui->traceDelayCoarse->value()*100 + ui->traceDelayFine->value();
double t = ((double) n_samples) / m_sampleRate;
2017-02-16 19:54:55 -05:00
if (n_samples < 1000) {
ui->traceDelayText->setToolTip(tr("%1 S").arg(n_samples));
} else if (n_samples < 1000000) {
ui->traceDelayText->setToolTip(tr("%1 kS").arg(n_samples/1000.0));
} else {
ui->traceDelayText->setToolTip(tr("%1 MS").arg(n_samples/1000000.0));
}
2017-02-16 19:54:55 -05:00
if(t < 0.000001)
ui->traceDelayText->setText(tr("%1\nns").arg(t * 1000000000.0, 0, 'f', 2));
else if(t < 0.001)
ui->traceDelayText->setText(tr("%1\nµs").arg(t * 1000000.0, 0, 'f', 2));
else if(t < 1.0)
ui->traceDelayText->setText(tr("%1\nms").arg(t * 1000.0, 0, 'f', 2));
else
ui->traceDelayText->setText(tr("%1\ns").arg(t * 1.0, 0, 'f', 2));
}
2017-02-16 19:54:55 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTrigIndexDisplay()
{
2017-02-20 16:19:50 -05:00
ui->trigText->setText(tr("%1").arg(ui->trig->value()));
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTrigLevelDisplay()
{
double t = (ui->trigLevelCoarse->value() / 100.0f) + (ui->trigLevelFine->value() / 50000.0f);
Projector::ProjectionType projectionType = (Projector::ProjectionType) ui->trigMode->currentIndex();
ui->trigLevelCoarse->setToolTip(QString("Trigger level coarse: %1 %").arg(ui->trigLevelCoarse->value() / 100.0f));
ui->trigLevelFine->setToolTip(QString("Trigger level fine: %1 ppm").arg(ui->trigLevelFine->value() * 20));
if (projectionType == Projector::ProjectionMagDB) {
2017-02-20 16:19:50 -05:00
ui->trigLevelText->setText(tr("%1\ndB").arg(100.0 * (t - 1.0), 0, 'f', 1));
}
else
{
double a;
if ((projectionType == Projector::ProjectionMagLin) || (projectionType == Projector::ProjectionMagSq)) {
2017-02-20 16:19:50 -05:00
a = 1.0 + t;
} else {
a = t;
}
if(fabs(a) < 0.000001)
ui->trigLevelText->setText(tr("%1\nn").arg(a * 1000000000.0f, 0, 'f', 2));
else if(fabs(a) < 0.001)
ui->trigLevelText->setText(tr("%1\nµ").arg(a * 1000000.0f, 0, 'f', 2));
else if(fabs(a) < 1.0)
ui->trigLevelText->setText(tr("%1\nm").arg(a * 1000.0f, 0, 'f', 2));
else
ui->trigLevelText->setText(tr("%1").arg(a * 1.0f, 0, 'f', 2));
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTrigDelayDisplay()
{
if (m_sampleRate > 0)
{
double delayMult = ui->trigDelayCoarse->value() + ui->trigDelayFine->value() / (m_scopeVis->getTraceChunkSize() / 10.0);
unsigned int n_samples_delay = m_settings.m_traceLenMult * m_scopeVis->getTraceChunkSize() * delayMult;
if (n_samples_delay < 1000) {
ui->trigDelayText->setToolTip(tr("%1 S").arg(n_samples_delay));
} else if (n_samples_delay < 1000000) {
ui->trigDelayText->setToolTip(tr("%1 kS").arg(n_samples_delay/1000.0));
} else if (n_samples_delay < 1000000000) {
ui->trigDelayText->setToolTip(tr("%1 MS").arg(n_samples_delay/1000000.0));
} else {
ui->trigDelayText->setToolTip(tr("%1 GS").arg(n_samples_delay/1000000000.0));
}
2017-02-20 16:19:50 -05:00
m_sampleRate = m_glScope->getSampleRate();
double t = (n_samples_delay * 1.0f / m_sampleRate);
2017-02-20 16:19:50 -05:00
if(t < 0.000001)
ui->trigDelayText->setText(tr("%1\nns").arg(t * 1000000000.0, 0, 'f', 2));
else if(t < 0.001)
ui->trigDelayText->setText(tr("%1\nµs").arg(t * 1000000.0, 0, 'f', 2));
else if(t < 1.0)
ui->trigDelayText->setText(tr("%1\nms").arg(t * 1000.0, 0, 'f', 2));
else
ui->trigDelayText->setText(tr("%1\ns").arg(t * 1.0, 0, 'f', 2));
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTrigPreDisplay()
{
if (m_sampleRate > 0)
{
unsigned int n_samples_delay = m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f);
double dt = m_glScope->getTraceSize() * (ui->trigPre->value()/100.0f) / m_sampleRate;
if (n_samples_delay < 1000) {
ui->trigPreText->setToolTip(tr("%1 S").arg(n_samples_delay));
} else if (n_samples_delay < 1000000) {
ui->trigPreText->setToolTip(tr("%1 kS").arg(n_samples_delay/1000.0));
} else if (n_samples_delay < 1000000000) {
ui->trigPreText->setToolTip(tr("%1 MS").arg(n_samples_delay/1000000.0));
} else {
ui->trigPreText->setToolTip(tr("%1 GS").arg(n_samples_delay/1000000000.0));
}
if(dt < 0.000001)
ui->trigPreText->setText(tr("%1\nns").arg(dt * 1000000000.0f, 0, 'f', 2));
else if(dt < 0.001)
ui->trigPreText->setText(tr("%1\nµs").arg(dt * 1000000.0f, 0, 'f', 2));
else if(dt < 1.0)
ui->trigPreText->setText(tr("%1\nms").arg(dt * 1000.0f, 0, 'f', 2));
else
ui->trigPreText->setText(tr("%1\ns").arg(dt * 1.0f, 0, 'f', 2));
2017-02-21 20:52:38 -05:00
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::changeCurrentTrace()
2017-02-05 07:26:07 -05:00
{
2021-05-28 18:55:04 -04:00
GLScopeSettings::TraceData traceData;
2017-02-05 07:26:07 -05:00
fillTraceData(traceData);
uint32_t currentTraceIndex = ui->trace->value();
ScopeVis::MsgScopeVisChangeTrace *msg = ScopeVis::MsgScopeVisChangeTrace::create(traceData, currentTraceIndex);
m_scopeVis->getInputMessageQueue()->push(msg);
2021-06-12 04:16:33 -04:00
if (currentTraceIndex < m_settings.m_tracesData.size()) {
m_settings.m_tracesData[currentTraceIndex] = traceData;
}
2017-02-05 07:26:07 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::changeCurrentTrigger()
{
GLScopeSettings::TriggerData triggerData;
fillTriggerData(triggerData);
uint32_t currentTriggerIndex = ui->trig->value();
ScopeVis::MsgScopeVisChangeTrigger *msg = ScopeVis::MsgScopeVisChangeTrigger::create(triggerData, currentTriggerIndex);
m_scopeVis->getInputMessageQueue()->push(msg);
2021-06-12 04:16:33 -04:00
if (currentTriggerIndex < m_settings.m_triggersData.size()) {
m_settings.m_triggersData[currentTriggerIndex] = triggerData;
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::fillProjectionCombo(QComboBox* comboBox)
2017-02-04 22:41:32 -05:00
{
comboBox->addItem("Real", Projector::ProjectionReal);
comboBox->addItem("Imag", Projector::ProjectionImag);
comboBox->addItem("Mag", Projector::ProjectionMagLin);
comboBox->addItem("MagSq", Projector::ProjectionMagSq);
comboBox->addItem("dMagSq", Projector::ProjectionDMagSq);
comboBox->addItem("MagdB", Projector::ProjectionMagDB);
comboBox->addItem("Phi", Projector::ProjectionPhase);
comboBox->addItem("DOAP", Projector::ProjectionDOAP);
comboBox->addItem("DOAN", Projector::ProjectionDOAN);
comboBox->addItem("dPhi", Projector::ProjectionDPhase);
comboBox->addItem("BPSK", Projector::ProjectionBPSK);
comboBox->addItem("QPSK", Projector::ProjectionQPSK);
comboBox->addItem("8PSK", Projector::Projection8PSK);
comboBox->addItem("16PSK", Projector::Projection16PSK);
2017-02-04 22:41:32 -05:00
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::disableLiveMode(bool disable)
{
ui->traceLen->setEnabled(!disable);
ui->trig->setEnabled(!disable);
ui->trigAdd->setEnabled(!disable);
ui->trigDel->setEnabled(!disable);
ui->trigMode->setEnabled(!disable);
ui->trigCount->setEnabled(!disable);
ui->trigPos->setEnabled(!disable);
ui->trigNeg->setEnabled(!disable);
ui->trigBoth->setEnabled(!disable);
ui->trigLevelCoarse->setEnabled(!disable);
ui->trigLevelFine->setEnabled(!disable);
ui->trigDelayCoarse->setEnabled(!disable);
ui->trigDelayFine->setEnabled(!disable);
ui->trigPre->setEnabled(!disable);
ui->trigOneShot->setEnabled(!disable);
ui->freerun->setEnabled(!disable);
2018-10-14 20:47:26 -04:00
ui->memorySave->setEnabled(disable);
ui->memoryLoad->setEnabled(disable);
}
2021-05-28 18:55:04 -04:00
void GLScopeGUI::fillTraceData(GLScopeSettings::TraceData& traceData)
2017-02-04 22:41:32 -05:00
{
2021-05-28 18:55:04 -04:00
traceData.m_streamIndex = ui->traceStream->currentIndex();
traceData.m_projectionType = (Projector::ProjectionType) ui->traceMode->currentIndex();
2021-06-26 19:52:42 -04:00
traceData.m_hasTextOverlay = (traceData.m_projectionType == Projector::ProjectionMagDB)
|| (traceData.m_projectionType == Projector::ProjectionMagSq);
traceData.m_textOverlay.clear();
2021-06-27 04:10:28 -04:00
2021-06-26 19:52:42 -04:00
double ampValue = ((ui->amp->value() / 1000.0) + ui->ampCoarse->value()) * pow(10.0, ui->ampExp->value());
traceData.m_amp = 1.0 / ampValue;
2021-06-27 04:10:28 -04:00
double ofsValue = ((ui->ofsFine->value() / 1000.0) + ui->ofsCoarse->value()) * pow(10.0, ui->ofsExp->value());
traceData.m_ofs = ofsValue;
2017-02-16 19:54:55 -05:00
traceData.m_traceDelayCoarse = ui->traceDelayCoarse->value();
traceData.m_traceDelayFine = ui->traceDelayFine->value();
traceData.m_traceDelay = traceData.m_traceDelayCoarse * 100 + traceData.m_traceDelayFine;
traceData.setColor(m_focusedTraceColor);
traceData.m_viewTrace = ui->traceView->isChecked();
2017-02-04 22:41:32 -05:00
}
void GLScopeGUI::fillTriggerData(GLScopeSettings::TriggerData& triggerData)
2017-02-04 22:41:32 -05:00
{
triggerData.m_streamIndex = ui->trigStream->currentIndex();
triggerData.m_projectionType = (Projector::ProjectionType) ui->trigMode->currentIndex();
2017-02-04 22:41:32 -05:00
triggerData.m_inputIndex = 0;
triggerData.m_triggerLevel = (ui->trigLevelCoarse->value() / 100.0) + (ui->trigLevelFine->value() / 50000.0);
triggerData.m_triggerLevelCoarse = ui->trigLevelCoarse->value();
triggerData.m_triggerLevelFine = ui->trigLevelFine->value();
2017-02-04 22:41:32 -05:00
triggerData.m_triggerPositiveEdge = ui->trigPos->isChecked();
triggerData.m_triggerBothEdges = ui->trigBoth->isChecked();
2018-10-27 19:38:58 -04:00
triggerData.m_triggerHoldoff = ui->trigHoldoff->value();
2017-02-04 22:41:32 -05:00
triggerData.m_triggerRepeat = ui->trigCount->value();
triggerData.m_triggerDelayMult = ui->trigDelayCoarse->value() + ui->trigDelayFine->value() / (m_scopeVis->getTraceChunkSize() / 10.0);
triggerData.m_triggerDelay = (int) (m_settings.m_traceLenMult * m_scopeVis->getTraceChunkSize() * triggerData.m_triggerDelayMult);
triggerData.m_triggerDelayCoarse = ui->trigDelayCoarse->value();
triggerData.m_triggerDelayFine = ui->trigDelayFine->value();
triggerData.setColor(m_focusedTriggerColor);
2017-02-04 22:41:32 -05:00
}
2017-02-03 02:27:03 -05:00
2021-05-28 18:55:04 -04:00
void GLScopeGUI::setTraceUI(const GLScopeSettings::TraceData& traceData)
{
TraceUIBlocker traceUIBlocker(ui);
2021-05-28 18:55:04 -04:00
ui->traceStream->setCurrentIndex(traceData.m_streamIndex);
ui->traceMode->setCurrentIndex((int) traceData.m_projectionType);
2021-06-27 04:10:28 -04:00
2021-06-26 19:52:42 -04:00
double ampValue = 1.0 / traceData.m_amp;
int ampExp;
double ampMant = CalcDb::frexp10(ampValue, &ampExp) * 10.0;
int ampCoarse = (int) ampMant;
int ampFine = round((ampMant - ampCoarse) * 1000.0);
ampExp -= 1;
ui->amp->setValue(ampFine);
ui->ampCoarse->setValue(ampCoarse);
ui->ampExp->setValue(ampExp);
setAmpScaleDisplay();
double ofsValue = traceData.m_ofs;
2021-06-27 04:10:28 -04:00
int ofsExp;
double ofsMant = CalcDb::frexp10(ofsValue, &ofsExp) * 10.0;
int ofsCoarse = (int) ofsMant;
int ofsFine = round((ofsMant - ofsCoarse) * 1000.0);
ofsExp -= ofsMant == 0 ? 0 : 1;
2021-06-27 04:10:28 -04:00
ui->ofsFine->setValue(ofsFine);
ui->ofsCoarse->setValue(ofsCoarse);
ui->ofsExp->setValue(ofsExp);
setAmpOfsDisplay();
2017-02-16 19:54:55 -05:00
ui->traceDelayCoarse->setValue(traceData.m_traceDelayCoarse);
ui->traceDelayFine->setValue(traceData.m_traceDelayFine);
setTraceDelayDisplay();
m_focusedTraceColor = traceData.m_traceColor;
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));
ui->traceView->setChecked(traceData.m_viewTrace);
}
void GLScopeGUI::setTriggerUI(const GLScopeSettings::TriggerData& triggerData)
{
TrigUIBlocker trigUIBlocker(ui);
ui->trigStream->setCurrentIndex(triggerData.m_streamIndex);
ui->trigMode->setCurrentIndex((int) triggerData.m_projectionType);
ui->trigCount->setValue(triggerData.m_triggerRepeat);
setTrigCountDisplay();
ui->trigPos->setChecked(false);
ui->trigNeg->setChecked(false);
ui->trigPos->doToggle(false);
ui->trigNeg->doToggle(false);
if (triggerData.m_triggerBothEdges)
{
ui->trigBoth->setChecked(true);
ui->trigBoth->doToggle(true);
}
else
{
ui->trigBoth->setChecked(false);
ui->trigBoth->doToggle(false);
if (triggerData.m_triggerPositiveEdge)
{
ui->trigPos->setChecked(true);
ui->trigPos->doToggle(true);
}
else
{
ui->trigNeg->setChecked(true);
ui->trigNeg->doToggle(true);
}
}
2018-10-27 19:38:58 -04:00
ui->trigHoldoffText->setText(tr("%1").arg(triggerData.m_triggerHoldoff));
ui->trigLevelCoarse->setValue(triggerData.m_triggerLevelCoarse);
ui->trigLevelFine->setValue(triggerData.m_triggerLevelFine);
setTrigLevelDisplay();
ui->trigDelayCoarse->setValue(triggerData.m_triggerDelayCoarse);
ui->trigDelayFine->setValue(triggerData.m_triggerDelayFine);
setTrigDelayDisplay();
m_focusedTriggerColor = triggerData.m_triggerColor;
int r, g, b, a;
m_focusedTriggerColor.getRgb(&r, &g, &b, &a);
ui->trigColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b));
}
void GLScopeGUI::applySettings(const GLScopeSettings& settings, bool force)
2017-01-29 13:51:45 -05:00
{
if (m_scopeVis)
{
ScopeVis::MsgConfigureScopeVis *msg = ScopeVis::MsgConfigureScopeVis::create(settings, force);
m_scopeVis->getInputMessageQueue()->push(msg);
}
}
void GLScopeGUI::displaySettings()
{
MainUIBlocker mainUIBlocker(ui);
ui->traceText->setText(m_ctlTraceIndex == 0 ? "X" : QString("Y%1").arg(m_ctlTraceIndex));
ui->trace->setValue(m_ctlTraceIndex);
const GLScopeSettings::TraceData& traceData = m_settings.m_tracesData[m_ctlTraceIndex];
setTraceUI(traceData);
ui->trigText->setText(tr("%1").arg(m_ctlTriggerIndex));
ui->trig->setValue(m_ctlTriggerIndex);
const GLScopeSettings::TriggerData& triggerData = m_settings.m_triggersData[m_ctlTriggerIndex];
setTriggerUI(triggerData);
setDisplayMode(m_settings.m_displayMode);
ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_settings.m_traceIntensity));
ui->traceIntensity->setValue(m_settings.m_traceIntensity);
m_glScope->setDisplayTraceIntensity(m_settings.m_traceIntensity);
ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_settings.m_gridIntensity));
ui->gridIntensity->setValue(m_settings.m_gridIntensity);
m_glScope->setDisplayGridIntensity(m_settings.m_gridIntensity);
setTimeScaleDisplay();
ui->timeOfs->setValue(m_settings.m_timeOfs);
setTimeOfsDisplay();
ui->traceLen->setValue(m_settings.m_traceLenMult);
setPreTrigger(100.0f * m_settings.m_trigPre / m_glScope->getTraceSize());
ui->freerun->setChecked(m_settings.m_freerun);
changeCurrentTrigger(); // Ensure consistency with GUI
2017-01-29 13:51:45 -05:00
}
bool GLScopeGUI::handleMessage(Message* message)
2017-01-29 13:51:45 -05:00
{
(void) message;
2017-01-29 13:51:45 -05:00
return false;
}
2018-08-12 10:48:03 -04:00
GLScopeGUI::TrigUIBlocker::TrigUIBlocker(Ui::GLScopeGUI *ui) :
m_ui(ui)
{
m_oldStateTrigStream = ui->trigStream->blockSignals(true);
m_oldStateTrigMode = ui->trigMode->blockSignals(true);
m_oldStateTrigCount = ui->trigCount->blockSignals(true);
m_oldStateTrigPos = ui->trigPos->blockSignals(true);
m_oldStateTrigNeg = ui->trigNeg->blockSignals(true);
m_oldStateTrigBoth = ui->trigBoth->blockSignals(true);
m_oldStateTrigLevelCoarse = ui->trigLevelCoarse->blockSignals(true);
m_oldStateTrigLevelFine = ui->trigLevelFine->blockSignals(true);
m_oldStateTrigDelayCoarse = ui->trigDelayCoarse->blockSignals(true);
m_oldStateTrigDelayFine = ui->trigDelayFine->blockSignals(true);
m_oldStateTrigColor = ui->trigColor->blockSignals(true);
}
2018-08-12 10:48:03 -04:00
GLScopeGUI::TrigUIBlocker::~TrigUIBlocker()
{
unBlock();
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::TrigUIBlocker::unBlock()
{
m_ui->trigStream->blockSignals(m_oldStateTrigStream);
m_ui->trigMode->blockSignals(m_oldStateTrigMode);
m_ui->trigCount->blockSignals(m_oldStateTrigCount);
m_ui->trigPos->blockSignals(m_oldStateTrigPos);
m_ui->trigNeg->blockSignals(m_oldStateTrigNeg);
m_ui->trigBoth->blockSignals(m_oldStateTrigBoth);
m_ui->trigLevelCoarse->blockSignals(m_oldStateTrigLevelCoarse);
m_ui->trigLevelFine->blockSignals(m_oldStateTrigLevelFine);
m_ui->trigDelayCoarse->blockSignals(m_oldStateTrigDelayCoarse);
m_ui->trigDelayFine->blockSignals(m_oldStateTrigDelayFine);
m_ui->trigColor->blockSignals(m_oldStateTrigColor);
}
2018-08-12 10:48:03 -04:00
GLScopeGUI::TraceUIBlocker::TraceUIBlocker(Ui::GLScopeGUI* ui) :
m_ui(ui)
{
m_oldStateTraceStream = m_ui->traceStream->blockSignals(true);
m_oldStateTraceMode = m_ui->traceMode->blockSignals(true);
m_oldStateAmp = m_ui->amp->blockSignals(true);
m_oldStateAmpCoarse = m_ui->ampCoarse->blockSignals(true);
m_oldStateAmpExp = m_ui->ampExp->blockSignals(true);
m_oldStateOfsCoarse = m_ui->ofsCoarse->blockSignals(true);
m_oldStateOfsFine = m_ui->ofsFine->blockSignals(true);
m_oldStateOfsExp = m_ui->ofsExp->blockSignals(true);
m_oldStateTraceDelayCoarse = m_ui->traceDelayCoarse->blockSignals(true);
m_oldStateTraceDelayFine = m_ui->traceDelayFine->blockSignals(true);
m_oldStateTraceColor = m_ui->traceColor->blockSignals(true);
m_oldStateTraceView = m_ui->traceView->blockSignals(true);
m_oldStateTrace = m_ui->trace->blockSignals(true);
m_oldStateTraceAdd = m_ui->traceAdd->blockSignals(true);
m_oldStateTraceDel = m_ui->traceDel->blockSignals(true);
}
2018-08-12 10:48:03 -04:00
GLScopeGUI::TraceUIBlocker::~TraceUIBlocker()
{
unBlock();
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::TraceUIBlocker::unBlock()
{
m_ui->traceStream->blockSignals(m_oldStateTraceStream);
2017-02-20 16:19:50 -05:00
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->ampCoarse->blockSignals(m_oldStateAmpCoarse);
m_ui->ampExp->blockSignals(m_oldStateAmpExp);
m_ui->ofsCoarse->blockSignals(m_oldStateOfsCoarse);
m_ui->ofsFine->blockSignals(m_oldStateOfsFine);
m_ui->ofsExp->blockSignals(m_oldStateOfsExp);
m_ui->traceDelayCoarse->blockSignals(m_oldStateTraceDelayCoarse);
m_ui->traceDelayFine->blockSignals(m_oldStateTraceDelayFine);
m_ui->traceColor->blockSignals(m_oldStateTraceColor);
m_ui->traceView->blockSignals(m_oldStateTraceView);
}
2018-08-12 10:48:03 -04:00
GLScopeGUI::MainUIBlocker::MainUIBlocker(Ui::GLScopeGUI* ui) :
m_ui(ui)
{
m_oldStateOnlyX = m_ui->onlyX->blockSignals(true);
m_oldStateOnlyY = m_ui->onlyY->blockSignals(true);
m_oldStateHorizontalXY = m_ui->horizontalXY->blockSignals(true);
m_oldStateVerticalXY = m_ui->verticalXY->blockSignals(true);
m_oldStatePolar = m_ui->polar->blockSignals(true);
// m_oldStateTime = m_ui->time->blockSignals(true);
// m_oldStateTimeOfs = m_ui->timeOfs->blockSignals(true);
// m_oldStateTraceLen = m_ui->traceLen->blockSignals(true);
}
2018-08-12 10:48:03 -04:00
GLScopeGUI::MainUIBlocker::~MainUIBlocker()
{
unBlock();
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::MainUIBlocker::unBlock()
{
m_ui->onlyX->blockSignals(m_oldStateOnlyX);
m_ui->onlyY->blockSignals(m_oldStateOnlyY);
m_ui->horizontalXY->blockSignals(m_oldStateHorizontalXY);
m_ui->verticalXY->blockSignals(m_oldStateVerticalXY);
m_ui->polar->blockSignals(m_oldStatePolar);
// m_ui->time->blockSignals(m_oldStateTime);
// m_ui->timeOfs->blockSignals(m_oldStateTimeOfs);
// m_ui->traceLen->blockSignals(m_oldStateTraceLen);
}
void GLScopeGUI::setDisplayMode(GLScopeSettings::DisplayMode displayMode)
{
uint32_t nbTraces = m_scopeVis->getNbTraces();
ui->onlyX->setChecked(false);
ui->onlyY->setChecked(false);
ui->horizontalXY->setChecked(false);
ui->verticalXY->setChecked(false);
ui->polar->setChecked(false);
ui->onlyX->setEnabled(true);
ui->onlyY->setEnabled(nbTraces > 1);
ui->horizontalXY->setEnabled(nbTraces > 1);
ui->verticalXY->setEnabled(nbTraces > 1);
ui->polar->setEnabled(nbTraces > 1);
2021-06-12 04:16:33 -04:00
if (ui->trace->maximum() == 1)
{
ui->onlyX->setChecked(true);
ui->onlyX->setEnabled(false);
}
else
{
switch (displayMode)
{
case GLScopeSettings::DisplayX:
ui->onlyX->setChecked(true);
ui->onlyX->setEnabled(false);
break;
case GLScopeSettings::DisplayY:
ui->onlyY->setChecked(true);
ui->onlyY->setEnabled(false);
break;
case GLScopeSettings::DisplayXYH:
ui->horizontalXY->setChecked(true);
ui->horizontalXY->setEnabled(false);
break;
case GLScopeSettings::DisplayXYV:
ui->verticalXY->setChecked(true);
ui->verticalXY->setEnabled(false);
break;
case GLScopeSettings::DisplayPol:
ui->polar->setChecked(true);
ui->polar->setEnabled(false);
break;
default:
ui->onlyX->setChecked(true);
ui->onlyX->setEnabled(false);
break;
}
}
2021-06-10 18:21:42 -04:00
m_settings.m_displayMode = displayMode;
m_scopeVis->configure(
m_settings.m_displayMode,
m_settings.m_traceIntensity,
m_settings.m_gridIntensity
);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTraceIntensity(int value)
{
if ((value < ui->traceIntensity->minimum()) || (value > ui->traceIntensity->maximum())) {
return;
}
ui->traceIntensity->setValue(value);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setGridIntensity(int value)
{
if ((value < ui->gridIntensity->minimum()) || (value > ui->gridIntensity->maximum())) {
return;
}
ui->gridIntensity->setValue(value);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTimeBase(int step)
{
if ((step < ui->time->minimum()) || (step > ui->time->maximum())) {
return;
}
ui->time->setValue(step);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTimeOffset(int step)
{
if ((step < ui->timeOfs->minimum()) || (step > ui->timeOfs->maximum())) {
return;
}
ui->timeOfs->setValue(step);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setTraceLength(int step)
{
if ((step < ui->traceLen->minimum()) || (step > ui->traceLen->maximum())) {
return;
}
ui->traceLen->setValue(step);
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::setPreTrigger(int step)
{
if ((step < ui->trigPre->minimum()) || (step > ui->trigPre->maximum())) {
return;
}
ui->trigPre->setValue(step);
}
2021-05-28 18:55:04 -04:00
void GLScopeGUI::changeTrace(int traceIndex, const GLScopeSettings::TraceData& traceData)
{
ScopeVis::MsgScopeVisChangeTrace *msg = ScopeVis::MsgScopeVisChangeTrace::create(traceData, traceIndex);
m_scopeVis->getInputMessageQueue()->push(msg);
2021-06-12 04:16:33 -04:00
settingsTraceChange(traceData, traceIndex);
}
2021-05-28 18:55:04 -04:00
void GLScopeGUI::addTrace(const GLScopeSettings::TraceData& traceData)
{
if (ui->trace->maximum() < 7) // Limit number of channels to 8. Is it necessary?
{
if (ui->trace->value() == 0)
{
ui->onlyY->setEnabled(true);
ui->horizontalXY->setEnabled(true);
ui->verticalXY->setEnabled(true);
ui->polar->setEnabled(true);
}
ScopeVis::MsgScopeVisAddTrace *msg = ScopeVis::MsgScopeVisAddTrace::create(traceData);
m_scopeVis->getInputMessageQueue()->push(msg);
2021-06-12 04:16:33 -04:00
settingsTraceAdd(traceData);
ui->trace->setMaximum(ui->trace->maximum() + 1);
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::focusOnTrace(int traceIndex)
{
on_trace_valueChanged(traceIndex);
}
void GLScopeGUI::changeTrigger(int triggerIndex, const GLScopeSettings::TriggerData& triggerData)
{
ScopeVis::MsgScopeVisChangeTrigger *msg = ScopeVis::MsgScopeVisChangeTrigger::create(triggerData, triggerIndex);
m_scopeVis->getInputMessageQueue()->push(msg);
2021-06-12 04:16:33 -04:00
settingsTriggerChange(triggerData, triggerIndex);
}
void GLScopeGUI::addTrigger(const GLScopeSettings::TriggerData& triggerData)
{
if (ui->trig->maximum() < 9)
{
ScopeVis::MsgScopeVisAddTrigger *msg = ScopeVis::MsgScopeVisAddTrigger::create(triggerData);
m_scopeVis->getInputMessageQueue()->push(msg);
2021-06-12 04:16:33 -04:00
settingsTriggerAdd(triggerData);
ui->trig->setMaximum(ui->trig->maximum() + 1);
}
}
2018-08-12 10:48:03 -04:00
void GLScopeGUI::focusOnTrigger(int triggerIndex)
{
on_trig_valueChanged(triggerIndex);
}
void GLScopeGUI::traceLengthChange()
{
on_traceLen_valueChanged(m_settings.m_traceLenMult);
}
2021-06-12 04:16:33 -04:00
void GLScopeGUI::settingsTraceAdd(const GLScopeSettings::TraceData& traceData)
{
m_settings.m_tracesData.push_back(traceData);
}
void GLScopeGUI::settingsTraceChange(const GLScopeSettings::TraceData& traceData, uint32_t traceIndex)
{
m_settings.m_tracesData[traceIndex] = traceData;
}
void GLScopeGUI::settingsTraceDel(uint32_t traceIndex)
{
unsigned int iDest = 0;
for (unsigned int iSource = 0; iSource < m_settings.m_tracesData.size(); iSource++)
{
if (iSource != traceIndex) {
m_settings.m_tracesData[iDest++] = m_settings.m_tracesData[iSource];
}
}
if (m_settings.m_tracesData.size() != 0) {
m_settings.m_tracesData.pop_back();
}
}
void GLScopeGUI::settingsTraceMove(uint32_t traceIndex, bool upElseDown)
{
int nextTraceIndex = (traceIndex + (upElseDown ? 1 : -1)) % m_settings.m_tracesData.size();
GLScopeSettings::TraceData nextTraceData = m_settings.m_tracesData[nextTraceIndex];
m_settings.m_tracesData[nextTraceIndex] = m_settings.m_tracesData[traceIndex];
m_settings.m_tracesData[traceIndex] = nextTraceData;
}
void GLScopeGUI::settingsTriggerAdd(const GLScopeSettings::TriggerData& triggerData)
{
m_settings.m_triggersData.push_back(triggerData);
}
void GLScopeGUI::settingsTriggerChange(const GLScopeSettings::TriggerData& triggerData, uint32_t triggerIndex)
{
m_settings.m_triggersData[triggerIndex] = triggerData;
}
void GLScopeGUI::settingsTriggerDel(uint32_t triggerIndex)
{
unsigned int iDest = 0;
for (unsigned int iSource = 0; iSource < m_settings.m_triggersData.size(); iSource++)
{
if (iSource != triggerIndex) {
m_settings.m_triggersData[iDest++] = m_settings.m_triggersData[iSource];
}
}
if (m_settings.m_triggersData.size() != 0) {
m_settings.m_triggersData.pop_back();
}
}
void GLScopeGUI::settingsTriggerMove(uint32_t triggerIndex, bool upElseDown)
{
int nextTriggerIndex = (triggerIndex + (upElseDown ? 1 : -1)) % m_settings.m_triggersData.size();
GLScopeSettings::TriggerData nextTriggerData = m_settings.m_triggersData[nextTriggerIndex];
m_settings.m_triggersData[nextTriggerIndex] = m_settings.m_triggersData[triggerIndex];
m_settings.m_triggersData[triggerIndex] = nextTriggerData;
}