From bf51365c1ff176d5ecb6a2a1f3da09cb1086ea46 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sun, 2 Feb 2014 19:24:34 +0000 Subject: [PATCH] Improved row annotation colouring --- pv/view/decodetrace.cpp | 11 ++++++----- pv/view/decodetrace.h | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 161eb966..dd76b4ca 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -164,8 +164,9 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) assert(_decoder_stack); const vector rows(_decoder_stack->get_rows()); - BOOST_FOREACH (const Row &row, rows) + for (size_t i = 0; i < rows.size(); i++) { + const Row &row = rows[i]; vector annotations; _decoder_stack->get_annotation_subset(annotations, row, start_sample, end_sample); @@ -173,7 +174,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) BOOST_FOREACH(const Annotation &a, annotations) draw_annotation(a, p, get_text_colour(), annotation_height, left, right, - samples_per_pixel, pixels_offset, y); + samples_per_pixel, pixels_offset, y, i); y += row_height; } } @@ -251,14 +252,14 @@ QMenu* DecodeTrace::create_context_menu(QWidget *parent) void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a, QPainter &p, QColor text_color, int h, int left, int right, double samples_per_pixel, - double pixels_offset, int y) const + double pixels_offset, int y, unsigned int row_index) const { const double start = a.start_sample() / samples_per_pixel - pixels_offset; const double end = a.end_sample() / samples_per_pixel - pixels_offset; - const QColor fill = Colours[(a.format() * (countof(Colours) / 2 + 1)) % - countof(Colours)]; + const QColor fill = Colours[((row_index * 2 + a.format()) * + (countof(Colours) / 4 + 1)) % countof(Colours)]; const QColor outline(fill.darker()); if (start > right + DrawPadding || end < left - DrawPadding) diff --git a/pv/view/decodetrace.h b/pv/view/decodetrace.h index 2df848ac..9f0e68b5 100644 --- a/pv/view/decodetrace.h +++ b/pv/view/decodetrace.h @@ -108,7 +108,8 @@ public: private: void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p, QColor text_colour, int text_height, int left, int right, - double samples_per_pixel, double pixels_offset, int y) const; + double samples_per_pixel, double pixels_offset, int y, + unsigned int row_index) const; void draw_instant(const pv::data::decode::Annotation &a, QPainter &p, QColor fill, QColor outline, QColor text_color, int h, double x, -- 2.30.2