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

Method draw_annotation

DSView/pv/view/decodetrace.cpp:326–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a,
327 QPainter &p, QColor text_color, int h, int left, int right,
328 double samples_per_pixel, double pixels_offset, int y,
329 size_t base_colour, double min_annWidth, QColor fore, QColor back, double &last_x)
330{
331 const double start = max(a.start_sample() / samples_per_pixel -
332 pixels_offset, (double)left);
333 const double end = min(a.end_sample() / samples_per_pixel -
334 pixels_offset, (double)right);
335
336 const size_t colour = ((base_colour + a.type()) % MaxAnnType) % countof(Colours);
337 const QColor &fill = Colours[colour];
338 const QColor &outline = OutlineColours[colour];
339
340 if (start > right + DrawPadding || end < left - DrawPadding){
341 return;
342 }
343
344 if (end - last_x <= 0.5 && end - start < 1){
345 return;
346 }
347
348 last_x = end;
349
350 if (_decoder_stack->get_mark_index() == (int64_t)(a.start_sample()+ a.end_sample())/2) {
351 p.setPen(View::Blue);
352 int xpos = (start+end)/2;
353 int ypos = get_y()+_totalHeight*0.5 + 1;
354 const QPoint triangle[] = {
355 QPoint(xpos, ypos),
356 QPoint(xpos-1, ypos + 1),
357 QPoint(xpos, ypos + 1),
358 QPoint(xpos+1, ypos + 1),
359 QPoint(xpos-2, ypos + 2),
360 QPoint(xpos-1, ypos + 2),
361 QPoint(xpos, ypos + 2),
362 QPoint(xpos+1, ypos + 2),
363 QPoint(xpos+2, ypos + 2),
364 };
365 p.drawPoints(triangle, 9);
366 }
367
368 if (a.start_sample() == a.end_sample()){
369 draw_instant(a, p, fill, outline, text_color, h,
370 start, y, min_annWidth);
371 }
372 else {
373 draw_range(a, p, fill, outline, text_color, h,
374 start, end, y, fore, back);
375
376 if ((a.type()/100 == 2) && (end - start > 20))
377 {
378 for(auto dec : _decoder_stack->stack())
379 {
380 auto probes = dec->binded_probe_list();
381
382 for (auto probe : probes) {
383 int type = dec->get_channel_type(probe);

Callers

nothing calls this directly

Calls 10

start_sampleMethod · 0.80
end_sampleMethod · 0.80
typeMethod · 0.80
get_mark_indexMethod · 0.80
binded_probe_listMethod · 0.80
get_channel_typeMethod · 0.80
binded_probe_indexMethod · 0.80
signal_typeMethod · 0.80
paint_markMethod · 0.80
get_indexMethod · 0.45

Tested by

no test coverage detected