#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>
{
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()),
{
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)
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(
// 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());
}
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
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);