diff --git a/Software/PC_Application/Traces/traceplot.cpp b/Software/PC_Application/Traces/traceplot.cpp index f4ebba1..689fa3d 100644 --- a/Software/PC_Application/Traces/traceplot.cpp +++ b/Software/PC_Application/Traces/traceplot.cpp @@ -21,7 +21,8 @@ TracePlot::TracePlot(TraceModel &model, QWidget *parent) selectedMarker(nullptr), traceRemovalPending(false), dropPending(false), - dropTrace(nullptr) + dropTrace(nullptr), + marginTop(20) { contextmenu = new QMenu(); markedForDeletion = false; @@ -37,9 +38,6 @@ TracePlot::TracePlot(TraceModel &model, QWidget *parent) cursorLabel = new QLabel("Test", this); cursorLabel->setStyleSheet("color: white;"); - auto font = cursorLabel->font(); - font.setPixelSize(12); - cursorLabel->setFont(font); cursorLabel->hide(); setMouseTracking(true); setAcceptDrops(true); @@ -155,6 +153,8 @@ void TracePlot::paintEvent(QPaintEvent *event) // show names of active traces and marker data (if enabled) bool hasMarkerData = false; + auto marginMarkerData = pref.Graphs.fontSizeMarkerData * 12.5; + marginTop = pref.Graphs.fontSizeTraceNames + 8; int x = 1; // xcoordinate for the next trace name int y = marginTop; // ycoordinate for the next marker data auto areaTextTop = 5; @@ -168,7 +168,7 @@ void TracePlot::paintEvent(QPaintEvent *event) // Trace name auto textArea = QRect(x, areaTextTop, width() - x, marginTop); QFont font = p.font(); - font.setPixelSize(12); + font.setPixelSize(pref.Graphs.fontSizeTraceNames); p.setFont(font); p.setPen(t.first->color()); auto space = " "; @@ -194,6 +194,9 @@ void TracePlot::paintEvent(QPaintEvent *event) continue; } hasMarkerData = true; + QFont font = p.font(); + font.setPixelSize(pref.Graphs.fontSizeMarkerData); + p.setFont(font); // Rounded box auto space = " "; @@ -269,6 +272,9 @@ void TracePlot::mouseMoveEvent(QMouseEvent *event) cursorLabel->setText(text); cursorLabel->adjustSize(); cursorLabel->move(event->pos() + QPoint(15, 0)); + auto font = cursorLabel->font(); + font.setPixelSize(Preferences::getInstance().Graphs.fontSizeCursorOverlay); + cursorLabel->setFont(font); cursorLabel->show(); } else { cursorLabel->hide(); diff --git a/Software/PC_Application/Traces/traceplot.h b/Software/PC_Application/Traces/traceplot.h index 3ddc3f9..9c2e263 100644 --- a/Software/PC_Application/Traces/traceplot.h +++ b/Software/PC_Application/Traces/traceplot.h @@ -88,13 +88,10 @@ protected slots: virtual void markerRemoved(Marker *m); virtual bool markerVisible(double x) = 0; protected: - static constexpr unsigned int marginTop = 20; static constexpr unsigned int marginBottom = 0; static constexpr unsigned int marginLeft = 0; static constexpr unsigned int marginRight = 0; - static constexpr unsigned int marginMarkerData = 150; - double sweep_fmin, sweep_fmax; TraceModel &model; Marker *selectedMarker; @@ -108,6 +105,7 @@ protected: QLabel *cursorLabel; + unsigned int marginTop; }; #endif // TRACEPLOT_H diff --git a/Software/PC_Application/Traces/tracewaterfall.cpp b/Software/PC_Application/Traces/tracewaterfall.cpp index a6dc656..3ef3df4 100644 --- a/Software/PC_Application/Traces/tracewaterfall.cpp +++ b/Software/PC_Application/Traces/tracewaterfall.cpp @@ -214,16 +214,12 @@ void TraceWaterfall::draw(QPainter &p) { auto pref = Preferences::getInstance(); -// constexpr int yAxisLegendSpace = 25; -// constexpr int yAxisDisabledSpace = 10; - constexpr int xAxisSpace = 30; + int xAxisSpace = pref.Graphs.fontSizeAxis * 3; constexpr int topMargin = 10; auto w = p.window(); auto pen = QPen(pref.Graphs.Color.axis, 0); pen.setCosmetic(true); p.setPen(pen); -// plotAreaLeft = yAxisDisabledSpace; -// plotAreaWidth = w.width() - 3 * yAxisDisabledSpace - yAxisLegendSpace; auto leftMargin = TraceXYPlot::sideMargin(align == Alignment::PrimaryOnly || align == Alignment::BothAxes); auto rightMargin = TraceXYPlot::sideMargin(align == Alignment::SecondaryOnly || align == Alignment::BothAxes); @@ -235,6 +231,9 @@ void TraceWaterfall::draw(QPainter &p) plotAreaBottom = plotRect.y()+plotRect.height(); // draw Y legend + auto font = p.font(); + font.setPixelSize(pref.Graphs.fontSizeAxis); + p.setFont(font); QRect legendRect; constexpr int legendMargin = 10; if(leftMargin < rightMargin) { @@ -271,10 +270,7 @@ void TraceWaterfall::draw(QPainter &p) p.drawRect(plotRect); // draw axis types - auto font = p.font(); - font.setPixelSize(AxisLabelSize); - p.setFont(font); - p.drawText(QRect(0, w.height()-AxisLabelSize*1.5, w.width(), AxisLabelSize*1.5), Qt::AlignHCenter, xAxis.TypeToName()); + p.drawText(QRect(0, w.height()-pref.Graphs.fontSizeAxis*1.5, w.width(), pref.Graphs.fontSizeAxis*1.5), Qt::AlignHCenter, xAxis.TypeToName()); if(xAxis.getTicks().size() >= 1) { // draw X ticks @@ -313,9 +309,9 @@ void TraceWaterfall::draw(QPainter &p) back.append(".."); p.setPen(QPen(QColor("orange"))); QRect bounding; - p.drawText(QRect(2, plotAreaBottom + AxisLabelSize + 5, w.width(), AxisLabelSize), 0, front, &bounding); + p.drawText(QRect(2, plotAreaBottom + pref.Graphs.fontSizeAxis + 5, w.width(), pref.Graphs.fontSizeAxis), 0, front, &bounding); 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 + pref.Graphs.fontSizeAxis + 5, w.width(), pref.Graphs.fontSizeAxis), 0, back); } int lastTickLabelEnd = 0; @@ -335,7 +331,7 @@ void TraceWaterfall::draw(QPainter &p) p.setPen(QPen(pref.Graphs.Color.axis, 1)); if(displayFullFreq) { QRect bounding; - p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, AxisLabelSize), Qt::AlignHCenter, tickValue, &bounding); + p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, pref.Graphs.fontSizeAxis), Qt::AlignHCenter, tickValue, &bounding); lastTickLabelEnd = bounding.x() + bounding.width(); } else { // check if the same prefix was used as in the fullFreq string @@ -346,10 +342,10 @@ void TraceWaterfall::draw(QPainter &p) tickValue.remove(0, tickValue.size() - displayLastDigits - unit.length()); QRect bounding; - p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, AxisLabelSize), Qt::AlignHCenter, tickValue, &bounding); + p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, pref.Graphs.fontSizeAxis), Qt::AlignHCenter, tickValue, &bounding); lastTickLabelEnd = bounding.x() + bounding.width(); p.setPen(QPen(QColor("orange"))); - p.drawText(QRect(0, plotAreaBottom + 5, bounding.x() - 1, AxisLabelSize), Qt::AlignRight, "..", &bounding); + p.drawText(QRect(0, plotAreaBottom + 5, bounding.x() - 1, pref.Graphs.fontSizeAxis), Qt::AlignRight, "..", &bounding); } } } diff --git a/Software/PC_Application/Traces/tracewaterfall.h b/Software/PC_Application/Traces/tracewaterfall.h index f2fc9ef..50174af 100644 --- a/Software/PC_Application/Traces/tracewaterfall.h +++ b/Software/PC_Application/Traces/tracewaterfall.h @@ -44,8 +44,6 @@ protected slots: private slots: void updateYAxis(); private: - static constexpr int AxisLabelSize = 10; - // color scale, input value from 0.0 to 1.0 QColor getColor(double scale); diff --git a/Software/PC_Application/Traces/tracexyplot.cpp b/Software/PC_Application/Traces/tracexyplot.cpp index 25498cf..226bc1e 100644 --- a/Software/PC_Application/Traces/tracexyplot.cpp +++ b/Software/PC_Application/Traces/tracexyplot.cpp @@ -192,7 +192,7 @@ bool TraceXYPlot::isTDRtype(YAxis::Type type) int TraceXYPlot::sideMargin(bool YAxisEnabled) { if(YAxisEnabled) { - return yAxisSpace; + return Preferences::getInstance().Graphs.fontSizeAxis * 5.5; } else { return yAxisDisabledSpace; } @@ -334,6 +334,8 @@ void TraceXYPlot::draw(QPainter &p) auto pen = QPen(pref.Graphs.Color.axis, 0); pen.setCosmetic(true); p.setPen(pen); + auto yAxisSpace = pref.Graphs.fontSizeAxis * 5.5; + auto xAxisSpace = pref.Graphs.fontSizeAxis * 3; plotAreaLeft = yAxis[0].getType() == YAxis::Type::Disabled ? yAxisDisabledSpace : yAxisSpace; plotAreaWidth = w.width(); plotAreaTop = 10; @@ -354,20 +356,20 @@ void TraceXYPlot::draw(QPainter &p) // draw axis types auto font = p.font(); - font.setPixelSize(AxisLabelSize); + font.setPixelSize(pref.Graphs.fontSizeAxis); p.setFont(font); - p.drawText(QRect(0, w.height()-AxisLabelSize*1.5, w.width(), AxisLabelSize*1.5), Qt::AlignHCenter, xAxis.TypeToName()); + p.drawText(QRect(0, w.height()-pref.Graphs.fontSizeAxis*1.5, w.width(), pref.Graphs.fontSizeAxis*1.5), Qt::AlignHCenter, xAxis.TypeToName()); for(int i=0;i<2;i++) { if(yAxis[i].getType() == YAxis::Type::Disabled) { continue; } QString labelY = yAxis[i].TypeToName(); 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() - pref.Graphs.fontSizeAxis * 1.5; p.save(); p.translate(xStart, w.height()-xAxisSpace); p.rotate(-90); - p.drawText(QRect(0, 0, w.height()-xAxisSpace, AxisLabelSize*1.5), Qt::AlignHCenter, labelY); + p.drawText(QRect(0, 0, w.height()-xAxisSpace, pref.Graphs.fontSizeAxis*1.5), Qt::AlignHCenter, labelY); p.restore(); // draw ticks if(yAxis[i].getType() != YAxis::Type::Disabled && yAxis[i].getTicks().size() > 0) { @@ -397,9 +399,9 @@ void TraceXYPlot::draw(QPainter &p) } auto tickValue = Unit::ToString(yAxis[i].getTicks()[j], unit, prefix, significantDigits); if(i == 0) { - p.drawText(QRectF(0, yCoord - AxisLabelSize/2 - 2, tickStart + 2 * tickLen, AxisLabelSize), Qt::AlignRight, tickValue); + p.drawText(QRectF(0, yCoord - pref.Graphs.fontSizeAxis/2 - 2, tickStart + 2 * tickLen, pref.Graphs.fontSizeAxis), Qt::AlignRight, tickValue); } else { - p.drawText(QRectF(tickStart + 2 * tickLen + 2, yCoord - AxisLabelSize/2 - 2, yAxisSpace, AxisLabelSize), Qt::AlignLeft, tickValue); + p.drawText(QRectF(tickStart + 2 * tickLen + 2, yCoord - pref.Graphs.fontSizeAxis/2 - 2, yAxisSpace, pref.Graphs.fontSizeAxis), Qt::AlignLeft, tickValue); } // tick lines @@ -540,9 +542,9 @@ void TraceXYPlot::draw(QPainter &p) back.append(".."); p.setPen(QPen(QColor("orange"))); QRect bounding; - p.drawText(QRect(2, plotAreaBottom + AxisLabelSize + 5, w.width(), AxisLabelSize), 0, front, &bounding); + p.drawText(QRect(2, plotAreaBottom + pref.Graphs.fontSizeAxis + 5, w.width(), pref.Graphs.fontSizeAxis), 0, front, &bounding); 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 + pref.Graphs.fontSizeAxis + 5, w.width(), pref.Graphs.fontSizeAxis), 0, back); } int lastTickLabelEnd = 0; @@ -562,7 +564,7 @@ void TraceXYPlot::draw(QPainter &p) p.setPen(QPen(pref.Graphs.Color.axis, 1)); if(displayFullFreq) { QRect bounding; - p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, AxisLabelSize), Qt::AlignHCenter, tickValue, &bounding); + p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, pref.Graphs.fontSizeAxis), Qt::AlignHCenter, tickValue, &bounding); lastTickLabelEnd = bounding.x() + bounding.width(); } else { // check if the same prefix was used as in the fullFreq string @@ -573,10 +575,10 @@ void TraceXYPlot::draw(QPainter &p) tickValue.remove(0, tickValue.size() - displayLastDigits - unit.length()); QRect bounding; - p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, AxisLabelSize), Qt::AlignHCenter, tickValue, &bounding); + p.drawText(QRect(xCoord - 40, plotAreaBottom + 5, 80, pref.Graphs.fontSizeAxis), Qt::AlignHCenter, tickValue, &bounding); lastTickLabelEnd = bounding.x() + bounding.width(); p.setPen(QPen(QColor("orange"))); - p.drawText(QRect(0, plotAreaBottom + 5, bounding.x() - 1, AxisLabelSize), Qt::AlignRight, "..", &bounding); + p.drawText(QRect(0, plotAreaBottom + 5, bounding.x() - 1, pref.Graphs.fontSizeAxis), Qt::AlignRight, "..", &bounding); } } } diff --git a/Software/PC_Application/Traces/tracexyplot.h b/Software/PC_Application/Traces/tracexyplot.h index 85e2da2..1491184 100644 --- a/Software/PC_Application/Traces/tracexyplot.h +++ b/Software/PC_Application/Traces/tracexyplot.h @@ -46,10 +46,7 @@ protected: private slots: void updateAxisTicks(); private: - static constexpr int AxisLabelSize = 10; - static constexpr int yAxisSpace = 55; static constexpr int yAxisDisabledSpace = 10; - static constexpr int xAxisSpace = 30; static QString AxisModeToName(XAxisMode mode); static XAxisMode AxisModeFromName(QString name); void enableTraceAxis(Trace *t, int axis, bool enabled); diff --git a/Software/PC_Application/preferences.cpp b/Software/PC_Application/preferences.cpp index efa9fac..87abd0c 100644 --- a/Software/PC_Application/preferences.cpp +++ b/Software/PC_Application/preferences.cpp @@ -249,6 +249,10 @@ void PreferencesDialog::setInitialGUIState() ui->GraphsColorTicksBackground->setColor(p->Graphs.Color.Ticks.Background.background); ui->GraphsDomainChangeBehavior->setCurrentIndex((int) p->Graphs.domainChangeBehavior); ui->GraphsLineWidth->setValue(p->Graphs.lineWidth); + ui->GraphsFontSizeAxis->setValue(p->Graphs.fontSizeAxis); + ui->GraphsFontSizeCursorOverlay->setValue(p->Graphs.fontSizeCursorOverlay); + ui->GraphsFontSizeMarkerData->setValue(p->Graphs.fontSizeMarkerData); + ui->GraphsFontSizeTraceNames->setValue(p->Graphs.fontSizeTraceNames); ui->MarkerShowMarkerData->setChecked(p->Marker.defaultBehavior.showDataOnGraphs); ui->MarkerShowAllMarkerData->setChecked(p->Marker.defaultBehavior.showAllData); @@ -309,6 +313,10 @@ void PreferencesDialog::updateFromGUI() p->Graphs.Color.Ticks.divisions = ui->GraphsColorTicksDivisions->getColor(); p->Graphs.domainChangeBehavior = (GraphDomainChangeBehavior) ui->GraphsDomainChangeBehavior->currentIndex(); p->Graphs.lineWidth = ui->GraphsLineWidth->value(); + p->Graphs.fontSizeAxis = ui->GraphsFontSizeAxis->value(); + p->Graphs.fontSizeCursorOverlay = ui->GraphsFontSizeCursorOverlay->value(); + p->Graphs.fontSizeMarkerData = ui->GraphsFontSizeMarkerData->value(); + p->Graphs.fontSizeTraceNames = ui->GraphsFontSizeTraceNames->value(); p->Marker.defaultBehavior.showDataOnGraphs = ui->MarkerShowMarkerData->isChecked(); p->Marker.defaultBehavior.showAllData = ui->MarkerShowAllMarkerData->isChecked(); diff --git a/Software/PC_Application/preferences.h b/Software/PC_Application/preferences.h index 67a28c4..de87fc1 100644 --- a/Software/PC_Application/preferences.h +++ b/Software/PC_Application/preferences.h @@ -95,6 +95,10 @@ public: GraphDomainChangeBehavior domainChangeBehavior; double lineWidth; + int fontSizeAxis; + int fontSizeMarkerData; + int fontSizeTraceNames; + int fontSizeCursorOverlay; } Graphs; struct { struct { @@ -163,6 +167,10 @@ private: {&Graphs.Color.Ticks.divisions, "Graphs.Color.Ticks.divisions", QColor(Qt::gray)}, {&Graphs.domainChangeBehavior, "Graphs.domainChangeBehavior", GraphDomainChangeBehavior::AdjustGraphs}, {&Graphs.lineWidth, "Graphs.lineWidth", 1.0}, + {&Graphs.fontSizeAxis, "Graphs.fontSizeAxis", 10}, + {&Graphs.fontSizeCursorOverlay, "Graphs.fontSizeCursorOverlay", 12}, + {&Graphs.fontSizeMarkerData, "Graphs.fontSizeMarkerData", 12}, + {&Graphs.fontSizeTraceNames, "Graphs.fontSizeTraceNames", 12}, {&Marker.defaultBehavior.showDataOnGraphs, "Marker.defaultBehavior.ShowDataOnGraphs", true}, {&Marker.defaultBehavior.showAllData, "Marker.defaultBehavior.ShowAllData", false}, {&Marker.interpolatePoints, "Marker.interpolatePoints", false}, diff --git a/Software/PC_Application/preferencesdialog.ui b/Software/PC_Application/preferencesdialog.ui index 5cfa158..53505fc 100644 --- a/Software/PC_Application/preferencesdialog.ui +++ b/Software/PC_Application/preferencesdialog.ui @@ -83,7 +83,7 @@ - 1 + 2 @@ -945,6 +945,85 @@ + + + + Size + + + + + + Line Width: + + + + + + + 0.100000000000000 + + + + + + + Font (axes): + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + Font (trace names): + + + + + + + Font (marker data): + + + + + + + Font (cursor overlay): + + + + + + @@ -979,7 +1058,7 @@ - + Ticks @@ -1028,20 +1107,6 @@ - - - - Line Width: - - - - - - - 0.100000000000000 - - -