diff --git a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tilewidget.cpp b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tilewidget.cpp index b8dad1a..c391126 100644 --- a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tilewidget.cpp +++ b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tilewidget.cpp @@ -214,6 +214,14 @@ void TileWidget::setPlot(TracePlot *plot) } } +void TileWidget::removePlot() +{ + if(hasContent) { + content->setParentTile(nullptr); + removeContent(); + } +} + TileWidget::TileWidget(TraceModel &model, TileWidget &parent) : TileWidget(model) { diff --git a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tilewidget.h b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tilewidget.h index 4d93034..28185f9 100644 --- a/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tilewidget.h +++ b/Software/PC_Application/LibreVNA-GUI/CustomWidgets/tilewidget.h @@ -39,6 +39,7 @@ public slots: void splitHorizontally(bool moveContentToSecondChild = false); void closeTile(); void setPlot(TracePlot *plot); + void removePlot(); private slots: void on_bSmithchart_clicked(); diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp index 469a7ab..323aa34 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp @@ -659,19 +659,19 @@ void EyeDiagramPlot::draw(QPainter &p) } else { qDebug() << "Empty eye data, displaydata:" << displayData; } - if(dropPending) { - p.setOpacity(0.5); - p.setBrush(Qt::white); - p.setPen(Qt::white); + if(dropPending && supported(dropTrace)) { + p.setOpacity(dropOpacity); + p.setBrush(dropBackgroundColor); + p.setPen(dropForegroundColor); // show drop area over whole plot - p.drawRect(plotRect); + p.drawRect(getDropRect()); auto font = p.font(); font.setPixelSize(20); p.setFont(font); p.setOpacity(1.0); - p.setPen(Qt::white); + p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor); auto text = "Drop here to add\n" + dropTrace->name() + "\nto eye diagram"; - p.drawText(plotRect, Qt::AlignCenter, text); + p.drawText(getDropRect(), Qt::AlignCenter, text); } } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp index 70566f2..3aec5cc 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp @@ -6,6 +6,11 @@ #include "preferences.h" #include "Util/util.h" #include "CustomWidgets/tilewidget.h" +#include "tracexyplot.h" +#include "tracesmithchart.h" +#include "eyediagramplot.h" +#include "tracewaterfall.h" +#include "tracepolarchart.h" #include #include @@ -101,6 +106,41 @@ void TracePlot::updateSpan(double min, double max) triggerReplot(); } +QString TracePlot::TypeToString(Type t) +{ + switch(t) { + case Type::EyeDiagram: return "Eye Diagram"; + case Type::PolarChart: return "Polar Chart"; + case Type::SmithChart: return "Smith Chart"; + case Type::Waterfall: return "Waterfall"; + case Type::XYPlot: return "XY Plot"; + } +} + +TracePlot::Type TracePlot::TypeFromString(QString s) +{ + for(unsigned int i=0;i<=(int) Type::EyeDiagram;i++) { + if(TypeToString((Type) i) == s) { + return (Type) i; + } + } + // use default + return Type::XYPlot; +} + +TracePlot *TracePlot::createFromType(TraceModel &model, Type t) +{ + switch(t) { + case Type::EyeDiagram: return new EyeDiagramPlot(model); + case Type::PolarChart: return new TracePolarChart(model); + case Type::SmithChart: return new TraceSmithChart(model); + case Type::Waterfall: return new TraceWaterfall(model); + case Type::XYPlot: return new TraceXYPlot(model); + default: + return nullptr; + } +} + void TracePlot::initializeTraceInfo() { // Populate already present traces @@ -295,6 +335,46 @@ void TracePlot::paintEvent(QPaintEvent *event) p.setWindow(0, 0, w, h); draw(p); + + if(dropPending) { + p.setOpacity(dropOpacity); + p.setBrush(dropBackgroundColor); + p.setPen(dropForegroundColor); + + auto dropRect = getDropRect(); + + p.fillRect(0, 0, dropRect.left(), h-1, p.brush()); + p.fillRect(dropRect.left(), 0, dropRect.width()-1, dropRect.top(), p.brush()); + p.fillRect(dropRect.left(), dropRect.bottom(), dropRect.width()-1, h-1, p.brush()); + p.fillRect(dropRect.right(), 0, w-1, h-1, p.brush()); + + p.setOpacity(1.0); + p.drawLine(QPoint(0, 0), dropRect.topLeft()); + p.drawLine(QPoint(0, h-1), dropRect.bottomLeft()); + p.drawLine(QPoint(w-1, 0), dropRect.topRight()); + p.drawLine(QPoint(w-1, h-1), dropRect.bottomRight()); + p.drawLine(QPoint(0, 0), QPoint(0, h-1)); + p.drawLine(QPoint(0, h-1), QPoint(w-1, h-1)); + p.drawLine(QPoint(w-1, h-1), QPoint(w-1, 0)); + p.drawLine(QPoint(w-1, 0), QPoint(0, 0)); + p.drawLine(dropRect.topLeft(), dropRect.topRight()); + p.drawLine(dropRect.topRight(), dropRect.bottomRight()); + p.drawLine(dropRect.bottomRight(), dropRect.bottomLeft()); + p.drawLine(dropRect.bottomLeft(), dropRect.topLeft()); + + auto font = p.font(); + font.setPixelSize(20); + p.setFont(font); + p.setPen(dropSection == DropSection::Above ? dropHighlightColor : dropForegroundColor); + p.drawText(QRect(0, 0, w, dropRect.top()), Qt::AlignCenter, "Insert above"); + p.setPen(dropSection == DropSection::Below ? dropHighlightColor : dropForegroundColor); + p.drawText(QRect(0, dropRect.bottom(), w, dropRect.top()), Qt::AlignCenter, "Insert below"); + p.setPen(dropSection == DropSection::ToTheLeft ? dropHighlightColor : dropForegroundColor); + p.drawText(QRect(0, 0, dropRect.left(), h), Qt::AlignCenter, "Insert to\nthe left"); + p.setPen(dropSection == DropSection::ToTheRight ? dropHighlightColor : dropForegroundColor); + p.drawText(QRect(dropRect.right(), 0, dropRect.left(), h), Qt::AlignCenter, "Insert to\nthe right"); + } + replotTimer.start(MaxUpdateInterval); } @@ -330,6 +410,15 @@ void TracePlot::finishContextMenu() contextmenu->addMenu(add); } + auto removeTile = new QAction("Remove Tile", contextmenu); + contextmenu->addAction(removeTile); + connect(removeTile, &QAction::triggered, [=]() { + markedForDeletion = true; + QTimer::singleShot(0, [=](){ + parentTile->closeTile(); + }); + }); + auto close = new QAction("Close", contextmenu); contextmenu->addAction(close); connect(close, &QAction::triggered, [=]() { @@ -511,19 +600,91 @@ void TracePlot::dragEnterEvent(QDragEnterEvent *event) quintptr dropPtr; stream >> dropPtr; auto trace = (Trace*) dropPtr; - if(dropSupported(trace)) { +// if(dropSupported(trace)) { event->acceptProposedAction(); dropPending = true; dropTrace = trace; - } +// } } triggerReplot(); } +void TracePlot::dragMoveEvent(QDragMoveEvent *event) +{ + if(!dropPending) { + return; + } + auto dropRect = getDropRect(); + auto pos = event->position().toPoint() - QPoint(marginLeft, marginTop); + if(dropRect.contains(pos)) { + dropSection = DropSection::OnPlot; + } else { + // transform to relative coordinates from 0 to 1 + auto x = (double) pos.x() / (width() - marginLeft - marginRight); + auto y = (double) pos.y() / (height() - marginTop - marginBottom); + qDebug() << "x:" << x << "y:" << y; + if(y < 0.5) { + if(x < y) { + dropSection = DropSection::ToTheLeft; + } else if(x > (1.0 - y)) { + dropSection = DropSection::ToTheRight; + } else { + dropSection = DropSection::Above; + } + } else { + if(x < (1.0 - y)) { + dropSection = DropSection::ToTheLeft; + } else if(x > y) { + dropSection = DropSection::ToTheRight; + } else { + dropSection = DropSection::Below; + } + } + } + dropPosition = pos; + replot(); +} + void TracePlot::dropEvent(QDropEvent *event) { if(dropTrace) { - traceDropped(dropTrace, event->position().toPoint() - - QPoint(marginLeft, marginTop)); + if(dropSection == DropSection::OnPlot) { + traceDropped(dropTrace, event->position().toPoint() - - QPoint(marginLeft, marginTop)); + } else { + TileWidget *newTile = nullptr; + // parentTile will be modified by the split, save here + TileWidget *oldParent = parentTile; + switch(dropSection) { + case DropSection::Above: + parentTile->splitVertically(true); + newTile = oldParent->Child1(); + break; + case DropSection::Below: + parentTile->splitVertically(false); + newTile = oldParent->Child2(); + break; + case DropSection::ToTheLeft: + parentTile->splitHorizontally(true); + newTile = oldParent->Child1(); + break; + case DropSection::ToTheRight: + parentTile->splitHorizontally(false); + newTile = oldParent->Child2(); + break; + case DropSection::OnPlot: + // already handled above + break; + } + TracePlot *graph = createDefaultPlotForTrace(model, dropTrace); + if(!graph->configureForTrace(dropTrace)) { + // can't be used for the configuration the trace is in, fall back to XY-Plot + delete graph; + graph = new TraceXYPlot(model); + graph->configureForTrace(dropTrace); + } + newTile->setPlot(graph); + graph->enableTrace(dropTrace, true); + } } dropPending = false; dropTrace = nullptr; @@ -547,11 +708,32 @@ void TracePlot::traceDropped(Trace *t, QPoint position) } } +QRect TracePlot::getDropRect() +{ + constexpr double dropBorders = 0.2; + auto w = width() - marginLeft - marginRight; + auto h = height() - marginTop - marginBottom; + return QRect(QPoint(w*dropBorders, h*dropBorders), QSize(w*(1.0-2*dropBorders), h*(1.0-2*dropBorders))); +} + std::set TracePlot::getPlots() { return plots; } +TracePlot *TracePlot::createDefaultPlotForTrace(TraceModel &model, Trace *t) +{ + auto &p = Preferences::getInstance(); + + TracePlot *ret = nullptr; + if(t->isReflection()) { + ret = createFromType(model, TypeFromString(p.Graphs.defaultGraphs.reflection)); + } else { + ret = createFromType(model, TypeFromString(p.Graphs.defaultGraphs.transmission)); + } + return ret; +} + void TracePlot::newTraceAvailable(Trace *t) { traces[t] = false; diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.h b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.h index 6282e8e..0aca1f9 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.h +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.h @@ -1,4 +1,4 @@ -#ifndef TRACEPLOT_H +#ifndef TRACEPLOT_H #define TRACEPLOT_H #include "tracemodel.h" @@ -33,6 +33,10 @@ public: void mouseDoubleClickEvent(QMouseEvent *event) override; virtual void updateSpan(double min, double max); virtual Type getType() = 0; + static QString TypeToString(Type t); + static Type TypeFromString(QString s); + static TracePlot* createFromType(TraceModel &model, Type t); + static TracePlot *createDefaultPlotForTrace(TraceModel &model, Trace *t); static std::set getPlots(); @@ -92,10 +96,12 @@ protected: // handle trace drops virtual bool dropSupported(Trace *t); void dragEnterEvent(QDragEnterEvent *event) override; + void dragMoveEvent(QDragMoveEvent *event) override; void dropEvent(QDropEvent *event) override; void dragLeaveEvent(QDragLeaveEvent *event) override; virtual void traceDropped(Trace *t, QPoint position); virtual QString mouseText(QPoint pos) {Q_UNUSED(pos) return QString();} + QRect getDropRect(); protected slots: void newTraceAvailable(Trace *t); @@ -110,6 +116,11 @@ protected: static constexpr unsigned int marginLeft = 0; static constexpr unsigned int marginRight = 0; + static constexpr double dropOpacity = 0.9; + static constexpr auto dropBackgroundColor = Qt::darkGray; + static constexpr auto dropForegroundColor = Qt::white; + static constexpr auto dropHighlightColor = Qt::red; + double sweep_fmin, sweep_fmax; double xSweep; // current position in the sweep (NaN if no live traces are active on the plot) TraceModel &model; @@ -123,6 +134,15 @@ protected: bool dropPending; QPoint dropPosition; + enum class DropSection { + Above, + Below, + ToTheLeft, + ToTheRight, + OnPlot, + }; + DropSection dropSection; + Trace *dropTrace; QLabel *cursorLabel; diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracepolarchart.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracepolarchart.cpp index 042a185..044c99b 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracepolarchart.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracepolarchart.cpp @@ -207,22 +207,20 @@ void TracePolarChart::draw(QPainter &p) { } } - if(dropPending) { + if(dropPending && supported(dropTrace)) { // adjust coords due to shifted restore - p.setOpacity(0.5); - p.setBrush(Qt::white); - p.setPen(Qt::white); - p.drawEllipse(-polarCoordMax, -polarCoordMax, 2*polarCoordMax, 2*polarCoordMax); + p.setOpacity(dropOpacity); + p.setBrush(dropBackgroundColor); + p.setPen(dropForegroundColor); + p.drawRect(getDropRect()); auto font = p.font(); font.setPixelSize(20); p.setFont(font); p.setOpacity(1.0); - p.setPen(Qt::white); + p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor); auto text = "Drop here to add\n" + dropTrace->name() + "\nto polar chart"; p.drawText(p.window(), Qt::AlignCenter, text); - } else { } - } bool TracePolarChart::dropSupported(Trace *t) diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp index 38ba585..73f0058 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp @@ -380,20 +380,19 @@ void TraceSmithChart::draw(QPainter &p) { } } } - if(dropPending) { + if(dropPending && supported(dropTrace)) { // adjust coords due to shifted restore - p.setOpacity(0.5); - p.setBrush(Qt::white); - p.setPen(Qt::white); - p.drawEllipse(-polarCoordMax, -polarCoordMax, 2*polarCoordMax, 2*polarCoordMax); + p.setOpacity(dropOpacity); + p.setBrush(dropBackgroundColor); + p.setPen(dropForegroundColor); + p.drawRect(getDropRect()); auto font = p.font(); font.setPixelSize(20); p.setFont(font); p.setOpacity(1.0); - p.setPen(Qt::white); + p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor); auto text = "Drop here to add\n" + dropTrace->name() + "\nto Smith chart"; p.drawText(p.window(), Qt::AlignCenter, text); - } else { } } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracewaterfall.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracewaterfall.cpp index d697171..6e9bb61 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracewaterfall.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracewaterfall.cpp @@ -470,18 +470,18 @@ void TraceWaterfall::draw(QPainter &p) } if(dropPending) { - p.setOpacity(0.5); - p.setBrush(Qt::white); - p.setPen(Qt::white); + p.setOpacity(dropOpacity); + p.setBrush(dropBackgroundColor); + p.setPen(dropForegroundColor); // show drop area over whole plot - p.drawRect(plotRect); + p.drawRect(getDropRect()); auto font = p.font(); font.setPixelSize(20); p.setFont(font); p.setOpacity(1.0); - p.setPen(Qt::white); + p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor); auto text = "Drop here to add\n" + dropTrace->name() + "\nto waterfall plot"; - p.drawText(plotRect, Qt::AlignCenter, text); + p.drawText(getDropRect(), Qt::AlignCenter, text); } } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.cpp index e59dd31..b524ded 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.cpp @@ -15,6 +15,7 @@ #include #include #include +#include TraceWidget::TraceWidget(TraceModel &model, QWidget *parent) : @@ -30,6 +31,11 @@ TraceWidget::TraceWidget(TraceModel &model, QWidget *parent) : ui->view->viewport()->installEventFilter(this); connect(ui->bImport, &QPushButton::clicked, this, &TraceWidget::importDialog); connect(ui->bExport, &QPushButton::clicked, this, &TraceWidget::exportDialog); + connect(ui->view->selectionModel(), &QItemSelectionModel::currentRowChanged, this, [=](const QModelIndex ¤t, const QModelIndex &previous){ + Q_UNUSED(previous) + ui->edit->setEnabled(current.isValid()); + ui->remove->setEnabled(current.isValid()); + }); installEventFilter(this); createCount = 0; SetupSCPI(); @@ -65,6 +71,8 @@ bool TraceWidget::eventFilter(QObject *, QEvent *event) int key = static_cast(event)->key(); if(key == Qt::Key_Escape) { ui->view->clearSelection(); + ui->edit->setEnabled(false); + ui->remove->setEnabled(false); return true; } else if(key == Qt::Key_Delete) { model.removeTrace(ui->view->currentIndex().row()); diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.ui b/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.ui index ec719a7..f1c5fdc 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.ui +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracewidget.ui @@ -123,6 +123,9 @@ + + false + 0 @@ -183,6 +186,9 @@ + + false + 0 diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp index 859daa7..19e75b1 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp @@ -32,7 +32,6 @@ TraceXYPlot::TraceXYPlot(TraceModel &model, QWidget *parent) setXAxis(XAxis::Type::Frequency, XAxisMode::UseSpan, false, 0, 6000000000, 600000000); initializeTraceInfo(); } - TraceXYPlot::~TraceXYPlot() { for(auto l : constantLines) { @@ -782,40 +781,66 @@ void TraceXYPlot::draw(QPainter &p) } if(dropPending) { - p.setOpacity(0.5); - p.setBrush(Qt::white); - p.setPen(Qt::white); + p.setOpacity(dropOpacity); + p.setBrush(dropBackgroundColor); + p.setPen(dropForegroundColor); + + auto dropRect = getDropRect(); + if((yAxis[0].getType() == YAxis::Type::Disabled || !supported(dropTrace, yAxis[0].getType())) || (yAxis[1].getType() == YAxis::Type::Disabled || !supported(dropTrace, yAxis[1].getType()))) { // only one axis enabled, show drop area over whole plot - p.drawRect(plotRect); + p.drawRect(dropRect); auto font = p.font(); font.setPixelSize(20); p.setFont(font); p.setOpacity(1.0); - p.setPen(Qt::white); + p.setPen(dropSection == DropSection::OnPlot ? dropHighlightColor : dropForegroundColor); auto text = "Drop here to add\n" + dropTrace->name() + "\nto XY-plot"; - p.drawText(plotRect, Qt::AlignCenter, text); + p.drawText(dropRect, Qt::AlignCenter, text); + dropOnLeftAxis = true; + dropOnRightAxis = true; } else { // both axis enabled, show regions - auto leftRect = plotRect; - leftRect.setWidth(plotRect.width() * 0.3); - auto centerRect = plotRect; - centerRect.setX(centerRect.x() + plotRect.width() * 0.35); - centerRect.setWidth(plotRect.width() * 0.3); - auto rightRect = plotRect; - rightRect.setX(rightRect.x() + plotRect.width() * 0.7); - rightRect.setWidth(plotRect.width() * 0.3); + auto leftRect = dropRect; + leftRect.setWidth(dropRect.width() * 0.333); + auto centerRect = dropRect; + centerRect.setX(centerRect.x() + dropRect.width() * 0.333); + centerRect.setWidth(dropRect.width() * 0.333); + auto rightRect = dropRect; + rightRect.setX(rightRect.x() + dropRect.width() * 0.666); + rightRect.setWidth(dropRect.width() * 0.333); p.drawRect(leftRect); p.drawRect(centerRect); p.drawRect(rightRect); p.setOpacity(1.0); - p.setPen(Qt::white); + p.setPen(dropForegroundColor); auto font = p.font(); font.setPixelSize(20); p.setFont(font); + if(dropSection == DropSection::OnPlot && leftRect.contains(dropPosition)) { + p.setPen(dropHighlightColor); + dropOnLeftAxis = true; + dropOnRightAxis = false; + } else { + p.setPen(dropForegroundColor); + } p.drawText(leftRect, Qt::AlignCenter, "Drop here to add\nto primary axis"); + if(dropSection == DropSection::OnPlot && centerRect.contains(dropPosition)) { + p.setPen(dropHighlightColor); + dropOnLeftAxis = true; + dropOnRightAxis = true; + } else { + p.setPen(dropForegroundColor); + } p.drawText(centerRect, Qt::AlignCenter, "Drop here to add\nto boths axes"); + if(dropSection == DropSection::OnPlot && rightRect.contains(dropPosition)) { + p.setPen(dropHighlightColor); + dropOnLeftAxis = false; + dropOnRightAxis = true; + } else { + p.setPen(dropForegroundColor); + } p.drawText(rightRect, Qt::AlignCenter, "Drop here to add\nto secondary axis"); } } @@ -1162,12 +1187,11 @@ void TraceXYPlot::traceDropped(Trace *t, QPoint position) enableTraceAxis(t, 0, true); return; } - // both axis enabled, check drop position - auto drop = Util::Scale(position.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth, 0.0, 1.0); - if(drop < 0.66) { + // both axis enabled + if(dropOnLeftAxis) { enableTraceAxis(t, 0, true); } - if(drop > 0.33) { + if(dropOnRightAxis) { enableTraceAxis(t, 1, true); } } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.h b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.h index 17a87c3..0b31b91 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.h +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.h @@ -115,6 +115,9 @@ private: void traceDropped(Trace *t, QPoint position) override; QString mouseText(QPoint pos) override; + bool dropOnLeftAxis; + bool dropOnRightAxis; + std::set tracesAxis[2]; YAxis yAxis[2]; diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp index d4d1b76..0d3afad 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp @@ -1570,12 +1570,7 @@ void VNA::createDefaultTracesAndGraphs(int ports) QString param = "S"+QString::number(i+1)+QString::number(j+1); auto trace = new Trace(param, getDefaultColor(ports, i, j), param); traceModel.addTrace(trace); - TracePlot *plot; - if(i == j) { - plot = new TraceSmithChart(traceModel); - } else { - plot = new TraceXYPlot(traceModel); - } + TracePlot *plot = TracePlot::createDefaultPlotForTrace(traceModel, trace); plot->updateSpan(settings.Freq.start, settings.Freq.stop); plot->enableTrace(trace, true); plots[i].push_back(plot); diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.cpp b/Software/PC_Application/LibreVNA-GUI/preferences.cpp index 3c11e0f..2b231c1 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferences.cpp +++ b/Software/PC_Application/LibreVNA-GUI/preferences.cpp @@ -258,6 +258,8 @@ void PreferencesDialog::setInitialGUIState() ui->AcquisitionFullSpanStop->setValue(p->Acquisition.fullSpanStop); ui->AcquisitionFullSpanCalibrated->setChecked(p->Acquisition.fullSpanCalibratedRange); + ui->GraphsDefaultTransmission->setCurrentText(p->Graphs.defaultGraphs.transmission); + ui->GraphsDefaultReflection->setCurrentText(p->Graphs.defaultGraphs.reflection); ui->GraphsShowUnit->setChecked(p->Graphs.showUnits); ui->GraphsColorBackground->setColor(p->Graphs.Color.background); ui->GraphsColorAxis->setColor(p->Graphs.Color.axis); @@ -353,6 +355,8 @@ void PreferencesDialog::updateFromGUI() p->Acquisition.fullSpanStop = ui->AcquisitionFullSpanStop->value(); p->Acquisition.fullSpanCalibratedRange = ui->AcquisitionFullSpanCalibrated->isChecked(); + p->Graphs.defaultGraphs.transmission = ui->GraphsDefaultTransmission->currentText(); + p->Graphs.defaultGraphs.reflection = ui->GraphsDefaultReflection->currentText(); p->Graphs.showUnits = ui->GraphsShowUnit->isChecked(); p->Graphs.Color.background = ui->GraphsColorBackground->getColor(); p->Graphs.Color.axis = ui->GraphsColorAxis->getColor(); diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.h b/Software/PC_Application/LibreVNA-GUI/preferences.h index d71d350..8bfe66d 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferences.h +++ b/Software/PC_Application/LibreVNA-GUI/preferences.h @@ -137,6 +137,11 @@ public: bool hide; double hidePercent; } SweepIndicator; + + struct { + QString transmission; + QString reflection; + } defaultGraphs; } Graphs; struct { struct { @@ -223,6 +228,8 @@ private: {&Graphs.SweepIndicator.line, "Graphs.SweepIndicator.line", false}, {&Graphs.SweepIndicator.hide, "Graphs.SweepIndicator.hide", false}, {&Graphs.SweepIndicator.hidePercent, "Graphs.SweepIndicator.hidePercent", 3.0}, + {&Graphs.defaultGraphs.transmission, "Graphs.defaultGraphs.transmission", "XY Plot"}, + {&Graphs.defaultGraphs.reflection, "Graphs.defaultGraphs.reflection", "Smith Chart"}, {&Marker.defaultBehavior.showDataOnGraphs, "Marker.defaultBehavior.ShowDataOnGraphs", true}, {&Marker.defaultBehavior.showdB, "Marker.defaultBehavior.showdB", true}, {&Marker.defaultBehavior.showdBm, "Marker.defaultBehavior.showdBm", true}, diff --git a/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui b/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui index 2f7ba8b..ff9c805 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui +++ b/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui @@ -93,7 +93,7 @@ - 0 + 2 @@ -107,8 +107,8 @@ 0 0 - 679 - 836 + 683 + 897 @@ -698,8 +698,8 @@ 0 0 - 450 - 320 + 697 + 563 @@ -855,13 +855,84 @@ 0 0 - 437 - 862 + 683 + 1058 + + + + Default Graphs + + + + + + For transmission measurements: + + + + + + + For reflection measurements: + + + + + + + + XY Plot + + + + + Polar Chart + + + + + Waterfall + + + + + Eye Diagram + + + + + + + + + XY-Plot + + + + + Smith Chart + + + + + Polar Chart + + + + + Waterfall + + + + + + + @@ -1278,8 +1349,8 @@ 0 0 - 402 - 540 + 683 + 605 @@ -1617,8 +1688,8 @@ 0 0 - 138 - 112 + 168 + 127 @@ -1707,8 +1778,8 @@ 0 0 - 194 - 146 + 215 + 168