Merge branch 'master' of github.com:jankae/LibreVNA
This commit is contained in:
commit
787f0d0223
@ -11,7 +11,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Edit line</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="modal">
|
<property name="modal">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -3,7 +3,12 @@
|
|||||||
#include "ui_xyplotaxisdialog.h"
|
#include "ui_xyplotaxisdialog.h"
|
||||||
#include "traceaxis.h"
|
#include "traceaxis.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
#include <CustomWidgets/informationbox.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -183,16 +188,68 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) :
|
|||||||
ui->removeLine->setEnabled(true);
|
ui->removeLine->setEnabled(true);
|
||||||
editLine(line);
|
editLine(line);
|
||||||
connect(line, &XYPlotConstantLine::editingFinished, [=](){
|
connect(line, &XYPlotConstantLine::editingFinished, [=](){
|
||||||
item->setText(line->getDescription());
|
if(line->getPoints().size() < 2) { // must have 2 points to be a line
|
||||||
|
int index = ui->lineList->currentRow();
|
||||||
|
removeLine(index);
|
||||||
|
} else {
|
||||||
|
item->setText(line->getDescription());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
connect(ui->removeLine, &QPushButton::clicked, [=](){
|
connect(ui->removeLine, &QPushButton::clicked, [=](){
|
||||||
auto index = ui->lineList->currentRow();
|
int index = ui->lineList->currentRow();
|
||||||
delete ui->lineList->takeItem(index);
|
removeLine(index);
|
||||||
delete plot->constantLines[index];
|
});
|
||||||
plot->constantLines.erase(plot->constantLines.begin() + index);
|
connect(ui->exportLines, &QPushButton::clicked, [=](){
|
||||||
if(plot->constantLines.size() == 0) {
|
QString filename = QFileDialog::getSaveFileName(nullptr, "Save limit lines", "", "Limit files (*.limits)", nullptr, QFileDialog::DontUseNativeDialog);
|
||||||
ui->removeLine->setEnabled(false);
|
if(filename.isEmpty()) {
|
||||||
|
// aborted selection
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!filename.endsWith(".limits")) {
|
||||||
|
filename.append(".limits");
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json jlines;
|
||||||
|
for(auto l : plot->constantLines ) {
|
||||||
|
jlines.push_back(l->toJSON());
|
||||||
|
}
|
||||||
|
nlohmann::json j;
|
||||||
|
j["limitLines"] = jlines;
|
||||||
|
|
||||||
|
ofstream file;
|
||||||
|
file.open(filename.toStdString());
|
||||||
|
file << setw(4) << j << endl;
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
});
|
||||||
|
connect(ui->importLines, &QPushButton::clicked, [=](){
|
||||||
|
QString filename = QFileDialog::getOpenFileName(nullptr, "Load limit lines", "", "Limit files (*.limits)", nullptr, QFileDialog::DontUseNativeDialog);
|
||||||
|
ifstream file;
|
||||||
|
file.open(filename.toStdString());
|
||||||
|
if(!file.is_open()) {
|
||||||
|
qWarning() << "Unable to open file:" << filename;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nlohmann::json j;
|
||||||
|
try {
|
||||||
|
file >> j;
|
||||||
|
} catch (exception &e) {
|
||||||
|
InformationBox::ShowError("Error", "Failed to parse file (" + QString(e.what()) + ")");
|
||||||
|
qWarning() << "Parsing of limits file failed: " << e.what();
|
||||||
|
file.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
if(j.contains("limitLines")) {
|
||||||
|
for(auto jline : j["limitLines"]) {
|
||||||
|
auto line = new XYPlotConstantLine;
|
||||||
|
line->fromJSON(jline);
|
||||||
|
plot->constantLines.push_back(line);
|
||||||
|
auto item = new QListWidgetItem(line->getDescription());
|
||||||
|
ui->lineList->addItem(item);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -276,3 +333,15 @@ bool XYplotAxisDialog::isSupported(XAxis::Type type)
|
|||||||
{
|
{
|
||||||
return XAxis::isSupported(type, plot->getModel().getSource());
|
return XAxis::isSupported(type, plot->getModel().getSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XYplotAxisDialog::removeLine(int index) {
|
||||||
|
if (index < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete ui->lineList->takeItem(index);
|
||||||
|
delete plot->constantLines[index];
|
||||||
|
plot->constantLines.erase(plot->constantLines.begin() + index);
|
||||||
|
if(plot->constantLines.size() == 0) {
|
||||||
|
ui->removeLine->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -26,6 +26,7 @@ private:
|
|||||||
bool isSupported(XAxis::Type type);
|
bool isSupported(XAxis::Type type);
|
||||||
Ui::XYplotAxisDialog *ui;
|
Ui::XYplotAxisDialog *ui;
|
||||||
TraceXYPlot *plot;
|
TraceXYPlot *plot;
|
||||||
|
void removeLine(int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // XYPLOTAXISDIALOG_H
|
#endif // XYPLOTAXISDIALOG_H
|
||||||
|
@ -489,6 +489,34 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="exportLines">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Export</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../icons.qrc">
|
||||||
|
<normaloff>:/icons/export.png</normaloff>:/icons/export.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="importLines">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Import</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../icons.qrc">
|
||||||
|
<normaloff>:/icons/import.png</normaloff>:/icons/import.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -564,8 +592,8 @@
|
|||||||
</connection>
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="Y2group"/>
|
|
||||||
<buttongroup name="Y1group"/>
|
<buttongroup name="Y1group"/>
|
||||||
<buttongroup name="Xgroup"/>
|
<buttongroup name="Xgroup"/>
|
||||||
|
<buttongroup name="Y2group"/>
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -248,6 +248,58 @@ AppWindow::AppWindow(QWidget *parent)
|
|||||||
|
|
||||||
connect(modeHandler, &ModeHandler::StatusBarMessageChanged, setModeStatusbar);
|
connect(modeHandler, &ModeHandler::StatusBarMessageChanged, setModeStatusbar);
|
||||||
|
|
||||||
|
SetupMenu();
|
||||||
|
|
||||||
|
setWindowTitle(qlibrevnaApp->applicationName() + " v" + getAppVersion());
|
||||||
|
|
||||||
|
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
||||||
|
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||||
|
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
||||||
|
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
|
||||||
|
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
restoreGeometry(settings.value("geometry").toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
SetupSCPI();
|
||||||
|
|
||||||
|
auto pref = Preferences::getInstance();
|
||||||
|
if(pref.Startup.UseSetupFile) {
|
||||||
|
LoadSetup(pref.Startup.SetupFile);
|
||||||
|
}
|
||||||
|
// List available devices
|
||||||
|
UpdateDeviceList();
|
||||||
|
if(pref.Startup.ConnectToFirstDevice) {
|
||||||
|
// at least one device available
|
||||||
|
ConnectToDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parser.isSet("setup")) {
|
||||||
|
LoadSetup(parser.value("setup"));
|
||||||
|
}
|
||||||
|
if(parser.isSet("cal")) {
|
||||||
|
VNA* mode = static_cast<VNA*>(modeHandler->findFirstOfType(Mode::Type::VNA));
|
||||||
|
mode->LoadCalibration(parser.value("cal"));
|
||||||
|
}
|
||||||
|
if(!parser.isSet("no-gui")) {
|
||||||
|
InformationBox::setGUI(true);
|
||||||
|
resize(1280, 800);
|
||||||
|
show();
|
||||||
|
} else {
|
||||||
|
InformationBox::setGUI(false);
|
||||||
|
noGUIset = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AppWindow::~AppWindow()
|
||||||
|
{
|
||||||
|
StopTCPServer();
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppWindow::SetupMenu()
|
||||||
|
{
|
||||||
// UI connections
|
// UI connections
|
||||||
connect(ui->actionUpdate_Device_List, &QAction::triggered, this, &AppWindow::UpdateDeviceList);
|
connect(ui->actionUpdate_Device_List, &QAction::triggered, this, &AppWindow::UpdateDeviceList);
|
||||||
connect(ui->actionDisconnect, &QAction::triggered, this, &AppWindow::DisconnectDevice);
|
connect(ui->actionDisconnect, &QAction::triggered, this, &AppWindow::DisconnectDevice);
|
||||||
@ -329,53 +381,6 @@ AppWindow::AppWindow(QWidget *parent)
|
|||||||
auto &a = About::getInstance();
|
auto &a = About::getInstance();
|
||||||
a.about();
|
a.about();
|
||||||
});
|
});
|
||||||
|
|
||||||
setWindowTitle(qlibrevnaApp->applicationName() + " v" + getAppVersion());
|
|
||||||
|
|
||||||
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
|
||||||
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
|
||||||
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
|
||||||
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
|
|
||||||
|
|
||||||
{
|
|
||||||
QSettings settings;
|
|
||||||
restoreGeometry(settings.value("geometry").toByteArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
SetupSCPI();
|
|
||||||
|
|
||||||
auto pref = Preferences::getInstance();
|
|
||||||
if(pref.Startup.UseSetupFile) {
|
|
||||||
LoadSetup(pref.Startup.SetupFile);
|
|
||||||
}
|
|
||||||
// List available devices
|
|
||||||
UpdateDeviceList();
|
|
||||||
if(pref.Startup.ConnectToFirstDevice) {
|
|
||||||
// at least one device available
|
|
||||||
ConnectToDevice();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(parser.isSet("setup")) {
|
|
||||||
LoadSetup(parser.value("setup"));
|
|
||||||
}
|
|
||||||
if(parser.isSet("cal")) {
|
|
||||||
VNA* mode = static_cast<VNA*>(modeHandler->findFirstOfType(Mode::Type::VNA));
|
|
||||||
mode->LoadCalibration(parser.value("cal"));
|
|
||||||
}
|
|
||||||
if(!parser.isSet("no-gui")) {
|
|
||||||
InformationBox::setGUI(true);
|
|
||||||
resize(1280, 800);
|
|
||||||
show();
|
|
||||||
} else {
|
|
||||||
InformationBox::setGUI(false);
|
|
||||||
noGUIset = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AppWindow::~AppWindow()
|
|
||||||
{
|
|
||||||
StopTCPServer();
|
|
||||||
delete ui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppWindow::closeEvent(QCloseEvent *event)
|
void AppWindow::closeEvent(QCloseEvent *event)
|
||||||
@ -937,6 +942,7 @@ int AppWindow::UpdateDeviceList()
|
|||||||
devices.insert(device->serial());
|
devices.insert(device->serial());
|
||||||
}
|
}
|
||||||
int available = 0;
|
int available = 0;
|
||||||
|
bool found = false;
|
||||||
if(devices.size()) {
|
if(devices.size()) {
|
||||||
for(auto d : devices) {
|
for(auto d : devices) {
|
||||||
if(!parser.value("device").isEmpty() && parser.value("device") != d) {
|
if(!parser.value("device").isEmpty() && parser.value("device") != d) {
|
||||||
@ -952,13 +958,11 @@ int AppWindow::UpdateDeviceList()
|
|||||||
connect(connectAction, &QAction::triggered, [this, d]() {
|
connect(connectAction, &QAction::triggered, [this, d]() {
|
||||||
ConnectToDevice(d);
|
ConnectToDevice(d);
|
||||||
});
|
});
|
||||||
ui->menuConnect_to->setEnabled(true);
|
found = true;
|
||||||
available++;
|
available++;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// no devices available, disable connection option
|
|
||||||
ui->menuConnect_to->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
ui->menuConnect_to->setEnabled(found);
|
||||||
qDebug() << "Updated device list, found" << available;
|
qDebug() << "Updated device list, found" << available;
|
||||||
return available;
|
return available;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ private:
|
|||||||
|
|
||||||
void DeviceConnectionLost();
|
void DeviceConnectionLost();
|
||||||
|
|
||||||
|
void SetupMenu();
|
||||||
void SetupStatusBar();
|
void SetupStatusBar();
|
||||||
void UpdateStatusBar(DeviceStatusBar status);
|
void UpdateStatusBar(DeviceStatusBar status);
|
||||||
void CreateToolbars();
|
void CreateToolbars();
|
||||||
|
@ -9,11 +9,10 @@
|
|||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
|
||||||
ModeWindow::ModeWindow(ModeHandler* handler, AppWindow* aw):
|
ModeWindow::ModeWindow(ModeHandler* handler, AppWindow* aw):
|
||||||
QWidget(aw),
|
QWidget(nullptr),
|
||||||
handler(handler),
|
handler(handler),
|
||||||
aw(aw)
|
aw(aw)
|
||||||
{
|
{
|
||||||
|
|
||||||
SetupUi();
|
SetupUi();
|
||||||
|
|
||||||
connect(handler, &ModeHandler::ModeCreated, this, &ModeWindow::ModeCreated);
|
connect(handler, &ModeHandler::ModeCreated, this, &ModeWindow::ModeCreated);
|
||||||
@ -63,7 +62,7 @@ void ModeWindow::SetupUi()
|
|||||||
mAdd->addAction(action);
|
mAdd->addAction(action);
|
||||||
connect(action, &QAction::triggered, [=](){
|
connect(action, &QAction::triggered, [=](){
|
||||||
bool ok;
|
bool ok;
|
||||||
QString text = QInputDialog::getText(this,
|
QString text = QInputDialog::getText(aw,
|
||||||
"Create new "+Mode::TypeToName(type)+" tab",
|
"Create new "+Mode::TypeToName(type)+" tab",
|
||||||
"Name:", QLineEdit::Normal,
|
"Name:", QLineEdit::Normal,
|
||||||
Mode::TypeToName(type), &ok);
|
Mode::TypeToName(type), &ok);
|
||||||
|
Loading…
Reference in New Issue
Block a user