mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-02-03 22:24:26 +01:00
Import/export options in file menu
This commit is contained in:
parent
009de1af17
commit
b9e4117db1
|
|
@ -289,6 +289,13 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window, QString name)
|
|||
window->addDockWidget(Qt::LeftDockWidgetArea, tracesDock);
|
||||
docks.insert(tracesDock);
|
||||
|
||||
auto importAction = new QAction("CSV");
|
||||
connect(importAction, &QAction::triggered, traceWidget, &TraceWidgetSA::importDialog);
|
||||
importActions.push_back(importAction);
|
||||
|
||||
auto exportAction = new QAction("CSV");
|
||||
connect(exportAction, &QAction::triggered, traceWidget, &TraceWidgetSA::exportDialog);
|
||||
exportActions.push_back(exportAction);
|
||||
|
||||
auto markerWidget = new MarkerWidget(*markerModel);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "mode.h"
|
||||
#include "CustomWidgets/tilewidget.h"
|
||||
#include "scpi.h"
|
||||
#include "Traces/tracewidget.h"
|
||||
#include "tracewidgetsa.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
|
@ -36,6 +36,9 @@ public:
|
|||
|
||||
void preset() override;
|
||||
|
||||
QList<QAction*> getImportOptions() override { return importActions;}
|
||||
QList<QAction*> getExportOptions() override { return exportActions;}
|
||||
|
||||
virtual void deviceInfoUpdated() override;
|
||||
|
||||
public slots:
|
||||
|
|
@ -98,7 +101,7 @@ private:
|
|||
|
||||
double firstPointTime; // timestamp of the first point in the sweep, only use when zerospan is used
|
||||
TraceModel traceModel;
|
||||
TraceWidget *traceWidget;
|
||||
TraceWidgetSA *traceWidget;
|
||||
MarkerModel *markerModel;
|
||||
Averaging average;
|
||||
|
||||
|
|
@ -125,6 +128,10 @@ private:
|
|||
QCheckBox *enable;
|
||||
} normalize;
|
||||
|
||||
// import/export actions
|
||||
QList<QAction*> importActions;
|
||||
QList<QAction*> exportActions;
|
||||
|
||||
signals:
|
||||
void dataChanged();
|
||||
void startFreqChanged(double freq);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class TraceWidgetSA : public TraceWidget
|
|||
{
|
||||
public:
|
||||
TraceWidgetSA(TraceModel &model, QWidget *parent = nullptr);
|
||||
protected slots:
|
||||
public slots:
|
||||
virtual void exportDialog() override;
|
||||
virtual void importDialog() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,36 +17,41 @@ TraceWidgetVNA::TraceWidgetVNA(TraceModel &model, Calibration &cal, Deembedding
|
|||
deembed(deembed)
|
||||
{
|
||||
auto exportMenu = new QMenu();
|
||||
auto exportTouchstone = new QAction("Touchstone");
|
||||
auto exportCSV = new QAction("CSV");
|
||||
exportMenu->addAction(exportTouchstone);
|
||||
exportMenu->addAction(exportCSV);
|
||||
auto exportTouchstoneAction = new QAction("Touchstone");
|
||||
auto exportCSVAction = new QAction("CSV");
|
||||
exportMenu->addAction(exportTouchstoneAction);
|
||||
exportMenu->addAction(exportCSVAction);
|
||||
|
||||
ui->bExport->setMenu(exportMenu);
|
||||
|
||||
connect(exportTouchstone, &QAction::triggered, [&]() {
|
||||
auto e = new TraceTouchstoneExport(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+1, i/2+1, traces[i]);
|
||||
}
|
||||
if(AppWindow::showGUI()) {
|
||||
e->show();
|
||||
}
|
||||
});
|
||||
connect(exportTouchstoneAction, &QAction::triggered, this, &TraceWidgetVNA::exportTouchstone);
|
||||
connect(exportCSVAction, &QAction::triggered, this, &TraceWidgetVNA::exportCSV);
|
||||
}
|
||||
|
||||
connect(exportCSV, &QAction::triggered, [&]() {
|
||||
auto e = new TraceCSVExport(model);
|
||||
if(AppWindow::showGUI()) {
|
||||
e->show();
|
||||
void TraceWidgetVNA::exportCSV()
|
||||
{
|
||||
auto e = new TraceCSVExport(model);
|
||||
if(AppWindow::showGUI()) {
|
||||
e->show();
|
||||
}
|
||||
}
|
||||
|
||||
void TraceWidgetVNA::exportTouchstone()
|
||||
{
|
||||
auto e = new TraceTouchstoneExport(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+1, i/2+1, traces[i]);
|
||||
}
|
||||
if(AppWindow::showGUI()) {
|
||||
e->show();
|
||||
}
|
||||
}
|
||||
|
||||
void TraceWidgetVNA::importDialog()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ class TraceWidgetVNA : public TraceWidget
|
|||
{
|
||||
public:
|
||||
TraceWidgetVNA(TraceModel &model, Calibration &cal, Deembedding &deembed, QWidget *parent = nullptr);
|
||||
protected slots:
|
||||
public slots:
|
||||
void exportCSV();
|
||||
void exportTouchstone();
|
||||
virtual void exportDialog() override {}
|
||||
virtual void importDialog() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -581,6 +581,18 @@ VNA::VNA(AppWindow *window, QString name)
|
|||
window->addDockWidget(Qt::LeftDockWidgetArea, tracesDock);
|
||||
docks.insert(tracesDock);
|
||||
|
||||
auto importAction = new QAction("Touchstone/CSV");
|
||||
connect(importAction, &QAction::triggered, traceWidget, &TraceWidgetVNA::importDialog);
|
||||
importActions.push_back(importAction);
|
||||
|
||||
auto exportTouchstone = new QAction("Touchstone");
|
||||
connect(exportTouchstone, &QAction::triggered, traceWidget, &TraceWidgetVNA::exportTouchstone);
|
||||
exportActions.push_back(exportTouchstone);
|
||||
|
||||
auto exportCSV = new QAction("CSV");
|
||||
connect(exportCSV, &QAction::triggered, traceWidget, &TraceWidgetVNA::exportCSV);
|
||||
exportActions.push_back(exportCSV);
|
||||
|
||||
|
||||
auto markerWidget = new MarkerWidget(*markerModel);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "CustomWidgets/tilewidget.h"
|
||||
#include "Deembedding/deembedding.h"
|
||||
#include "scpi.h"
|
||||
#include "Traces/tracewidget.h"
|
||||
#include "tracewidgetvna.h"
|
||||
#include "Calibration/calibration.h"
|
||||
|
||||
#include <QObject>
|
||||
|
|
@ -38,6 +38,9 @@ public:
|
|||
|
||||
void preset() override;
|
||||
|
||||
QList<QAction*> getImportOptions() override { return importActions;}
|
||||
QList<QAction*> getExportOptions() override { return exportActions;}
|
||||
|
||||
enum class SweepType {
|
||||
Frequency = 0,
|
||||
Power = 1,
|
||||
|
|
@ -140,7 +143,7 @@ private:
|
|||
Settings settings;
|
||||
unsigned int averages;
|
||||
TraceModel traceModel;
|
||||
TraceWidget *traceWidget;
|
||||
TraceWidgetVNA *traceWidget;
|
||||
MarkerModel *markerModel;
|
||||
Averaging average;
|
||||
bool singleSweep;
|
||||
|
|
@ -179,6 +182,10 @@ private:
|
|||
TileWidget *tiles;
|
||||
QScrollArea *central;
|
||||
|
||||
// import/export actions
|
||||
QList<QAction*> importActions;
|
||||
QList<QAction*> exportActions;
|
||||
|
||||
signals:
|
||||
void deviceInitialized();
|
||||
void dataChanged();
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ AppWindow::AppWindow(QWidget *parent)
|
|||
};
|
||||
|
||||
connect(modeHandler, &ModeHandler::StatusBarMessageChanged, setModeStatusbar);
|
||||
connect(modeHandler, &ModeHandler::CurrentModeChanged, this, &AppWindow::UpdateImportExportMenus);
|
||||
|
||||
SetupMenu();
|
||||
|
||||
|
|
@ -1384,6 +1385,27 @@ bool AppWindow::LoadSetup(QString filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
void AppWindow::UpdateImportExportMenus()
|
||||
{
|
||||
// clear menus of all actions first
|
||||
ui->menuImport->clear();
|
||||
ui->menuExport->clear();
|
||||
|
||||
// add action from currently active mode
|
||||
auto active = modeHandler->getActiveMode();
|
||||
if(active) {
|
||||
for(auto a : active->getImportOptions()) {
|
||||
ui->menuImport->addAction(a);
|
||||
}
|
||||
for(auto a : active->getExportOptions()) {
|
||||
ui->menuExport->addAction(a);
|
||||
}
|
||||
}
|
||||
// disable/enable menus
|
||||
ui->menuImport->setEnabled(ui->menuImport->actions().size());
|
||||
ui->menuExport->setEnabled(ui->menuExport->actions().size());
|
||||
}
|
||||
|
||||
void AppWindow::LoadSetup(nlohmann::json j)
|
||||
{
|
||||
// auto d = new JSONPickerDialog(j);
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ private slots:
|
|||
void DeviceInfoUpdated();
|
||||
void SaveSetup(QString filename);
|
||||
bool LoadSetup(QString filename);
|
||||
void UpdateImportExportMenus();
|
||||
private:
|
||||
nlohmann::json SaveSetup();
|
||||
void LoadSetup(nlohmann::json j);
|
||||
|
|
|
|||
|
|
@ -27,9 +27,23 @@
|
|||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuImport">
|
||||
<property name="title">
|
||||
<string>Import</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuExport">
|
||||
<property name="title">
|
||||
<string>Export</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="actionSave_setup"/>
|
||||
<addaction name="actionLoad_setup"/>
|
||||
<addaction name="actionSave_image"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="menuImport"/>
|
||||
<addaction name="menuExport"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuDevice">
|
||||
|
|
@ -232,6 +246,16 @@
|
|||
<string>Create Debug Data</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actiondummy">
|
||||
<property name="text">
|
||||
<string>dummy</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDummy_4">
|
||||
<property name="text">
|
||||
<string>Dummy</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="icons.qrc"/>
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ public:
|
|||
virtual void setAveragingMode(Averaging::Mode mode) = 0;
|
||||
|
||||
virtual void preset() = 0;
|
||||
virtual QList<QAction*> getImportOptions() { return {};}
|
||||
virtual QList<QAction*> getExportOptions() { return {};}
|
||||
|
||||
signals:
|
||||
void statusbarMessage(QString msg);
|
||||
|
|
|
|||
Loading…
Reference in a new issue