Commit a5ead175 authored by DreamSourceLab's avatar DreamSourceLab
Browse files

Add region decode feature

parent f0aff5e7
......@@ -93,11 +93,32 @@ void Decoder::set_option(const char *id, GVariant *value)
_setted = true;
}
void Decoder::set_decode_region(uint64_t start, uint64_t end)
{
_decode_start_back = start;
_decode_end_back = end;
if (_decode_start != start ||
_decode_end != end)
_setted = true;
}
uint64_t Decoder::decode_start() const
{
return _decode_start;
}
uint64_t Decoder::decode_end() const
{
return _decode_end;
}
bool Decoder::commit()
{
if (_setted) {
_probes = _probes_back;
_options = _options_back;
_decode_start = _decode_start_back;
_decode_end = _decode_end_back;
_setted = false;
return true;
} else {
......
......@@ -73,6 +73,10 @@ public:
std::set< boost::shared_ptr<pv::data::Logic> > get_data();
void set_decode_region(uint64_t start, uint64_t end);
uint64_t decode_start() const;
uint64_t decode_end() const;
bool commit();
private:
......@@ -88,6 +92,9 @@ private:
_probes_back;
std::map<std::string, GVariant*> _options_back;
uint64_t _decode_start, _decode_end;
uint64_t _decode_start_back, _decode_end_back;
bool _setted;
};
......
......@@ -333,43 +333,83 @@ boost::optional<uint64_t> DecoderStack::wait_for_data() const
_sample_count);
}
//void DecoderStack::decode_data(
// const uint64_t sample_count, const unsigned int unit_size,
// srd_session *const session)
//{
// //uint8_t chunk[DecodeChunkLength];
// uint8_t *chunk = NULL;
// //chunk = (uint8_t *)realloc(chunk, DecodeChunkLength);
// const uint64_t chunk_sample_count =
// DecodeChunkLength / _snapshot->unit_size();
// for (uint64_t i = 0;
// !boost::this_thread::interruption_requested() &&
// i < sample_count;
// i += chunk_sample_count)
// {
// //lock_guard<mutex> decode_lock(_global_decode_mutex);
// const uint64_t chunk_end = min(
// i + chunk_sample_count, sample_count);
// chunk = _snapshot->get_samples(i, chunk_end);
// if (srd_session_send(session, i, i + sample_count, chunk,
// (chunk_end - i) * unit_size, unit_size) != SRD_OK) {
// _error_message = tr("Decoder reported an error");
// break;
// }
// {
// lock_guard<mutex> lock(_output_mutex);
// _samples_decoded = chunk_end;
// }
// if (i % DecodeNotifyPeriod == 0)
// new_decode_data();
// }
// _options_changed = false;
// decode_done();
// //new_decode_data();
//}
void DecoderStack::decode_data(
const uint64_t sample_count, const unsigned int unit_size,
srd_session *const session)
const uint64_t decode_start, const uint64_t decode_end,
const unsigned int unit_size, srd_session *const session)
{
//uint8_t chunk[DecodeChunkLength];
uint8_t *chunk = NULL;
//chunk = (uint8_t *)realloc(chunk, DecodeChunkLength);
const uint64_t chunk_sample_count =
DecodeChunkLength / _snapshot->unit_size();
DecodeChunkLength / _snapshot->unit_size();
for (uint64_t i = 0;
!boost::this_thread::interruption_requested() &&
i < sample_count;
i += chunk_sample_count)
{
for (uint64_t i = decode_start;
!boost::this_thread::interruption_requested() &&
i < decode_end;
i += chunk_sample_count)
{
//lock_guard<mutex> decode_lock(_global_decode_mutex);
const uint64_t chunk_end = min(
i + chunk_sample_count, sample_count);
i + chunk_sample_count, decode_end);
chunk = _snapshot->get_samples(i, chunk_end);
if (srd_session_send(session, i, i + sample_count, chunk,
if (srd_session_send(session, i, chunk_end, chunk,
(chunk_end - i) * unit_size, unit_size) != SRD_OK) {
_error_message = tr("Decoder reported an error");
break;
}
_error_message = tr("Decoder reported an error");
break;
}
{
lock_guard<mutex> lock(_output_mutex);
_samples_decoded = chunk_end;
}
{
lock_guard<mutex> lock(_output_mutex);
_samples_decoded = chunk_end - decode_start + 1;
}
if (i % DecodeNotifyPeriod == 0)
new_decode_data();
}
}
_options_changed = false;
decode_done();
//new_decode_data();
......@@ -382,6 +422,8 @@ void DecoderStack::decode_proc()
optional<uint64_t> sample_count;
srd_session *session;
srd_decoder_inst *prev_di = NULL;
uint64_t decode_start;
uint64_t decode_end;
assert(_snapshot);
......@@ -409,6 +451,8 @@ void DecoderStack::decode_proc()
srd_inst_stack (session, prev_di, di);
prev_di = di;
decode_start = dec->decode_start();
decode_end = min(dec->decode_end(), _snapshot->get_sample_count());
}
// Get the intial sample count
......@@ -429,7 +473,8 @@ void DecoderStack::decode_proc()
// do {
// decode_data(*sample_count, unit_size, session);
// } while(_error_message.isEmpty() && (sample_count = wait_for_data()));
decode_data(*sample_count, unit_size, session);
//decode_data(*sample_count, unit_size, session);
decode_data(decode_start, decode_end, unit_size, session);
// Destroy the session
srd_session_destroy(session);
......@@ -439,7 +484,10 @@ void DecoderStack::decode_proc()
uint64_t DecoderStack::sample_count() const
{
return _sample_count;
if (_snapshot)
return _snapshot->get_sample_count();
else
return 0;
}
void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder)
......
......@@ -125,7 +125,10 @@ public:
private:
boost::optional<uint64_t> wait_for_data() const;
void decode_data(const uint64_t sample_count,
// void decode_data(const uint64_t sample_count,
// const unsigned int unit_size, srd_session *const session);
void decode_data(const uint64_t decode_start, const uint64_t decode_end,
const unsigned int unit_size, srd_session *const session);
void decode_proc();
......
......@@ -134,7 +134,7 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession &session) :
connect(_t3_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(delta_update()));
connect(_fen_checkBox, SIGNAL(stateChanged(int)), &_view, SLOT(set_measure_en(int)));
connect(_view.get_viewport(), SIGNAL(mouse_measure()), this, SLOT(mouse_measure()));
connect(_view.get_viewport(), SIGNAL(measure_updated()), this, SLOT(measure_updated()));
this->setWidget(_widget);
_widget->setGeometry(0, 0, sizeHint().width(), 2000);
......@@ -220,7 +220,7 @@ void MeasureDock::cursor_update()
update();
}
void MeasureDock::mouse_measure()
void MeasureDock::measure_updated()
{
_width_label->setText(_view.get_viewport()->get_measure("width"));
_period_label->setText(_view.get_viewport()->get_measure("period"));
......
......@@ -74,7 +74,7 @@ private slots:
public slots:
void cursor_update();
void cursor_moved();
void mouse_measure();
void measure_updated();
private:
SigSession &_session;
......
......@@ -1104,6 +1104,9 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
_cur_logic_snapshot.reset();
_cur_dso_snapshot.reset();
_cur_analog_snapshot.reset();
BOOST_FOREACH(const boost::shared_ptr<view::DecodeTrace> d, _decode_traces)
d->frame_ended();
}
frame_ended();
......@@ -1287,6 +1290,13 @@ bool SigSession::add_decoder(srd_decoder *const dec)
boost::shared_ptr<view::DecodeTrace> d(
new view::DecodeTrace(*this, decoder_stack,
_decode_traces.size()));
// set view early for decode start/end region setting
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _signals) {
if (s->get_view()) {
d->set_view(s->get_view());
break;
}
}
if (d->create_popup()) {
_decode_traces.push_back(d);
ret = true;
......
......@@ -58,7 +58,7 @@ AnalogSignal::AnalogSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
_data(data)
{
_colour = SignalColours[probe->index % countof(SignalColours)];
_scale = _signalHeight * 1.0f / 65536;
_scale = _totalHeight * 1.0f / 65536;
}
AnalogSignal::~AnalogSignal()
......@@ -81,7 +81,7 @@ void AnalogSignal::paint_mid(QPainter &p, int left, int right)
assert(_view);
assert(right >= left);
const int y = get_y() + _signalHeight * 0.5;
const int y = get_y() + _totalHeight * 0.5;
const double scale = _view->scale();
assert(scale > 0);
const double offset = _view->offset();
......@@ -91,7 +91,7 @@ void AnalogSignal::paint_mid(QPainter &p, int left, int right)
if (snapshots.empty())
return;
_scale = _signalHeight * 1.0f / 65536;
_scale = _totalHeight * 1.0f / 65536;
const boost::shared_ptr<pv::data::AnalogSnapshot> &snapshot =
snapshots.front();
......
......@@ -50,14 +50,10 @@ extern "C" {
#include "../widgets/decodergroupbox.h"
#include "../widgets/decodermenu.h"
#include "../device/devinst.h"
#include "../view/cursor.h"
using boost::dynamic_pointer_cast;
using boost::shared_ptr;
using std::list;
using std::max;
using std::map;
using std::min;
using std::vector;
using namespace boost;
using namespace std;
namespace pv {
namespace view {
......@@ -114,12 +110,21 @@ const QColor DecodeTrace::OutlineColours[16] = {
QColor(0x6B, 0x23, 0x37)
};
const QString DecodeTrace::RegionStart = "Start";
const QString DecodeTrace::RegionEnd = "End ";
DecodeTrace::DecodeTrace(pv::SigSession &session,
boost::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) :
Trace(QString::fromUtf8(
decoder_stack->stack().front()->decoder()->name), index, SR_CHANNEL_DECODER),
_session(session),
_decoder_stack(decoder_stack),
_decode_start(0),
_decode_end(INT64_MAX),
_start_index(0),
_end_index(0),
_start_count(0),
_end_count(0),
_show_hide_mapper(this),
_popup_form(NULL),
_popup()
......@@ -169,8 +174,31 @@ void DecodeTrace::paint_back(QPainter &p, int left, int right)
QPen pen(Signal::dsGray);
pen.setStyle(Qt::DotLine);
p.setPen(pen);
const double sigY = get_y() - (_signalHeight - _view->get_signalHeight())*0.5;
const double sigY = get_y() - (_totalHeight - _view->get_signalHeight())*0.5;
p.drawLine(left, sigY, right, sigY);
// --draw decode region control
const double samples_per_pixel = _session.get_device()->get_sample_rate() * _view->scale();
const double startX = _decode_start/samples_per_pixel - (_view->offset() / _view->scale());
const double endX = _decode_end/samples_per_pixel - (_view->offset() / _view->scale());
const double regionY = get_y() - _totalHeight*0.5 - ControlRectWidth;
p.setBrush(Signal::dsBlue);
p.drawLine(startX, regionY, startX, regionY + _totalHeight + ControlRectWidth);
p.drawLine(endX, regionY, endX, regionY + _totalHeight + ControlRectWidth);
const QPointF start_points[] = {
QPointF(startX-ControlRectWidth, regionY),
QPointF(startX+ControlRectWidth, regionY),
QPointF(startX, regionY+ControlRectWidth)
};
const QPointF end_points[] = {
QPointF(endX-ControlRectWidth, regionY),
QPointF(endX+ControlRectWidth, regionY),
QPointF(endX, regionY+ControlRectWidth)
};
p.drawPolygon(start_points, countof(start_points));
p.drawPolygon(end_points, countof(end_points));
}
void DecodeTrace::paint_mid(QPainter &p, int left, int right)
......@@ -203,22 +231,24 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
const QString err = _decoder_stack->error_message();
if (!err.isEmpty())
{
//draw_unresolved_period(p, _view->get_signalHeight(), left, right,
//draw_unresolved_period(p, annotation_height, left, right,
// samples_per_pixel, pixels_offset);
draw_error(p, err, left, right);
return;
}
// Draw the hatching
if (draw_unresolved_period(p, _view->get_signalHeight(), left, right))
if (draw_unresolved_period(p, annotation_height, left, right))
return;
// Iterate through the rows
assert(_view);
int y = get_y() - (_signalHeight - _view->get_signalHeight())*0.5;
int y = get_y() - (_totalHeight - annotation_height)*0.5;
assert(_decoder_stack);
const double decode_startX = _decode_start/samples_per_pixel - (_view->offset() / _view->scale());
const double decode_endX = _decode_end/samples_per_pixel - (_view->offset() / _view->scale());
const std::vector< std::pair<Row, bool> > rows(_decoder_stack->get_visible_rows());
for (size_t i = 0; i < rows.size(); i++)
{
......@@ -226,8 +256,8 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
const bool shown = rows[i].second;
if (!shown && _decoder_stack->has_annotations(row)) {
draw_unshown_row(p, y, _view->get_signalHeight(), left, right);
y += _view->get_signalHeight();
draw_unshown_row(p, y, annotation_height, decode_startX, decode_endX);
y += annotation_height;
_cur_row_headings.push_back(row.title());
continue;
}
......@@ -253,10 +283,10 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
base_colour);
}
} else if (max_annWidth != 0){
draw_nodetail(p, annotation_height, left, right, y, base_colour);
draw_nodetail(p, annotation_height, decode_startX, decode_endX, y, base_colour);
}
if (max_annWidth != 0) {
y += _view->get_signalHeight();
y += annotation_height;
_cur_row_headings.push_back(row.title());
}
}
......@@ -272,7 +302,7 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right)
for (size_t i = 0; i < _cur_row_headings.size(); i++)
{
const int y = (i + 0.5) * row_height + get_y() - _signalHeight * 0.5;
const int y = (i + 0.5) * row_height + get_y() - _totalHeight * 0.5;
p.setPen(QPen(Qt::NoPen));
p.setBrush(QApplication::palette().brush(QPalette::WindowText));
......@@ -317,11 +347,13 @@ bool DecodeTrace::create_popup()
if (QDialog::Accepted == _popup->exec())
{
BOOST_FOREACH(shared_ptr<data::decode::Decoder> dec,
BOOST_FOREACH(boost::shared_ptr<data::decode::Decoder> dec,
_decoder_stack->stack())
{
if (dec->commit()) {
_decoder_stack->options_changed(true);
_decode_start = dec->decode_start();
_decode_end = dec->decode_end();
ret = true;
}
}
......@@ -361,7 +393,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
_probe_selectors.clear();
_decoder_forms.clear();
const list< shared_ptr<Decoder> >& stack = _decoder_stack->stack();
const list< boost::shared_ptr<Decoder> >& stack = _decoder_stack->stack();
if (stack.empty())
{
......@@ -372,10 +404,10 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
}
else
{
list< shared_ptr<Decoder> >::const_iterator iter =
list< boost::shared_ptr<Decoder> >::const_iterator iter =
stack.begin();
for (int i = 0; i < (int)stack.size(); i++, iter++) {
shared_ptr<Decoder> dec(*iter);
boost::shared_ptr<Decoder> dec(*iter);
create_decoder_form(i, dec, parent, form);
}
......@@ -383,6 +415,40 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
tr("<i>* Required channels</i>"), parent));
}
// Add region combobox
_start_comboBox = new QComboBox(parent);
_end_comboBox = new QComboBox(parent);
_start_comboBox->addItem(RegionStart);
_end_comboBox->addItem(RegionEnd);
if (_view) {
int index = 1;
for(std::list<Cursor*>::iterator i = _view->get_cursorList().begin();
i != _view->get_cursorList().end(); i++) {
QString curCursor = tr("Cursor ")+QString::number(index);
_start_comboBox->addItem(curCursor);
_end_comboBox->addItem(curCursor);
index++;
}
}
if (_start_count > _start_comboBox->count())
_start_index = 0;
if (_end_count > _end_comboBox->count())
_end_index = 0;
_start_count = _start_comboBox->count();
_end_count = _end_comboBox->count();
_start_comboBox->setCurrentIndex(_start_index);
_end_comboBox->setCurrentIndex(_end_index);
connect(_start_comboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_region_set(int)));
connect(_end_comboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_region_set(int)));
on_region_set(_start_index);
form->addRow(_start_comboBox, new QLabel(
tr("Decode Start From")));
form->addRow(_end_comboBox, new QLabel(
tr("Decode End to")));
// Add stacking button
pv::widgets::DecoderMenu *const decoder_menu =
new pv::widgets::DecoderMenu(parent);
......@@ -564,16 +630,16 @@ bool DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left,
assert(_decoder_stack);
shared_ptr<Logic> data;
shared_ptr<LogicSignal> logic_signal;
boost::shared_ptr<Logic> data;
boost::shared_ptr<LogicSignal> logic_signal;
//const int64_t sample_count = _session.get_device()->get_sample_limit();
const int64_t sample_count = _decoder_stack->sample_count();
if (sample_count == 0)
//const int64_t need_sample_count = _decoder_stack->sample_count();
const uint64_t need_sample_count = _decode_end - _decode_start + 1;
if (need_sample_count == 0)
return true;
const int64_t samples_decoded = _decoder_stack->samples_decoded();
if (sample_count == samples_decoded)
const uint64_t samples_decoded = _decoder_stack->samples_decoded();
if (need_sample_count == samples_decoded)
return false;
const int y = get_y();
......@@ -591,7 +657,7 @@ bool DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left,
p.setBrush(QBrush(NoDecodeColour, Qt::Dense7Pattern));
p.drawRect(no_decode_rect);
const int progress100 = ceil(samples_decoded * 100.0 / sample_count);
const int progress100 = ceil(samples_decoded * 100.0 / need_sample_count);
p.setPen(dsLightBlue);
QFont font=p.font();
font.setPointSize(_view->get_signalHeight()*2/3);
......@@ -620,7 +686,7 @@ void DecodeTrace::draw_unshown_row(QPainter &p, int y, int h, int left,
}
void DecodeTrace::create_decoder_form(int index,
shared_ptr<data::decode::Decoder> &dec, QWidget *parent,
boost::shared_ptr<data::decode::Decoder> &dec, QWidget *parent,
QFormLayout *form)
{
const GSList *l;
......@@ -672,7 +738,7 @@ void DecodeTrace::create_decoder_form(int index,
}
// Add the options
shared_ptr<prop::binding::DecoderOptions> binding(
boost::shared_ptr<prop::binding::DecoderOptions> binding(
new prop::binding::DecoderOptions(_decoder_stack, dec));
binding->add_properties_to_form(decoder_form, true);
......@@ -683,16 +749,16 @@ void DecodeTrace::create_decoder_form(int index,
}
QComboBox* DecodeTrace::create_probe_selector(
QWidget *parent, const shared_ptr<data::decode::Decoder> &dec,
QWidget *parent, const boost::shared_ptr<data::decode::Decoder> &dec,
const srd_channel *const pdch)
{
assert(dec);
const vector< shared_ptr<Signal> > sigs(_session.get_signals());
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
assert(_decoder_stack);
const map<const srd_channel*,
shared_ptr<LogicSignal> >::const_iterator probe_iter =
boost::shared_ptr<LogicSignal> >::const_iterator probe_iter =
dec->channels().find(pdch);
QComboBox *selector = new QComboBox(parent);
......@@ -703,7 +769,7 @@ QComboBox* DecodeTrace::create_probe_selector(
selector->setCurrentIndex(0);
for(size_t i = 0; i < sigs.size(); i++) {
const shared_ptr<view::Signal> s(sigs[i]);
const boost::shared_ptr<view::Signal> s(sigs[i]);
assert(s);
if (dynamic_pointer_cast<LogicSignal>(s) && s->enabled())
......@@ -720,12 +786,12 @@ QComboBox* DecodeTrace::create_probe_selector(
return selector;
}
void DecodeTrace::commit_decoder_probes(shared_ptr<data::decode::Decoder> &dec)
void DecodeTrace::commit_decoder_probes(boost::shared_ptr<data::decode::Decoder> &dec)
{
assert(dec);
map<const srd_channel*, shared_ptr<LogicSignal> > probe_map;
const vector< shared_ptr<Signal> > sigs(_session.get_signals());
map<const srd_channel*, boost::shared_ptr<LogicSignal> > probe_map;
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
_index_list.clear();
BOOST_FOREACH(const ProbeSelector &s, _probe_selectors)
......@@ -737,7 +803,7 @@ void DecodeTrace::commit_decoder_probes(shared_ptr<data::decode::Decoder> &dec)
(LogicSignal*)s._combo->itemData(
s._combo->currentIndex()).value<void*>();
BOOST_FOREACH(shared_ptr<Signal> sig, sigs)
BOOST_FOREACH(boost::shared_ptr<Signal> sig, sigs)
if(sig.get() == selection) {
probe_map[s._pdch] =
dynamic_pointer_cast<LogicSignal>(sig);
......@@ -752,7 +818,7 @@ void DecodeTrace::commit_decoder_probes(shared_ptr<data::decode::Decoder> &dec)
void DecodeTrace::commit_probes()
{
assert(_decoder_stack);
BOOST_FOREACH(shared_ptr<data::decode::Decoder> dec,
BOOST_FOREACH(boost::shared_ptr<data::decode::Decoder> dec,
_decoder_stack->stack())
commit_decoder_probes(dec);
......@@ -787,7 +853,7 @@ void DecodeTrace::on_stack_decoder(srd_decoder *decoder)
{
assert(decoder);
assert(_decoder_stack);
_decoder_stack->push(shared_ptr<data::decode::Decoder>(
_decoder_stack->push(boost::shared_ptr<data::decode::Decoder>(
new data::decode::Decoder(decoder)));
//_decoder_stack->begin_decode();
......@@ -798,14 +864,14 @@ void DecodeTrace::on_show_hide_decoder(int index)
{
using pv::data::decode::Decoder;
const list< shared_ptr<Decoder> > stack(_decoder_stack->stack());
const list< boost::shared_ptr<Decoder> > stack(_decoder_stack->stack());
// Find the decoder in the stack
list< shared_ptr<Decoder> >::const_iterator iter = stack.begin();
list< boost::shared_ptr<Decoder> >::const_iterator iter = stack.begin();
for(int i = 0; i < index; i++, iter++)
assert(iter != stack.end());
shared_ptr<Decoder> dec = *iter;
boost::shared_ptr<Decoder> dec = *iter;
assert(dec);
const bool show = !dec->shown();
......@@ -863,5 +929,62 @@ QRectF DecodeTrace::get_rect(DecodeSetRegions type, int y, int right)
return QRectF(0, 0, 0, 0);
}
void DecodeTrace::on_region_set(int index)
{
(void)index;
const uint64_t last_samples = _session.get_device()->get_sample_limit() - 1;
const int index1 = _start_comboBox->currentIndex();
const int index2 = _end_comboBox->currentIndex();
uint64_t decode_start, decode_end;
if (index1 == 0) {
decode_start = 0;
} else {
decode_start = _view->get_cursor_samples(index1-1);
}
if (index2 == 0) {
decode_end = last_samples;
} else {
decode_end = _view->get_cursor_samples(index2-1);
}
if (decode_start > last_samples)
decode_start = 0;
if (decode_end > last_samples)
decode_end = last_samples;
if (decode_start > decode_end) {
uint64_t tmp = decode_start;
decode_start = decode_end;
decode_end = tmp;
}
_start_index = index1;
_end_index = index2;
BOOST_FOREACH(boost::shared_ptr<data::decode::Decoder> dec,
_decoder_stack->stack()) {
dec->set_decode_region(decode_start, decode_end);
}
}
void DecodeTrace::frame_ended()
{
const uint64_t last_samples = _session.get_device()->get_sample_limit() - 1;
if (_decode_start > last_samples) {
_decode_start = 0;
_start_index = 0;
}
if (_end_index ==0 ||
_decode_end > last_samples) {
_decode_end = last_samples;
_end_index = 0;
}
BOOST_FOREACH(boost::shared_ptr<data::decode::Decoder> dec,
_decoder_stack->stack()) {
dec->set_decode_region(_decode_start, _decode_end);
dec->commit();
}
}
} // namespace view
} // namespace pv
......@@ -89,6 +89,10 @@ private:
static const QColor OutlineColours[16];
static const int DefaultFontSize = 8;
static const int ControlRectWidth = 5;
static const QString RegionStart;
static const QString RegionEnd;
public:
DecodeTrace(pv::SigSession &session,
......@@ -132,6 +136,11 @@ public:
QRectF get_rect(DecodeSetRegions type, int y, int right);
/**
* decode region
**/
void frame_ended();
protected:
void paint_type_options(QPainter &p, int right, const QPoint pt);
......@@ -191,11 +200,16 @@ private slots:
void on_decode_done();
void on_region_set(int index);
private:
pv::SigSession &_session;
boost::shared_ptr<pv::data::DecoderStack> _decoder_stack;
uint64_t _decode_start, _decode_end;
int _start_index, _end_index;
int _start_count, _end_count;
QComboBox *_start_comboBox, *_end_comboBox;
std::list< boost::shared_ptr<pv::prop::binding::DecoderOptions> >
_bindings;
......
......@@ -51,7 +51,7 @@ GroupSignal::GroupSignal(QString name, boost::shared_ptr<data::Group> data,
_data(data)
{
_colour = SignalColours[probe_index_list.front() % countof(SignalColours)];
_scale = _signalHeight * 1.0f / std::pow(2.0, static_cast<double>(probe_index_list.size()));
_scale = _totalHeight * 1.0f / std::pow(2.0, static_cast<double>(probe_index_list.size()));
}
GroupSignal::~GroupSignal()
......@@ -79,12 +79,12 @@ void GroupSignal::paint_mid(QPainter &p, int left, int right)
assert(_view);
assert(right >= left);
const int y = get_y() + _signalHeight * 0.5;
const int y = get_y() + _totalHeight * 0.5;
const double scale = _view->scale();
assert(scale > 0);
const double offset = _view->offset();
_scale = _signalHeight * 1.0f / std::pow(2.0, static_cast<int>(_index_list.size()));
_scale = _totalHeight * 1.0f / std::pow(2.0, static_cast<int>(_index_list.size()));
const deque< boost::shared_ptr<pv::data::GroupSnapshot> > &snapshots =
_data->get_snapshots();
......
......@@ -148,12 +148,12 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right)
assert(_view);
assert(right >= left);
const int y = get_y() + _signalHeight * 0.5;
const int y = get_y() + _totalHeight * 0.5;
const double scale = _view->scale();
assert(scale > 0);
const double offset = _view->offset();
const float high_offset = y - _signalHeight + 0.5f;
const float high_offset = y - _totalHeight + 0.5f;
const float low_offset = y + 0.5f;
const deque< boost::shared_ptr<pv::data::LogicSnapshot> > &snapshots =
......@@ -314,7 +314,7 @@ void LogicSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
bool LogicSignal::measure(const QPointF &p, uint64_t &index0, uint64_t &index1, uint64_t &index2) const
{
const float gap = abs(p.y() - get_y());
if (gap < get_signalHeight() * 0.5) {
if (gap < get_totalHeight() * 0.5) {
const deque< boost::shared_ptr<pv::data::LogicSnapshot> > &snapshots =
_data->get_snapshots();
if (snapshots.empty())
......@@ -359,7 +359,7 @@ bool LogicSignal::edges(const QPointF &p, uint64_t start, uint64_t &rising, uint
{
uint64_t index, end;
const float gap = abs(p.y() - get_y());
if (gap < get_signalHeight() * 0.5) {
if (gap < get_totalHeight() * 0.5) {
const deque< boost::shared_ptr<pv::data::LogicSnapshot> > &snapshots =
_data->get_snapshots();
if (snapshots.empty())
......
......@@ -59,7 +59,7 @@ Trace::Trace(QString name, uint16_t index, int type) :
_v_offset(INT_MAX),
_type(type),
_sec_index(0),
_signalHeight(30)
_totalHeight(30)
{
_index_list.push_back(index);
}
......@@ -71,7 +71,7 @@ Trace::Trace(QString name, std::list<int> index_list, int type, int sec_index) :
_type(type),
_index_list(index_list),
_sec_index(sec_index),
_signalHeight(30)
_totalHeight(30)
{
}
......@@ -84,7 +84,7 @@ Trace::Trace(const Trace &t) :
_index_list(t._index_list),
_sec_index(t._sec_index),
_old_v_offset(t._old_v_offset),
_signalHeight(t._signalHeight),
_totalHeight(t._totalHeight),
_text_size(t._text_size)
{
}
......@@ -167,14 +167,14 @@ int Trace::get_zeroPos()
return _v_offset - _view->v_offset();
}
int Trace::get_signalHeight() const
int Trace::get_totalHeight() const
{
return _signalHeight;
return _totalHeight;
}
void Trace::set_signalHeight(int height)
void Trace::set_totalHeight(int height)
{
_signalHeight = height;
_totalHeight = height;
}
void Trace::set_view(pv::view::View *view)
......@@ -183,6 +183,11 @@ void Trace::set_view(pv::view::View *view)
_view = view;
}
pv::view::View* Trace::get_view() const
{
return _view;
}
void Trace::paint_back(QPainter &p, int left, int right)
{
QPen pen(Signal::dsGray);
......
......@@ -127,12 +127,12 @@ public:
/**
* Gets the height of this signal.
*/
int get_signalHeight() const;
int get_totalHeight() const;
/**
* Sets the height of this signal.
*/
void set_signalHeight(int height);
void set_totalHeight(int height);
/**
* Geom
......@@ -159,6 +159,7 @@ public:
virtual bool enabled() const = 0;
virtual void set_view(pv::view::View *view);
pv::view::View* get_view() const;
/**
* Paints the background layer of the trace with a QPainter
......@@ -291,7 +292,7 @@ protected:
std::list<int> _index_list;
int _sec_index;
int _old_v_offset;
int _signalHeight;
int _totalHeight;
QSizeF _text_size;
};
......
......@@ -501,7 +501,7 @@ void View::signals_changed()
BOOST_FOREACH(boost::shared_ptr<Trace> t, traces) {
t->set_view(this);
const double traceHeight = _signalHeight*t->rows_size();
t->set_signalHeight((int)traceHeight);
t->set_totalHeight((int)traceHeight);
t->set_v_offset(next_v_offset + 0.5 * traceHeight + SignalMargin);
next_v_offset += traceHeight + 2 * SignalMargin;
}
......
This diff is collapsed.
......@@ -54,13 +54,30 @@ public:
static const int DsoMeasureStages = 3;
static const double MinorDragRateUp;
static const double DragDamping;
enum ActionType {
NO_ACTION,
CURS_MOVE,
LOGIC_EDGE,
LOGIC_MOVE,
LOGIC_ZOOM,
DSO_XM_STEP0,
DSO_XM_STEP1,
DSO_XM_STEP2,
DSO_XM_STEP3,
DSO_YM,
DSO_TRIG_MOVE,
DECODE_REGION
};
enum MeasureType {
NO_MEASURE,
LOGIC_FREQ,
LOGIC_EDGE,
LOGIC_MOVE,
LOGIC_CURS,
DSO_FREQ
LOGIC_EDGE_CNT,
DSO_VALUE
};
public:
......@@ -103,7 +120,7 @@ private slots:
void set_receive_len(quint64 length);
signals:
void mouse_measure();
void measure_updated();
private:
View &_view;
......@@ -118,11 +135,8 @@ private:
QPixmap pixmap;
bool _zoom_rect_visible;
QRectF _zoom_rect;
bool _measure_en;
bool _measure_shown;
ActionType _action_type;
MeasureType _measure_type;
uint64_t _cur_sample;
uint64_t _nxt_sample;
......@@ -158,13 +172,11 @@ private:
QTimer _drag_timer;
int _drag_strength;
bool _dso_xm;
int _dso_xm_stage;
bool _dso_xm_valid;
int _dso_xm_y;
uint64_t _dso_xm_index[DsoMeasureStages];
bool _dso_ym;
bool _dso_ym_done;
bool _dso_ym_valid;
uint16_t _dso_ym_sig_index;
double _dso_ym_sig_value;
uint64_t _dso_ym_index;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment