X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fcursorpair.cpp;h=c148b85139d55d052cf5c444af8a18f27cd002e7;hb=332afa7438aa5532599fe65f9092e1b24b34fe04;hp=7fe90c7b6ef11ccb12d3a91d8a3bb05c53334ee9;hpb=b42d25c43e52c900cbdd3e5cde0282961b8721e7;p=pulseview.git diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index 7fe90c7..c148b85 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -22,6 +22,10 @@ #include "view.h" +#include + +using namespace std; + namespace pv { namespace view { @@ -52,5 +56,33 @@ Cursor& CursorPair::second() return _second; } +void CursorPair::draw_markers(QPainter &p, + const QRect &rect, unsigned int prefix) +{ + _first.paint_label(p, rect, prefix); + _second.paint_label(p, rect, prefix); +} + +void CursorPair::draw_viewport_background(QPainter &p, + const QRect &rect) +{ + p.setPen(Qt::NoPen); + p.setBrush(QBrush(View::CursorAreaColour)); + + const float x1 = (_first.time() - _view.offset()) / _view.scale(); + const float x2 = (_second.time() - _view.offset()) / _view.scale(); + const int l = (int)max(min(x1, x2), 0.0f); + const int r = (int)min(max(x1, x2), (float)rect.width()); + + p.drawRect(l, 0, r - l, rect.height()); +} + +void CursorPair::draw_viewport_foreground(QPainter &p, + const QRect &rect) +{ + _first.paint(p, rect); + _second.paint(p, rect); +} + } // namespace view } // namespace pv