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

Method paint_hover_measure

DSView/pv/view/mathtrace.cpp:409–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407}
408
409void MathTrace::paint_hover_measure(QPainter &p, QColor fore, QColor back)
410{
411 // Hover measure
412 if (_hover_en) {
413 QString hover_str = get_voltage(_hover_voltage, 2);
414 const int hover_width = p.boundingRect(0, 0, INT_MAX, INT_MAX,
415 Qt::AlignLeft | Qt::AlignTop, hover_str).width() + 10;
416 const int hover_height = p.boundingRect(0, 0, INT_MAX, INT_MAX,
417 Qt::AlignLeft | Qt::AlignTop, hover_str).height();
418 QRectF hover_rect(_hover_point.x(), _hover_point.y()-hover_height/2, hover_width, hover_height);
419 if (hover_rect.right() > get_view_rect().right())
420 hover_rect.moveRight(_hover_point.x());
421 if (hover_rect.top() < get_view_rect().top())
422 hover_rect.moveTop(_hover_point.y());
423 if (hover_rect.bottom() > get_view_rect().bottom())
424 hover_rect.moveBottom(_hover_point.y());
425
426 p.setPen(fore);
427 p.setBrush(back);
428 p.drawRect(_hover_point.x()-1, _hover_point.y()-1,
429 DsoSignal::HoverPointSize, DsoSignal::HoverPointSize);
430 p.drawText(hover_rect, Qt::AlignCenter | Qt::AlignTop | Qt::TextDontClip, hover_str);
431 }
432
433 auto &cursor_list = _view->get_cursorList();
434
435 for (auto cursor : cursor_list) {
436 float pt_value;
437 bool bError = false;
438
439 const QPointF pt = get_point(cursor->index(), pt_value, bError);
440
441 if (bError){
442 continue; //Have no value
443 }
444
445 const QString pt_str = get_voltage(pt_value, 2);
446
447 const int pt_width = p.boundingRect(0, 0, INT_MAX, INT_MAX,
448 Qt::AlignLeft | Qt::AlignTop, pt_str).width() + 10;
449 const int pt_height = p.boundingRect(0, 0, INT_MAX, INT_MAX,
450 Qt::AlignLeft | Qt::AlignTop, pt_str).height();
451 QRectF pt_rect(pt.x(), pt.y()-pt_height/2, pt_width, pt_height);
452
453 if (pt_rect.right() > get_view_rect().right())
454 pt_rect.moveRight(pt.x());
455 if (pt_rect.top() < get_view_rect().top())
456 pt_rect.moveTop(pt.y());
457 if (pt_rect.bottom() > get_view_rect().bottom())
458 pt_rect.moveBottom(pt.y());
459
460 p.drawRect(pt.x()-1, pt.y()-1, 2, 2);
461 p.drawLine(pt.x()-2, pt.y()-2, pt.x()+2, pt.y()+2);
462 p.drawLine(pt.x()+2, pt.y()-2, pt.x()-2, pt.y()+2);
463 p.drawText(pt_rect, Qt::AlignCenter | Qt::AlignTop | Qt::TextDontClip, pt_str);
464 }
465}
466

Callers

nothing calls this directly

Calls 1

indexMethod · 0.80

Tested by

no test coverage detected