X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fview.cpp;h=508b91c5c385ff7e34fae595105396ba94bc4d66;hp=b4815e704ac6b002f21fc0eb42aa6850e33619cf;hb=f9abdc014adda6771828db4c8caa8f66e066b7a3;hpb=38eeddeab105aea3f8015dda5399ebbead21550a diff --git a/pv/view/view.cpp b/pv/view/view.cpp index b4815e70..508b91c5 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -145,16 +145,12 @@ void View::zoom(double steps) void View::zoom(double steps, int offset) { const double cursor_offset = _offset + _scale * offset; - _scale *= pow(3.0/2.0, -steps); - _scale = max(min(_scale, MaxScale), MinScale); - _offset = cursor_offset - _scale * offset; - - _ruler->update(); - _viewport->update(); - update_scroll(); + const double new_scale = max(min(_scale * pow(3.0/2.0, -steps), + MaxScale), MinScale); + const double new_offset = cursor_offset - new_scale * offset; + set_scale_offset(new_scale, new_offset); } - void View::set_scale_offset(double scale, double offset) { _scale = scale; @@ -163,6 +159,7 @@ void View::set_scale_offset(double scale, double offset) update_scroll(); _ruler->update(); _viewport->update(); + scale_offset_changed(); } vector< shared_ptr > View::get_traces() const @@ -255,6 +252,12 @@ void View::normalize_layout() v_scroll_value_changed(verticalScrollBar()->sliderPosition()); } +void View::update_viewport() +{ + assert(_viewport); + _viewport->update(); +} + void View::get_scroll_layout(double &length, double &offset) const { const shared_ptr sig_data = _session.get_data(); @@ -384,10 +387,11 @@ void View::v_scroll_value_changed(int value) void View::signals_changed() { int offset = SignalMargin + SignalHeight; - const vector< shared_ptr > sigs(_session.get_signals()); - BOOST_FOREACH(shared_ptr s, sigs) { - s->init_context_bar_actions(NULL); - s->set_v_offset(offset); + const vector< shared_ptr > traces(get_traces()); + BOOST_FOREACH(shared_ptr t, traces) { + t->set_view(this); + t->init_context_bar_actions(NULL); + t->set_v_offset(offset); offset += SignalHeight + 2 * SignalMargin; }