mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
The waveform data plotted is aligned
This commit is contained in:
parent
5f55e76659
commit
c668b4cca1
@ -531,8 +531,10 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod
|
||||
if (!bCheckEnd){
|
||||
bCheckEnd = true;
|
||||
|
||||
if (end_index >= _snapshot->get_mipmap_sample_count()){
|
||||
end_index = _snapshot->get_mipmap_sample_count() - 1;
|
||||
uint64_t mipmap_sample_count = _snapshot->get_mipmap_sample_count();
|
||||
|
||||
if (end_index >= mipmap_sample_count){
|
||||
end_index = mipmap_sample_count - 1;
|
||||
dsv_info("Reset the decode end sample, new:%llu, old:%llu", end_index, decode_end);
|
||||
}
|
||||
}
|
||||
|
@ -506,12 +506,17 @@ void LogicSnapshot::calc_mipmap(unsigned int order, uint8_t index0, uint8_t inde
|
||||
|
||||
const uint8_t *LogicSnapshot::get_samples(uint64_t start_sample, uint64_t &end_sample, int sig_index)
|
||||
{
|
||||
assert(start_sample < _ring_sample_count);
|
||||
assert(start_sample <= end_sample);
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
if (end_sample >= _ring_sample_count){
|
||||
end_sample = _ring_sample_count - 1;
|
||||
}
|
||||
uint64_t sample_count = _ring_sample_count;
|
||||
|
||||
assert(start_sample < sample_count);
|
||||
|
||||
if (end_sample >= sample_count)
|
||||
end_sample = sample_count - 1;
|
||||
|
||||
assert(end_sample <= sample_count);
|
||||
assert(start_sample <= end_sample);
|
||||
|
||||
int order = get_ch_order(sig_index);
|
||||
uint64_t index0 = start_sample >> (LeafBlockPower + RootScalePower);
|
||||
@ -522,7 +527,7 @@ const uint8_t *LogicSnapshot::get_samples(uint64_t start_sample, uint64_t &end_s
|
||||
(index1 << LeafBlockPower) +
|
||||
~(~0ULL << LeafBlockPower);
|
||||
|
||||
end_sample = min(end_sample + 1, _ring_sample_count);
|
||||
end_sample = min(end_sample + 1, sample_count);
|
||||
|
||||
if (order == -1 || _ch_data[order][index0].lbp[index1] == NULL)
|
||||
return NULL;
|
||||
@ -534,12 +539,15 @@ const uint8_t *LogicSnapshot::get_decode_samples(uint64_t start_sample, uint64_t
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
assert(start_sample < _mipmap_sample_count);
|
||||
assert(start_sample <= end_sample);
|
||||
uint64_t sample_count = _mipmap_sample_count;
|
||||
|
||||
if (end_sample >= _mipmap_sample_count){
|
||||
end_sample = _mipmap_sample_count - 1;
|
||||
}
|
||||
assert(start_sample < sample_count);
|
||||
|
||||
if (end_sample >= sample_count)
|
||||
end_sample = sample_count - 1;
|
||||
|
||||
assert(end_sample <= sample_count);
|
||||
assert(start_sample <= end_sample);
|
||||
|
||||
int order = get_ch_order(sig_index);
|
||||
uint64_t index0 = start_sample >> (LeafBlockPower + RootScalePower);
|
||||
@ -550,7 +558,7 @@ const uint8_t *LogicSnapshot::get_decode_samples(uint64_t start_sample, uint64_t
|
||||
(index1 << LeafBlockPower) +
|
||||
~(~0ULL << LeafBlockPower);
|
||||
|
||||
end_sample = min(end_sample + 1, _mipmap_sample_count);
|
||||
end_sample = min(end_sample + 1, sample_count);
|
||||
|
||||
if (order == -1 || _ch_data[order][index0].lbp[index1] == NULL)
|
||||
return NULL;
|
||||
@ -1097,7 +1105,7 @@ int LogicSnapshot::get_ch_order(int sig_index)
|
||||
|
||||
uint64_t LogicSnapshot::get_mipmap_sample_count()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
// std::lock_guard<std::mutex> lock(_mutex);
|
||||
return _mipmap_sample_count;
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ LogicSignal::LogicSignal(data::LogicSnapshot *data,
|
||||
{
|
||||
_trig = NONTRIG;
|
||||
_signal_type = LOGIC_SIGNAL;
|
||||
_paint_align_sample_count = 0;
|
||||
}
|
||||
|
||||
LogicSignal::LogicSignal(view::LogicSignal *s,
|
||||
@ -56,6 +57,7 @@ LogicSignal::LogicSignal(view::LogicSignal *s,
|
||||
_trig(s->get_trig())
|
||||
{
|
||||
_signal_type = LOGIC_SIGNAL;
|
||||
_paint_align_sample_count = 0;
|
||||
}
|
||||
|
||||
LogicSignal::~LogicSignal()
|
||||
@ -95,6 +97,17 @@ bool LogicSignal::commit_trig()
|
||||
}
|
||||
|
||||
void LogicSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor back)
|
||||
{
|
||||
uint64_t end_align_sample = _data->get_ring_sample_count() - 1;
|
||||
paint_mid_align(p, left, right, fore, back, end_align_sample);
|
||||
}
|
||||
|
||||
void LogicSignal::paint_mid_align_sample(QPainter &p, int left, int right, QColor fore, QColor back, uint64_t end_align_sample)
|
||||
{
|
||||
paint_mid_align(p, left, right, fore, back, end_align_sample);
|
||||
}
|
||||
|
||||
void LogicSignal::paint_mid_align(QPainter &p, int left, int right, QColor fore, QColor back, uint64_t end_align_sample)
|
||||
{
|
||||
using pv::view::View;
|
||||
|
||||
@ -119,7 +132,10 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColo
|
||||
if (!_data->has_data(_probe->index))
|
||||
return;
|
||||
|
||||
const int64_t last_sample = _data->get_ring_sample_count() - 1;
|
||||
if (end_align_sample >= _data->get_ring_sample_count())
|
||||
end_align_sample = _data->get_ring_sample_count() - 1;
|
||||
|
||||
const int64_t last_sample = end_align_sample;
|
||||
const double samples_per_pixel = samplerate * scale;
|
||||
|
||||
uint16_t width = right - left;
|
||||
|
@ -107,21 +107,25 @@ public:
|
||||
|
||||
void paint_mark(QPainter &p, int xstart, int xend, int type);
|
||||
|
||||
void paint_mid_align_sample(QPainter &p, int left, int right, QColor fore, QColor back, uint64_t end_align_sample);
|
||||
|
||||
protected:
|
||||
void paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore);
|
||||
|
||||
private:
|
||||
|
||||
void paint_caps(QPainter &p, QLineF *const lines,
|
||||
std::vector< std::pair<uint64_t, bool> > &edges,
|
||||
bool level, double samples_per_pixel, double pixels_offset,
|
||||
float x_offset, float y_offset);
|
||||
|
||||
void paint_mid_align(QPainter &p, int left, int right, QColor fore, QColor back, uint64_t end_align_sample);
|
||||
|
||||
private:
|
||||
pv::data::LogicSnapshot* _data;
|
||||
std::vector< std::pair<uint16_t, bool> > _cur_edges;
|
||||
std::vector<std::pair<bool, bool>> _cur_pulses;
|
||||
LogicSetRegions _trig;
|
||||
uint64_t _paint_align_sample_count;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
@ -34,8 +34,7 @@ namespace view {
|
||||
Signal::Signal(sr_channel *probe) :
|
||||
Trace(probe->name, probe->index, probe->type),
|
||||
_probe(probe)
|
||||
{
|
||||
_signal_type = UNKNOWN_SIGNAL;
|
||||
{
|
||||
session = AppControl::Instance()->GetSession();
|
||||
}
|
||||
|
||||
@ -43,7 +42,6 @@ Signal::Signal(const Signal &s, sr_channel *probe) :
|
||||
Trace((const Trace &)s),
|
||||
_probe(probe)
|
||||
{
|
||||
_signal_type = UNKNOWN_SIGNAL;
|
||||
session = AppControl::Instance()->GetSession();
|
||||
}
|
||||
|
||||
|
@ -37,14 +37,6 @@
|
||||
#include <libsigrok.h>
|
||||
#include "trace.h"
|
||||
|
||||
enum SIGNAL_TYPE
|
||||
{
|
||||
UNKNOWN_SIGNAL = 0,
|
||||
LOGIC_SIGNAL = 1,
|
||||
DSO_SIGNAL = 2,
|
||||
ANALOG_SIGNAL = 3,
|
||||
};
|
||||
|
||||
namespace pv {
|
||||
|
||||
namespace data {
|
||||
@ -82,14 +74,10 @@ public:
|
||||
*/
|
||||
void set_name(QString name);
|
||||
|
||||
inline SIGNAL_TYPE signal_type(){
|
||||
return _signal_type;
|
||||
}
|
||||
|
||||
protected:
|
||||
sr_channel *const _probe;
|
||||
SigSession *session;
|
||||
SIGNAL_TYPE _signal_type;
|
||||
SigSession *session;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
@ -58,6 +58,7 @@ Trace::Trace(QString name, uint16_t index, int type) :
|
||||
_typeWidth(SquareNum)
|
||||
{
|
||||
_index_list.push_back(index);
|
||||
_signal_type = UNKNOWN_SIGNAL;
|
||||
}
|
||||
|
||||
Trace::Trace(QString name, std::list<int> index_list, int type, int sec_index) :
|
||||
@ -70,6 +71,7 @@ Trace::Trace(QString name, std::list<int> index_list, int type, int sec_index) :
|
||||
_totalHeight(30),
|
||||
_typeWidth(SquareNum)
|
||||
{
|
||||
_signal_type = UNKNOWN_SIGNAL;
|
||||
}
|
||||
|
||||
Trace::Trace(const Trace &t) :
|
||||
@ -85,6 +87,7 @@ Trace::Trace(const Trace &t) :
|
||||
_typeWidth(t._typeWidth),
|
||||
_text_size(t._text_size)
|
||||
{
|
||||
_signal_type = UNKNOWN_SIGNAL;
|
||||
}
|
||||
|
||||
QString Trace::get_name()
|
||||
|
@ -36,6 +36,14 @@
|
||||
|
||||
class QFormLayout;
|
||||
|
||||
enum SIGNAL_TYPE
|
||||
{
|
||||
UNKNOWN_SIGNAL = 0,
|
||||
LOGIC_SIGNAL = 1,
|
||||
DSO_SIGNAL = 2,
|
||||
ANALOG_SIGNAL = 3,
|
||||
};
|
||||
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
@ -235,6 +243,10 @@ public:
|
||||
|
||||
virtual bool mouse_wheel(int right, const QPoint pt, const int shift);
|
||||
|
||||
inline SIGNAL_TYPE signal_type(){
|
||||
return _signal_type;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@ -286,6 +298,7 @@ protected:
|
||||
int _typeWidth;
|
||||
|
||||
QSizeF _text_size;
|
||||
SIGNAL_TYPE _signal_type;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
@ -251,9 +251,19 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
|
||||
|
||||
if (_view.session().get_device()->get_work_mode() == LOGIC)
|
||||
{
|
||||
bool bFirst = true;
|
||||
uint64_t end_align_sample;
|
||||
|
||||
for(auto t : traces){
|
||||
if (t->enabled())
|
||||
t->paint_mid(p, 0, t->get_view_rect().right(), fore, back);
|
||||
if (t->enabled()){
|
||||
LogicSignal *logic_signal = (LogicSignal*)t;
|
||||
|
||||
if (bFirst)
|
||||
end_align_sample = logic_signal->data()->get_ring_sample_count();
|
||||
|
||||
logic_signal->paint_mid_align_sample(p, 0, t->get_view_rect().right(), fore, back, end_align_sample);
|
||||
bFirst = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -273,7 +283,7 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
|
||||
for(auto t : traces)
|
||||
{
|
||||
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);
|
||||
}
|
||||
_need_update = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user