void AnalogSignal::paint_back(QPainter &p, int left, int right)
{
if (_channel->enabled())
- paint_axis(p, get_y(), left, right);
+ paint_axis(p, get_visual_y(), left, right);
}
void AnalogSignal::paint_mid(QPainter &p, int left, int right)
assert(right >= left);
assert(_owner);
- const int y = get_y();
+ const int y = get_visual_y();
const View *const view = _owner->view();
assert(view);
void DecodeTrace::paint_back(QPainter &p, int left, int right)
{
Trace::paint_back(p, left, right);
- paint_axis(p, get_y(), left, right);
+ paint_axis(p, get_visual_y(), left, right);
}
void DecodeTrace::paint_mid(QPainter &p, int left, int right)
}
// Iterate through the rows
- int y = get_y();
+ int y = get_visual_y();
pair<uint64_t, uint64_t> sample_range = get_sample_range(left, right);
assert(_decoder_stack);
for (size_t i = 0; i < _visible_rows.size(); i++)
{
- const int y = i * _row_height + get_y();
+ const int y = i * _row_height + get_visual_y();
p.setPen(QPen(Qt::NoPen));
p.setBrush(QApplication::palette().brush(QPalette::WindowText));
void DecodeTrace::draw_error(QPainter &p, const QString &message,
int left, int right)
{
- const int y = get_y();
+ const int y = get_visual_y();
p.setPen(ErrorBgColour.darker());
p.setBrush(ErrorBgColour);
if (sample_count == samples_decoded)
return;
- const int y = get_y();
+ const int y = get_visual_y();
tie(pixels_offset, samples_per_pixel) =
get_pixels_offset_samples_per_pixel();
if (!_row_height)
return -1;
- const int row = (point.y() - get_y() + _row_height / 2) / _row_height;
+ const int row = (point.y() - get_visual_y() + _row_height / 2) /
+ _row_height;
if (row < 0 || row >= (int)_visible_rows.size())
return -1;
// decode trace, not below.
hp.setX(hp.x() - (text_size.width() / 2) - padding);
- hp.setY(get_y() - (_row_height / 2) + (hover_row * _row_height)
- - _row_height - text_size.height());
+ hp.setY(get_visual_y() - (_row_height / 2) +
+ (hover_row * _row_height) -
+ _row_height - text_size.height());
QToolTip::showText(view->viewport()->mapToGlobal(hp), ann);
}
if (!p)
return;
- const QPoint pt(width() - BaselineOffset, item->get_y());
+ const QPoint pt(width() - BaselineOffset, item->get_visual_y());
p->set_position(mapToGlobal(pt), Popup::Right);
p->show();
}
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
- return a->v_offset() < b->v_offset(); });
+ return a->visual_v_offset() < b->visual_v_offset(); });
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
for (std::shared_ptr<RowItem> r : _view)
if (r->dragging()) {
- r->set_v_offset(r->drag_point().y() + delta);
+ r->force_to_v_offset(r->drag_point().y() + delta);
// Ensure the trace is selected
r->select();
void LogicSignal::paint_back(QPainter &p, int left, int right)
{
if (_channel->enabled())
- paint_axis(p, get_y(), left, right);
+ paint_axis(p, get_visual_y(), left, right);
}
void LogicSignal::paint_mid(QPainter &p, int left, int right)
assert(right >= left);
assert(_owner);
- const int y = get_y();
+ const int y = get_visual_y();
const View *const view = _owner->view();
assert(view);
-
+
const double scale = view->scale();
assert(scale > 0);
RowItem::RowItem() :
_owner(NULL),
- _v_offset(0)
+ _layout_v_offset(0),
+ _visual_v_offset(0)
{
}
-int RowItem::v_offset() const
+int RowItem::layout_v_offset() const
{
- return _v_offset;
+ return _layout_v_offset;
}
-void RowItem::set_v_offset(int v_offset)
+void RowItem::set_layout_v_offset(int v_offset)
{
- _v_offset = v_offset;
+ if (_layout_v_offset == v_offset)
+ return;
+
+ _layout_v_offset = v_offset;
+}
+
+int RowItem::visual_v_offset() const
+{
+ return _visual_v_offset;
+}
+
+void RowItem::set_visual_v_offset(int v_offset)
+{
+ _visual_v_offset = v_offset;
+}
+
+void RowItem::force_to_v_offset(int v_offset)
+{
+ _layout_v_offset = _visual_v_offset = v_offset;
}
RowItemOwner* RowItem::owner() const
void RowItem::set_owner(RowItemOwner *owner)
{
- assert((_owner && !owner) || (!_owner && owner));
+ assert(_owner || owner);
+
+ if (_owner)
+ _visual_v_offset += _owner->owner_v_offset();
_owner = owner;
+ if (_owner)
+ _visual_v_offset -= _owner->owner_v_offset();
}
-int RowItem::get_y() const
+int RowItem::get_visual_y() const
{
assert(_owner);
- return _v_offset + _owner->owner_v_offset();
+ return _visual_v_offset + _owner->owner_v_offset();
}
QPoint RowItem::point() const
{
- return QPoint(0, v_offset());
+ return QPoint(0, visual_v_offset());
}
void RowItem::paint_back(QPainter &p, int left, int right)
/**
* Gets the vertical layout offset of this signal.
*/
- int v_offset() const;
+ int layout_v_offset() const;
/**
* Sets the vertical layout offset of this signal.
*/
- void set_v_offset(int v_offset);
+ void set_layout_v_offset(int v_offset);
+
+ /**
+ * Gets the vertical visual offset of this signal.
+ */
+ int visual_v_offset() const;
+
+ /**
+ * Sets the vertical visual offset of this signal.
+ */
+ void set_visual_v_offset(int v_offset);
+
+ /**
+ * Sets the visual and layout offset of this signal.
+ */
+ void force_to_v_offset(int v_offset);
/**
* Gets the owner this trace in the view trace hierachy.
void set_owner(pv::view::RowItemOwner *owner);
/**
- * Gets the y-offset of the axis.
+ * Gets the visual y-offset of the axis.
*/
- int get_y() const;
+ int get_visual_y() const;
/**
* Gets the drag point of the row item.
protected:
pv::view::RowItemOwner *_owner;
- int _v_offset;
+ int _layout_v_offset;
+ int _visual_v_offset;
};
} // namespace view
if (!r->enabled())
continue;
- const int child_offset = r->v_offset();
+ const int child_offset = r->layout_v_offset();
const pair<int, int> child_extents = r->v_extents();
extents.first = min(child_extents.first + child_offset,
extents.first);
void Trace::paint_label(QPainter &p, int right, bool hover)
{
- const int y = get_y();
+ const int y = get_visual_y();
p.setBrush(_colour);
const float half_height = label_size.height() / 2;
return QRectF(
right - half_height - label_size.width() - 0.5,
- get_y() + 0.5f - half_height,
+ get_visual_y() + 0.5f - half_height,
label_size.width() + half_height,
label_size.height());
}
int TraceGroup::owner_v_offset() const
{
- return v_offset() + _owner->owner_v_offset();
+ return _owner ? layout_v_offset() + _owner->owner_v_offset() : 0;
}
void TraceGroup::update_viewport()
child_items().begin(), child_items().end());
clear_child_items();
- for (shared_ptr<RowItem> r : items) {
+ for (shared_ptr<RowItem> r : items)
_owner->add_child_item(r);
- r->set_v_offset(r->v_offset() + v_offset());
- }
_owner->remove_child_item(shared_from_this());
appearance_changed();
const pair<int, int> extents = r->v_extents();
if (r->enabled())
offset += -extents.first;
- r->set_v_offset(offset);
+ r->force_to_v_offset(offset);
if (r->enabled())
offset += extents.second;
}
vector< shared_ptr<RowItem> > row_items(_view.begin(), _view.end());
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
- return a->v_offset() < b->v_offset(); });
+ return a->visual_v_offset() < b->visual_v_offset(); });
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);