PulseView  unreleased development snapshot
A Qt-based sigrok GUI
annotation.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2012 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 #include <libsigrokdecode/libsigrokdecode.h>
21 
22 #include <cassert>
23 #include <vector>
24 
28 
29 using std::vector;
30 
31 namespace pv {
32 namespace data {
33 namespace decode {
34 
35 Annotation::Annotation(uint64_t start_sample, uint64_t end_sample,
36  const vector<QString>* texts, uint32_t ann_class_id, const RowData *data) :
37  start_sample_(start_sample),
38  end_sample_(end_sample),
39  texts_(texts),
40  ann_class_id_(ann_class_id),
41  data_(data)
42 {
43 }
44 
48  texts_(a.texts_),
50  data_(a.data_)
51 {
52 }
53 
55 {
56  if (&a != this) {
57  start_sample_ = a.start_sample_;
58  end_sample_ = a.end_sample_;
59  texts_ = a.texts_;
60  ann_class_id_ = a.ann_class_id_;
61  data_ = a.data_;
62  }
63 
64  return *this;
65 }
66 
68 {
69  return data_;
70 }
71 
72 const Row* Annotation::row() const
73 {
74  return data_->row();
75 }
76 
77 uint64_t Annotation::start_sample() const
78 {
79  return start_sample_;
80 }
81 
82 uint64_t Annotation::end_sample() const
83 {
84  return end_sample_;
85 }
86 
87 uint64_t Annotation::length() const
88 {
89  return end_sample_ - start_sample_;
90 }
91 
92 uint32_t Annotation::ann_class_id() const
93 {
94  return ann_class_id_;
95 }
96 
97 const QString Annotation::ann_class_name() const
98 {
99  const AnnotationClass* ann_class =
101 
102  return QString(ann_class->name);
103 }
104 
106 {
107  const AnnotationClass* ann_class =
109 
110  return QString(ann_class->description);
111 }
112 
113 const vector<QString>* Annotation::annotations() const
114 {
115  return texts_;
116 }
117 
118 const QString Annotation::longest_annotation() const
119 {
120  return texts_->front();
121 }
122 
124 {
125  const Row* row = data_->row();
126 
127  return (row->visible() && row->class_is_visible(ann_class_id_)
128  && row->decoder()->visible());
129 }
130 
131 const QColor Annotation::color() const
132 {
134 }
135 
136 const QColor Annotation::bright_color() const
137 {
139 }
140 
141 const QColor Annotation::dark_color() const
142 {
144 }
145 
146 bool Annotation::operator<(const Annotation &other) const
147 {
148  return (start_sample_ < other.start_sample_);
149 }
150 
151 } // namespace decode
152 } // namespace data
153 } // namespace pv
const QString ann_class_name() const
Definition: annotation.cpp:97
Annotation(uint64_t start_sample, uint64_t end_sample, const vector< QString > *texts, uint32_t ann_class_id, const RowData *data)
Definition: annotation.cpp:35
AnnotationClass * get_ann_class_by_id(size_t id)
Definition: decoder.cpp:294
bool visible() const
Definition: decoder.cpp:137
const QColor bright_color() const
Definition: annotation.cpp:136
const QColor color() const
Definition: annotation.cpp:131
uint64_t start_sample() const
Definition: annotation.cpp:77
uint64_t end_sample() const
Definition: annotation.cpp:82
const QColor get_bright_class_color(uint32_t ann_class_id) const
Definition: row.cpp:162
const vector< QString > * annotations() const
Definition: annotation.cpp:113
const QString ann_class_description() const
Definition: annotation.cpp:105
Annotation & operator=(Annotation &&a)
Definition: annotation.cpp:54
bool visible() const
Definition: row.cpp:106
static std::string data()
Definition: exprtk.hpp:39024
const Decoder * decoder() const
Definition: row.cpp:48
bool operator<(const Annotation &other) const
Definition: annotation.cpp:146
const vector< QString > * texts_
Definition: annotation.hpp:74
const QColor get_dark_class_color(uint32_t ann_class_id) const
Definition: row.cpp:171
const QColor get_class_color(uint32_t ann_class_id) const
Definition: row.cpp:151
uint32_t ann_class_id() const
Definition: annotation.cpp:92
const Row * row() const
Definition: rowdata.cpp:39
const RowData * row_data() const
Definition: annotation.cpp:67
uint64_t length() const
Definition: annotation.cpp:87
const Row * row() const
Definition: annotation.cpp:72
const QColor dark_color() const
Definition: annotation.cpp:141
const QString longest_annotation() const
Definition: annotation.cpp:118
bool class_is_visible(uint32_t ann_class_id) const
Definition: row.cpp:189