diff --git a/DSView/pv/data/decode/AnnotationResTable.cpp b/DSView/pv/data/decode/AnnotationResTable.cpp new file mode 100644 index 00000000..805129f3 --- /dev/null +++ b/DSView/pv/data/decode/AnnotationResTable.cpp @@ -0,0 +1,56 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2013 Joel Holdsworth + * Copyright (C) 2014 DreamSourceLab + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "AnnotationResTable.h" +#include + + +AnnotationResTable::AnnotationResTable(){ + +} + +AnnotationResTable::~AnnotationResTable(){ + +} + +int AnnotationResTable::MakeIndex(const std::string &key, AnnotationStringList *&ls) +{ + auto fd =m_indexs.find(key); + if (fd != m_indexs.end()){ + return (*fd).second; + } + + int dex = m_indexs.size(); + m_indexs[key] = dex; + + //make a new string vector + m_resourceTable.push_back(AnnotationStringList()); + ls = &m_resourceTable[dex]; + + return dex; +} + +const AnnotationStringList& AnnotationResTable::GetString(int index){ + int num = m_resourceTable.size(); + assert(index >= 0 && index < num); + return m_resourceTable[index]; +} + diff --git a/DSView/pv/data/decode/AnnotationResTable.h b/DSView/pv/data/decode/AnnotationResTable.h new file mode 100644 index 00000000..21639ae5 --- /dev/null +++ b/DSView/pv/data/decode/AnnotationResTable.h @@ -0,0 +1,48 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2013 Joel Holdsworth + * Copyright (C) 2014 DreamSourceLab + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#pragma once + +#include +#include +#include +#include + +typedef std::vector AnnotationStringList; + +class AnnotationResTable{ + + public: + AnnotationResTable(); + + ~AnnotationResTable(); + + int MakeIndex(const std::string &key, AnnotationStringList *&ls); + + const AnnotationStringList& GetString(int index); + + inline int GetCount(){return m_resourceTable.size();} + + + private: + std::map m_indexs; + std::vector m_resourceTable; +}; \ No newline at end of file diff --git a/DSView/pv/data/decode/annotation.cpp b/DSView/pv/data/decode/annotation.cpp index 7f23e36e..dbb10075 100755 --- a/DSView/pv/data/decode/annotation.cpp +++ b/DSView/pv/data/decode/annotation.cpp @@ -25,11 +25,16 @@ #include #include "annotation.h" - +#include "AnnotationResTable.h" +#include + namespace pv { namespace data { namespace decode { +//a find talbe instance +AnnotationResTable *Annotation::m_resTable = new AnnotationResTable(); + Annotation::Annotation(const srd_proto_data *const pdata) : _start_sample(pdata->start_sample), _end_sample(pdata->end_sample) @@ -40,13 +45,31 @@ Annotation::Annotation(const srd_proto_data *const pdata) : assert(pda); _format = pda->ann_class; - _type = pda->ann_type; + _type = pda->ann_type; + _strIndex = 0; + + std::string key; + //make resource find key const char *const *annotations = (char**)pda->ann_text; - while(*annotations) { - _annotations.push_back(QString::fromUtf8(*annotations)); - annotations++; + while(*annotations) { + const char *ptr = *annotations; + key.append(ptr, strlen(ptr)); + annotations++; } + + AnnotationStringList *annotationArray = NULL; + _strIndex = Annotation::m_resTable->MakeIndex(key, annotationArray); + + //save new string lines + if (annotationArray){ + annotations = (char **)pda->ann_text; + while (*annotations) + { + annotationArray->push_back(QString::fromUtf8(*annotations)); + annotations++; + } + } } Annotation::Annotation() @@ -57,7 +80,7 @@ Annotation::Annotation() Annotation::~Annotation() { - _annotations.clear(); + } uint64_t Annotation::start_sample() const @@ -82,8 +105,9 @@ int Annotation::type() const const std::vector& Annotation::annotations() const { - return _annotations; -} + return Annotation::m_resTable->GetString(_strIndex); +} + } // namespace decode } // namespace data diff --git a/DSView/pv/data/decode/annotation.h b/DSView/pv/data/decode/annotation.h index 03e208ef..f55035b0 100755 --- a/DSView/pv/data/decode/annotation.h +++ b/DSView/pv/data/decode/annotation.h @@ -26,6 +26,8 @@ #include +class AnnotationResTable; + struct srd_proto_data; namespace pv { @@ -37,20 +39,26 @@ class Annotation public: Annotation(const srd_proto_data *const pdata); Annotation(); +public: + ~Annotation(); uint64_t start_sample() const; uint64_t end_sample() const; int format() const; - int type() const; + int type() const; + +public: const std::vector& annotations() const; private: uint64_t _start_sample; uint64_t _end_sample; - int _format; - int _type; - std::vector _annotations; + short _format; + short _type; + short _strIndex; + + static AnnotationResTable * m_resTable; }; } // namespace decode diff --git a/DSView/pv/data/decode/row.h b/DSView/pv/data/decode/row.h index 9466a68d..1b2fb84f 100755 --- a/DSView/pv/data/decode/row.h +++ b/DSView/pv/data/decode/row.h @@ -52,7 +52,7 @@ public: private: const srd_decoder *_decoder; const srd_decoder_annotation_row *_row; - int _order; + int _order; }; } // decode diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index 60bb699e..1c4f6602 100755 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -658,7 +658,7 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) // Add the annotation boost::lock_guard lock(d->_output_mutex); if (!(*row_iter).second.push_annotation(a)) - d->_no_memory = true; + d->_no_memory = true; } void DecoderStack::on_new_frame() diff --git a/DSView/pv/data/decoderstack.h b/DSView/pv/data/decoderstack.h index c7baf7cc..091a9d96 100755 --- a/DSView/pv/data/decoderstack.h +++ b/DSView/pv/data/decoderstack.h @@ -77,9 +77,11 @@ public: }; public: - DecoderStack(pv::SigSession &_session, + DecoderStack(pv::SigSession &_session, const srd_decoder *const decoder); +public: + virtual ~DecoderStack(); const std::list< boost::shared_ptr >& stack() const; diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 746f34f2..b585a0f9 100755 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -518,9 +518,11 @@ void MainWindow::device_attach() struct sr_dev_driver **const drivers = sr_driver_list(); struct sr_dev_driver **driver; + for (driver = drivers; *driver; driver++) - if (*driver) - _device_manager.driver_scan(*driver); + if (*driver) + _device_manager.driver_scan(*driver); + _session.set_default_device(boost::bind(&MainWindow::session_error, this, QString(tr("Set Default Device failed")), _1)); diff --git a/DSView/pv/view/analogsignal.h b/DSView/pv/view/analogsignal.h index 0555175d..94e29290 100755 --- a/DSView/pv/view/analogsignal.h +++ b/DSView/pv/view/analogsignal.h @@ -37,7 +37,7 @@ class AnalogSnapshot; namespace view { -//when device is data acquisition model, to draw trace +//when device is data acquisition model, to draw signal trace //created by SigSession class AnalogSignal : public Signal { diff --git a/DSView/pv/view/devmode.cpp b/DSView/pv/view/devmode.cpp index f567a7a0..572f9651 100755 --- a/DSView/pv/view/devmode.cpp +++ b/DSView/pv/view/devmode.cpp @@ -90,7 +90,7 @@ void DevMode::changeEvent(QEvent *event) } void DevMode::set_device() -{ +{ const boost::shared_ptr dev_inst = _session.get_device(); assert(dev_inst); @@ -142,7 +142,7 @@ void DevMode::set_device() } void DevMode::paintEvent(QPaintEvent*) -{ +{ using pv::view::Trace; QStyleOption o; diff --git a/DSView/pv/view/devmode.h b/DSView/pv/view/devmode.h index 999f1df0..6dc2f5d9 100755 --- a/DSView/pv/view/devmode.h +++ b/DSView/pv/view/devmode.h @@ -50,6 +50,7 @@ class SigSession; namespace view { +//devece work mode select list class DevMode : public QWidget { Q_OBJECT diff --git a/DSView/pv/view/spectrumtrace.h b/DSView/pv/view/spectrumtrace.h index ea78082d..7173188b 100755 --- a/DSView/pv/view/spectrumtrace.h +++ b/DSView/pv/view/spectrumtrace.h @@ -40,7 +40,7 @@ class SpectrumStack; namespace view { -//draw Scope signal trace +//when device is oscillcopse mode, to draw signal trace //created by SigSession class SpectrumTrace : public Trace { diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index e5fa036a..4646fd9d 100755 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -157,7 +157,7 @@ void Viewport::paintEvent(QPaintEvent *event) BOOST_FOREACH(const boost::shared_ptr t, traces) { assert(t); - + t->paint_back(p, 0, _view.get_view_width(), fore, back); if (_view.back_ready()) break; @@ -234,6 +234,15 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back) BOOST_FOREACH(const boost::shared_ptr t, traces) { assert(t); + + /* + auto ptr = t->get(); + if (ptr->enabled()){ + ptr->paint_mid(dbp, 0, t->get_view_rect().right(), fore, back); + continue; + } + */ + if (t->enabled()) t->paint_mid(dbp, 0, t->get_view_rect().right(), fore, back); }