minor GUI fixes + preparation for spectrum analyzer export/import
This commit is contained in:
parent
d63640d437
commit
37bd9a0435
@ -22,6 +22,7 @@ HEADERS += \
|
|||||||
Generator/generator.h \
|
Generator/generator.h \
|
||||||
Generator/signalgenwidget.h \
|
Generator/signalgenwidget.h \
|
||||||
SpectrumAnalyzer/spectrumanalyzer.h \
|
SpectrumAnalyzer/spectrumanalyzer.h \
|
||||||
|
SpectrumAnalyzer/tracewidgetsa.h \
|
||||||
Tools/eseries.h \
|
Tools/eseries.h \
|
||||||
Tools/impedancematchdialog.h \
|
Tools/impedancematchdialog.h \
|
||||||
Traces/fftcomplex.h \
|
Traces/fftcomplex.h \
|
||||||
@ -41,6 +42,7 @@ HEADERS += \
|
|||||||
Util/qpointervariant.h \
|
Util/qpointervariant.h \
|
||||||
Util/util.h \
|
Util/util.h \
|
||||||
VNA/portextension.h \
|
VNA/portextension.h \
|
||||||
|
VNA/tracewidgetvna.h \
|
||||||
VNA/vna.h \
|
VNA/vna.h \
|
||||||
appwindow.h \
|
appwindow.h \
|
||||||
averaging.h \
|
averaging.h \
|
||||||
@ -72,6 +74,7 @@ SOURCES += \
|
|||||||
Generator/generator.cpp \
|
Generator/generator.cpp \
|
||||||
Generator/signalgenwidget.cpp \
|
Generator/signalgenwidget.cpp \
|
||||||
SpectrumAnalyzer/spectrumanalyzer.cpp \
|
SpectrumAnalyzer/spectrumanalyzer.cpp \
|
||||||
|
SpectrumAnalyzer/tracewidgetsa.cpp \
|
||||||
Tools/eseries.cpp \
|
Tools/eseries.cpp \
|
||||||
Tools/impedancematchdialog.cpp \
|
Tools/impedancematchdialog.cpp \
|
||||||
Traces/fftcomplex.cpp \
|
Traces/fftcomplex.cpp \
|
||||||
@ -89,6 +92,7 @@ SOURCES += \
|
|||||||
Traces/tracexyplot.cpp \
|
Traces/tracexyplot.cpp \
|
||||||
Traces/xyplotaxisdialog.cpp \
|
Traces/xyplotaxisdialog.cpp \
|
||||||
VNA/portextension.cpp \
|
VNA/portextension.cpp \
|
||||||
|
VNA/tracewidgetvna.cpp \
|
||||||
VNA/vna.cpp \
|
VNA/vna.cpp \
|
||||||
appwindow.cpp \
|
appwindow.cpp \
|
||||||
averaging.cpp \
|
averaging.cpp \
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "CustomWidgets/toggleswitch.h"
|
#include "CustomWidgets/toggleswitch.h"
|
||||||
#include "Device/manualcontroldialog.h"
|
#include "Device/manualcontroldialog.h"
|
||||||
#include "Traces/tracemodel.h"
|
#include "Traces/tracemodel.h"
|
||||||
#include "Traces/tracewidget.h"
|
#include "tracewidgetsa.h"
|
||||||
#include "Traces/tracesmithchart.h"
|
#include "Traces/tracesmithchart.h"
|
||||||
#include "Traces/tracexyplot.h"
|
#include "Traces/tracexyplot.h"
|
||||||
#include "Traces/traceimportdialog.h"
|
#include "Traces/traceimportdialog.h"
|
||||||
@ -242,7 +242,7 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window)
|
|||||||
markerModel = new TraceMarkerModel(traceModel, this);
|
markerModel = new TraceMarkerModel(traceModel, this);
|
||||||
|
|
||||||
auto tracesDock = new QDockWidget("Traces");
|
auto tracesDock = new QDockWidget("Traces");
|
||||||
tracesDock->setWidget(new TraceWidget(traceModel, window, true));
|
tracesDock->setWidget(new TraceWidgetSA(traceModel, window));
|
||||||
window->addDockWidget(Qt::LeftDockWidgetArea, tracesDock);
|
window->addDockWidget(Qt::LeftDockWidgetArea, tracesDock);
|
||||||
docks.insert(tracesDock);
|
docks.insert(tracesDock);
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
#include "tracewidgetsa.h"
|
||||||
|
|
||||||
|
TraceWidgetSA::TraceWidgetSA(TraceModel &model, QWidget *parent)
|
||||||
|
: TraceWidget(model, parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
18
Software/PC_Application/SpectrumAnalyzer/tracewidgetsa.h
Normal file
18
Software/PC_Application/SpectrumAnalyzer/tracewidgetsa.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef TRACEWIDGETSA_H
|
||||||
|
#define TRACEWIDGETSA_H
|
||||||
|
|
||||||
|
#include "Traces/tracewidget.h"
|
||||||
|
|
||||||
|
class TraceWidgetSA : public TraceWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TraceWidgetSA(TraceModel &model, QWidget *parent = nullptr);
|
||||||
|
protected slots:
|
||||||
|
virtual void exportDialog() override {};
|
||||||
|
virtual void importDialog() override {};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual Trace::LiveParameter defaultParameter() override {return Trace::LiveParameter::Port1;};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRACEWIDGETSA_H
|
@ -99,6 +99,7 @@ void TracePlot::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
|
|
||||||
void TracePlot::paintEvent(QPaintEvent *event)
|
void TracePlot::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto pref = Preferences::getInstance();
|
auto pref = Preferences::getInstance();
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
// p.setRenderHint(QPainter::Antialiasing);
|
// p.setRenderHint(QPainter::Antialiasing);
|
||||||
|
@ -10,16 +10,17 @@
|
|||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
TraceWidget::TraceWidget(TraceModel &model, QWidget *parent, bool SA) :
|
TraceWidget::TraceWidget(TraceModel &model, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::TraceWidget),
|
ui(new Ui::TraceWidget),
|
||||||
model(model),
|
model(model)
|
||||||
SA(SA)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->view->setModel(&model);
|
ui->view->setModel(&model);
|
||||||
ui->view->setAutoScroll(false);
|
ui->view->setAutoScroll(false);
|
||||||
ui->view->viewport()->installEventFilter(this);
|
ui->view->viewport()->installEventFilter(this);
|
||||||
|
connect(ui->bImport, &QPushButton::clicked, this, &TraceWidget::importDialog);
|
||||||
|
connect(ui->bExport, &QPushButton::clicked, this, &TraceWidget::exportDialog);
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
createCount = 0;
|
createCount = 0;
|
||||||
}
|
}
|
||||||
@ -32,8 +33,7 @@ TraceWidget::~TraceWidget()
|
|||||||
void TraceWidget::on_add_clicked()
|
void TraceWidget::on_add_clicked()
|
||||||
{
|
{
|
||||||
createCount++;
|
createCount++;
|
||||||
auto liveParam = SA ? Trace::LiveParameter::Port1 : Trace::LiveParameter::S11;
|
auto t = new Trace("Trace #"+QString::number(createCount), Qt::darkYellow, defaultParameter());
|
||||||
auto t = new Trace("Trace #"+QString::number(createCount), Qt::darkYellow, liveParam);
|
|
||||||
t->setColor(QColor::fromHsl((createCount * 50) % 360, 250, 128));
|
t->setColor(QColor::fromHsl((createCount * 50) % 360, 250, 128));
|
||||||
model.addTrace(t);
|
model.addTrace(t);
|
||||||
}
|
}
|
||||||
@ -123,46 +123,3 @@ void TraceWidget::on_view_clicked(const QModelIndex &index)
|
|||||||
model.togglePause(index.row());
|
model.togglePause(index.row());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceWidget::on_bImport_clicked()
|
|
||||||
{
|
|
||||||
auto filename = QFileDialog::getOpenFileName(nullptr, "Open measurement file", "", "Touchstone files (*.s1p *.s2p *.s3p *.s4p)", nullptr, QFileDialog::DontUseNativeDialog);
|
|
||||||
if (filename.length() > 0) {
|
|
||||||
auto t = Touchstone::fromFile(filename.toStdString());
|
|
||||||
std::vector<Trace*> traces;
|
|
||||||
for(unsigned int i=0;i<t.ports()*t.ports();i++) {
|
|
||||||
auto trace = new Trace();
|
|
||||||
trace->fillFromTouchstone(t, i, filename);
|
|
||||||
unsigned int sink = i / t.ports() + 1;
|
|
||||||
unsigned int source = i % t.ports() + 1;
|
|
||||||
trace->setName("S"+QString::number(sink)+QString::number(source));
|
|
||||||
traces.push_back(trace);
|
|
||||||
}
|
|
||||||
// contruct prefix from filename
|
|
||||||
// remove any directory names (keep only the filename itself)
|
|
||||||
int lastSlash = qMax(filename.lastIndexOf('/'), filename.lastIndexOf('\\'));
|
|
||||||
if(lastSlash != -1) {
|
|
||||||
filename.remove(0, lastSlash + 1);
|
|
||||||
}
|
|
||||||
// remove file type
|
|
||||||
filename.truncate(filename.indexOf('.'));
|
|
||||||
auto i = new TraceImportDialog(model, traces, filename+"_");
|
|
||||||
i->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TraceWidget::on_bExport_clicked()
|
|
||||||
{
|
|
||||||
auto e = new TraceExportDialog(model);
|
|
||||||
// Attempt to set default traces (this will result in correctly populated
|
|
||||||
// 2 port export if the initial 4 traces have not been modified)
|
|
||||||
e->setPortNum(2);
|
|
||||||
auto traces = model.getTraces();
|
|
||||||
for(unsigned int i=0;i<4;i++) {
|
|
||||||
if(i >= traces.size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
e->setTrace(i%2, i/2, traces[i]);
|
|
||||||
}
|
|
||||||
e->show();
|
|
||||||
}
|
|
||||||
|
@ -13,28 +13,26 @@ class TraceWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TraceWidget(TraceModel &model, QWidget *parent = nullptr, bool SA = false);
|
explicit TraceWidget(TraceModel &model, QWidget *parent = nullptr);
|
||||||
~TraceWidget();
|
~TraceWidget();
|
||||||
|
|
||||||
public slots:
|
protected slots:
|
||||||
void on_add_clicked();
|
void on_add_clicked();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_remove_clicked();
|
void on_remove_clicked();
|
||||||
void on_edit_clicked();
|
void on_edit_clicked();
|
||||||
void on_view_doubleClicked(const QModelIndex &index);
|
void on_view_doubleClicked(const QModelIndex &index);
|
||||||
void on_view_clicked(const QModelIndex &index);
|
void on_view_clicked(const QModelIndex &index);
|
||||||
void on_bImport_clicked();
|
virtual void exportDialog() = 0;
|
||||||
void on_bExport_clicked();
|
virtual void importDialog() = 0;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
virtual Trace::LiveParameter defaultParameter() = 0;
|
||||||
QPoint dragStartPosition;
|
QPoint dragStartPosition;
|
||||||
Trace *dragTrace;
|
Trace *dragTrace;
|
||||||
Ui::TraceWidget *ui;
|
Ui::TraceWidget *ui;
|
||||||
TraceModel &model;
|
TraceModel &model;
|
||||||
int createCount;
|
int createCount;
|
||||||
bool SA;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACEWIDGET_H
|
#endif // TRACEWIDGET_H
|
||||||
|
54
Software/PC_Application/VNA/tracewidgetvna.cpp
Normal file
54
Software/PC_Application/VNA/tracewidgetvna.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#include "tracewidgetvna.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include "Traces/traceimportdialog.h"
|
||||||
|
#include "Traces/traceexportdialog.h"
|
||||||
|
|
||||||
|
TraceWidgetVNA::TraceWidgetVNA(TraceModel &model, QWidget *parent)
|
||||||
|
: TraceWidget(model, parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TraceWidgetVNA::exportDialog()
|
||||||
|
{
|
||||||
|
auto e = new TraceExportDialog(model);
|
||||||
|
// Attempt to set default traces (this will result in correctly populated
|
||||||
|
// 2 port export if the initial 4 traces have not been modified)
|
||||||
|
e->setPortNum(2);
|
||||||
|
auto traces = model.getTraces();
|
||||||
|
for(unsigned int i=0;i<4;i++) {
|
||||||
|
if(i >= traces.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
e->setTrace(i%2, i/2, traces[i]);
|
||||||
|
}
|
||||||
|
e->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TraceWidgetVNA::importDialog()
|
||||||
|
{
|
||||||
|
auto filename = QFileDialog::getOpenFileName(nullptr, "Open measurement file", "", "Touchstone files (*.s1p *.s2p *.s3p *.s4p)", nullptr, QFileDialog::DontUseNativeDialog);
|
||||||
|
if (filename.length() > 0) {
|
||||||
|
auto t = Touchstone::fromFile(filename.toStdString());
|
||||||
|
std::vector<Trace*> traces;
|
||||||
|
for(unsigned int i=0;i<t.ports()*t.ports();i++) {
|
||||||
|
auto trace = new Trace();
|
||||||
|
trace->fillFromTouchstone(t, i, filename);
|
||||||
|
unsigned int sink = i / t.ports() + 1;
|
||||||
|
unsigned int source = i % t.ports() + 1;
|
||||||
|
trace->setName("S"+QString::number(sink)+QString::number(source));
|
||||||
|
traces.push_back(trace);
|
||||||
|
}
|
||||||
|
// contruct prefix from filename
|
||||||
|
// remove any directory names (keep only the filename itself)
|
||||||
|
int lastSlash = qMax(filename.lastIndexOf('/'), filename.lastIndexOf('\\'));
|
||||||
|
if(lastSlash != -1) {
|
||||||
|
filename.remove(0, lastSlash + 1);
|
||||||
|
}
|
||||||
|
// remove file type
|
||||||
|
filename.truncate(filename.indexOf('.'));
|
||||||
|
auto i = new TraceImportDialog(model, traces, filename+"_");
|
||||||
|
i->show();
|
||||||
|
}
|
||||||
|
}
|
18
Software/PC_Application/VNA/tracewidgetvna.h
Normal file
18
Software/PC_Application/VNA/tracewidgetvna.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef TRACEWIDGETVNA_H
|
||||||
|
#define TRACEWIDGETVNA_H
|
||||||
|
|
||||||
|
#include "Traces/tracewidget.h"
|
||||||
|
|
||||||
|
class TraceWidgetVNA : public TraceWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TraceWidgetVNA(TraceModel &model, QWidget *parent = nullptr);
|
||||||
|
protected slots:
|
||||||
|
virtual void exportDialog() override;
|
||||||
|
virtual void importDialog() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual Trace::LiveParameter defaultParameter() override {return Trace::LiveParameter::S11;};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRACEWIDGETVNA_H
|
@ -24,7 +24,7 @@
|
|||||||
#include "CustomWidgets/toggleswitch.h"
|
#include "CustomWidgets/toggleswitch.h"
|
||||||
#include "Device/manualcontroldialog.h"
|
#include "Device/manualcontroldialog.h"
|
||||||
#include "Traces/tracemodel.h"
|
#include "Traces/tracemodel.h"
|
||||||
#include "Traces/tracewidget.h"
|
#include "tracewidgetvna.h"
|
||||||
#include "Traces/tracesmithchart.h"
|
#include "Traces/tracesmithchart.h"
|
||||||
#include "Traces/tracexyplot.h"
|
#include "Traces/tracexyplot.h"
|
||||||
#include "Traces/traceimportdialog.h"
|
#include "Traces/traceimportdialog.h"
|
||||||
@ -352,7 +352,7 @@ VNA::VNA(AppWindow *window)
|
|||||||
markerModel = new TraceMarkerModel(traceModel, this);
|
markerModel = new TraceMarkerModel(traceModel, this);
|
||||||
|
|
||||||
auto tracesDock = new QDockWidget("Traces");
|
auto tracesDock = new QDockWidget("Traces");
|
||||||
tracesDock->setWidget(new TraceWidget(traceModel));
|
tracesDock->setWidget(new TraceWidgetVNA(traceModel));
|
||||||
window->addDockWidget(Qt::LeftDockWidgetArea, tracesDock);
|
window->addDockWidget(Qt::LeftDockWidgetArea, tracesDock);
|
||||||
docks.insert(tracesDock);
|
docks.insert(tracesDock);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ Mode::Mode(AppWindow *window, QString name)
|
|||||||
// Create mode switch button
|
// Create mode switch button
|
||||||
auto modeSwitch = new QPushButton(name);
|
auto modeSwitch = new QPushButton(name);
|
||||||
modeSwitch->setCheckable(true);
|
modeSwitch->setCheckable(true);
|
||||||
modeSwitch->setMaximumHeight(window->getUi()->menubar->height());
|
modeSwitch->setMaximumHeight(window->menuBar()->height());
|
||||||
if(!cornerWidget) {
|
if(!cornerWidget) {
|
||||||
// this is the first created mode, initialize corner widget and set this mode as active
|
// this is the first created mode, initialize corner widget and set this mode as active
|
||||||
modeSwitch->setChecked(true);
|
modeSwitch->setChecked(true);
|
||||||
@ -29,7 +29,7 @@ Mode::Mode(AppWindow *window, QString name)
|
|||||||
cornerWidget->layout()->setContentsMargins(0,0,0,0);
|
cornerWidget->layout()->setContentsMargins(0,0,0,0);
|
||||||
window->menuBar()->setCornerWidget(cornerWidget);
|
window->menuBar()->setCornerWidget(cornerWidget);
|
||||||
modeButtonGroup = new QButtonGroup;
|
modeButtonGroup = new QButtonGroup;
|
||||||
window->getUi()->menubar->setMaximumHeight(window->getUi()->menubar->height());
|
// window->menuBar()->setMaximumHeight(window->menuBar()->height());
|
||||||
}
|
}
|
||||||
cornerWidget->layout()->addWidget(modeSwitch);
|
cornerWidget->layout()->addWidget(modeSwitch);
|
||||||
modeButtonGroup->addButton(modeSwitch);
|
modeButtonGroup->addButton(modeSwitch);
|
||||||
|
Loading…
Reference in New Issue
Block a user