void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p, int h, double start, double end, int y, const ViewItemPaintParams &pp, int row_title_width) const { const double top = y + .5 - h / 2; const double bottom = y + .5 + h / 2; const vector<QString> annotations = a.annotations(); // If the two ends are within 1 pixel, draw a vertical line if (start + 1.0 > end) { p.drawLine(QPointF(start, top), QPointF(start, bottom)); return; } const double cap_width = min((end - start) / 4, EndCapWidth); QPointF pts[] = { QPointF(start, y + .5f), QPointF(start + cap_width, top), QPointF(end - cap_width, top), QPointF(end, y + .5f), QPointF(end - cap_width, bottom), QPointF(start + cap_width, bottom) }; p.drawConvexPolygon(pts, countof(pts)); if (annotations.empty()) return; const int ann_start = start + cap_width; const int ann_end = end - cap_width; const int real_start = std::max(ann_start, pp.left() + row_title_width); const int real_end = std::min(ann_end, pp.right()); const int real_width = real_end - real_start; QRectF rect(real_start, y - h / 2, real_width, h); if (rect.width() <= 4) return; p.setPen(Qt::black); // Try to find an annotation that will fit QString best_annotation; int best_width = 0; for (const QString &a : annotations) { const int w = p.boundingRect(QRectF(), 0, a).width(); if (w <= rect.width() && w > best_width) best_annotation = a, best_width = w; } if (best_annotation.isEmpty()) best_annotation = annotations.back(); // If not ellide the last in the list p.drawText(rect, Qt::AlignCenter, p.fontMetrics().elidedText( best_annotation, Qt::ElideRight, rect.width())); }
void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a, QPainter &p, int h, const ViewItemPaintParams &pp, int y, size_t base_colour, int row_title_width) const { double samples_per_pixel, pixels_offset; tie(pixels_offset, samples_per_pixel) = get_pixels_offset_samples_per_pixel(); const double start = a.start_sample() / samples_per_pixel - pixels_offset; const double end = a.end_sample() / samples_per_pixel - pixels_offset; const size_t colour = (base_colour + a.format()) % countof(Colours); p.setPen(OutlineColours[colour]); p.setBrush(Colours[colour]); if (start > pp.right() + DrawPadding || end < pp.left() - DrawPadding) return; if (a.start_sample() == a.end_sample()) draw_instant(a, p, h, start, y); else draw_range(a, p, h, start, end, y, pp, row_title_width); }
void TimeMarker::paint_fore(QPainter &p, ViewItemPaintParams &pp) { if (!enabled()) return; const float x = get_x(); p.setPen(color_.darker()); p.drawLine(QPointF(x, pp.top()), QPointF(x, pp.bottom())); }
void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y) { p.setRenderHint(QPainter::Antialiasing, false); p.setPen(AxisPen); p.drawLine(QPointF(pp.left(), y), QPointF(pp.right(), y)); p.setRenderHint(QPainter::Antialiasing, true); }
QRectF SignalScaleHandle::hit_box_rect(const ViewItemPaintParams &pp) const { const int text_height = ViewItemPaintParams::text_height(); const double x = -pp.pixels_offset() - text_height / 2; const double min_x = pp.left() + text_height; const double max_x = pp.right() - text_height * 2; return QRectF(min(max(x, min_x), max_x), owner_.get_visual_y() + owner_.scale_handle_offset() - text_height / 2, text_height, text_height); }
void TriggerMarker::paint_fore(QPainter &p, ViewItemPaintParams &pp) { if (!enabled()) return; QPen pen(Color); pen.setStyle(Qt::DashLine); const float x = get_x(); p.setPen(pen); p.drawLine(QPointF(x, pp.top()), QPointF(x, pp.bottom())); }
void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp) { if (coloured_bg_) p.setBrush(bgcolour_); else p.setBrush(bgcolour_state_ ? BrightGrayBGColour : DarkGrayBGColour); p.setPen(QPen(Qt::NoPen)); const std::pair<int, int> extents = v_extents(); const int x = 0; const int y = get_visual_y() + extents.first; const int w = pp.right() - pp.left(); const int h = extents.second - extents.first; p.drawRect(x, y, w, h); }
void DecodeTrace::draw_error(QPainter &p, const QString &message, const ViewItemPaintParams &pp) { const int y = get_visual_y(); p.setPen(ErrorBgColour.darker()); p.setBrush(ErrorBgColour); const QRectF bounding_rect = QRectF(pp.width(), INT_MIN / 2 + y, pp.width(), INT_MAX); const QRectF text_rect = p.boundingRect(bounding_rect, Qt::AlignCenter, message); const float r = text_rect.height() / 4; p.drawRoundedRect(text_rect.adjusted(-r, -r, r, r), r, r, Qt::AbsoluteSize); p.setPen(Qt::black); p.drawText(text_rect, message); }
QRectF TimeMarker::hit_box_rect(const ViewItemPaintParams &pp) const { const float x = get_x(); const float h = QFontMetrics(QApplication::font()).height(); return QRectF(x - h / 2.0f, pp.top(), h, pp.height()); }