projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
InputFile: Use new reset() function to allow re-reading file
[pulseview.git]
/
pv
/
view
/
decodetrace.cpp
diff --git
a/pv/view/decodetrace.cpp
b/pv/view/decodetrace.cpp
index 6f00a451fba062abfc9ccf13bc3c464f1ce0ac69..c2369e866fbe3b7286c602adc41735ed1c6a579b 100644
(file)
--- a/
pv/view/decodetrace.cpp
+++ b/
pv/view/decodetrace.cpp
@@
-44,6
+44,7
@@
extern "C" {
#include "decodetrace.hpp"
#include <pv/session.hpp>
#include "decodetrace.hpp"
#include <pv/session.hpp>
+#include <pv/strnatcmp.hpp>
#include <pv/data/decoderstack.hpp>
#include <pv/data/decode/decoder.hpp>
#include <pv/data/logic.hpp>
#include <pv/data/decoderstack.hpp>
#include <pv/data/decode/decoder.hpp>
#include <pv/data/logic.hpp>
@@
-140,6
+141,10
@@
DecodeTrace::DecodeTrace(pv::Session &session,
{
assert(decoder_stack_);
{
assert(decoder_stack_);
+ // Determine shortest string we want to see displayed in full
+ QFontMetrics m(QApplication::font());
+ min_useful_label_width_ = m.width("XX"); // e.g. two hex characters
+
set_colour(DecodeColours[index % countof(DecodeColours)]);
connect(decoder_stack_.get(), SIGNAL(new_decode_data()),
set_colour(DecodeColours[index % countof(DecodeColours)]);
connect(decoder_stack_.get(), SIGNAL(new_decode_data()),
@@
-164,7
+169,10
@@
pair<int, int> DecodeTrace::v_extents() const
{
const int row_height = (ViewItemPaintParams::text_height() * 6) / 4;
{
const int row_height = (ViewItemPaintParams::text_height() * 6) / 4;
- return make_pair(-row_height, row_height * max_visible_rows_);
+ // Make an empty decode trace appear symmetrical
+ const int row_count = max(1, max_visible_rows_);
+
+ return make_pair(-row_height, row_height * row_count);
}
void DecodeTrace::paint_back(QPainter &p, const ViewItemPaintParams &pp)
}
void DecodeTrace::paint_back(QPainter &p, const ViewItemPaintParams &pp)
@@
-190,6
+198,9
@@
void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
return;
}
return;
}
+ // Set default pen to allow for text width calculation
+ p.setPen(Qt::black);
+
// Iterate through the rows
int y = get_visual_y();
pair<uint64_t, uint64_t> sample_range = get_sample_range(
// Iterate through the rows
int y = get_visual_y();
pair<uint64_t, uint64_t> sample_range = get_sample_range(
@@
-199,9
+210,7
@@
void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
const vector<Row> rows(decoder_stack_->get_visible_rows());
visible_rows_.clear();
const vector<Row> rows(decoder_stack_->get_visible_rows());
visible_rows_.clear();
- for (size_t i = 0; i < rows.size(); i++) {
- const Row &row = rows[i];
-
+ for (const Row& row : rows) {
// Cache the row title widths
int row_title_width;
try {
// Cache the row title widths
int row_title_width;
try {
@@
-229,13
+238,16
@@
void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
y += row_height_;
y += row_height_;
- visible_rows_.push_back(row
s[i]
);
+ visible_rows_.push_back(row);
}
}
// Draw the hatching
draw_unresolved_period(p, annotation_height, pp.left(), pp.right());
}
}
// Draw the hatching
draw_unresolved_period(p, annotation_height, pp.left(), pp.right());
+ if ((int)visible_rows_.size() > max_visible_rows_)
+ owner_->extents_changed(false, true);
+
// Update the maximum row count if needed
max_visible_rows_ = std::max(max_visible_rows_, (int)visible_rows_.size());
}
// Update the maximum row count if needed
max_visible_rows_ = std::max(max_visible_rows_, (int)visible_rows_.size());
}
@@
-374,7
+386,7
@@
void DecodeTrace::draw_annotations(vector<pv::data::decode::Annotation> annotati
bool a_is_separate = false;
// Annotation wider than the threshold for a useful label width?
bool a_is_separate = false;
// Annotation wider than the threshold for a useful label width?
- if (a_width >
20
) {
+ if (a_width >
= min_useful_label_width_
) {
for (const QString &ann_text : a.annotations()) {
const int w = p.boundingRect(QRectF(), 0, ann_text).width();
// Annotation wide enough to fit a label? Don't put it in a block then
for (const QString &ann_text : a.annotations()) {
const int w = p.boundingRect(QRectF(), 0, ann_text).width();
// Annotation wide enough to fit a label? Don't put it in a block then
@@
-431,16
+443,16
@@
void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a,
pixels_offset;
const size_t colour = (base_colour + a.format()) % countof(Colours);
pixels_offset;
const size_t colour = (base_colour + a.format()) % countof(Colours);
-
const QColor &fill = Colours[colour]
;
-
const QColor &outline = OutlineColours[colour]
;
+
p.setPen(OutlineColours[colour])
;
+
p.setBrush(Colours[colour])
;
if (start > pp.right() + DrawPadding || end < pp.left() - DrawPadding)
return;
if (a.start_sample() == a.end_sample())
if (start > pp.right() + DrawPadding || end < pp.left() - DrawPadding)
return;
if (a.start_sample() == a.end_sample())
- draw_instant(a, p,
fill, outline,
h, start, y);
+ draw_instant(a, p, h, start, y);
else
else
- draw_range(a, p,
fill, outline,
h, start, end, y, pp,
+ draw_range(a, p, h, start, end, y, pp,
row_title_width);
}
row_title_width);
}
@@
-483,7
+495,7
@@
void DecodeTrace::draw_annotation_block(
}
void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &p,
}
void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &p,
-
QColor fill, QColor outline,
int h, double x, int y) const
+ int h, double x, int y) const
{
const QString text = a.annotations().empty() ?
QString() : a.annotations().back();
{
const QString text = a.annotations().empty() ?
QString() : a.annotations().back();
@@
-491,8
+503,6
@@
void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &
0.0) + h;
const QRectF rect(x - w / 2, y - h / 2, w, h);
0.0) + h;
const QRectF rect(x - w / 2, y - h / 2, w, h);
- p.setPen(outline);
- p.setBrush(fill);
p.drawRoundedRect(rect, h / 2, h / 2);
p.setPen(Qt::black);
p.drawRoundedRect(rect, h / 2, h / 2);
p.setPen(Qt::black);
@@
-500,16
+510,13
@@
void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &
}
void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p,
}
void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p,
-
QColor fill, QColor outline, int h, double start
,
-
double end, int y, const ViewItemPaintParams &pp,
int row_title_width) const
+
int h, double start, double end, int y, const ViewItemPaintParams &pp
,
+ int row_title_width) const
{
const double top = y + .5 - h / 2;
const double bottom = y + .5 + h / 2;
const vector<QString> annotations = a.annotations();
{
const double top = y + .5 - h / 2;
const double bottom = y + .5 + h / 2;
const vector<QString> annotations = a.annotations();
- p.setPen(outline);
- p.setBrush(fill);
-
// If the two ends are within 1 pixel, draw a vertical line
if (start + 1.0 > end) {
p.drawLine(QPointF(start, top), QPointF(start, bottom));
// If the two ends are within 1 pixel, draw a vertical line
if (start + 1.0 > end) {
p.drawLine(QPointF(start, top), QPointF(start, bottom));
@@
-798,8
+805,8
@@
void DecodeTrace::create_decoder_form(int index,
connect(combo, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_channel_selected(int)));
decoder_form->addRow(tr("<b>%1</b> (%2) *")
connect(combo, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_channel_selected(int)));
decoder_form->addRow(tr("<b>%1</b> (%2) *")
- .arg(QString::fromUtf8(pdch->name)
)
-
.arg(
QString::fromUtf8(pdch->desc)), combo);
+ .arg(QString::fromUtf8(pdch->name)
,
+
QString::fromUtf8(pdch->desc)), combo);
const ChannelSelector s = {combo, dec, pdch};
channel_selectors_.push_back(s);
const ChannelSelector s = {combo, dec, pdch};
channel_selectors_.push_back(s);
@@
-813,8
+820,8
@@
void DecodeTrace::create_decoder_form(int index,
connect(combo, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_channel_selected(int)));
decoder_form->addRow(tr("<b>%1</b> (%2)")
connect(combo, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_channel_selected(int)));
decoder_form->addRow(tr("<b>%1</b> (%2)")
- .arg(QString::fromUtf8(pdch->name)
)
-
.arg(
QString::fromUtf8(pdch->desc)), combo);
+ .arg(QString::fromUtf8(pdch->name)
,
+
QString::fromUtf8(pdch->desc)), combo);
const ChannelSelector s = {combo, dec, pdch};
channel_selectors_.push_back(s);
const ChannelSelector s = {combo, dec, pdch};
channel_selectors_.push_back(s);
@@
-842,7
+849,8
@@
QComboBox* DecodeTrace::create_channel_selector(
vector< shared_ptr<Signal> > sig_list(sigs.begin(), sigs.end());
std::sort(sig_list.begin(), sig_list.end(),
[](const shared_ptr<Signal> &a, const shared_ptr<Signal> b) {
vector< shared_ptr<Signal> > sig_list(sigs.begin(), sigs.end());
std::sort(sig_list.begin(), sig_list.end(),
[](const shared_ptr<Signal> &a, const shared_ptr<Signal> b) {
- return a->name().compare(b->name()) < 0; });
+ return strnatcasecmp(a->name().toStdString(),
+ b->name().toStdString()) < 0; });
assert(decoder_stack_);
const auto channel_iter = dec->channels().find(pdch);
assert(decoder_stack_);
const auto channel_iter = dec->channels().find(pdch);