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

Method paint_back

DSView/pv/view/dsosignal.cpp:691–764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

689}
690
691void DsoSignal::paint_back(QPainter &p, int left, int right, QColor fore, QColor back)
692{
693 assert(_view);
694
695 if (!_show)
696 return;
697
698 int i, j;
699 const int height = get_view_rect().height();
700 const int width = right - left;
701
702 fore.setAlpha(View::BackAlpha);
703
704 QPen solidPen(fore);
705 solidPen.setStyle(Qt::SolidLine);
706 p.setPen(solidPen);
707 p.setBrush(back.black() > 0x80 ? back.darker() : back.lighter());
708 p.drawRect(left, UpMargin, width, height);
709
710 // draw zoom region
711 fore.setAlpha(View::ForeAlpha);
712 p.setPen(fore);
713
714 const uint64_t sample_len = session->cur_samplelimits();
715 const double samplerate = session->cur_snap_samplerate();
716 const double samples_per_pixel = samplerate * _view->scale();
717 const double shown_rate = min(samples_per_pixel * width * 1.0 / sample_len, 1.0);
718 const double start = _view->offset() * samples_per_pixel;
719 const double shown_offset = min(start / sample_len, 1.0) * width;
720 const double shown_len = max(shown_rate * width, 6.0);
721 const QPointF left_edge[] = {QPoint(shown_offset + 3, UpMargin/2 - 6),
722 QPoint(shown_offset, UpMargin/2 - 6),
723 QPoint(shown_offset, UpMargin/2 + 6),
724 QPoint(shown_offset + 3, UpMargin/2 + 6)};
725 const QPointF right_edge[] = {QPoint(shown_offset + shown_len - 3, UpMargin/2 - 6),
726 QPoint(shown_offset + shown_len , UpMargin/2 - 6),
727 QPoint(shown_offset + shown_len , UpMargin/2 + 6),
728 QPoint(shown_offset + shown_len - 3, UpMargin/2 + 6)};
729 p.drawLine(left, UpMargin/2, shown_offset, UpMargin/2);
730 p.drawLine(shown_offset + shown_len, UpMargin/2, left + width, UpMargin/2);
731 p.drawPolyline(left_edge, countof(left_edge));
732 p.drawPolyline(right_edge, countof(right_edge));
733 p.setBrush(fore);
734 p.drawRect(shown_offset, UpMargin/2 - 3, shown_len, 6);
735
736 // draw divider
737 fore.setAlpha(View::BackAlpha);
738 QPen dashPen(fore);
739 dashPen.setStyle(Qt::DashLine);
740 p.setPen(dashPen);
741 const double spanY =height * 1.0 / DS_CONF_DSO_VDIVS;
742 for (i = 1; i <= DS_CONF_DSO_VDIVS; i++) {
743 const double posY = spanY * i + UpMargin;
744 if (i != DS_CONF_DSO_VDIVS)
745 p.drawLine(left, posY, right, posY);
746 const double miniSpanY = spanY / 5;
747 for (j = 1; j < 5; j++) {
748 p.drawLine(width / 2.0f - 5, posY - miniSpanY * j,

Callers

nothing calls this directly

Calls 5

cur_samplelimitsMethod · 0.80
cur_snap_samplerateMethod · 0.80
scaleMethod · 0.80
offsetMethod · 0.80
set_backMethod · 0.80

Tested by

no test coverage detected