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

Method paint_envelope

DSView/pv/view/analogsignal.cpp:525–599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525void AnalogSignal::paint_envelope(QPainter &p,
526 const pv::data::AnalogSnapshot *snapshot,
527 int zeroY, const int start_pixel,
528 const uint64_t start_index, const int64_t sample_count,
529 const double samples_per_pixel, const int order,
530 const float top, const float bottom, const int width)
531{
532 using namespace Qt;
533 using pv::data::AnalogSnapshot;
534 pv::data::AnalogSnapshot *pshot = const_cast<pv::data::AnalogSnapshot*>(snapshot);
535
536 AnalogSnapshot::EnvelopeSection e;
537 pshot->get_envelope_section(e, start_index, sample_count,
538 samples_per_pixel, order);
539 if (e.samples_num == 0)
540 return;
541
542 p.setPen(QPen(NoPen));
543 p.setBrush(_colour);
544
545 if (!_rects)
546 _rects = new QRectF[width+10];
547
548 QRectF *rect = _rects;
549 int px = -1, pre_px;
550 float y_min = zeroY, y_max = zeroY, pre_y_min = zeroY, pre_y_max = zeroY;
551 int pcnt = 0;
552 const double scale_pixels_per_samples = e.scale / samples_per_pixel;
553 int64_t end_v = pshot->get_ring_end();
554 const uint64_t ring_end = max((int64_t)0, end_v / e.scale - 1);
555 const int hw_offset = get_hw_offset();
556
557 float x = start_pixel;
558 for(uint64_t sample = 0; sample < e.length; sample++) {
559 const uint64_t ring_index = (e.start + sample) % (_view->session().cur_samplelimits() / e.scale);
560 if (sample != 0 && ring_index == ring_end)
561 break;
562
563 const AnalogSnapshot::EnvelopeSample *const ev =
564 e.samples + ((e.start + sample) % e.samples_num);
565
566 const float b = min(max((float)(zeroY + (ev->max - hw_offset) * _scale + 0.5), top), bottom);
567 const float t = min(max((float)(zeroY + (ev->min - hw_offset) * _scale + 0.5), top), bottom);
568
569 pre_px = px;
570 if(px != floor(x)) {
571 if (pre_px != -1) {
572 // We overlap this sample with the previous so that vertical
573 // gaps do not appear during steep rising or falling edges
574 if (pre_y_min > y_max)
575 *rect++ = QRectF(pre_px, y_min, 1.0f, pre_y_min-y_min+1);
576 else if (pre_y_max < y_min)
577 *rect++ = QRectF(pre_px, pre_y_max, 1.0f, y_max-pre_y_max+1);
578 else
579 *rect++ = QRectF(pre_px, y_min, 1.0f, y_max-y_min+1);
580 pre_y_min = y_min;
581 pre_y_max = y_max;
582 pcnt++;

Callers

nothing calls this directly

Calls 4

get_ring_endMethod · 0.80
cur_samplelimitsMethod · 0.80
sessionMethod · 0.80
get_envelope_sectionMethod · 0.45

Tested by

no test coverage detected