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

Method paint_envelope

DSView/pv/view/mathtrace.cpp:313–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313void MathTrace::paint_envelope(QPainter &p,
314 int zeroY, int left, const int64_t start, const int64_t end,
315 const double pixels_offset, const double samples_per_pixel)
316{
317 using namespace Qt;
318
319 data::MathStack::EnvelopeSection e;
320 _math_stack->get_math_envelope_section(e, start, end, samples_per_pixel);
321
322 if (e.length < 2)
323 return;
324
325 p.setPen(QPen(NoPen));
326 QColor envelope_colour = _colour;
327 envelope_colour.setAlpha(View::ForeAlpha);
328 p.setBrush(envelope_colour);
329
330 QRectF *const rects = new QRectF[e.length];
331 QRectF *rect = rects;
332 double top = get_view_rect().top();
333 double bottom = get_view_rect().bottom();
334
335 for(uint64_t sample = 0; sample < e.length-1; sample++) {
336 const float x = ((e.scale * sample + e.start) /
337 samples_per_pixel - pixels_offset) + left + _view->trig_hoff()/samples_per_pixel;
338 const data::MathStack::EnvelopeSample *const s =
339 e.samples + sample;
340
341 // We overlap this sample with the next so that vertical
342 // gaps do not appear during steep rising or falling edges
343 const float b = min(max(top, zeroY - max(s->max, (s+1)->min) * _scale), bottom);
344 const float t = min(max(top, zeroY - min(s->min, (s+1)->max) * _scale), bottom);
345
346 float h = b - t;
347 if(h >= 0.0f && h <= 1.0f)
348 h = 1.0f;
349 if(h <= 0.0f && h >= -1.0f)
350 h = -1.0f;
351
352 *rect++ = QRectF(x, t, 1.0f, h);
353 }
354
355 p.drawRects(rects, e.length);
356
357 delete[] rects;
358}
359
360void MathTrace::paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore)
361{

Callers

nothing calls this directly

Calls 2

trig_hoffMethod · 0.80

Tested by

no test coverage detected