2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
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.
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.
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/>.
20 #include <libsigrokdecode/libsigrokdecode.h>
25 #include <pv/data/decode/annotation.hpp>
26 #include <pv/data/decode/decoder.hpp>
27 #include "pv/data/decode/rowdata.hpp"
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),
40 ann_class_id_(ann_class_id),
45 Annotation::Annotation(Annotation&& a) :
46 start_sample_(a.start_sample_),
47 end_sample_(a.end_sample_),
49 ann_class_id_(a.ann_class_id_),
54 Annotation& Annotation::operator=(Annotation&& a)
57 start_sample_ = a.start_sample_;
58 end_sample_ = a.end_sample_;
60 ann_class_id_ = a.ann_class_id_;
67 const RowData* Annotation::row_data() const
72 const Row* Annotation::row() const
77 uint64_t Annotation::start_sample() const
82 uint64_t Annotation::end_sample() const
87 uint64_t Annotation::length() const
89 return end_sample_ - start_sample_;
92 uint32_t Annotation::ann_class_id() const
97 const QString Annotation::ann_class_name() const
99 const AnnotationClass* ann_class =
100 data_->row()->decoder()->get_ann_class_by_id(ann_class_id_);
102 return QString(ann_class->name);
105 const QString Annotation::ann_class_description() const
107 const AnnotationClass* ann_class =
108 data_->row()->decoder()->get_ann_class_by_id(ann_class_id_);
110 return QString(ann_class->description);
113 const vector<QString>* Annotation::annotations() const
118 const QString Annotation::longest_annotation() const
120 return texts_->front();
123 bool Annotation::visible() const
125 const Row* row = data_->row();
127 return (row->visible() && row->class_is_visible(ann_class_id_)
128 && row->decoder()->visible());
131 const QColor Annotation::color() const
133 return data_->row()->get_class_color(ann_class_id_);
136 const QColor Annotation::bright_color() const
138 return data_->row()->get_bright_class_color(ann_class_id_);
141 const QColor Annotation::dark_color() const
143 return data_->row()->get_dark_class_color(ann_class_id_);
146 bool Annotation::operator<(const Annotation &other) const
148 return (start_sample_ < other.start_sample_);
151 } // namespace decode