From 5ae57bfa9ae1cb2d72407cab16664cd4f53f2845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Wed, 8 May 2024 10:42:28 +0200 Subject: [PATCH] Preset default traces in mixed mode conversion dialog --- .../CustomWidgets/tracesetselector.cpp | 16 ++++++++++++++++ .../CustomWidgets/tracesetselector.h | 1 + .../LibreVNA-GUI/Tools/mixedmodeconversion.cpp | 1 + 3 files changed, 18 insertions(+) diff --git a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.cpp b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.cpp index da8ace55..cab81dbe 100644 --- a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.cpp +++ b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.cpp @@ -88,6 +88,22 @@ void TraceSetSelector::setPorts(unsigned int newPorts) emit selectionChanged(); } +void TraceSetSelector::setDefaultTraces() +{ + auto traces = model->getTraces(); + for(unsigned int i=1;i<=ports;i++) { + for(unsigned int j=1;j<=ports;j++) { + QString defaultTraceName = "S"+QString::number(i)+QString::number(j); + for(auto t : traces) { + if(t->name() == defaultTraceName) { + setTrace(i, j, t); + break; + } + } + } + } +} + bool TraceSetSelector::setTrace(unsigned int destPort, unsigned int srcPort, Trace *t) { if(destPort < 1 || destPort > ports || srcPort < 1 || srcPort > ports) { diff --git a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.h b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.h index 6b4857d6..33a4b3a6 100644 --- a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.h +++ b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tracesetselector.h @@ -20,6 +20,7 @@ class TraceSetSelector : public QWidget unsigned int getPorts() const; void setPorts(unsigned int newPorts); + void setDefaultTraces(); bool setTrace(unsigned int destPort, unsigned int srcPort, Trace *t); Trace *getTrace(unsigned int destPort, unsigned int srcPort); diff --git a/Software/PC_Application/LibreVNA-GUI/Tools/mixedmodeconversion.cpp b/Software/PC_Application/LibreVNA-GUI/Tools/mixedmodeconversion.cpp index a07f26eb..1c1d211b 100644 --- a/Software/PC_Application/LibreVNA-GUI/Tools/mixedmodeconversion.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Tools/mixedmodeconversion.cpp @@ -19,6 +19,7 @@ MixedModeConversion::MixedModeConversion(TraceModel &m, QWidget *parent) : }); connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject); selectionChanged(); + ui->selector->setDefaultTraces(); } MixedModeConversion::~MixedModeConversion()