Add setting for graph behavior when trace no longer supported

This commit is contained in:
Jan Käberich 2021-07-10 13:12:30 +02:00
parent b45645f04e
commit dda149f3d5
11 changed files with 363 additions and 227 deletions

View File

@ -83,8 +83,8 @@ void Marker::assignTrace(Trace *t)
// Marker was just created and this is the first assignment to a trace. // Marker was just created and this is the first assignment to a trace.
// Use display format on graph from preferences // Use display format on graph from preferences
auto p = Preferences::getInstance(); auto p = Preferences::getInstance();
if(p.General.markerDefault.showDataOnGraphs) { if(p.Graphs.markerBehavior.showDataOnGraphs) {
if(p.General.markerDefault.showAllData) { if(p.Graphs.markerBehavior.showAllData) {
for(auto f : applicableFormats()) { for(auto f : applicableFormats()) {
formatGraph.insert(f); formatGraph.insert(f);
} }

View File

@ -334,8 +334,8 @@ void Math::TimeGateGraph::paintEvent(QPaintEvent *event)
auto pref = Preferences::getInstance(); auto pref = Preferences::getInstance();
QPainter p(this); QPainter p(this);
// fill background // fill background
p.setBackground(QBrush(pref.General.graphColors.background)); p.setBackground(QBrush(pref.Graphs.Color.background));
p.fillRect(0, 0, width(), height(), QBrush(pref.General.graphColors.background)); p.fillRect(0, 0, width(), height(), QBrush(pref.Graphs.Color.background));
// plot trace // plot trace
auto pen = QPen(Qt::green, 1); auto pen = QPen(Qt::green, 1);

View File

@ -15,6 +15,7 @@ TracePlot::TracePlot(TraceModel &model, QWidget *parent)
: QWidget(parent), : QWidget(parent),
model(model), model(model),
selectedMarker(nullptr), selectedMarker(nullptr),
traceRemovalPending(false),
dropPending(false), dropPending(false),
dropTrace(nullptr) dropTrace(nullptr)
{ {
@ -96,6 +97,17 @@ void TracePlot::initializeTraceInfo()
connect(&model, &TraceModel::traceAdded, this, &TracePlot::newTraceAvailable); connect(&model, &TraceModel::traceAdded, this, &TracePlot::newTraceAvailable);
} }
std::vector<Trace *> TracePlot::activeTraces()
{
std::vector<Trace*> ret;
for(auto t : traces) {
if(t.second) {
ret.push_back(t.first);
}
}
return ret;
}
void TracePlot::contextMenuEvent(QContextMenuEvent *event) void TracePlot::contextMenuEvent(QContextMenuEvent *event)
{ {
auto m = markerAtPosition(event->pos()); auto m = markerAtPosition(event->pos());
@ -117,13 +129,25 @@ void TracePlot::contextMenuEvent(QContextMenuEvent *event)
void TracePlot::paintEvent(QPaintEvent *event) void TracePlot::paintEvent(QPaintEvent *event)
{ {
if(traceRemovalPending) {
for(auto t : traces) {
if(!t.second) {
// trace already disabled
}
if(!supported(t.first)) {
enableTrace(t.first, false);
}
}
traceRemovalPending = false;
}
Q_UNUSED(event) Q_UNUSED(event)
auto pref = Preferences::getInstance(); auto pref = Preferences::getInstance();
QPainter p(this); QPainter p(this);
// p.setRenderHint(QPainter::Antialiasing); // p.setRenderHint(QPainter::Antialiasing);
// fill background // fill background
p.setBackground(QBrush(pref.General.graphColors.background)); p.setBackground(QBrush(pref.Graphs.Color.background));
p.fillRect(0, 0, width(), height(), QBrush(pref.General.graphColors.background)); p.fillRect(0, 0, width(), height(), QBrush(pref.Graphs.Color.background));
// show names of active traces and marker data (if enabled) // show names of active traces and marker data (if enabled)
bool hasMarkerData = false; bool hasMarkerData = false;
@ -374,7 +398,27 @@ void TracePlot::checkIfStillSupported(Trace *t)
{ {
if(!supported(t)) { if(!supported(t)) {
// something with this trace changed and it can no longer be displayed on this graph // something with this trace changed and it can no longer be displayed on this graph
// behavior depends on preferences
switch(Preferences::getInstance().Graphs.domainChangeBehavior) {
case GraphDomainChangeBehavior::RemoveChangedTraces:
// simply remove the changed trace
enableTrace(t, false); enableTrace(t, false);
break;
case GraphDomainChangeBehavior::AdjustGrahpsIfOnlyTrace:
// remove trace if other traces are present, otherwise try to adjust graph
if(activeTraces().size() > 1) {
enableTrace(t, false);
break;
}
[[fallthrough]];
case GraphDomainChangeBehavior::AdjustGraphs:
// attempt to configure the graph for the changed trace, remove only if this fails
if(!configureForTrace(t)) {
enableTrace(t, false);
}
break;
}
} }
} }

View File

@ -39,6 +39,9 @@ protected:
static constexpr int MinUpdateInterval = 100; static constexpr int MinUpdateInterval = 100;
// need to be called in derived class constructor // need to be called in derived class constructor
void initializeTraceInfo(); void initializeTraceInfo();
std::vector<Trace*> activeTraces();
// changes the graph settings to make it possible to display a specific trace. The trace is not aded yet
virtual bool configureForTrace(Trace *t) { Q_UNUSED(t) return false; }; // default implementation fails for all traces
void contextMenuEvent(QContextMenuEvent *event) override; void contextMenuEvent(QContextMenuEvent *event) override;
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;
virtual void updateContextMenu(){}; virtual void updateContextMenu(){};
@ -92,6 +95,9 @@ protected:
TraceModel &model; TraceModel &model;
Marker *selectedMarker; Marker *selectedMarker;
// graph settings have been changed, check and possibly remove incompatible traces before next paint event
bool traceRemovalPending;
bool dropPending; bool dropPending;
QPoint dropPosition; QPoint dropPosition;
Trace *dropTrace; Trace *dropTrace;

View File

@ -145,14 +145,14 @@ void TraceSmithChart::draw(QPainter &p) {
transform = p.transform(); transform = p.transform();
// Outer circle // Outer circle
auto pen = QPen(pref.General.graphColors.axis); auto pen = QPen(pref.Graphs.Color.axis);
pen.setCosmetic(true); pen.setCosmetic(true);
p.setPen(pen); p.setPen(pen);
QRectF rectangle(-smithCoordMax, -smithCoordMax, 2*smithCoordMax, 2*smithCoordMax); QRectF rectangle(-smithCoordMax, -smithCoordMax, 2*smithCoordMax, 2*smithCoordMax);
p.drawArc(rectangle, 0, 5760); p.drawArc(rectangle, 0, 5760);
constexpr int Circles = 6; constexpr int Circles = 6;
pen = QPen(pref.General.graphColors.divisions, 0.5, Qt::DashLine); pen = QPen(pref.Graphs.Color.divisions, 0.5, Qt::DashLine);
pen.setCosmetic(true); pen.setCosmetic(true);
p.setPen(pen); p.setPen(pen);
for(int i=1;i<Circles;i++) { for(int i=1;i<Circles;i++) {

View File

@ -77,7 +77,7 @@ void TraceXYPlot::setYAxis(int axis, TraceXYPlot::YAxisType type, bool log, bool
YAxis[axis].rangeMin = min; YAxis[axis].rangeMin = min;
YAxis[axis].rangeMax = max; YAxis[axis].rangeMax = max;
YAxis[axis].rangeDiv = div; YAxis[axis].rangeDiv = div;
removeUnsupportedTraces(); traceRemovalPending = true;
updateAxisTicks(); updateAxisTicks();
updateContextMenu(); updateContextMenu();
replot(); replot();
@ -90,7 +90,7 @@ void TraceXYPlot::setXAxis(XAxisType type, XAxisMode mode, double min, double ma
XAxis.rangeMin = min; XAxis.rangeMin = min;
XAxis.rangeMax = max; XAxis.rangeMax = max;
XAxis.rangeDiv = div; XAxis.rangeDiv = div;
removeUnsupportedTraces(); traceRemovalPending = true;
updateAxisTicks(); updateAxisTicks();
updateContextMenu(); updateContextMenu();
replot(); replot();
@ -223,6 +223,32 @@ void TraceXYPlot::axisSetupDialog()
setup->show(); setup->show();
} }
bool TraceXYPlot::configureForTrace(Trace *t)
{
switch(t->outputType()) {
case Trace::DataType::Frequency:
setXAxis(XAxisType::Frequency, XAxisMode::FitTraces, 0, 1, 0.1);
setYAxis(0, YAxisType::Magnitude, false, true, 0, 1, 1.0);
setYAxis(1, YAxisType::Phase, false, true, 0, 1, 1.0);
break;
case Trace::DataType::Time:
setXAxis(XAxisType::Time, XAxisMode::FitTraces, 0, 1, 0.1);
setYAxis(0, YAxisType::ImpulseMag, false, true, 0, 1, 1.0);
setYAxis(1, YAxisType::Disabled, false, true, 0, 1, 1.0);
break;
case Trace::DataType::Power:
setXAxis(XAxisType::Power, XAxisMode::FitTraces, 0, 1, 0.1);
setYAxis(0, YAxisType::Magnitude, false, true, 0, 1, 1.0);
setYAxis(1, YAxisType::Phase, false, true, 0, 1, 1.0);
break;
case Trace::DataType::Invalid:
// unable to add
return false;
}
traceRemovalPending = true;
return true;
}
void TraceXYPlot::updateContextMenu() void TraceXYPlot::updateContextMenu()
{ {
contextmenu->clear(); contextmenu->clear();
@ -322,7 +348,7 @@ void TraceXYPlot::draw(QPainter &p)
constexpr int yAxisDisabledSpace = 10; constexpr int yAxisDisabledSpace = 10;
constexpr int xAxisSpace = 30; constexpr int xAxisSpace = 30;
auto w = p.window(); auto w = p.window();
auto pen = QPen(pref.General.graphColors.axis, 0); auto pen = QPen(pref.Graphs.Color.axis, 0);
pen.setCosmetic(true); pen.setCosmetic(true);
p.setPen(pen); p.setPen(pen);
plotAreaLeft = YAxis[0].type == YAxisType::Disabled ? yAxisDisabledSpace : yAxisSpace; plotAreaLeft = YAxis[0].type == YAxisType::Disabled ? yAxisDisabledSpace : yAxisSpace;
@ -378,14 +404,14 @@ void TraceXYPlot::draw(QPainter &p)
p.setPen(QPen(QColor("orange"))); p.setPen(QPen(QColor("orange")));
QRect bounding; QRect bounding;
p.drawText(QRect(2, plotAreaBottom + AxisLabelSize + 5, w.width(), AxisLabelSize), 0, front, &bounding); p.drawText(QRect(2, plotAreaBottom + AxisLabelSize + 5, w.width(), AxisLabelSize), 0, front, &bounding);
p.setPen(pref.General.graphColors.axis); p.setPen(pref.Graphs.Color.axis);
p.drawText(QRect(bounding.x() + bounding.width(), plotAreaBottom + AxisLabelSize + 5, w.width(), AxisLabelSize), 0, back); p.drawText(QRect(bounding.x() + bounding.width(), plotAreaBottom + AxisLabelSize + 5, w.width(), AxisLabelSize), 0, back);
} }
for(auto t : XAxis.ticks) { for(auto t : XAxis.ticks) {
auto xCoord = Util::Scale<double>(t, XAxis.rangeMin, XAxis.rangeMax, plotAreaLeft, plotAreaLeft + plotAreaWidth); auto xCoord = Util::Scale<double>(t, XAxis.rangeMin, XAxis.rangeMax, plotAreaLeft, plotAreaLeft + plotAreaWidth);
auto tickValue = Unit::ToString(t, "", prefixes, significantDigits); auto tickValue = Unit::ToString(t, "", prefixes, significantDigits);
p.setPen(QPen(pref.General.graphColors.axis, 1)); p.setPen(QPen(pref.Graphs.Color.axis, 1));
if(displayFullFreq) { if(displayFullFreq) {
p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, AxisLabelSize), Qt::AlignHCenter, tickValue); p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, AxisLabelSize), Qt::AlignHCenter, tickValue);
} else { } else {
@ -400,11 +426,11 @@ void TraceXYPlot::draw(QPainter &p)
p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, AxisLabelSize), Qt::AlignHCenter, tickValue, &bounding); p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, AxisLabelSize), Qt::AlignHCenter, tickValue, &bounding);
p.setPen(QPen(QColor("orange"))); p.setPen(QPen(QColor("orange")));
p.drawText(QRect(0, plotAreaBottom + 5, bounding.x() - 1, AxisLabelSize), Qt::AlignRight, ".."); p.drawText(QRect(0, plotAreaBottom + 5, bounding.x() - 1, AxisLabelSize), Qt::AlignRight, "..");
p.setPen(QPen(pref.General.graphColors.axis, 1)); p.setPen(QPen(pref.Graphs.Color.axis, 1));
} }
p.drawLine(xCoord, plotAreaBottom, xCoord, plotAreaBottom + 2); p.drawLine(xCoord, plotAreaBottom, xCoord, plotAreaBottom + 2);
if(xCoord != plotAreaLeft && xCoord != plotAreaLeft + plotAreaWidth) { if(xCoord != plotAreaLeft && xCoord != plotAreaLeft + plotAreaWidth) {
p.setPen(QPen(pref.General.graphColors.divisions, 0.5, Qt::DashLine)); p.setPen(QPen(pref.Graphs.Color.divisions, 0.5, Qt::DashLine));
p.drawLine(xCoord, 0, xCoord, plotAreaBottom); p.drawLine(xCoord, 0, xCoord, plotAreaBottom);
} }
} }
@ -415,7 +441,7 @@ void TraceXYPlot::draw(QPainter &p)
continue; continue;
} }
QString labelY = AxisTypeToName(YAxis[i].type); QString labelY = AxisTypeToName(YAxis[i].type);
p.setPen(QPen(pref.General.graphColors.axis, 1)); p.setPen(QPen(pref.Graphs.Color.axis, 1));
auto xStart = i == 0 ? 0 : w.width() - AxisLabelSize * 1.5; auto xStart = i == 0 ? 0 : w.width() - AxisLabelSize * 1.5;
p.save(); p.save();
p.translate(xStart, w.height()-xAxisSpace); p.translate(xStart, w.height()-xAxisSpace);
@ -436,7 +462,7 @@ void TraceXYPlot::draw(QPainter &p)
int significantDigits = floor(log10(max)) - floor(log10(step)) + 1; int significantDigits = floor(log10(max)) - floor(log10(step)) + 1;
for(auto t : YAxis[i].ticks) { for(auto t : YAxis[i].ticks) {
auto yCoord = Util::Scale<double>(t, YAxis[i].rangeMax, YAxis[i].rangeMin, 0, w.height() - xAxisSpace); auto yCoord = Util::Scale<double>(t, YAxis[i].rangeMax, YAxis[i].rangeMin, 0, w.height() - xAxisSpace);
p.setPen(QPen(pref.General.graphColors.axis, 1)); p.setPen(QPen(pref.Graphs.Color.axis, 1));
// draw tickmark on axis // draw tickmark on axis
auto tickStart = i == 0 ? plotAreaLeft : plotAreaLeft + plotAreaWidth; auto tickStart = i == 0 ? plotAreaLeft : plotAreaLeft + plotAreaWidth;
auto tickLen = i == 0 ? -2 : 2; auto tickLen = i == 0 ? -2 : 2;
@ -455,7 +481,7 @@ void TraceXYPlot::draw(QPainter &p)
} }
if(i == 0) { if(i == 0) {
// only draw tick lines for primary axis // only draw tick lines for primary axis
p.setPen(QPen(pref.General.graphColors.divisions, 0.5, Qt::DashLine)); p.setPen(QPen(pref.Graphs.Color.divisions, 0.5, Qt::DashLine));
p.drawLine(plotAreaLeft, yCoord, plotAreaLeft + plotAreaWidth, yCoord); p.drawLine(plotAreaLeft, yCoord, plotAreaLeft + plotAreaWidth, yCoord);
} }
} }
@ -839,18 +865,6 @@ bool TraceXYPlot::supported(Trace *t, TraceXYPlot::YAxisType type)
return true; return true;
} }
void TraceXYPlot::removeUnsupportedTraces()
{
for(unsigned int i=0;i<2;i++) {
auto set_copy = tracesAxis[i];
for(auto t : set_copy) {
if(!supported(t, YAxis[i].type)) {
enableTraceAxis(t, i, false);
}
}
}
}
QPointF TraceXYPlot::traceToCoordinate(Trace *t, unsigned int sample, TraceXYPlot::YAxisType type) QPointF TraceXYPlot::traceToCoordinate(Trace *t, unsigned int sample, TraceXYPlot::YAxisType type)
{ {
QPointF ret = QPointF(numeric_limits<double>::quiet_NaN(), numeric_limits<double>::quiet_NaN()); QPointF ret = QPointF(numeric_limits<double>::quiet_NaN(), numeric_limits<double>::quiet_NaN());
@ -981,24 +995,8 @@ void TraceXYPlot::traceDropped(Trace *t, QPoint position)
// user declined to change domain, to not add trace // user declined to change domain, to not add trace
return; return;
} }
switch(t->outputType()) { if(!configureForTrace(t)) {
case Trace::DataType::Frequency: // failed to configure
setXAxis(XAxisType::Frequency, XAxisMode::FitTraces, 0, 1, 0.1);
setYAxis(0, YAxisType::Magnitude, false, true, 0, 1, 1.0);
setYAxis(1, YAxisType::Phase, false, true, 0, 1, 1.0);
break;
case Trace::DataType::Time:
setXAxis(XAxisType::Time, XAxisMode::FitTraces, 0, 1, 0.1);
setYAxis(0, YAxisType::ImpulseMag, false, true, 0, 1, 1.0);
setYAxis(1, YAxisType::Disabled, false, true, 0, 1, 1.0);
break;
case Trace::DataType::Power:
setXAxis(XAxisType::Power, XAxisMode::FitTraces, 0, 1, 0.1);
setYAxis(0, YAxisType::Magnitude, false, true, 0, 1, 1.0);
setYAxis(1, YAxisType::Phase, false, true, 0, 1, 1.0);
break;
case Trace::DataType::Invalid:
// unable to add
return; return;
} }
} }

