]> sigrok.org Git - pulseview.git/blobdiff - pv/data/decode/annotation.cpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / data / decode / annotation.cpp
index 9f86b2bab84362e26503233c3cb516ee7ebcdf41..f8a5c47b66236a8be66327a2c9ea05568970749f 100644 (file)
@@ -17,9 +17,7 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-extern "C" {
 #include <libsigrokdecode/libsigrokdecode.h>
-}
 
 #include <cassert>
 #include <vector>
@@ -35,7 +33,7 @@ namespace data {
 namespace decode {
 
 Annotation::Annotation(uint64_t start_sample, uint64_t end_sample,
-       const vector<QString>* texts, Class ann_class_id, const RowData *data) :
+       const vector<QString>* texts, uint32_t ann_class_id, const RowData *data) :
        start_sample_(start_sample),
        end_sample_(end_sample),
        texts_(texts),
@@ -66,8 +64,14 @@ Annotation& Annotation::operator=(Annotation&& a)
        return *this;
 }
 
-Annotation::~Annotation()
+const RowData* Annotation::row_data() const
 {
+       return data_;
+}
+
+const Row* Annotation::row() const
+{
+       return data_->row();
 }
 
 uint64_t Annotation::start_sample() const
@@ -80,7 +84,12 @@ uint64_t Annotation::end_sample() const
        return end_sample_;
 }
 
-Annotation::Class Annotation::ann_class_id() const
+uint64_t Annotation::length() const
+{
+       return end_sample_ - start_sample_;
+}
+
+uint32_t Annotation::ann_class_id() const
 {
        return ann_class_id_;
 }
@@ -93,6 +102,14 @@ const QString Annotation::ann_class_name() const
        return QString(ann_class->name);
 }
 
+const QString Annotation::ann_class_description() const
+{
+       const AnnotationClass* ann_class =
+               data_->row()->decoder()->get_ann_class_by_id(ann_class_id_);
+
+       return QString(ann_class->description);
+}
+
 const vector<QString>* Annotation::annotations() const
 {
        return texts_;
@@ -103,9 +120,27 @@ const QString Annotation::longest_annotation() const
        return texts_->front();
 }
 
-const Row* Annotation::row() const
+bool Annotation::visible() const
 {
-       return data_->row();
+       const Row* row = data_->row();
+
+       return (row->visible() && row->class_is_visible(ann_class_id_)
+               && row->decoder()->visible());
+}
+
+const QColor Annotation::color() const
+{
+       return data_->row()->get_class_color(ann_class_id_);
+}
+
+const QColor Annotation::bright_color() const
+{
+       return data_->row()->get_bright_class_color(ann_class_id_);
+}
+
+const QColor Annotation::dark_color() const
+{
+       return data_->row()->get_dark_class_color(ann_class_id_);
 }
 
 bool Annotation::operator<(const Annotation &other) const