Save/load trace and graph setup

This commit is contained in:
Jan Käberich 2020-12-04 23:49:52 +01:00
parent b91f431473
commit 9ad8def2ea
33 changed files with 605 additions and 28 deletions

View file

@ -1,5 +1,6 @@
#include "tracemodel.h"
#include <QIcon>
#include <QDebug>
using namespace std;
@ -164,6 +165,32 @@ bool TraceModel::PortExcitationRequired(int port)
return false;
}
nlohmann::json TraceModel::toJSON()
{
nlohmann::json j;
for(auto t : traces) {
j.push_back(t->toJSON());
}
return j;
}
void TraceModel::fromJSON(nlohmann::json j)
{
// clear old traces
while(traces.size()) {
removeTrace(0);
}
for(auto jt : j) {
auto trace = new Trace();
try {
trace->fromJSON(jt);
addTrace(trace);
} catch (const exception &e) {
qWarning() << "Failed to create trace:" << e.what();
}
}
}
void TraceModel::clearVNAData()
{
for(auto t : traces) {