forked from Ivasoft/DSView
decoder's annotation string be from resource table
This commit is contained in:
56
DSView/pv/data/decode/AnnotationResTable.cpp
Normal file
56
DSView/pv/data/decode/AnnotationResTable.cpp
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the PulseView project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||||
|
* Copyright (C) 2014 DreamSourceLab <support@dreamsourcelab.com>
|
||||||
|
*
|
||||||
|
* 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 <assert.h>
|
||||||
|
|
||||||
|
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
48
DSView/pv/data/decode/AnnotationResTable.h
Normal file
48
DSView/pv/data/decode/AnnotationResTable.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the PulseView project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||||
|
* Copyright (C) 2014 DreamSourceLab <support@dreamsourcelab.com>
|
||||||
|
*
|
||||||
|
* 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 <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
typedef std::vector<QString> 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<std::string, int> m_indexs;
|
||||||
|
std::vector<AnnotationStringList> m_resourceTable;
|
||||||
|
};
|
||||||
@@ -25,11 +25,16 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "annotation.h"
|
#include "annotation.h"
|
||||||
|
#include "AnnotationResTable.h"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
namespace data {
|
namespace data {
|
||||||
namespace decode {
|
namespace decode {
|
||||||
|
|
||||||
|
//a find talbe instance
|
||||||
|
AnnotationResTable *Annotation::m_resTable = new AnnotationResTable();
|
||||||
|
|
||||||
Annotation::Annotation(const srd_proto_data *const pdata) :
|
Annotation::Annotation(const srd_proto_data *const pdata) :
|
||||||
_start_sample(pdata->start_sample),
|
_start_sample(pdata->start_sample),
|
||||||
_end_sample(pdata->end_sample)
|
_end_sample(pdata->end_sample)
|
||||||
@@ -40,13 +45,31 @@ Annotation::Annotation(const srd_proto_data *const pdata) :
|
|||||||
assert(pda);
|
assert(pda);
|
||||||
|
|
||||||
_format = pda->ann_class;
|
_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;
|
const char *const *annotations = (char**)pda->ann_text;
|
||||||
while(*annotations) {
|
while(*annotations) {
|
||||||
_annotations.push_back(QString::fromUtf8(*annotations));
|
const char *ptr = *annotations;
|
||||||
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()
|
Annotation::Annotation()
|
||||||
@@ -57,7 +80,7 @@ Annotation::Annotation()
|
|||||||
|
|
||||||
Annotation::~Annotation()
|
Annotation::~Annotation()
|
||||||
{
|
{
|
||||||
_annotations.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Annotation::start_sample() const
|
uint64_t Annotation::start_sample() const
|
||||||
@@ -82,8 +105,9 @@ int Annotation::type() const
|
|||||||
|
|
||||||
const std::vector<QString>& Annotation::annotations() const
|
const std::vector<QString>& Annotation::annotations() const
|
||||||
{
|
{
|
||||||
return _annotations;
|
return Annotation::m_resTable->GetString(_strIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace decode
|
} // namespace decode
|
||||||
} // namespace data
|
} // namespace data
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
class AnnotationResTable;
|
||||||
|
|
||||||
struct srd_proto_data;
|
struct srd_proto_data;
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
@@ -37,20 +39,26 @@ class Annotation
|
|||||||
public:
|
public:
|
||||||
Annotation(const srd_proto_data *const pdata);
|
Annotation(const srd_proto_data *const pdata);
|
||||||
Annotation();
|
Annotation();
|
||||||
|
public:
|
||||||
|
|
||||||
~Annotation();
|
~Annotation();
|
||||||
|
|
||||||
uint64_t start_sample() const;
|
uint64_t start_sample() const;
|
||||||
uint64_t end_sample() const;
|
uint64_t end_sample() const;
|
||||||
int format() const;
|
int format() const;
|
||||||
int type() const;
|
int type() const;
|
||||||
|
|
||||||
|
public:
|
||||||
const std::vector<QString>& annotations() const;
|
const std::vector<QString>& annotations() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t _start_sample;
|
uint64_t _start_sample;
|
||||||
uint64_t _end_sample;
|
uint64_t _end_sample;
|
||||||
int _format;
|
short _format;
|
||||||
int _type;
|
short _type;
|
||||||
std::vector<QString> _annotations;
|
short _strIndex;
|
||||||
|
|
||||||
|
static AnnotationResTable * m_resTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace decode
|
} // namespace decode
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
const srd_decoder *_decoder;
|
const srd_decoder *_decoder;
|
||||||
const srd_decoder_annotation_row *_row;
|
const srd_decoder_annotation_row *_row;
|
||||||
int _order;
|
int _order;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // decode
|
} // decode
|
||||||
|
|||||||
@@ -658,7 +658,7 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder)
|
|||||||
// Add the annotation
|
// Add the annotation
|
||||||
boost::lock_guard<boost::recursive_mutex> lock(d->_output_mutex);
|
boost::lock_guard<boost::recursive_mutex> lock(d->_output_mutex);
|
||||||
if (!(*row_iter).second.push_annotation(a))
|
if (!(*row_iter).second.push_annotation(a))
|
||||||
d->_no_memory = true;
|
d->_no_memory = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecoderStack::on_new_frame()
|
void DecoderStack::on_new_frame()
|
||||||
|
|||||||
@@ -77,9 +77,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DecoderStack(pv::SigSession &_session,
|
DecoderStack(pv::SigSession &_session,
|
||||||
const srd_decoder *const decoder);
|
const srd_decoder *const decoder);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
virtual ~DecoderStack();
|
virtual ~DecoderStack();
|
||||||
|
|
||||||
const std::list< boost::shared_ptr<decode::Decoder> >& stack() const;
|
const std::list< boost::shared_ptr<decode::Decoder> >& stack() const;
|
||||||
|
|||||||
@@ -518,9 +518,11 @@ void MainWindow::device_attach()
|
|||||||
|
|
||||||
struct sr_dev_driver **const drivers = sr_driver_list();
|
struct sr_dev_driver **const drivers = sr_driver_list();
|
||||||
struct sr_dev_driver **driver;
|
struct sr_dev_driver **driver;
|
||||||
|
|
||||||
for (driver = drivers; *driver; driver++)
|
for (driver = drivers; *driver; driver++)
|
||||||
if (*driver)
|
if (*driver)
|
||||||
_device_manager.driver_scan(*driver);
|
_device_manager.driver_scan(*driver);
|
||||||
|
|
||||||
|
|
||||||
_session.set_default_device(boost::bind(&MainWindow::session_error, this,
|
_session.set_default_device(boost::bind(&MainWindow::session_error, this,
|
||||||
QString(tr("Set Default Device failed")), _1));
|
QString(tr("Set Default Device failed")), _1));
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class AnalogSnapshot;
|
|||||||
|
|
||||||
namespace view {
|
namespace view {
|
||||||
|
|
||||||
//when device is data acquisition model, to draw trace
|
//when device is data acquisition model, to draw signal trace
|
||||||
//created by SigSession
|
//created by SigSession
|
||||||
class AnalogSignal : public Signal
|
class AnalogSignal : public Signal
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ void DevMode::changeEvent(QEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DevMode::set_device()
|
void DevMode::set_device()
|
||||||
{
|
{
|
||||||
const boost::shared_ptr<device::DevInst> dev_inst = _session.get_device();
|
const boost::shared_ptr<device::DevInst> dev_inst = _session.get_device();
|
||||||
assert(dev_inst);
|
assert(dev_inst);
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ void DevMode::set_device()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DevMode::paintEvent(QPaintEvent*)
|
void DevMode::paintEvent(QPaintEvent*)
|
||||||
{
|
{
|
||||||
using pv::view::Trace;
|
using pv::view::Trace;
|
||||||
|
|
||||||
QStyleOption o;
|
QStyleOption o;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class SigSession;
|
|||||||
|
|
||||||
namespace view {
|
namespace view {
|
||||||
|
|
||||||
|
//devece work mode select list
|
||||||
class DevMode : public QWidget
|
class DevMode : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class SpectrumStack;
|
|||||||
|
|
||||||
namespace view {
|
namespace view {
|
||||||
|
|
||||||
//draw Scope signal trace
|
//when device is oscillcopse mode, to draw signal trace
|
||||||
//created by SigSession
|
//created by SigSession
|
||||||
class SpectrumTrace : public Trace
|
class SpectrumTrace : public Trace
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ void Viewport::paintEvent(QPaintEvent *event)
|
|||||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||||
{
|
{
|
||||||
assert(t);
|
assert(t);
|
||||||
|
|
||||||
t->paint_back(p, 0, _view.get_view_width(), fore, back);
|
t->paint_back(p, 0, _view.get_view_width(), fore, back);
|
||||||
if (_view.back_ready())
|
if (_view.back_ready())
|
||||||
break;
|
break;
|
||||||
@@ -234,6 +234,15 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
|
|||||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||||
{
|
{
|
||||||
assert(t);
|
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())
|
if (t->enabled())
|
||||||
t->paint_mid(dbp, 0, t->get_view_rect().right(), fore, back);
|
t->paint_mid(dbp, 0, t->get_view_rect().right(), fore, back);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user