From 83dbfadf20f0f2bf7102261c6a5e916a34b813a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Fri, 17 Feb 2023 17:30:54 +0100 Subject: [PATCH] Nicer preset graph configuration for one port devices --- .../PC_Application/LibreVNA-GUI/VNA/vna.cpp | 129 ++++++++++-------- 1 file changed, 72 insertions(+), 57 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp index 29110d8..e859d34 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp @@ -1542,66 +1542,81 @@ void VNA::createDefaultTracesAndGraphs(int ports) } }; - vector> plots; - for(int i=0;i()); - for(int j=0;jupdateSpan(settings.Freq.start, settings.Freq.stop); - plot->enableTrace(trace, true); - plots[i].push_back(plot); - } - } - // Add created graphs to tiles - tiles->clear(); - TileWidget *tile = tiles; - for(int i=0;isplitVertically(); - row = tile->Child1(); - tile = tile->Child2(); - } else { - row = tile; - } - for(int j=0;jsplitHorizontally(); - graphTile = row->Child1(); - row = row->Child2(); - } else { - graphTile = row; - } - graphTile->setPlot(plots[i][j]); - } - } - if(ports >= 3) { - // default split at the middle does not result in all plots being the same size, adjust - tile = tiles; + if(ports > 1) { + vector> plots; for(int i=0;isetSplitPercentage(100 / (ports - i)); - rowTile = tile->Child1(); - } else { - rowTile = tile; + plots.push_back(vector()); + for(int j=0;jupdateSpan(settings.Freq.start, settings.Freq.stop); + plot->enableTrace(trace, true); + plots[i].push_back(plot); } - for(int j=0;jsetSplitPercentage(100 / (ports - j)); - rowTile = rowTile->Child2(); - } - tile = tile->Child2(); } + // Add created graphs to tiles + tiles->clear(); + TileWidget *tile = tiles; + for(int i=0;isplitVertically(); + row = tile->Child1(); + tile = tile->Child2(); + } else { + row = tile; + } + for(int j=0;jsplitHorizontally(); + graphTile = row->Child1(); + row = row->Child2(); + } else { + graphTile = row; + } + graphTile->setPlot(plots[i][j]); + } + } + if(ports >= 3) { + // default split at the middle does not result in all plots being the same size, adjust + tile = tiles; + for(int i=0;isetSplitPercentage(100 / (ports - i)); + rowTile = tile->Child1(); + } else { + rowTile = tile; + } + for(int j=0;jsetSplitPercentage(100 / (ports - j)); + rowTile = rowTile->Child2(); + } + tile = tile->Child2(); + } + } + } else if(ports == 1) { + tiles->clear(); + tiles->splitHorizontally(); + auto trace = new Trace("S11", getDefaultColor(ports, 0, 0), "S11"); + traceModel.addTrace(trace); + auto smithchart = new TraceSmithChart(traceModel); + auto xyplot = new TraceXYPlot(traceModel); + smithchart->updateSpan(settings.Freq.start, settings.Freq.stop); + smithchart->enableTrace(trace, true); + xyplot->updateSpan(settings.Freq.start, settings.Freq.stop); + xyplot->enableTrace(trace, true); + tiles->Child1()->setPlot(smithchart); + tiles->Child2()->setPlot(xyplot); } }