]> sigrok.org Git - pulseview.git/commitdiff
Improved row annotation colouring
authorJoel Holdsworth <redacted>
Sun, 2 Feb 2014 19:24:34 +0000 (19:24 +0000)
committerUwe Hermann <redacted>
Sun, 2 Feb 2014 20:57:26 +0000 (21:57 +0100)
pv/view/decodetrace.cpp
pv/view/decodetrace.h

index 161eb9668bdd2217a43e8173d396138ea2908c6e..dd76b4ca4a78e491dbac1b5784aba4d624d56739 100644 (file)
@@ -164,8 +164,9 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
        assert(_decoder_stack);
 
        const vector<Row> 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<Annotation> 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)
index 2df848acbba38110c95d4018b9d48be33ceddf8a..9f0e68b5deee5cd8fc0229f9182c2d526d4d11b4 100644 (file)
@@ -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,