2020-09-12 05:07:15 +08:00
|
|
|
#ifndef PREFERENCESDIALOG_H
|
|
|
|
#define PREFERENCESDIALOG_H
|
|
|
|
|
2021-10-21 19:00:34 +08:00
|
|
|
#include "Util/qpointervariant.h"
|
2022-01-16 00:00:57 +08:00
|
|
|
#include "savable.h"
|
2021-10-21 19:00:34 +08:00
|
|
|
|
2022-08-06 00:29:31 +08:00
|
|
|
#include "Device/compounddevice.h"
|
|
|
|
|
2020-09-12 05:07:15 +08:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <exception>
|
|
|
|
|
2021-07-10 19:12:30 +08:00
|
|
|
enum GraphDomainChangeBehavior {
|
|
|
|
RemoveChangedTraces = 0,
|
|
|
|
AdjustGraphs = 1,
|
|
|
|
AdjustGrahpsIfOnlyTrace = 2,
|
|
|
|
};
|
|
|
|
|
2022-08-06 00:29:31 +08:00
|
|
|
Q_DECLARE_METATYPE(GraphDomainChangeBehavior)
|
2021-07-10 19:12:30 +08:00
|
|
|
|
2022-04-22 19:46:46 +08:00
|
|
|
enum GraphLimitIndication {
|
|
|
|
DontShowAnything = 0,
|
|
|
|
PassFailText = 1,
|
|
|
|
Overlay = 2,
|
|
|
|
};
|
|
|
|
|
2022-08-06 00:29:31 +08:00
|
|
|
Q_DECLARE_METATYPE(GraphLimitIndication)
|
2022-04-22 19:46:46 +08:00
|
|
|
|
2022-07-09 21:02:36 +08:00
|
|
|
enum MarkerSortOrder {
|
|
|
|
PrefMarkerSortXCoord = 0,
|
|
|
|
PrefMarkerSortNumber = 1,
|
|
|
|
PrefMarkerSortTimestamp = 2,
|
|
|
|
};
|
|
|
|
|
2022-08-06 00:29:31 +08:00
|
|
|
Q_DECLARE_METATYPE(MarkerSortOrder)
|
2022-07-09 21:02:36 +08:00
|
|
|
|
2021-07-10 19:12:30 +08:00
|
|
|
|
2022-01-16 00:00:57 +08:00
|
|
|
class Preferences : public Savable {
|
2020-09-12 05:07:15 +08:00
|
|
|
public:
|
2020-10-23 03:12:33 +08:00
|
|
|
static Preferences& getInstance() {
|
|
|
|
return instance;
|
|
|
|
}
|
2020-09-12 05:07:15 +08:00
|
|
|
void load();
|
|
|
|
void store();
|
|
|
|
void edit();
|
|
|
|
void setDefault();
|
|
|
|
|
2021-04-11 18:33:37 +08:00
|
|
|
void manualTCPport() { TCPoverride = true; }
|
|
|
|
|
2020-09-12 05:07:15 +08:00
|
|
|
struct {
|
|
|
|
bool ConnectToFirstDevice;
|
|
|
|
bool RememberSweepSettings;
|
2022-01-30 06:31:58 +08:00
|
|
|
bool UseSetupFile;
|
2022-01-31 01:09:47 +08:00
|
|
|
bool AutosaveSetupFile;
|
2022-01-30 06:31:58 +08:00
|
|
|
QString SetupFile;
|
2020-09-12 05:07:15 +08:00
|
|
|
struct {
|
2021-07-10 04:26:44 +08:00
|
|
|
QString type;
|
|
|
|
double f_start;
|
|
|
|
double f_stop;
|
2022-01-05 23:01:51 +08:00
|
|
|
bool logSweep;
|
2021-07-10 04:26:44 +08:00
|
|
|
double f_excitation;
|
|
|
|
|
|
|
|
double dbm_start;
|
|
|
|
double dbm_stop;
|
|
|
|
double dbm_freq;
|
|
|
|
|
2020-09-12 05:07:15 +08:00
|
|
|
int points;
|
|
|
|
double bandwidth;
|
2020-10-23 17:39:07 +08:00
|
|
|
int averaging;
|
2020-09-12 05:07:15 +08:00
|
|
|
} DefaultSweep;
|
2020-10-22 23:13:36 +08:00
|
|
|
struct {
|
|
|
|
double frequency;
|
|
|
|
double level;
|
|
|
|
} Generator;
|
|
|
|
struct {
|
|
|
|
double start;
|
|
|
|
double stop;
|
|
|
|
double RBW;
|
|
|
|
int window;
|
|
|
|
int detector;
|
2020-10-23 17:39:07 +08:00
|
|
|
int averaging;
|
2020-10-22 23:13:36 +08:00
|
|
|
bool signalID;
|
|
|
|
} SA;
|
2020-09-12 05:07:15 +08:00
|
|
|
} Startup;
|
2020-09-16 05:22:08 +08:00
|
|
|
struct {
|
|
|
|
bool alwaysExciteBothPorts;
|
2020-09-20 16:13:06 +08:00
|
|
|
bool suppressPeaks;
|
2021-07-10 04:26:44 +08:00
|
|
|
bool adjustPowerLevel;
|
2020-12-18 22:03:01 +08:00
|
|
|
bool harmonicMixing;
|
2022-03-07 06:01:11 +08:00
|
|
|
bool allowSegmentedSweep;
|
2020-11-07 20:22:10 +08:00
|
|
|
bool useDFTinSAmode;
|
|
|
|
double RBWLimitForDFT;
|
2021-12-02 05:11:50 +08:00
|
|
|
bool useMedianAveraging;
|
2022-01-15 23:11:33 +08:00
|
|
|
|
|
|
|
// advanced, hardware specific settings
|
|
|
|
double IF1;
|
|
|
|
int ADCprescaler;
|
|
|
|
int DFTPhaseInc;
|
2020-09-16 05:22:08 +08:00
|
|
|
} Acquisition;
|
2020-10-23 03:12:33 +08:00
|
|
|
struct {
|
2021-12-27 23:13:03 +08:00
|
|
|
bool showUnits;
|
2020-10-23 03:12:33 +08:00
|
|
|
struct {
|
|
|
|
QColor background;
|
|
|
|
QColor axis;
|
2021-10-18 06:37:40 +08:00
|
|
|
struct {
|
|
|
|
QColor divisions;
|
|
|
|
struct {
|
|
|
|
bool enabled;
|
|
|
|
QColor background;
|
|
|
|
} Background;
|
|
|
|
} Ticks;
|
2021-07-10 19:12:30 +08:00
|
|
|
} Color;
|
|
|
|
GraphDomainChangeBehavior domainChangeBehavior;
|
2022-04-22 19:46:46 +08:00
|
|
|
GraphLimitIndication limitIndication;
|
2022-01-07 19:37:47 +08:00
|
|
|
|
|
|
|
double lineWidth;
|
2022-04-20 21:19:58 +08:00
|
|
|
int fontSizeAxis;
|
|
|
|
int fontSizeMarkerData;
|
|
|
|
int fontSizeTraceNames;
|
|
|
|
int fontSizeCursorOverlay;
|
2022-01-07 19:37:47 +08:00
|
|
|
} Graphs;
|
|
|
|
struct {
|
2021-05-15 02:34:23 +08:00
|
|
|
struct {
|
|
|
|
bool showDataOnGraphs;
|
|
|
|
bool showAllData;
|
2022-01-07 19:37:47 +08:00
|
|
|
} defaultBehavior;
|
|
|
|
bool interpolatePoints;
|
2022-07-09 21:02:36 +08:00
|
|
|
MarkerSortOrder sortOrder;
|
2022-01-07 19:37:47 +08:00
|
|
|
} Marker;
|
2021-07-10 19:12:30 +08:00
|
|
|
struct {
|
|
|
|
bool enabled;
|
|
|
|
int port;
|
|
|
|
} SCPIServer;
|
2021-04-11 18:33:37 +08:00
|
|
|
|
|
|
|
bool TCPoverride; // in case of manual port specification via command line
|
2022-01-16 00:00:57 +08:00
|
|
|
|
2022-08-06 00:29:31 +08:00
|
|
|
QString compoundDeviceJSON;
|
|
|
|
std::vector<CompoundDevice*> compoundDevices;
|
|
|
|
|
2022-01-16 00:00:57 +08:00
|
|
|
void fromJSON(nlohmann::json j) override;
|
|
|
|
nlohmann::json toJSON() override;
|
|
|
|
|
2022-08-06 00:29:31 +08:00
|
|
|
void nonTrivialParsing();
|
|
|
|
void nonTrivialWriting();
|
|
|
|
|
2020-09-12 05:07:15 +08:00
|
|
|
private:
|
2021-04-11 18:33:37 +08:00
|
|
|
Preferences() :
|
2022-08-06 00:29:31 +08:00
|
|
|
TCPoverride(false) {}
|
2020-10-23 03:12:33 +08:00
|
|
|
static Preferences instance;
|
2022-01-16 00:00:57 +08:00
|
|
|
|
|
|
|
const std::vector<Savable::SettingDescription> descr = {{
|
2020-09-12 05:07:15 +08:00
|
|
|
{&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true},
|
|
|
|
{&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false},
|
2022-01-30 06:31:58 +08:00
|
|
|
{&Startup.UseSetupFile, "Startup.UseSetupFile", false},
|
|
|
|
{&Startup.SetupFile, "Startup.SetupFile", ""},
|
2022-01-31 01:09:47 +08:00
|
|
|
{&Startup.AutosaveSetupFile, "Startup.AutosaveSetupFile", false},
|
2021-07-10 04:26:44 +08:00
|
|
|
{&Startup.DefaultSweep.type, "Startup.DefaultSweep.type", "Frequency"},
|
|
|
|
{&Startup.DefaultSweep.f_start, "Startup.DefaultSweep.start", 1000000.0},
|
|
|
|
{&Startup.DefaultSweep.f_stop, "Startup.DefaultSweep.stop", 6000000000.0},
|
2022-01-05 23:01:51 +08:00
|
|
|
{&Startup.DefaultSweep.logSweep, "Startup.DefaultSweep.logSweep", false},
|
2021-07-10 04:26:44 +08:00
|
|
|
{&Startup.DefaultSweep.f_excitation, "Startup.DefaultSweep.excitation", -10.00},
|
|
|
|
{&Startup.DefaultSweep.dbm_start, "Startup.DefaultSweep.dbm_start", -30.00},
|
|
|
|
{&Startup.DefaultSweep.dbm_stop, "Startup.DefaultSweep.dbm_stop", -10.0},
|
|
|
|
{&Startup.DefaultSweep.dbm_freq, "Startup.DefaultSweep.dbm_freq", 1000000000.0},
|
2020-09-12 05:07:15 +08:00
|
|
|
{&Startup.DefaultSweep.points, "Startup.DefaultSweep.points", 501},
|
|
|
|
{&Startup.DefaultSweep.bandwidth, "Startup.DefaultSweep.bandwidth", 1000.0},
|
2020-10-23 17:39:07 +08:00
|
|
|
{&Startup.DefaultSweep.averaging, "Startup.DefaultSweep.averaging", 1},
|
2020-10-22 23:13:36 +08:00
|
|
|
{&Startup.Generator.frequency, "Startup.Generator.frequency", 1000000000.0},
|
|
|
|
{&Startup.Generator.level, "Startup.Generator.level", -10.00},
|
|
|
|
{&Startup.SA.start, "Startup.SA.start", 950000000.0},
|
|
|
|
{&Startup.SA.stop, "Startup.SA.stop", 1050000000.0},
|
|
|
|
{&Startup.SA.RBW, "Startup.SA.RBW", 10000.0},
|
|
|
|
{&Startup.SA.window, "Startup.SA.window", 1},
|
|
|
|
{&Startup.SA.detector, "Startup.SA.detector", 0},
|
2020-10-23 17:39:07 +08:00
|
|
|
{&Startup.SA.averaging, "Startup.SA.averaging", 1},
|
2020-10-22 23:13:36 +08:00
|
|
|
{&Startup.SA.signalID, "Startup.SA.signalID", true},
|
2020-09-16 22:13:06 +08:00
|
|
|
{&Acquisition.alwaysExciteBothPorts, "Acquisition.alwaysExciteBothPorts", true},
|
2020-10-23 03:12:33 +08:00
|
|
|
{&Acquisition.suppressPeaks, "Acquisition.suppressPeaks", true},
|
2021-07-10 04:26:44 +08:00
|
|
|
{&Acquisition.adjustPowerLevel, "Acquisition.adjustPowerLevel", false},
|
2020-12-18 22:03:01 +08:00
|
|
|
{&Acquisition.harmonicMixing, "Acquisition.harmonicMixing", false},
|
2022-03-07 06:01:11 +08:00
|
|
|
{&Acquisition.allowSegmentedSweep, "Acquisition.allowSegmentedSweep", false},
|
2020-11-07 20:22:10 +08:00
|
|
|
{&Acquisition.useDFTinSAmode, "Acquisition.useDFTinSAmode", true},
|
|
|
|
{&Acquisition.RBWLimitForDFT, "Acquisition.RBWLimitForDFT", 3000.0},
|
2021-12-02 05:11:50 +08:00
|
|
|
{&Acquisition.useMedianAveraging, "Acquisition.useMedianAveraging", false},
|
2022-01-15 23:11:33 +08:00
|
|
|
{&Acquisition.IF1, "Acquisition.IF1", 62000000},
|
|
|
|
{&Acquisition.ADCprescaler, "Acquisition.ADCprescaler", 128},
|
|
|
|
{&Acquisition.DFTPhaseInc, "Acquisition.DFTPhaseInc", 1280},
|
2021-12-27 23:13:03 +08:00
|
|
|
{&Graphs.showUnits, "Graphs.showUnits", true},
|
2021-07-10 19:12:30 +08:00
|
|
|
{&Graphs.Color.background, "Graphs.Color.background", QColor(Qt::black)},
|
|
|
|
{&Graphs.Color.axis, "Graphs.Color.axis", QColor(Qt::white)},
|
2021-10-18 06:37:40 +08:00
|
|
|
{&Graphs.Color.Ticks.Background.enabled, "Graphs.Color.Ticks.Background.enabled", true},
|
2021-10-26 02:41:58 +08:00
|
|
|
{&Graphs.Color.Ticks.Background.background, "Graphs.Color.Ticks.Background.background", QColor(20, 20, 20)},
|
2021-10-18 06:37:40 +08:00
|
|
|
{&Graphs.Color.Ticks.divisions, "Graphs.Color.Ticks.divisions", QColor(Qt::gray)},
|
2021-07-10 19:12:30 +08:00
|
|
|
{&Graphs.domainChangeBehavior, "Graphs.domainChangeBehavior", GraphDomainChangeBehavior::AdjustGraphs},
|
2022-04-22 19:46:46 +08:00
|
|
|
{&Graphs.limitIndication, "Graphs.limitIndication", GraphLimitIndication::PassFailText},
|
2021-12-06 01:26:32 +08:00
|
|
|
{&Graphs.lineWidth, "Graphs.lineWidth", 1.0},
|
2022-04-20 21:19:58 +08:00
|
|
|
{&Graphs.fontSizeAxis, "Graphs.fontSizeAxis", 10},
|
|
|
|
{&Graphs.fontSizeCursorOverlay, "Graphs.fontSizeCursorOverlay", 12},
|
|
|
|
{&Graphs.fontSizeMarkerData, "Graphs.fontSizeMarkerData", 12},
|
|
|
|
{&Graphs.fontSizeTraceNames, "Graphs.fontSizeTraceNames", 12},
|
2022-01-07 19:37:47 +08:00
|
|
|
{&Marker.defaultBehavior.showDataOnGraphs, "Marker.defaultBehavior.ShowDataOnGraphs", true},
|
|
|
|
{&Marker.defaultBehavior.showAllData, "Marker.defaultBehavior.ShowAllData", false},
|
|
|
|
{&Marker.interpolatePoints, "Marker.interpolatePoints", false},
|
2022-07-09 21:02:36 +08:00
|
|
|
{&Marker.sortOrder, "Marker.sortOrder", MarkerSortOrder::PrefMarkerSortXCoord},
|
2021-07-10 19:12:30 +08:00
|
|
|
{&SCPIServer.enabled, "SCPIServer.enabled", true},
|
|
|
|
{&SCPIServer.port, "SCPIServer.port", 19542},
|
2022-08-06 00:29:31 +08:00
|
|
|
{&compoundDeviceJSON, "compoundDeviceJSON", "[]"},
|
2020-09-12 05:07:15 +08:00
|
|
|
}};
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class PreferencesDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
class PreferencesDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit PreferencesDialog(Preferences *pref, QWidget *parent = nullptr);
|
|
|
|
~PreferencesDialog();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setInitialGUIState();
|
2022-01-16 00:00:57 +08:00
|
|
|
void updateFromGUI();
|
2020-09-12 05:07:15 +08:00
|
|
|
Ui::PreferencesDialog *ui;
|
|
|
|
Preferences *p;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PREFERENCESDIALOG_H
|