Skip to content

Commit ef8cdec

Browse files
committed
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
1 parent 50bde26 commit ef8cdec

File tree

7 files changed

+27
-15
lines changed

7 files changed

+27
-15
lines changed

Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void TraceSetSelector::setPorts(unsigned int newPorts)
6969
// create possible trace selections
7070
c->addItem("None");
7171
for(auto t : availableTraces) {
72-
if(t->getDataType() != Trace::DataType::Frequency) {
72+
if(t->outputType() != Trace::DataType::Frequency) {
7373
// can only add frequency traces
7474
continue;
7575
}

Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp

+16-9
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ EyeDiagramPlot::~EyeDiagramPlot()
7070

7171
void EyeDiagramPlot::enableTrace(Trace *t, bool enabled)
7272
{
73+
bool already_enabled = trace == t;
74+
if(already_enabled == enabled) {
75+
// ignore, the requested condition is already fulfilled
76+
return;
77+
}
7378
if(enabled) {
7479
// only one trace at a time is allowed, disable all others
7580
for(auto t : traces) {
@@ -373,11 +378,13 @@ void EyeDiagramPlot::axisSetupDialog()
373378
yAxis.set(yAxis.getType(), false, ui->Yauto->isChecked(), ui->Ymin->value(), ui->Ymax->value(), ui->Ydivs->value(), ui->YautoDivs->isChecked());
374379
};
375380

376-
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, [=](){
377-
updateValues();
381+
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, [=](){
382+
triggerUpdate();
383+
updateValues();
378384
});
379-
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, [=](){
380-
updateValues();
385+
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, [=](){
386+
triggerUpdate();
387+
updateValues();
381388
});
382389

383390
if(AppWindow::showGUI()) {
@@ -395,7 +402,7 @@ void EyeDiagramPlot::updateContextMenu()
395402
contextmenu->addSeparator();
396403
auto image = new QAction("Save image...", contextmenu);
397404
contextmenu->addAction(image);
398-
connect(image, &QAction::triggered, [=]() {
405+
connect(image, &QAction::triggered, this, [=]() {
399406
auto filename = QFileDialog::getSaveFileName(nullptr, "Save plot image", "", "PNG image files (*.png)", nullptr, Preferences::QFileDialogOptions());
400407
if(filename.isEmpty()) {
401408
// aborted selection
@@ -419,7 +426,7 @@ void EyeDiagramPlot::updateContextMenu()
419426
if(traces[t]) {
420427
action->setChecked(true);
421428
}
422-
connect(action, &QAction::toggled, [=](bool active) {
429+
connect(action, &QAction::toggled, this, [=](bool active) {
423430
enableTrace(t, active);
424431
});
425432
contextmenu->addAction(action);
@@ -693,7 +700,7 @@ void EyeDiagramPlot::draw(QPainter &p)
693700

694701
bool EyeDiagramPlot::supported(Trace *t)
695702
{
696-
if(t->getDataType() != Trace::DataType::Frequency) {
703+
if(t->outputType() != Trace::DataType::Frequency) {
697704
// wrong domain
698705
return false;
699706
}
@@ -932,13 +939,13 @@ void EyeThread::run()
932939
if(eye.linearEdge) {
933940
if(next > last) {
934941
// rising edge
935-
double max_rise = timestep / (eye.risetime * 1.25);
942+
double max_rise = abs(eye.highlevel - eye.lowlevel) * timestep / (eye.risetime * 1.25);
936943
if(next - last > max_rise) {
937944
next = last + max_rise;
938945
}
939946
} else {
940947
// falling edge
941-
double max_fall = timestep / (eye.falltime * 1.25);
948+
double max_fall = abs(eye.highlevel - eye.lowlevel) * timestep / (eye.falltime * 1.25);
942949
if(next - last < -max_fall) {
943950
next = last - max_fall;
944951
}

Software/PC_Application/LibreVNA-GUI/Traces/trace.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ double Trace::findExtremum(bool max, double xmin, double xmax)
13901390

13911391
std::vector<double> Trace::findPeakFrequencies(unsigned int maxPeaks, double minLevel, double minValley, double xmin, double xmax, bool negativePeaks)
13921392
{
1393-
if(lastMath->getDataType() != DataType::Frequency) {
1393+
if(outputType() != DataType::Frequency) {
13941394
// not in frequency domain
13951395
return vector<double>();
13961396
}
@@ -1565,7 +1565,7 @@ unsigned int Trace::getFileParameter() const
15651565

15661566
double Trace::getNoise(double frequency)
15671567
{
1568-
if(source != Trace::Source::Live || !settings.valid || !liveParam.startsWith("PORT") || lastMath->getDataType() != DataType::Frequency) {
1568+
if(source != Trace::Source::Live || !settings.valid || !liveParam.startsWith("PORT") || outputType() != DataType::Frequency) {
15691569
// data not suitable for noise calculation
15701570
return std::numeric_limits<double>::quiet_NaN();
15711571
}

Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ void TracePlot::mouseMoveEvent(QMouseEvent *event)
490490
} else {
491491
cursorLabel->hide();
492492
}
493+
triggerReplot();
493494
}
494495
event->accept();
495496
}

Software/PC_Application/LibreVNA-GUI/Traces/tracepolarchart.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void TracePolarChart::draw(QPainter &p) {
144144
for(int i=1;i<nPoints;i++) {
145145
auto last = trace->sample(i-1);
146146
auto now = trace->sample(i);
147-
if ((trace->getDataType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency() || now.x > maximumVisibleFrequency())) {
147+
if ((trace->outputType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency() || now.x > maximumVisibleFrequency())) {
148148
continue;
149149
}
150150
if(isnan(now.y.real())) {

Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void TraceSmithChart::draw(QPainter &p) {
315315
for(int i=1;i<nPoints;i++) {
316316
auto last = trace->sample(i-1);
317317
auto now = trace->sample(i);
318-
if ((trace->getDataType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency() || now.x > maximumVisibleFrequency())) {
318+
if ((trace->outputType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency() || now.x > maximumVisibleFrequency())) {
319319
continue;
320320
}
321321
if(isnan(now.y.real())) {

Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ void TraceWidget::SetupSCPI()
443443
for(int j=0;j<ports;j++) {
444444
bool need_reflection = i==j;
445445
auto t = traces[j+i*ports];
446-
if(t->getDataType() != Trace::DataType::Frequency) {
446+
if(t->outputType() != Trace::DataType::Frequency) {
447447
// invalid domain
448448
return SCPI::getResultName(SCPI::Result::Error);
449449
}
@@ -649,6 +649,10 @@ void TraceWidget::contextMenuEvent(QContextMenuEvent *event)
649649
// force update of hash
650650
duplicate->toHash(true);
651651
model.addTrace(duplicate);
652+
// resolve math sources
653+
if(!duplicate->resolveMathSourceHashes()) {
654+
qWarning() << "Failed to resolve all math source hashes for"<<duplicate;
655+
}
652656
});
653657
ctxmenu->addAction(action_duplicate);
654658
ctxmenu->exec(event->globalPos());

0 commit comments

Comments
 (0)