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

Method paintEvent

src/gui/ClientDeEssCurveWidget.cpp:118–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118void ClientDeEssCurveWidget::paintEvent(QPaintEvent*)
119{
120 QPainter p(this);
121 p.setRenderHint(QPainter::Antialiasing, true);
122
123 const QRectF r = rect();
124 p.fillRect(r, kBgColor());
125
126 // Grid — vertical at major freqs, horizontal at 0 / -12 / -24.
127 p.save();
128 p.setPen(QPen(kGridColor(), 1.0));
129 for (float db : { 0.0f, -12.0f, -24.0f }) {
130 const float y = dbToY(db);
131 p.drawLine(QPointF(r.left(), y), QPointF(r.right(), y));
132 }
133 p.setPen(QPen(kGridMajorColor(), 1.0));
134 QFont font = p.font();
135 font.setPixelSize(8);
136 p.setFont(font);
137
138 // Build the QStaticText cache once — font is fixed at 8 px regardless
139 // of compact mode, so this set never needs invalidation after the
140 // first paint. Labels follow kFreqMajor: "100", "500", "1k", etc.
141 if (m_labelsDirty) {
142 m_axisLabels.clear();
143 m_axisLabels.reserve(static_cast<int>(std::size(kFreqMajor)));
144 for (float f : kFreqMajor) {
145 const QString lbl = (f >= 1000.0f)
146 ? QString::number(int(f / 1000.0f)) + "k"
147 : QString::number(int(f));
148 QStaticText st(lbl);
149 st.setPerformanceHint(QStaticText::AggressiveCaching);
150 m_axisLabels.append(std::move(st));
151 }
152 m_labelsDirty = false;
153 }
154
155 // drawStaticText anchors at top-left, drawText at the baseline —
156 // subtract ascent so the visual position matches the prior render.
157 const qreal ascent = p.fontMetrics().ascent();
158
159 for (size_t i = 0; i < std::size(kFreqMajor); ++i) {
160 const float f = kFreqMajor[i];
161 const float x = hzToX(f);
162 p.drawLine(QPointF(x, r.top()), QPointF(x, r.bottom()));
163 if (!m_compact) {
164 m_axisLabels[i].prepare(p.transform(), font);
165 p.setPen(kAxisLabelColor());
166 p.drawStaticText(QPointF(x + 2.0f, r.bottom() - 2.0f - ascent),
167 m_axisLabels[i]);
168 p.setPen(QPen(kGridMajorColor(), 1.0));
169 }
170 }
171 p.restore();
172
173 // Bandpass magnitude curve.
174 if (m_deEss) {
175 QPainterPath path;

Callers

nothing calls this directly

Calls 15

sizeFunction · 0.85
moveFunction · 0.85
fontMethod · 0.80
setAlphaMethod · 0.80
kBgColorFunction · 0.70
kGridColorFunction · 0.70
kGridMajorColorFunction · 0.70
kAxisLabelColorFunction · 0.70
kCurveColorFunction · 0.70
kBallGlowColorFunction · 0.70
kBallCoreColorFunction · 0.70
kThreshColorFunction · 0.70

Tested by

no test coverage detected