mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-07 07:23:43 +00:00
Save/load trace and graph setup
This commit is contained in:
parent
b91f431473
commit
9ad8def2ea
33 changed files with 605 additions and 28 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include <QLabel>
|
||||
#include <QFormLayout>
|
||||
#include "CustomWidgets/siunitedit.h"
|
||||
#include <QDebug>
|
||||
|
||||
QString WindowFunction::typeToName(WindowFunction::Type type)
|
||||
{
|
||||
|
|
@ -108,6 +109,45 @@ QString WindowFunction::getDescription()
|
|||
return ret;
|
||||
}
|
||||
|
||||
nlohmann::json WindowFunction::toJSON()
|
||||
{
|
||||
nlohmann::json j;
|
||||
j["type"] = typeToName(type).toStdString();
|
||||
// add additional parameter if type has one
|
||||
switch(type) {
|
||||
case Type::Gaussian:
|
||||
j["sigma"] = gaussian_sigma;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
void WindowFunction::fromJSON(nlohmann::json j)
|
||||
{
|
||||
qDebug() << "Setting window function from json";
|
||||
QString typeName = QString::fromStdString(j["type"]);
|
||||
unsigned int i=0;
|
||||
for(;i<(int) Type::Last;i++) {
|
||||
if(typeToName((Type) i) == typeName) {
|
||||
type = Type(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i>=(int) Type::Last) {
|
||||
qWarning() << "Invalid window type specified, defaulting to hamming";
|
||||
type = Type::Hamming;
|
||||
}
|
||||
switch(type) {
|
||||
case Type::Gaussian:
|
||||
gaussian_sigma = j.value("sigma", 0.4);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double WindowFunction::getFactor(unsigned int n, unsigned int N)
|
||||
{
|
||||
// all formulas from https://en.wikipedia.org/wiki/Window_function
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue