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

Method paint_trace

DSView/pv/view/dsosignal.cpp:967–1015  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965}
966
967void DsoSignal::paint_trace(QPainter &p,
968 const pv::data::DsoSnapshot *snapshot,
969 int zeroY, int left, const int64_t start, const int64_t end, int hw_offset,
970 const double pixels_offset, const double samples_per_pixel, uint64_t num_channels)
971{
972 (void)num_channels;
973
974 const int64_t sample_count = end - start + 1;
975
976 if (sample_count > 0) {
977 pv::data::DsoSnapshot *pshot = const_cast<pv::data::DsoSnapshot*>(snapshot);
978 const uint8_t *const samples_buffer = pshot->get_samples(start, end, get_index());;
979 assert(samples_buffer);
980
981 QColor trace_colour = _colour;
982 trace_colour.setAlpha(View::ForeAlpha);
983 p.setPen(trace_colour);
984
985 QPointF *points = new QPointF[sample_count];
986 QPointF *point = points;
987
988 float top = get_view_rect().top();
989 float bottom = get_view_rect().bottom();
990 float right = (float)get_view_rect().right();
991 double pixels_per_sample = 1.0/samples_per_pixel;
992
993 uint8_t value;
994 float x = (start / samples_per_pixel - pixels_offset) + left + _view->trig_hoff()*pixels_per_sample;
995 float y;
996
997 for (int64_t sample = 0; sample < sample_count; sample++) {
998 value = samples_buffer[sample];
999 y = min(max(top, zeroY + (value - hw_offset) * _scale), bottom);
1000 if (x > right) {
1001 point--;
1002 const float lastY = point->y() + (y - point->y()) / (x - point->x()) * (right - point->x());
1003 point++;
1004 *point++ = QPointF(right, lastY);
1005 break;
1006 }
1007 *point++ = QPointF(x, y);
1008 x += pixels_per_sample;
1009 }
1010
1011 p.drawPolyline(points, point - points);
1012
1013 delete[] points;
1014 }
1015}
1016
1017void DsoSignal::paint_envelope(QPainter &p,
1018 const pv::data::DsoSnapshot *snapshot,

Callers

nothing calls this directly

Calls 2

trig_hoffMethod · 0.80
get_samplesMethod · 0.45

Tested by

no test coverage detected