]> sigrok.org Git - pulseview.git/blob - pv/data/decode/row.hpp
71945f2e0cf0899ffc911001ef5beff0e4f17bb4
[pulseview.git] / pv / data / decode / row.hpp
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef PULSEVIEW_PV_DATA_DECODE_ROW_HPP
21 #define PULSEVIEW_PV_DATA_DECODE_ROW_HPP
22
23 #include <vector>
24
25 #include <QColor>
26
27 #include <pv/data/decode/annotation.hpp>
28 #include <pv/data/decode/decoder.hpp>
29
30 struct srd_decoder;
31 struct srd_decoder_annotation_row;
32
33 namespace pv {
34 namespace data {
35 namespace decode {
36
37 #define DECODE_COLOR_SATURATION (180) /* 0-255 */
38 #define DECODE_COLOR_VALUE (170) /* 0-255 */
39
40 struct AnnotationClass;
41 class Decoder;
42
43 class Row
44 {
45 public:
46         Row();
47
48         Row(uint32_t index, Decoder* decoder,
49                 const srd_decoder_annotation_row* srd_row = nullptr);
50
51         const Decoder* decoder() const;
52         const srd_decoder_annotation_row* get_srd_row() const;
53
54         const QString title() const;
55         const QString description() const;
56         vector<AnnotationClass*> ann_classes() const;
57         uint32_t index() const;
58
59         bool visible() const;
60         void set_visible(bool visible);
61
62         void set_base_color(QColor base_color);
63         const QColor color() const;
64         const QColor get_class_color(uint32_t ann_class_id) const;
65         const QColor get_bright_class_color(uint32_t ann_class_id) const;
66         const QColor get_dark_class_color(uint32_t ann_class_id) const;
67
68         bool has_hidden_classes() const;
69         bool class_is_visible(uint32_t ann_class_id) const;
70
71         bool operator<(const Row& other) const;
72         bool operator==(const Row& other) const;
73
74 private:
75         uint32_t index_;
76         Decoder* decoder_;
77         const srd_decoder_annotation_row* srd_row_;
78         bool visible_;
79
80         QColor color_;
81         map<uint32_t, QColor> ann_class_color_;
82         map<uint32_t, QColor> ann_bright_class_color_;
83         map<uint32_t, QColor> ann_dark_class_color_;
84 };
85
86 }  // namespace decode
87 }  // namespace data
88 }  // namespace pv
89
90 #endif // PULSEVIEW_PV_DATA_DECODE_ROW_HPP