MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / drawBarsGrid

Method drawBarsGrid

src/gui/WaveformWidget.cpp:753–795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

751}
752
753void WaveformWidget::drawBarsGrid(QPainter& painter, const QRectF& plotRect) const
754{
755 painter.save();
756
757 if (showGrid()) {
758 painter.setPen(QPen(kGridMinor(), 1.0));
759 for (int i = 0; i <= 10; ++i) {
760 const qreal x = plotRect.left() + plotRect.width() * i / 10.0;
761 painter.drawLine(QPointF(x, plotRect.top()),
762 QPointF(x, plotRect.bottom()));
763 }
764 }
765
766 const int refs[] = {0, -6, -12, -24, -48};
767
768 QFont labelFont = font();
769 labelFont.setPointSizeF(std::max(7.0, labelFont.pointSizeF() - 2.0));
770 painter.setFont(labelFont);
771
772 for (int db : refs) {
773 const qreal rawHeight = dbToAmplitude(static_cast<float>(db)) * m_amplitudeZoom * plotRect.height();
774 if (db <= -48 && rawHeight < 3.0)
775 continue;
776 const qreal y = plotRect.bottom() - std::min(rawHeight, plotRect.height());
777
778 painter.setPen(QPen(db >= -12 ? kGridMajor() : kGridMinor(), 1.0));
779 painter.drawLine(QPointF(plotRect.left(), y), QPointF(plotRect.right(), y));
780
781 painter.setPen(kMutedLabel());
782 painter.drawText(QRectF(plotRect.right() + 4.0, y - 7.0,
783 width() - plotRect.right() - 5.0, 14.0),
784 Qt::AlignLeft | Qt::AlignVCenter,
785 QString::number(db));
786 }
787
788 painter.setPen(kMutedLabel());
789 painter.drawText(QRectF(plotRect.right() + 4.0, plotRect.bottom() - 12.0,
790 width() - plotRect.right() - 5.0, 12.0),
791 Qt::AlignLeft | Qt::AlignVCenter,
792 QStringLiteral("dBFS"));
793
794 painter.restore();
795}
796
797void WaveformWidget::drawGrid(QPainter& painter,
798 const QRectF& plotRect,

Callers

nothing calls this directly

Calls 6

drawTextMethod · 0.80
showGridFunction · 0.70
kGridMinorFunction · 0.70
kGridMajorFunction · 0.70
kMutedLabelFunction · 0.70
saveMethod · 0.45

Tested by

no test coverage detected