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 "annotation.h"
|
||||
|
||||
#include "AnnotationResTable.h"
|
||||
#include <cstring>
|
||||
|
||||
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<QString>& Annotation::annotations() const
|
||||
{
|
||||
return _annotations;
|
||||
}
|
||||
return Annotation::m_resTable->GetString(_strIndex);
|
||||
}
|
||||
|
||||
|
||||
} // namespace decode
|
||||
} // namespace data
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
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<QString>& annotations() const;
|
||||
|
||||
private:
|
||||
uint64_t _start_sample;
|
||||
uint64_t _end_sample;
|
||||
int _format;
|
||||
int _type;
|
||||
std::vector<QString> _annotations;
|
||||
short _format;
|
||||
short _type;
|
||||
short _strIndex;
|
||||
|
||||
static AnnotationResTable * m_resTable;
|
||||
};
|
||||
|
||||
} // namespace decode
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
private:
|
||||
const srd_decoder *_decoder;
|
||||
const srd_decoder_annotation_row *_row;
|
||||
int _order;
|
||||
int _order;
|
||||
};
|
||||
|
||||
} // decode
|
||||
|
||||
@@ -658,7 +658,7 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder)
|
||||
// Add the annotation
|
||||
boost::lock_guard<boost::recursive_mutex> lock(d->_output_mutex);
|
||||
if (!(*row_iter).second.push_annotation(a))
|
||||
d->_no_memory = true;
|
||||
d->_no_memory = true;
|
||||
}
|
||||
|
||||
void DecoderStack::on_new_frame()
|
||||
|
||||
@@ -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<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 **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));
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ void DevMode::changeEvent(QEvent *event)
|
||||
}
|
||||
|
||||
void DevMode::set_device()
|
||||
{
|
||||
{
|
||||
const boost::shared_ptr<device::DevInst> 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;
|
||||
|
||||
@@ -50,6 +50,7 @@ class SigSession;
|
||||
|
||||
namespace view {
|
||||
|
||||
//devece work mode select list
|
||||
class DevMode : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ void Viewport::paintEvent(QPaintEvent *event)
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> 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<Trace> 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user