X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fdecode%2Fannotation.cpp;fp=pv%2Fview%2Fdecode%2Fannotation.cpp;h=741569b2e055f18ed5948ed738c3981dac56eeab;hp=4d9a048357bbe1ea7054edeb0dd64388d5217833;hb=9472f4476b27336e9187635015169e308bfe8af7;hpb=e0fc58100fbcd6c3bfd5aecb213d7541a3436622 diff --git a/pv/view/decode/annotation.cpp b/pv/view/decode/annotation.cpp index 4d9a0483..741569b2 100644 --- a/pv/view/decode/annotation.cpp +++ b/pv/view/decode/annotation.cpp @@ -22,6 +22,8 @@ extern "C" { #include } +#include + #include "annotation.h" using namespace boost; @@ -42,6 +44,32 @@ Annotation::Annotation(const srd_proto_data *const pdata) : } } +void Annotation::paint(QPainter &p, int left, int right, + double samples_per_pixel, double pixels_offset, int y) +{ + const int AnnotationHeight = 40; + + const double start = _start_sample / samples_per_pixel - + pixels_offset; + const double end = _end_sample / samples_per_pixel - + pixels_offset; + + if (start > right) + return; + if (end < left) + return; + + QRectF rect(start, y - AnnotationHeight/2, + end - start, AnnotationHeight); + + p.setPen(Qt::black); + p.fillRect(rect, QBrush(Qt::red)); + p.drawRect(rect); + + if(!_annotations.empty()) + p.drawText(rect, Qt::AlignCenter, _annotations.front()); +} + } // namespace decode } // namespace view } // namespace pv