diff --git a/Software/PC_Application/Application.pro b/Software/PC_Application/Application.pro index 828af30..b0337a0 100644 --- a/Software/PC_Application/Application.pro +++ b/Software/PC_Application/Application.pro @@ -5,6 +5,7 @@ HEADERS += \ Calibration/calkit.h \ Calibration/calkitdialog.h \ Calibration/measurementmodel.h \ + CustomWidgets/colorpickerbutton.h \ CustomWidgets/siunitedit.h \ CustomWidgets/tilewidget.h \ CustomWidgets/toggleswitch.h \ @@ -47,6 +48,7 @@ SOURCES += \ Calibration/calkit.cpp \ Calibration/calkitdialog.cpp \ Calibration/measurementmodel.cpp \ + CustomWidgets/colorpickerbutton.cpp \ CustomWidgets/qwtplotpiecewisecurve.cpp \ CustomWidgets/siunitedit.cpp \ CustomWidgets/tilewidget.cpp \ diff --git a/Software/PC_Application/CustomWidgets/colorpickerbutton.cpp b/Software/PC_Application/CustomWidgets/colorpickerbutton.cpp new file mode 100644 index 0000000..c6fe35f --- /dev/null +++ b/Software/PC_Application/CustomWidgets/colorpickerbutton.cpp @@ -0,0 +1,35 @@ +#include "colorpickerbutton.h" +#include + +ColorPickerButton::ColorPickerButton(QWidget *parent) + : QPushButton(parent) +{ + color = Qt::white; + connect(this, &ColorPickerButton::clicked, this, &ColorPickerButton::changeColor); + updateBackground(); +} + +void ColorPickerButton::setColor(const QColor &color) +{ + this->color = color; + updateBackground(); +} + +const QColor &ColorPickerButton::getColor() +{ + return color; +} + +void ColorPickerButton::changeColor() +{ + auto newColor = QColorDialog::getColor(color, parentWidget(), "Select color", QColorDialog::DontUseNativeDialog); + if(newColor.isValid() && newColor != color) { + setColor(newColor); + emit colorChanged(newColor); + } +} + +void ColorPickerButton::updateBackground() +{ + setStyleSheet("background-color:"+color.name()); +} diff --git a/Software/PC_Application/CustomWidgets/colorpickerbutton.h b/Software/PC_Application/CustomWidgets/colorpickerbutton.h new file mode 100644 index 0000000..a410325 --- /dev/null +++ b/Software/PC_Application/CustomWidgets/colorpickerbutton.h @@ -0,0 +1,23 @@ +#ifndef COLORPICKERBUTTON_H +#define COLORPICKERBUTTON_H + +#include + +class ColorPickerButton : public QPushButton +{ + Q_OBJECT +public: + ColorPickerButton(QWidget *parent = nullptr); + + void setColor(const QColor& color); + const QColor& getColor(); +signals: + void colorChanged(const QColor& color); +private slots: + void changeColor(); +private: + void updateBackground(); + QColor color; +}; + +#endif // COLORPICKERBUTTON_H diff --git a/Software/PC_Application/Generator/generator.cpp b/Software/PC_Application/Generator/generator.cpp index 866ae37..ae274ed 100644 --- a/Software/PC_Application/Generator/generator.cpp +++ b/Software/PC_Application/Generator/generator.cpp @@ -6,6 +6,8 @@ Generator::Generator(AppWindow *window) { central = new SignalgeneratorWidget(); + auto pref = Preferences::getInstance(); + // set initial values if(pref.Startup.RememberSweepSettings) { QSettings s; diff --git a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp index b5a9636..f6b5430 100644 --- a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -184,6 +184,7 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window) qRegisterMetaType("SpectrumResult"); // Set initial sweep settings + auto pref = Preferences::getInstance(); if(pref.Startup.RememberSweepSettings) { LoadSweepSettings(); } else { @@ -364,6 +365,7 @@ void SpectrumAnalyzer::ConstrainAndUpdateFrequencies() void SpectrumAnalyzer::LoadSweepSettings() { QSettings s; + auto pref = Preferences::getInstance(); settings.f_start = s.value("SAStart", pref.Startup.SA.start).toULongLong(); settings.f_stop = s.value("SAStop", pref.Startup.SA.stop).toULongLong(); ConstrainAndUpdateFrequencies(); diff --git a/Software/PC_Application/Traces/tracebodeplot.cpp b/Software/PC_Application/Traces/tracebodeplot.cpp index cceafa1..063e9c2 100644 --- a/Software/PC_Application/Traces/tracebodeplot.cpp +++ b/Software/PC_Application/Traces/tracebodeplot.cpp @@ -1,6 +1,5 @@ #include "tracebodeplot.h" #include -#include #include "qwtplotpiecewisecurve.h" #include "qwt_series_data.h" #include "trace.h" @@ -13,9 +12,12 @@ #include #include #include "bodeplotaxisdialog.h" +#include using namespace std; +set TraceBodePlot::allPlots; + static double AxisTransformation(TraceBodePlot::YAxisType type, complex data) { switch(type) { case TraceBodePlot::YAxisType::Magnitude: return 20*log10(abs(data)); break; @@ -58,16 +60,14 @@ TraceBodePlot::TraceBodePlot(TraceModel &model, QWidget *parent) selectedMarker(nullptr) { plot = new QwtPlot(this); - plot->setCanvasBackground(Background); - auto pal = plot->palette(); - pal.setColor(QPalette::Window, Background); - pal.setColor(QPalette::WindowText, Border); - pal.setColor(QPalette::Text, Border); + auto canvas = new QwtPlotCanvas(plot); canvas->setFrameStyle(QFrame::Plain); plot->setCanvas(canvas); - plot->setPalette(pal); plot->setAutoFillBackground(true); + grid = new QwtPlotGrid(); + grid->attach(plot); + setColorFromPreferences(); auto selectPicker = new BodeplotPicker(plot->xBottom, plot->yLeft, QwtPicker::NoRubberBand, QwtPicker::ActiveOnly, plot->canvas()); selectPicker->setStateMachine(new QwtPickerClickPointMachine); @@ -81,15 +81,11 @@ TraceBodePlot::TraceBodePlot(TraceModel &model, QWidget *parent) // Marker movement connect(drawPicker, SIGNAL(moved(QPointF)), this, SLOT(moved(QPointF))); - QwtPlotGrid *grid = new QwtPlotGrid(); - grid->setMajorPen(QPen(Divisions, 1.0, Qt::DotLine)); - grid->attach(plot); auto layout = new QGridLayout; layout->addWidget(plot); layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); plot->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); -// plot->plotLayout()->setAlignCanvasToScales(true); initializeTraceInfo(model); setAutoFillBackground(true); @@ -101,6 +97,8 @@ TraceBodePlot::TraceBodePlot(TraceModel &model, QWidget *parent) setXAxis(true, 0, 6000000000, 600000000); // get notified when the span changes connect(&model, &TraceModel::SpanChanged, this, qOverload(&TraceBodePlot::setXAxis)); + + allPlots.insert(this); } TraceBodePlot::~TraceBodePlot() @@ -111,6 +109,7 @@ TraceBodePlot::~TraceBodePlot() } } delete drawPicker; + allPlots.erase(this); } void TraceBodePlot::setXAxis(double min, double max) @@ -187,32 +186,16 @@ void TraceBodePlot::enableTrace(Trace *t, bool enabled) } } +void TraceBodePlot::updateGraphColors() +{ + for(auto p : allPlots) { + p->setColorFromPreferences(); + } +} + void TraceBodePlot::updateContextMenu() { contextmenu->clear(); -// for(int axis = 0;axis < 2;axis++) { -// QMenu *axisMenu; -// if(axis == 0) { -// axisMenu = contextmenu->addMenu("Primary Axis"); -// } else { -// axisMenu = contextmenu->addMenu("Secondary Axis"); -// } -// auto group = new QActionGroup(this); -// for(int i=0;i<(int) YAxisType::Last;i++) { -// auto action = new QAction(AxisTypeToName((YAxisType) i)); -// action->setCheckable(true); -// group->addAction(action); -// if(YAxis[axis].type == (YAxisType) i) { -// action->setChecked(true); -// } -// connect(action, &QAction::triggered, [=](bool active) { -// if(active) { -// setYAxisType(axis, (YAxisType) i); -// } -// }); -// } -// axisMenu->addActions(group->actions()); -// } auto setup = new QAction("Axis setup..."); connect(setup, &QAction::triggered, [this]() { auto setup = new BodeplotAxisDialog(this); @@ -483,13 +466,18 @@ void TraceBodePlot::moved(const QPointF pos) if(!selectedMarker || !selectedCurve) { return; } -// int index = selectedCurve->closestPoint(pos.toPoint()); -// qDebug() << index; -// if(index < 0) { -// // unable to find closest point -// return; -// } -// selectedMarker->setFrequency(selectedCurve->sample(index).x()); selectedMarker->setFrequency(pos.x()); } +void TraceBodePlot::setColorFromPreferences() +{ + auto pref = Preferences::getInstance(); + plot->setCanvasBackground(pref.General.graphColors.background); + auto pal = plot->palette(); + pal.setColor(QPalette::Window, pref.General.graphColors.background); + pal.setColor(QPalette::WindowText, pref.General.graphColors.axis); + pal.setColor(QPalette::Text, pref.General.graphColors.axis); + plot->setPalette(pal); + grid->setPen(pref.General.graphColors.divisions); +} + diff --git a/Software/PC_Application/Traces/tracebodeplot.h b/Software/PC_Application/Traces/tracebodeplot.h index b65a588..0564427 100644 --- a/Software/PC_Application/Traces/tracebodeplot.h +++ b/Software/PC_Application/Traces/tracebodeplot.h @@ -7,7 +7,7 @@ #include #include #include - +#include #include // Derived plotpicker, exposing transformation functions @@ -45,6 +45,9 @@ public: void setXAxis(bool autorange, double min, double max, double div); void enableTrace(Trace *t, bool enabled) override; + // Applies potentially changed colors to all bodeplots + static void updateGraphColors(); + protected: virtual void updateContextMenu(); virtual bool supported(Trace *t); @@ -60,6 +63,7 @@ private slots: void clicked(const QPointF pos); void moved(const QPointF pos); private: + void setColorFromPreferences(); QString AxisTypeToName(YAxisType type); void enableTraceAxis(Trace *t, int axis, bool enabled); bool supported(Trace *t, YAxisType type); @@ -89,10 +93,14 @@ private: std::map curves[2]; std::map markers; QwtPlot *plot; + QwtPlotGrid *grid; TraceMarker *selectedMarker; QwtPlotCurve *selectedCurve; BodeplotPicker *drawPicker; + + // keep track of all created plots for changing colors + static std::set allPlots; }; #endif // TRACEBODEPLOT_H diff --git a/Software/PC_Application/Traces/traceeditdialog.cpp b/Software/PC_Application/Traces/traceeditdialog.cpp index 4f42a9d..31e9405 100644 --- a/Software/PC_Application/Traces/traceeditdialog.cpp +++ b/Software/PC_Application/Traces/traceeditdialog.cpp @@ -10,7 +10,10 @@ TraceEditDialog::TraceEditDialog(Trace &t, QWidget *parent) : { ui->setupUi(this); ui->name->setText(t.name()); - setColor(trace.color()); + ui->color->setColor(trace.color()); + connect(ui->color, &ColorPickerButton::colorChanged, [=](const QColor& color){ + trace.setColor(color); + }); ui->GSource->setId(ui->bLive, 0); ui->GSource->setId(ui->bFile, 1); @@ -98,13 +101,6 @@ TraceEditDialog::~TraceEditDialog() delete ui; } -void TraceEditDialog::on_color_clicked() -{ - auto color = QColorDialog::getColor(trace.color(), this, "Select color", QColorDialog::DontUseNativeDialog); - setColor(color); -} - - void TraceEditDialog::on_buttonBox_accepted() { trace.setName(ui->name->text()); @@ -139,13 +135,3 @@ void TraceEditDialog::on_buttonBox_accepted() } delete this; } - -void TraceEditDialog::setColor(QColor c) -{ - QPalette pal = ui->color->palette(); - pal.setColor(QPalette::Button, c); - ui->color->setAutoFillBackground(true); - ui->color->setPalette(pal); - ui->color->update(); - trace.setColor(c); -} diff --git a/Software/PC_Application/Traces/traceeditdialog.h b/Software/PC_Application/Traces/traceeditdialog.h index 6149886..9f16d10 100644 --- a/Software/PC_Application/Traces/traceeditdialog.h +++ b/Software/PC_Application/Traces/traceeditdialog.h @@ -17,11 +17,9 @@ public: ~TraceEditDialog(); private slots: - void on_color_clicked(); void on_buttonBox_accepted(); private: - void setColor(QColor c); Ui::TraceEditDialog *ui; Trace &trace; bool VNAtrace; diff --git a/Software/PC_Application/Traces/traceeditdialog.ui b/Software/PC_Application/Traces/traceeditdialog.ui index 1f33371..2fb98df 100644 --- a/Software/PC_Application/Traces/traceeditdialog.ui +++ b/Software/PC_Application/Traces/traceeditdialog.ui @@ -37,7 +37,7 @@ - + 0 @@ -162,6 +162,11 @@
CustomWidgets/touchstoneimport.h
1 + + ColorPickerButton + QPushButton +
CustomWidgets/colorpickerbutton.h
+
diff --git a/Software/PC_Application/Traces/tracemarker.cpp b/Software/PC_Application/Traces/tracemarker.cpp index 9c92f44..210e7de 100644 --- a/Software/PC_Application/Traces/tracemarker.cpp +++ b/Software/PC_Application/Traces/tracemarker.cpp @@ -117,6 +117,8 @@ QString TraceMarker::readableData() return ret; } break; + default: + return "Unknown marker type"; } } @@ -378,6 +380,7 @@ void TraceMarker::adjustSettings(double value) case Type::Delta: default: setFrequency(value); + /* no break */ case Type::Lowpass: case Type::Highpass: case Type::Bandpass: @@ -396,6 +399,7 @@ void TraceMarker::update() } switch(type) { case Type::Manual: + case Type::Delta: // nothing to do break; case Type::Maximum: diff --git a/Software/PC_Application/Traces/traceplot.cpp b/Software/PC_Application/Traces/traceplot.cpp index 8248ecf..63dbfca 100644 --- a/Software/PC_Application/Traces/traceplot.cpp +++ b/Software/PC_Application/Traces/traceplot.cpp @@ -1,8 +1,8 @@ #include "traceplot.h" -const QColor TracePlot::Background = QColor(0,0,0); -const QColor TracePlot::Border = QColor(255,255,255); -const QColor TracePlot::Divisions = QColor(255,255,255); +//const QColor TracePlot::Background = QColor(0,0,0); +//const QColor TracePlot::Border = QColor(255,255,255); +//const QColor TracePlot::Divisions = QColor(255,255,255); #include "tracemarker.h" std::set TracePlot::plots; diff --git a/Software/PC_Application/Traces/traceplot.h b/Software/PC_Application/Traces/traceplot.h index 0270616..856f82e 100644 --- a/Software/PC_Application/Traces/traceplot.h +++ b/Software/PC_Application/Traces/traceplot.h @@ -25,9 +25,9 @@ signals: void deleted(TracePlot*); protected: - static const QColor Background;// = QColor(0,0,0); - static const QColor Border;// = QColor(255,255,255); - static const QColor Divisions;// = QColor(255,255,255); +// static const QColor Background;// = QColor(0,0,0); +// static const QColor Border;// = QColor(255,255,255); +// static const QColor Divisions;// = QColor(255,255,255); static constexpr int MinUpdateInterval = 100; // need to be called in derived class constructor void initializeTraceInfo(TraceModel &model); diff --git a/Software/PC_Application/Traces/tracesmithchart.cpp b/Software/PC_Application/Traces/tracesmithchart.cpp index 07a5828..08e89a4 100644 --- a/Software/PC_Application/Traces/tracesmithchart.cpp +++ b/Software/PC_Application/Traces/tracesmithchart.cpp @@ -4,6 +4,7 @@ #include #include "tracemarker.h" #include +#include "preferences.h" using namespace std; @@ -92,13 +93,15 @@ void TraceSmithChart::draw(QPainter * painter, double width_factor) { // painter->setFont(font); // painter->drawText(-512, -512, title); + auto pref = Preferences::getInstance(); + // Outer circle - painter->setPen(QPen(Border, 1.5 * width_factor)); + painter->setPen(QPen(pref.General.graphColors.axis, 1.5 * width_factor)); QRectF rectangle(-smithCoordMax, -smithCoordMax, 2*smithCoordMax, 2*smithCoordMax); painter->drawArc(rectangle, 0, 5760); constexpr int Circles = 6; - painter->setPen(QPen(Divisions, 0.5 * width_factor, Qt::DashLine)); + painter->setPen(QPen(pref.General.graphColors.divisions, 0.5 * width_factor, Qt::DashLine)); for(int i=1;idrawArc(rectangle, 0, 5760); @@ -162,10 +165,11 @@ void TraceSmithChart::replot() void TraceSmithChart::paintEvent(QPaintEvent * /* the event */) { + auto pref = Preferences::getInstance(); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); - painter.setBackground(QBrush(Background)); - painter.fillRect(0, 0, width(), height(), QBrush(Background)); + painter.setBackground(QBrush(pref.General.graphColors.background)); + painter.fillRect(0, 0, width(), height(), QBrush(pref.General.graphColors.background)); double side = qMin(width(), height()) * screenUsage; diff --git a/Software/PC_Application/VNA/vna.cpp b/Software/PC_Application/VNA/vna.cpp index ef683d1..84396be 100644 --- a/Software/PC_Application/VNA/vna.cpp +++ b/Software/PC_Application/VNA/vna.cpp @@ -417,6 +417,7 @@ VNA::VNA(AppWindow *window) qRegisterMetaType("Datapoint"); // Set initial sweep settings + auto pref = Preferences::getInstance(); if(pref.Acquisition.alwaysExciteBothPorts) { settings.excitePort1 = 1; settings.excitePort2 = 1; @@ -539,7 +540,7 @@ void VNA::UpdateStatusPanel() void VNA::SettingsChanged() { - settings.suppressPeaks = pref.Acquisition.suppressPeaks ? 1 : 0; + settings.suppressPeaks = Preferences::getInstance().Acquisition.suppressPeaks ? 1 : 0; if(window->getDevice()) { window->getDevice()->Configure(settings); } @@ -675,8 +676,7 @@ void VNA::SetAveraging(unsigned int averages) void VNA::ExcitationRequired(bool port1, bool port2) { - qDebug() << pref.Acquisition.alwaysExciteBothPorts; - if(pref.Acquisition.alwaysExciteBothPorts) { + if(Preferences::getInstance().Acquisition.alwaysExciteBothPorts) { port1 = true; port2 = true; } @@ -771,6 +771,7 @@ void VNA::ConstrainAndUpdateFrequencies() void VNA::LoadSweepSettings() { + auto pref = Preferences::getInstance(); QSettings s; settings.f_start = s.value("SweepStart", pref.Startup.DefaultSweep.start).toULongLong(); settings.f_stop = s.value("SweepStop", pref.Startup.DefaultSweep.stop).toULongLong(); diff --git a/Software/PC_Application/appwindow.cpp b/Software/PC_Application/appwindow.cpp index 8fb1968..1b7f3a1 100644 --- a/Software/PC_Application/appwindow.cpp +++ b/Software/PC_Application/appwindow.cpp @@ -55,7 +55,7 @@ AppWindow::AppWindow(QWidget *parent) QCoreApplication::setOrganizationName("VNA"); QCoreApplication::setApplicationName("Application"); - pref.load(); + Preferences::getInstance().load(); device = nullptr; ui->setupUi(this); @@ -108,9 +108,9 @@ AppWindow::AppWindow(QWidget *parent) } }); connect(ui->actionPreferences, &QAction::triggered, [=](){ - qDebug() << pref.Acquisition.alwaysExciteBothPorts; - pref.edit(); - qDebug() << pref.Acquisition.alwaysExciteBothPorts; + Preferences::getInstance().edit(); + // settings might have changed, update necessary stuff + TraceBodePlot::updateGraphColors(); }); setWindowTitle("VNA"); @@ -131,7 +131,7 @@ AppWindow::AppWindow(QWidget *parent) qRegisterMetaType("Datapoint"); // List available devices - if(UpdateDeviceList() && pref.Startup.ConnectToFirstDevice) { + if(UpdateDeviceList() && Preferences::getInstance().Startup.ConnectToFirstDevice) { // at least one device available ConnectToDevice(); } @@ -145,7 +145,7 @@ void AppWindow::closeEvent(QCloseEvent *event) if(Mode::getActiveMode()) { Mode::getActiveMode()->deactivate(); } - pref.store(); + Preferences::getInstance().store(); QMainWindow::closeEvent(event); } @@ -244,11 +244,6 @@ void AppWindow::CreateToolbars() tb_reference->setObjectName("Reference Toolbar"); } -Preferences &AppWindow::getPreferenceRef() -{ - return pref; -} - int AppWindow::UpdateDeviceList() { deviceActionGroup->setExclusive(true); diff --git a/Software/PC_Application/appwindow.h b/Software/PC_Application/appwindow.h index ba8c60e..32dd158 100644 --- a/Software/PC_Application/appwindow.h +++ b/Software/PC_Application/appwindow.h @@ -34,8 +34,6 @@ public: QStackedWidget *getCentral() const; Device *getDevice() const; - Preferences &getPreferenceRef(); - protected: void closeEvent(QCloseEvent *event) override; private slots: @@ -60,8 +58,6 @@ private: } reference; } toolbars; - Preferences pref; - Device *device; DeviceLog deviceLog; QString deviceSerial; diff --git a/Software/PC_Application/mode.cpp b/Software/PC_Application/mode.cpp index 5b05762..977c981 100644 --- a/Software/PC_Application/mode.cpp +++ b/Software/PC_Application/mode.cpp @@ -10,7 +10,6 @@ QButtonGroup* Mode::modeButtonGroup = nullptr; Mode::Mode(AppWindow *window, QString name) : window(window), - pref(window->getPreferenceRef()), name(name), central(nullptr) { diff --git a/Software/PC_Application/mode.h b/Software/PC_Application/mode.h index eeb558d..d747c53 100644 --- a/Software/PC_Application/mode.h +++ b/Software/PC_Application/mode.h @@ -29,8 +29,6 @@ protected: std::set toolbars; std::set docks; - Preferences &pref; - private: static Mode *activeMode; static QWidget *cornerWidget; diff --git a/Software/PC_Application/preferences.cpp b/Software/PC_Application/preferences.cpp index e4457b1..3dd3128 100644 --- a/Software/PC_Application/preferences.cpp +++ b/Software/PC_Application/preferences.cpp @@ -7,6 +7,8 @@ using namespace std; +Preferences Preferences::instance; + PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : QDialog(parent), ui(new Ui::PreferencesDialog), @@ -100,6 +102,9 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : p->Startup.SA.signalID = ui->StartupSASignalID->isChecked(); p->Acquisition.alwaysExciteBothPorts = ui->AcquisitionAlwaysExciteBoth->isChecked(); p->Acquisition.suppressPeaks = ui->AcquisitionSuppressPeaks->isChecked(); + p->General.graphColors.background = ui->GeneralGraphBackground->getColor(); + p->General.graphColors.axis = ui->GeneralGraphAxis->getColor(); + p->General.graphColors.divisions = ui->GeneralGraphDivisions->getColor(); accept(); }); @@ -135,6 +140,10 @@ void PreferencesDialog::setInitialGUIState() ui->AcquisitionAlwaysExciteBoth->setChecked(p->Acquisition.alwaysExciteBothPorts); ui->AcquisitionSuppressPeaks->setChecked(p->Acquisition.suppressPeaks); + + ui->GeneralGraphBackground->setColor(p->General.graphColors.background); + ui->GeneralGraphAxis->setColor(p->General.graphColors.axis); + ui->GeneralGraphDivisions->setColor(p->General.graphColors.divisions); } void Preferences::load() diff --git a/Software/PC_Application/preferences.h b/Software/PC_Application/preferences.h index 7c2bdde..43831c9 100644 --- a/Software/PC_Application/preferences.h +++ b/Software/PC_Application/preferences.h @@ -30,6 +30,9 @@ private: class Preferences { public: + static Preferences& getInstance() { + return instance; + } void load(); void store(); void edit(); @@ -62,13 +65,22 @@ public: bool alwaysExciteBothPorts; bool suppressPeaks; } Acquisition; + struct { + struct { + QColor background; + QColor axis; + QColor divisions; + } graphColors; + } General; private: + Preferences(){}; + static Preferences instance; using SettingDescription = struct { QPointerVariant var; QString name; QVariant def; }; - const std::array descr = {{ + const std::array descr = {{ {&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true}, {&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false}, {&Startup.DefaultSweep.start, "Startup.DefaultSweep.start", 1000000.0}, @@ -85,7 +97,10 @@ private: {&Startup.SA.detector, "Startup.SA.detector", 0}, {&Startup.SA.signalID, "Startup.SA.signalID", true}, {&Acquisition.alwaysExciteBothPorts, "Acquisition.alwaysExciteBothPorts", true}, - {&Acquisition.suppressPeaks, "Acquisition.suppressPeaks", true}, + {&Acquisition.suppressPeaks, "Acquisition.suppressPeaks", true}, + {&General.graphColors.background, "General.graphColors.background", QColor(Qt::black)}, + {&General.graphColors.axis, "General.graphColors.axis", QColor(Qt::white)}, + {&General.graphColors.divisions, "General.graphColors.divisions", QColor(Qt::gray)}, }}; }; diff --git a/Software/PC_Application/preferencesdialog.ui b/Software/PC_Application/preferencesdialog.ui index 14e3a3f..8284d52 100644 --- a/Software/PC_Application/preferencesdialog.ui +++ b/Software/PC_Application/preferencesdialog.ui @@ -51,6 +51,11 @@ Acquisition
+ + + General + + @@ -68,7 +73,7 @@ - 0 + 2 @@ -449,6 +454,95 @@ + + + + + + + + + + Graph colors + + + + + + Background: + + + + + + + + + + + + + + Axis: + + + + + + + + + + + + + + Divisions: + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + @@ -474,6 +568,11 @@ QLineEdit
CustomWidgets/siunitedit.h
+ + ColorPickerButton + QPushButton +
CustomWidgets/colorpickerbutton.h
+