View File

@ -60,6 +60,7 @@ public slots:
void axisSetupDialog(); void axisSetupDialog();
protected: protected:
virtual bool configureForTrace(Trace *t) override;
virtual void updateContextMenu() override; virtual void updateContextMenu() override;
virtual bool dropSupported(Trace *t) override; virtual bool dropSupported(Trace *t) override;
virtual void draw(QPainter &p) override; virtual void draw(QPainter &p) override;
@ -77,7 +78,6 @@ private:
void enableTraceAxis(Trace *t, int axis, bool enabled); void enableTraceAxis(Trace *t, int axis, bool enabled);
bool supported(Trace *t) override; bool supported(Trace *t) override;
bool supported(Trace *t, YAxisType type); bool supported(Trace *t, YAxisType type);
void removeUnsupportedTraces();
QPointF traceToCoordinate(Trace *t, unsigned int sample, YAxisType type); QPointF traceToCoordinate(Trace *t, unsigned int sample, YAxisType type);
QPoint plotValueToPixel(QPointF plotValue, int Yaxis); QPoint plotValueToPixel(QPointF plotValue, int Yaxis);
QPointF pixelToPlotValue(QPoint pixel, int YAxis); QPointF pixelToPlotValue(QPoint pixel, int YAxis);

View File

@ -92,12 +92,12 @@ AppWindow::AppWindow(QWidget *parent)
auto port = parser.value("port").toUInt(&OK); auto port = parser.value("port").toUInt(&OK);
if(!OK) { if(!OK) {
// set default port // set default port
port = Preferences::getInstance().General.SCPI.port; port = Preferences::getInstance().SCPIServer.port;
} }
StartTCPServer(port); StartTCPServer(port);
Preferences::getInstance().manualTCPport(); Preferences::getInstance().manualTCPport();
} else if(Preferences::getInstance().General.SCPI.enabled) { } else if(Preferences::getInstance().SCPIServer.enabled) {
StartTCPServer(Preferences::getInstance().General.SCPI.port); StartTCPServer(Preferences::getInstance().SCPIServer.port);
} }
ui->setupUi(this); ui->setupUi(this);
@ -194,13 +194,13 @@ AppWindow::AppWindow(QWidget *parent)
connect(ui->actionPreferences, &QAction::triggered, [=](){ connect(ui->actionPreferences, &QAction::triggered, [=](){
// save previous SCPI settings in case they change // save previous SCPI settings in case they change
auto &p = Preferences::getInstance(); auto &p = Preferences::getInstance();
auto SCPIenabled = p.General.SCPI.enabled; auto SCPIenabled = p.SCPIServer.enabled;
auto SCPIport = p.General.SCPI.port; auto SCPIport = p.SCPIServer.port;
p.edit(); p.edit();
if(SCPIenabled != p.General.SCPI.enabled || SCPIport != p.General.SCPI.port) { if(SCPIenabled != p.SCPIServer.enabled || SCPIport != p.SCPIServer.port) {
StopTCPServer(); StopTCPServer();
if(p.General.SCPI.enabled) { if(p.SCPIServer.enabled) {
StartTCPServer(p.General.SCPI.port); StartTCPServer(p.SCPIServer.port);
} }
} }
auto active = Mode::getActiveMode(); auto active = Mode::getActiveMode();

View File

@ -74,17 +74,19 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) :
// General page // General page
if(p->TCPoverride) { if(p->TCPoverride) {
ui->GeneralSCPIPort->setEnabled(false); ui->SCPIServerPort->setEnabled(false);
ui->GeneralSCPIEnabled->setEnabled(false); ui->SCPIServerEnabled->setEnabled(false);
} }
connect(ui->GeneralMarkerDataGraph, &QCheckBox::toggled, [=](bool enabled) { connect(ui->GraphsShowMarkerData, &QCheckBox::toggled, [=](bool enabled) {
ui->GeneralMarkerDataGraphAll->setEnabled(enabled); ui->GraphsShowAllMarkerData->setEnabled(enabled);
}); });
// Page selection // Page selection
connect(ui->treeWidget, &QTreeWidget::currentItemChanged, [=](QTreeWidgetItem *current, QTreeWidgetItem *) { connect(ui->treeWidget, &QTreeWidget::currentItemChanged, [=](QTreeWidgetItem *current, QTreeWidgetItem *) {
auto name = current->text(0); auto name = current->text(0);
// remove any potential white space in name (can't have whitespace in page names)
name.replace(" ", "");
for(int i=0;i<ui->pageWidget->count();i++) { for(int i=0;i<ui->pageWidget->count();i++) {
auto w = ui->pageWidget->widget(i); auto w = ui->pageWidget->widget(i);
if(name == w->objectName()) { if(name == w->objectName()) {
@ -130,13 +132,14 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) :
p->Acquisition.harmonicMixing = ui->AcquisitionUseHarmonic->isChecked(); p->Acquisition.harmonicMixing = ui->AcquisitionUseHarmonic->isChecked();
p->Acquisition.useDFTinSAmode = ui->AcquisitionUseDFT->isChecked(); p->Acquisition.useDFTinSAmode = ui->AcquisitionUseDFT->isChecked();
p->Acquisition.RBWLimitForDFT = ui->AcquisitionDFTlimitRBW->value(); p->Acquisition.RBWLimitForDFT = ui->AcquisitionDFTlimitRBW->value();
p->General.graphColors.background = ui->GeneralGraphBackground->getColor(); p->Graphs.Color.background = ui->GraphsColorBackground->getColor();
p->General.graphColors.axis = ui->GeneralGraphAxis->getColor(); p->Graphs.Color.axis = ui->GraphsColorAxis->getColor();
p->General.graphColors.divisions = ui->GeneralGraphDivisions->getColor(); p->Graphs.Color.divisions = ui->GraphsColorDivisions->getColor();
p->General.markerDefault.showDataOnGraphs = ui->GeneralMarkerDataGraph->isChecked(); p->Graphs.domainChangeBehavior = (GraphDomainChangeBehavior) ui->GraphsDomainChangeBehavior->currentIndex();
p->General.markerDefault.showAllData = ui->GeneralMarkerDataGraphAll->isChecked(); p->Graphs.markerBehavior.showDataOnGraphs = ui->GraphsShowMarkerData->isChecked();
p->General.SCPI.enabled = ui->GeneralSCPIEnabled->isChecked(); p->Graphs.markerBehavior.showAllData = ui->GraphsShowAllMarkerData->isChecked();
p->General.SCPI.port = ui->GeneralSCPIPort->value(); p->SCPIServer.enabled = ui->SCPIServerEnabled->isChecked();
p->SCPIServer.port = ui->SCPIServerPort->value();
accept(); accept();
}); });
@ -193,13 +196,14 @@ void PreferencesDialog::setInitialGUIState()
ui->AcquisitionUseDFT->setChecked(p->Acquisition.useDFTinSAmode); ui->AcquisitionUseDFT->setChecked(p->Acquisition.useDFTinSAmode);
ui->AcquisitionDFTlimitRBW->setValue(p->Acquisition.RBWLimitForDFT); ui->AcquisitionDFTlimitRBW->setValue(p->Acquisition.RBWLimitForDFT);
ui->GeneralGraphBackground->setColor(p->General.graphColors.background); ui->GraphsColorBackground->setColor(p->Graphs.Color.background);
ui->GeneralGraphAxis->setColor(p->General.graphColors.axis); ui->GraphsColorAxis->setColor(p->Graphs.Color.axis);
ui->GeneralGraphDivisions->setColor(p->General.graphColors.divisions); ui->GraphsColorDivisions->setColor(p->Graphs.Color.divisions);
ui->GeneralMarkerDataGraph->setChecked(p->General.markerDefault.showDataOnGraphs); ui->GraphsDomainChangeBehavior->setCurrentIndex((int) p->Graphs.domainChangeBehavior);
ui->GeneralMarkerDataGraphAll->setChecked(p->General.markerDefault.showAllData); ui->GraphsShowMarkerData->setChecked(p->Graphs.markerBehavior.showDataOnGraphs);
ui->GeneralSCPIEnabled->setChecked(p->General.SCPI.enabled); ui->GraphsShowAllMarkerData->setChecked(p->Graphs.markerBehavior.showAllData);
ui->GeneralSCPIPort->setValue(p->General.SCPI.port); ui->SCPIServerEnabled->setChecked(p->SCPIServer.enabled);
ui->SCPIServerPort->setValue(p->SCPIServer.port);
QTreeWidgetItem *item = ui->treeWidget->topLevelItem(0); QTreeWidgetItem *item = ui->treeWidget->topLevelItem(0);
if (item != nullptr) { if (item != nullptr) {

View File

@ -6,6 +6,15 @@
#include <exception> #include <exception>
#include "Util/qpointervariant.h" #include "Util/qpointervariant.h"
enum GraphDomainChangeBehavior {
RemoveChangedTraces = 0,
AdjustGraphs = 1,
AdjustGrahpsIfOnlyTrace = 2,
};
Q_DECLARE_METATYPE(GraphDomainChangeBehavior);
class Preferences { class Preferences {
public: public:
static Preferences& getInstance() { static Preferences& getInstance() {
@ -62,16 +71,17 @@ public:
QColor background; QColor background;
QColor axis; QColor axis;
QColor divisions; QColor divisions;
} graphColors; } Color;
GraphDomainChangeBehavior domainChangeBehavior;
struct { struct {
bool showDataOnGraphs; bool showDataOnGraphs;
bool showAllData; bool showAllData;
} markerDefault; } markerBehavior;
} Graphs;
struct { struct {
bool enabled; bool enabled;
int port; int port;
} SCPI; } SCPIServer;
} General;
bool TCPoverride; // in case of manual port specification via command line bool TCPoverride; // in case of manual port specification via command line
private: private:
@ -83,7 +93,7 @@ private:
QString name; QString name;
QVariant def; QVariant def;
}; };
const std::array<SettingDescription, 34> descr = {{ const std::array<SettingDescription, 35> descr = {{
{&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true}, {&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true},
{&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false}, {&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false},
{&Startup.DefaultSweep.type, "Startup.DefaultSweep.type", "Frequency"}, {&Startup.DefaultSweep.type, "Startup.DefaultSweep.type", "Frequency"},
@ -111,13 +121,14 @@ private:
{&Acquisition.harmonicMixing, "Acquisition.harmonicMixing", false}, {&Acquisition.harmonicMixing, "Acquisition.harmonicMixing", false},
{&Acquisition.useDFTinSAmode, "Acquisition.useDFTinSAmode", true}, {&Acquisition.useDFTinSAmode, "Acquisition.useDFTinSAmode", true},
{&Acquisition.RBWLimitForDFT, "Acquisition.RBWLimitForDFT", 3000.0}, {&Acquisition.RBWLimitForDFT, "Acquisition.RBWLimitForDFT", 3000.0},
{&General.graphColors.background, "General.graphColors.background", QColor(Qt::black)}, {&Graphs.Color.background, "Graphs.Color.background", QColor(Qt::black)},
{&General.graphColors.axis, "General.graphColors.axis", QColor(Qt::white)}, {&Graphs.Color.axis, "Graphs.Color.axis", QColor(Qt::white)},
{&General.graphColors.divisions, "General.graphColors.divisions", QColor(Qt::gray)}, {&Graphs.Color.divisions, "Graphs.Color.divisions", QColor(Qt::gray)},
{&General.markerDefault.showDataOnGraphs, "General.MarkerDefault.ShowDataOnGraphs", true}, {&Graphs.domainChangeBehavior, "Graphs.domainChangeBehavior", GraphDomainChangeBehavior::AdjustGraphs},
{&General.markerDefault.showAllData, "General.MarkerDefault.ShowAllData", false}, {&Graphs.markerBehavior.showDataOnGraphs, "Graphs.markerBehavior.ShowDataOnGraphs", true},
{&General.SCPI.enabled, "General.SCPI.enabled", true}, {&Graphs.markerBehavior.showAllData, "Graphs.markerBehavior.ShowAllData", false},
{&General.SCPI.port, "General.SCPI.port", 19542}, {&SCPIServer.enabled, "SCPIServer.enabled", true},
{&SCPIServer.port, "SCPIServer.port", 19542},
}}; }};
}; };

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>919</width> <width>919</width>
<height>875</height> <height>876</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -53,7 +53,12 @@
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>General</string> <string>Graphs</string>
</property>
</item>
<item>
<property name="text">
<string>SCPI Server</string>
</property> </property>
</item> </item>
</widget> </widget>
@ -73,7 +78,7 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="Startup"> <widget class="QWidget" name="Startup">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
@ -647,16 +652,14 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="General"> <widget class="QWidget" name="Graphs">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_11">
<item> <item>
<widget class="QGroupBox" name="groupBox_5"> <widget class="QGroupBox" name="groupBox_5">
<property name="title"> <property name="title">
<string>Graph colors</string> <string>Colors</string>
</property> </property>
<layout class="QFormLayout" name="formLayout_4"> <layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0"> <item row="0" column="0">
@ -667,7 +670,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="ColorPickerButton" name="GeneralGraphBackground"> <widget class="ColorPickerButton" name="GraphsColorBackground">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -681,7 +684,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="ColorPickerButton" name="GeneralGraphAxis"> <widget class="ColorPickerButton" name="GraphsColorAxis">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -695,7 +698,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="ColorPickerButton" name="GeneralGraphDivisions"> <widget class="ColorPickerButton" name="GraphsColorDivisions">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -704,6 +707,44 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_12">
<property name="title">
<string>Trace Domain Handling</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_25">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;A trace may change its output format/domain if certain settings are changed (e.g. from frequency to time domain when enabling TDR). Depending on the type of change, the graphs settings also have to be adjusted. Select the the behavior of the graphs when this happens:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="GraphsDomainChangeBehavior">
<item>
<property name="text">
<string>Remove changed trace from all unsupported graphs</string>
</property>
</item>
<item>
<property name="text">
<string>Adjust graphs to support the changed trace (may remove other traces)</string>
</property>
</item>
<item>
<property name="text">
<string>Adjust graph only if it contains no other traces</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_9"> <widget class="QGroupBox" name="groupBox_9">
<property name="title"> <property name="title">
@ -711,14 +752,14 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_9"> <layout class="QVBoxLayout" name="verticalLayout_9">
<item> <item>
<widget class="QCheckBox" name="GeneralMarkerDataGraph"> <widget class="QCheckBox" name="GraphsShowMarkerData">
<property name="text"> <property name="text">
<string>Show data on graphs</string> <string>Show data on graphs</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="GeneralMarkerDataGraphAll"> <widget class="QCheckBox" name="GraphsShowAllMarkerData">
<property name="text"> <property name="text">
<string>Show data in all available formats</string> <string>Show data in all available formats</string>
</property> </property>
@ -727,43 +768,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>SCPI Control</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="GeneralSCPIEnabled">
<property name="text">
<string>Enable server</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="GeneralSCPIPort">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
@ -786,13 +790,82 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>80</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</widget>
<widget class="QWidget" name="SCPIServer">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>SCPI Control</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="SCPIServerEnabled">
<property name="text">
<string>Enable server</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="SCPIServerPort">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<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_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>471</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</widget> </widget>