Various bugfixes, mostly eye diagram related

- Update eye diagram when settings are changed but data is static
- Keep trace on eye diagram visible when random other trace is deleted
- resolve references when duplicating a math trace
- use correct trace output domain in various checks throughout the code
This commit is contained in:
Jan Käberich 2025-02-14 14:03:09 +01:00
parent 50bde261af
commit ef8cdeccd7
7 changed files with 27 additions and 15 deletions

View file

@ -69,7 +69,7 @@ void TraceSetSelector::setPorts(unsigned int newPorts)
// create possible trace selections
c->addItem("None");
for(auto t : availableTraces) {
if(t->getDataType() != Trace::DataType::Frequency) {
if(t->outputType() != Trace::DataType::Frequency) {
// can only add frequency traces
continue;
}

View file

@ -70,6 +70,11 @@ EyeDiagramPlot::~EyeDiagramPlot()
void EyeDiagramPlot::enableTrace(Trace *t, bool enabled)
{
bool already_enabled = trace == t;
if(already_enabled == enabled) {
// ignore, the requested condition is already fulfilled
return;
}
if(enabled) {
// only one trace at a time is allowed, disable all others
for(auto t : traces) {
@ -373,11 +378,13 @@ void EyeDiagramPlot::axisSetupDialog()
yAxis.set(yAxis.getType(), false, ui->Yauto->isChecked(), ui->Ymin->value(), ui->Ymax->value(), ui->Ydivs->value(), ui->YautoDivs->isChecked());
};
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, [=](){
updateValues();
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, [=](){
triggerUpdate();
updateValues();
});
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, [=](){
updateValues();
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, [=](){
triggerUpdate();
updateValues();
});
if(AppWindow::showGUI()) {
@ -395,7 +402,7 @@ void EyeDiagramPlot::updateContextMenu()
contextmenu->addSeparator();
auto image = new QAction("Save image...", contextmenu);
contextmenu->addAction(image);
connect(image, &QAction::triggered, [=]() {
connect(image, &QAction::triggered, this, [=]() {
auto filename = QFileDialog::getSaveFileName(nullptr, "Save plot image", "", "PNG image files (*.png)", nullptr, Preferences::QFileDialogOptions());
if(filename.isEmpty()) {
// aborted selection
@ -419,7 +426,7 @@ void EyeDiagramPlot::updateContextMenu()
if(traces[t]) {
action->setChecked(true);
}
connect(action, &QAction::toggled, [=](bool active) {
connect(action, &QAction::toggled, this, [=](bool active) {
enableTrace(t, active);
});
contextmenu->addAction(action);
@ -693,7 +700,7 @@ void EyeDiagramPlot::draw(QPainter &p)
bool EyeDiagramPlot::supported(Trace *t)
{
if(t->getDataType() != Trace::DataType::Frequency) {
if(t->outputType() != Trace::DataType::Frequency) {
// wrong domain
return false;
}
@ -932,13 +939,13 @@ void EyeThread::run()
if(eye.linearEdge) {
if(next > last) {
// rising edge
double max_rise = timestep / (eye.risetime * 1.25);
double max_rise = abs(eye.highlevel - eye.lowlevel) * timestep / (eye.risetime * 1.25);
if(next - last > max_rise) {
next = last + max_rise;
}
} else {
// falling edge
double max_fall = timestep / (eye.falltime * 1.25);
double max_fall = abs(eye.highlevel - eye.lowlevel) * timestep / (eye.falltime * 1.25);
if(next - last < -max_fall) {
next = last - max_fall;
}

View file

@ -1390,7 +1390,7 @@ double Trace::findExtremum(bool max, double xmin, double xmax)
std::vector<double> Trace::findPeakFrequencies(unsigned int maxPeaks, double minLevel, double minValley, double xmin, double xmax, bool negativePeaks)
{
if(lastMath->getDataType() != DataType::Frequency) {
if(outputType() != DataType::Frequency) {
// not in frequency domain
return vector<double>();
}
@ -1565,7 +1565,7 @@ unsigned int Trace::getFileParameter() const
double Trace::getNoise(double frequency)
{
if(source != Trace::Source::Live || !settings.valid || !liveParam.startsWith("PORT") || lastMath->getDataType() != DataType::Frequency) {
if(source != Trace::Source::Live || !settings.valid || !liveParam.startsWith("PORT") || outputType() != DataType::Frequency) {
// data not suitable for noise calculation
return std::numeric_limits<double>::quiet_NaN();
}

View file

@ -490,6 +490,7 @@ void TracePlot::mouseMoveEvent(QMouseEvent *event)
} else {
cursorLabel->hide();
}
triggerReplot();
}
event->accept();
}

View file

@ -144,7 +144,7 @@ void TracePolarChart::draw(QPainter &p) {
for(int i=1;i<nPoints;i++) {
auto last = trace->sample(i-1);
auto now = trace->sample(i);
if ((trace->getDataType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency() || now.x > maximumVisibleFrequency())) {
if ((trace->outputType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency() || now.x > maximumVisibleFrequency())) {
continue;
}
if(isnan(now.y.real())) {

View file

@ -315,7 +315,7 @@ void TraceSmithChart::draw(QPainter &p) {
for(int i=1;i<nPoints;i++) {
auto last = trace->sample(i-1);
auto now = trace->sample(i);
if ((trace->getDataType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency() || now.x > maximumVisibleFrequency())) {
if ((trace->outputType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency() || now.x > maximumVisibleFrequency())) {
continue;
}
if(isnan(now.y.real())) {

View file

@ -443,7 +443,7 @@ void TraceWidget::SetupSCPI()
for(int j=0;j<ports;j++) {
bool need_reflection = i==j;
auto t = traces[j+i*ports];
if(t->getDataType() != Trace::DataType::Frequency) {
if(t->outputType() != Trace::DataType::Frequency) {
// invalid domain
return SCPI::getResultName(SCPI::Result::Error);
}
@ -649,6 +649,10 @@ void TraceWidget::contextMenuEvent(QContextMenuEvent *event)
// force update of hash
duplicate->toHash(true);
model.addTrace(duplicate);
// resolve math sources
if(!duplicate->resolveMathSourceHashes()) {
qWarning() << "Failed to resolve all math source hashes for"<<duplicate;
}
});
ctxmenu->addAction(action_duplicate);
ctxmenu->exec(event->globalPos());