diff --git a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.cpp b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.cpp index cab81db..7fce26d 100644 --- a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.cpp +++ b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.cpp @@ -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; } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp index 4f0a90c..fd6a954 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp @@ -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; } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/trace.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/trace.cpp index 13e68c2..c0c30fb 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/trace.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/trace.cpp @@ -1390,7 +1390,7 @@ double Trace::findExtremum(bool max, double xmin, double xmax) std::vector 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(); } @@ -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::quiet_NaN(); } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp index 94537a6..6a65e8b 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp @@ -490,6 +490,7 @@ void TracePlot::mouseMoveEvent(QMouseEvent *event) } else { cursorLabel->hide(); } + triggerReplot(); } event->accept(); } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracepolarchart.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracepolarchart.cpp index 044c99b..ddec0f6 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracepolarchart.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracepolarchart.cpp @@ -144,7 +144,7 @@ void TracePolarChart::draw(QPainter &p) { for(int i=1;isample(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())) { diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp index 5a85d1e..9bf81c7 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp @@ -315,7 +315,7 @@ void TraceSmithChart::draw(QPainter &p) { for(int i=1;isample(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())) { diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.cpp index 2ec14b1..3640178 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.cpp @@ -443,7 +443,7 @@ void TraceWidget::SetupSCPI() for(int j=0;jgetDataType() != 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"<addAction(action_duplicate); ctxmenu->exec(event->globalPos());