MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / paint_trace

Method paint_trace

DSView/pv/view/analogsignal.cpp:472–523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470}
471
472void AnalogSignal::paint_trace(QPainter &p,
473 const pv::data::AnalogSnapshot *snapshot,
474 int zeroY, const int start_pixel,
475 const uint64_t start_index, const int64_t sample_count,
476 const double samples_per_pixel, const int order,
477 const float top, const float bottom, const int width)
478{
479 (void)width;
480
481 pv::data::AnalogSnapshot *pshot = const_cast<pv::data::AnalogSnapshot*>(snapshot);
482
483 int64_t channel_num = (int64_t)pshot->get_channel_num();
484 if (sample_count > 0) {
485 const uint8_t unit_bytes = pshot->get_unit_bytes();
486 const uint8_t *const samples = pshot->get_samples(0);
487 assert(samples);
488
489 p.setPen(_colour);
490 //p.setPen(QPen(_colour, 2, Qt::SolidLine));
491
492 QPointF *points = new QPointF[sample_count];
493 QPointF *point = points;
494 uint64_t yindex = start_index;
495
496 const int hw_offset = get_hw_offset();
497 float x = start_pixel;
498 double pixels_per_sample = 1.0/samples_per_pixel;
499
500 for (int64_t sample = 0; sample < sample_count; sample++) {
501 uint64_t index = (yindex * channel_num + order) * unit_bytes;
502 float yvalue = samples[index];
503
504 for(uint8_t i = 1; i < unit_bytes; i++){
505 yvalue += (samples[++index] << i*8);
506 }
507
508 yvalue = zeroY + (yvalue - hw_offset) * _scale;
509 yvalue = min(max(yvalue, top), bottom);
510 *point++ = QPointF(x, yvalue);
511
512 if (yindex == pshot->get_ring_end())
513 break;
514
515 yindex++;
516 yindex %= pshot->get_sample_count();
517 x += pixels_per_sample;
518 }
519
520 p.drawPolyline(points, point - points);
521 delete[] points;
522 }
523}
524
525void AnalogSignal::paint_envelope(QPainter &p,
526 const pv::data::AnalogSnapshot *snapshot,

Callers

nothing calls this directly

Calls 5

get_channel_numMethod · 0.80
get_unit_bytesMethod · 0.80
get_ring_endMethod · 0.80
get_sample_countMethod · 0.80
get_samplesMethod · 0.45

Tested by

no test coverage detected