Customizable graph colors
This commit is contained in:
parent
978ac89aa9
commit
74e068d8d1
@ -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 \
|
||||
|
35
Software/PC_Application/CustomWidgets/colorpickerbutton.cpp
Normal file
35
Software/PC_Application/CustomWidgets/colorpickerbutton.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "colorpickerbutton.h"
|
||||
#include <QColorDialog>
|
||||
|
||||
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());
|
||||
}
|
23
Software/PC_Application/CustomWidgets/colorpickerbutton.h
Normal file
23
Software/PC_Application/CustomWidgets/colorpickerbutton.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef COLORPICKERBUTTON_H
|
||||
#define COLORPICKERBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
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
|
@ -6,6 +6,8 @@ Generator::Generator(AppWindow *window)
|
||||
{
|
||||
central = new SignalgeneratorWidget();
|
||||
|
||||
auto pref = Preferences::getInstance();
|
||||
|
||||
// set initial values
|
||||
if(pref.Startup.RememberSweepSettings) {
|
||||
QSettings s;
|
||||
|
@ -184,6 +184,7 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window)
|
||||
qRegisterMetaType<Protocol::SpectrumAnalyzerResult>("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();
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "tracebodeplot.h"
|
||||
#include <QGridLayout>
|
||||
#include <qwt_plot_grid.h>
|
||||
#include "qwtplotpiecewisecurve.h"
|
||||
#include "qwt_series_data.h"
|
||||
#include "trace.h"
|
||||
@ -13,9 +12,12 @@
|
||||
#include <qwt_symbol.h>
|
||||
#include <qwt_picker_machine.h>
|
||||
#include "bodeplotaxisdialog.h"
|
||||
#include <preferences.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
set<TraceBodePlot*> TraceBodePlot::allPlots;
|
||||
|
||||
static double AxisTransformation(TraceBodePlot::YAxisType type, complex<double> 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<double, double>(&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);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <qwt_plot_curve.h>
|
||||
#include <qwt_series_data.h>
|
||||
#include <qwt_plot_marker.h>
|
||||
|
||||
#include <qwt_plot_grid.h>
|
||||
#include <qwt_plot_picker.h>
|
||||
|
||||
// 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<Trace*, CurveData> curves[2];
|
||||
std::map<TraceMarker*, QwtPlotMarker*> markers;
|
||||
QwtPlot *plot;
|
||||
QwtPlotGrid *grid;
|
||||
TraceMarker *selectedMarker;
|
||||
QwtPlotCurve *selectedCurve;
|
||||
|
||||
BodeplotPicker *drawPicker;
|
||||
|
||||
// keep track of all created plots for changing colors
|
||||
static std::set<TraceBodePlot*> allPlots;
|
||||
};
|
||||
|
||||
#endif // TRACEBODEPLOT_H
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -37,7 +37,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="color">
|
||||
<widget class="ColorPickerButton" name="color">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -162,6 +162,11 @@
|
||||
<header>CustomWidgets/touchstoneimport.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ColorPickerButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>CustomWidgets/colorpickerbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
@ -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:
|
||||
|
@ -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*> TracePlot::plots;
|
||||
|
@ -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);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <math.h>
|
||||
#include "tracemarker.h"
|
||||
#include <QDebug>
|
||||
#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;i<Circles;i++) {
|
||||
rectangle.adjust(2*smithCoordMax/Circles, smithCoordMax/Circles, 0, -smithCoordMax/Circles);
|
||||
painter->drawArc(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;
|
||||
|
||||
|
@ -417,6 +417,7 @@ VNA::VNA(AppWindow *window)
|
||||
qRegisterMetaType<Protocol::Datapoint>("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();
|
||||
|
@ -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<Protocol::Datapoint>("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);
|
||||
|
@ -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;
|
||||
|
@ -10,7 +10,6 @@ QButtonGroup* Mode::modeButtonGroup = nullptr;
|
||||
|
||||
Mode::Mode(AppWindow *window, QString name)
|
||||
: window(window),
|
||||
pref(window->getPreferenceRef()),
|
||||
name(name),
|
||||
central(nullptr)
|
||||
{
|
||||
|
@ -29,8 +29,6 @@ protected:
|
||||
std::set<QToolBar*> toolbars;
|
||||
std::set<QDockWidget*> docks;
|
||||
|
||||
Preferences &pref;
|
||||
|
||||
private:
|
||||
static Mode *activeMode;
|
||||
static QWidget *cornerWidget;
|
||||
|
@ -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()
|
||||
|
@ -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<SettingDescription, 17> descr = {{
|
||||
const std::array<SettingDescription, 20> 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)},
|
||||
}};
|
||||
};
|
||||
|
||||
|
@ -51,6 +51,11 @@
|
||||
<string>Acquisition</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>General</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -68,7 +73,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Startup">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
@ -449,6 +454,95 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="General">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<property name="title">
|
||||
<string>Graph colors</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Background:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="ColorPickerButton" name="GeneralGraphBackground">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Axis:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="ColorPickerButton" name="GeneralGraphAxis">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Divisions:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="ColorPickerButton" name="GeneralGraphDivisions">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -474,6 +568,11 @@
|
||||
<extends>QLineEdit</extends>
|
||||
<header>CustomWidgets/siunitedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ColorPickerButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>CustomWidgets/colorpickerbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Loading…
Reference in New Issue
Block a user