MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / paint_label

Method paint_label

DSView/pv/view/trace.cpp:186–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186void Trace::paint_label(QPainter &p, int right, const QPoint pt, QColor fore)
187{
188 if (_type == SR_CHANNEL_FFT && !enabled())
189 return;
190
191 compute_text_size(p);
192 const int y = get_y();
193
194 const QRectF color_rect = get_rect("color", y, right);
195 const QRectF name_rect = get_rect("name", y, right);
196 const QRectF label_rect = get_rect("label", get_zero_vpos(), right);
197
198 // Paint the ColorButton
199 QColor foreBack = fore;
200 foreBack.setAlpha(View::BackAlpha);
201 p.setPen(Qt::transparent);
202 p.setBrush(enabled() ? (_colour.isValid() ? _colour : fore) : foreBack);
203 p.drawRect(color_rect);
204
205 if (_type == SR_CHANNEL_DSO ||
206 _type == SR_CHANNEL_MATH) {
207 p.setPen(enabled() ? Qt::white: foreBack);
208 p.drawText(color_rect, Qt::AlignCenter | Qt::AlignVCenter, _name);
209 }
210
211 if (_type != SR_CHANNEL_DSO) {
212 // Paint the signal name
213 p.setPen(enabled() ? fore: foreBack);
214 p.drawText(name_rect, Qt::AlignLeft | Qt::AlignVCenter, _name);
215 }
216
217 // Paint the trigButton
218 paint_type_options(p, right, pt, fore);
219
220 // Paint the label
221 if (enabled()) {
222 const QPointF points[] = {
223 label_rect.topLeft(),
224 label_rect.topRight(),
225 QPointF(right, get_zero_vpos()),
226 label_rect.bottomRight(),
227 label_rect.bottomLeft()
228 };
229
230 p.setPen(Qt::transparent);
231 if (_type == SR_CHANNEL_DSO ||
232 _type == SR_CHANNEL_FFT ||
233 _type == SR_CHANNEL_ANALOG ||
234 _type == SR_CHANNEL_MATH) {
235 p.setBrush(_colour);
236 p.drawPolygon(points, countof(points));
237 } else {
238 QColor color = PROBE_COLORS[*_index_list.begin() % countof(PROBE_COLORS)];
239 p.setBrush(color);
240 p.drawPolygon(points, countof(points));
241 }
242
243 p.setPen(Qt::white);

Callers 3

draw_logic_tick_markMethod · 0.45
draw_osc_tick_markMethod · 0.45
paintEventMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected