X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdata%2Fdecode%2Frow.cpp;fp=pv%2Fdata%2Fdecode%2Frow.cpp;h=70c430ac9d7395722192fe3b5a29e16a4036174d;hb=ae30ff422a495a6b1a4ad2893566628863ea222b;hp=f1895ae4ef7c71bb100c46d645fc356cc4d78b57;hpb=1dcd9b18186741d3ce3164f7e8d6cb13abb578d3;p=pulseview.git diff --git a/pv/data/decode/row.cpp b/pv/data/decode/row.cpp index f1895ae4..70c430ac 100644 --- a/pv/data/decode/row.cpp +++ b/pv/data/decode/row.cpp @@ -112,6 +112,54 @@ void Row::set_visible(bool visible) visible_ = visible; } +void Row::set_base_color(QColor base_color) +{ + // For the row color, use the base color hue and add an offset that's + // not a dividend of 360 + + const int h = (base_color.toHsv().hue() + 20 * index_) % 360; + const int s = DECODE_COLOR_SATURATION; + const int v = DECODE_COLOR_VALUE; + color_.setHsl(h, s, v); + + vector classes = ann_classes(); + for (const AnnotationClass* ann_class : classes) { + + // For each class color, use the row color hue and add an offset that's + // not a dividend of 360 and not a multiple of the row offset + + QColor ann_color(color_); + const int h = (ann_color.toHsv().hue() + 55 * ann_class->id) % 360; + const int s = DECODE_COLOR_SATURATION; + const int v = DECODE_COLOR_VALUE; + ann_color.setHsl(h, s, v); + + ann_class_color_[ann_class->id] = ann_color; + ann_bright_class_color_[ann_class->id] = ann_color.lighter(); + ann_dark_class_color_[ann_class->id] = ann_color.darker(); + } +} + +const QColor Row::color() const +{ + return color_; +} + +const QColor Row::get_class_color(uint32_t ann_class_id) const +{ + return ann_class_color_.at(ann_class_id); +} + +const QColor Row::get_bright_class_color(uint32_t ann_class_id) const +{ + return ann_bright_class_color_.at(ann_class_id); +} + +const QColor Row::get_dark_class_color(uint32_t ann_class_id) const +{ + return ann_dark_class_color_.at(ann_class_id); +} + bool Row::has_hidden_classes() const { for (const AnnotationClass* c : ann_classes())