2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include <libsigrokdecode/libsigrokdecode.h>
32 #include <unordered_set>
34 #include <boost/archive/text_iarchive.hpp>
35 #include <boost/archive/text_oarchive.hpp>
36 #include <boost/serialization/serialization.hpp>
38 #include <QApplication>
40 #include <QFontMetrics>
42 #include <QMouseEvent>
44 #include <QVBoxLayout>
46 #include <libsigrokcxx/libsigrokcxx.hpp>
48 #include "analogsignal.hpp"
50 #include "logicsignal.hpp"
53 #include "tracegroup.hpp"
54 #include "triggermarker.hpp"
56 #include "viewport.hpp"
58 #include "pv/data/logic.hpp"
59 #include "pv/data/logicsegment.hpp"
60 #include "pv/devices/device.hpp"
61 #include "pv/globalsettings.hpp"
62 #include "pv/session.hpp"
63 #include "pv/util.hpp"
66 #include "decodetrace.hpp"
69 using pv::data::SignalData;
70 using pv::data::Segment;
71 using pv::util::TimeUnit;
72 using pv::util::Timestamp;
74 using std::back_inserter;
80 using std::make_shared;
82 using std::numeric_limits;
85 using std::set_difference;
86 using std::shared_ptr;
87 using std::stringstream;
88 using std::unordered_map;
89 using std::unordered_set;
96 const Timestamp View::MaxScale("1e9");
97 const Timestamp View::MinScale("1e-12");
99 const int View::MaxScrollValue = INT_MAX / 2;
101 const int View::ScaleUnits[3] = {1, 2, 5};
104 CustomScrollArea::CustomScrollArea(QWidget *parent) :
105 QAbstractScrollArea(parent)
109 bool CustomScrollArea::viewportEvent(QEvent *event)
111 switch (event->type()) {
113 case QEvent::MouseButtonPress:
114 case QEvent::MouseButtonRelease:
115 case QEvent::MouseButtonDblClick:
116 case QEvent::MouseMove:
118 case QEvent::TouchBegin:
119 case QEvent::TouchUpdate:
120 case QEvent::TouchEnd:
123 return QAbstractScrollArea::viewportEvent(event);
127 View::View(Session &session, bool is_main_view, QWidget *parent) :
128 ViewBase(session, is_main_view, parent),
130 // Note: Place defaults in View::reset_view_state(), not here
131 splitter_(new QSplitter()),
132 header_was_shrunk_(false), // The splitter remains unchanged after a reset, so this goes here
133 sticky_scrolling_(false) // Default setting is set in MainWindow::setup_ui()
135 QVBoxLayout *root_layout = new QVBoxLayout(this);
136 root_layout->setContentsMargins(0, 0, 0, 0);
137 root_layout->addWidget(splitter_);
139 viewport_ = new Viewport(*this);
140 scrollarea_ = new CustomScrollArea(splitter_);
141 scrollarea_->setViewport(viewport_);
142 scrollarea_->setFrameShape(QFrame::NoFrame);
144 ruler_ = new Ruler(*this);
146 header_ = new Header(*this);
147 header_->setMinimumWidth(10); // So that the arrow tips show at least
149 // We put the header into a simple layout so that we can add the top margin,
150 // allowing us to make it line up with the bottom of the ruler
151 QWidget *header_container = new QWidget();
152 header_container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
153 QVBoxLayout *header_layout = new QVBoxLayout(header_container);
154 header_layout->setContentsMargins(0, ruler_->sizeHint().height(), 0, 0);
155 header_layout->addWidget(header_);
157 // To let the ruler and scrollarea be on the same split pane, we need a layout
158 QWidget *trace_container = new QWidget();
159 trace_container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
160 QVBoxLayout *trace_layout = new QVBoxLayout(trace_container);
161 trace_layout->setSpacing(0); // We don't want space between the ruler and scrollarea
162 trace_layout->setContentsMargins(0, 0, 0, 0);
163 trace_layout->addWidget(ruler_);
164 trace_layout->addWidget(scrollarea_);
166 splitter_->addWidget(header_container);
167 splitter_->addWidget(trace_container);
168 splitter_->setHandleWidth(1); // Don't show a visible rubber band
169 splitter_->setCollapsible(0, false); // Prevent the header from collapsing
170 splitter_->setCollapsible(1, false); // Prevent the traces from collapsing
171 splitter_->setStretchFactor(0, 0); // Prevent the panes from being resized
172 splitter_->setStretchFactor(1, 1); // when the entire view is resized
173 splitter_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
175 viewport_->installEventFilter(this);
176 ruler_->installEventFilter(this);
177 header_->installEventFilter(this);
179 // Set up settings and event handlers
180 GlobalSettings settings;
181 colored_bg_ = settings.value(GlobalSettings::Key_View_ColoredBG).toBool();
182 snap_distance_ = settings.value(GlobalSettings::Key_View_SnapDistance).toInt();
184 GlobalSettings::add_change_handler(this);
186 connect(scrollarea_->horizontalScrollBar(), SIGNAL(valueChanged(int)),
187 this, SLOT(h_scroll_value_changed(int)));
188 connect(scrollarea_->verticalScrollBar(), SIGNAL(valueChanged(int)),
189 this, SLOT(v_scroll_value_changed()));
191 connect(header_, SIGNAL(selection_changed()),
192 ruler_, SLOT(clear_selection()));
193 connect(ruler_, SIGNAL(selection_changed()),
194 header_, SLOT(clear_selection()));
196 connect(header_, SIGNAL(selection_changed()),
197 this, SIGNAL(selection_changed()));
198 connect(ruler_, SIGNAL(selection_changed()),
199 this, SIGNAL(selection_changed()));
201 connect(splitter_, SIGNAL(splitterMoved(int, int)),
202 this, SLOT(on_splitter_moved()));
204 connect(&lazy_event_handler_, SIGNAL(timeout()),
205 this, SLOT(process_sticky_events()));
206 lazy_event_handler_.setSingleShot(true);
208 // Trigger the initial event manually. The default device has signals
209 // which were created before this object came into being
212 // make sure the transparent widgets are on the top
221 GlobalSettings::remove_change_handler(this);
224 void View::reset_view_state()
226 ViewBase::reset_view_state();
228 segment_display_mode_ = Trace::ShowLastSegmentOnly;
229 segment_selectable_ = false;
233 updating_scroll_ = false;
234 settings_restored_ = false;
235 always_zoom_to_fit_ = false;
237 tick_prefix_ = pv::util::SIPrefix::yocto;
239 time_unit_ = util::TimeUnit::Time;
240 show_cursors_ = false;
241 cursors_ = make_shared<CursorPair>(*this);
242 next_flag_text_ = 'A';
243 trigger_markers_.clear();
244 hover_point_ = QPoint(-1, -1);
245 scroll_needs_defaults_ = true;
247 scale_at_acq_start_ = 0;
248 offset_at_acq_start_ = 0;
249 suppress_zoom_to_fit_after_acq_ = false;
251 show_cursors_ = false;
252 cursor_state_changed(show_cursors_);
255 // Update the zoom state
256 calculate_tick_spacing();
258 // Make sure the standard bar's segment selector is in sync
259 set_segment_display_mode(segment_display_mode_);
262 Session& View::session()
267 const Session& View::session() const
272 unordered_set< shared_ptr<Signal> > View::signals() const
277 void View::clear_signals()
279 ViewBase::clear_signalbases();
283 void View::add_signal(const shared_ptr<Signal> signal)
285 ViewBase::add_signalbase(signal->base());
286 signals_.insert(signal);
288 signal->set_segment_display_mode(segment_display_mode_);
289 signal->set_current_segment(current_segment_);
291 connect(signal->base().get(), SIGNAL(name_changed(const QString&)),
292 this, SLOT(on_signal_name_changed()));
296 void View::clear_decode_signals()
298 decode_traces_.clear();
301 void View::add_decode_signal(shared_ptr<data::DecodeSignal> signal)
303 shared_ptr<DecodeTrace> d(
304 new DecodeTrace(session_, signal, decode_traces_.size()));
305 decode_traces_.push_back(d);
307 d->set_segment_display_mode(segment_display_mode_);
308 d->set_current_segment(current_segment_);
310 connect(signal.get(), SIGNAL(name_changed(const QString&)),
311 this, SLOT(on_signal_name_changed()));
314 void View::remove_decode_signal(shared_ptr<data::DecodeSignal> signal)
316 for (auto i = decode_traces_.begin(); i != decode_traces_.end(); i++)
317 if ((*i)->base() == signal) {
318 decode_traces_.erase(i);
325 shared_ptr<Signal> View::get_signal_under_mouse_cursor() const
327 return signal_under_mouse_cursor_;
335 const View* View::view() const
340 Viewport* View::viewport()
345 const Viewport* View::viewport() const
350 void View::save_settings(QSettings &settings) const
352 settings.setValue("scale", scale_);
353 settings.setValue("v_offset",
354 scrollarea_->verticalScrollBar()->sliderPosition());
356 settings.setValue("splitter_state", splitter_->saveState());
357 settings.setValue("segment_display_mode", segment_display_mode_);
361 boost::archive::text_oarchive oa(ss);
362 oa << boost::serialization::make_nvp("ruler_shift", ruler_shift_);
363 settings.setValue("ruler_shift", QString::fromStdString(ss.str()));
367 boost::archive::text_oarchive oa(ss);
368 oa << boost::serialization::make_nvp("offset", offset_);
369 settings.setValue("offset", QString::fromStdString(ss.str()));
372 for (shared_ptr<Signal> signal : signals_) {
373 settings.beginGroup(signal->base()->internal_name());
374 signal->save_settings(settings);
379 void View::restore_settings(QSettings &settings)
381 // Note: It is assumed that this function is only called once,
382 // immediately after restoring a previous session.
384 if (settings.contains("scale"))
385 set_scale(settings.value("scale").toDouble());
387 if (settings.contains("ruler_shift")) {
388 util::Timestamp shift;
390 ss << settings.value("ruler_shift").toString().toStdString();
393 boost::archive::text_iarchive ia(ss);
394 ia >> boost::serialization::make_nvp("ruler_shift", shift);
395 ruler_shift_ = shift;
396 } catch (boost::archive::archive_exception&) {
397 qDebug() << "Could not restore the view ruler shift";
401 if (settings.contains("offset")) {
402 util::Timestamp offset;
404 ss << settings.value("offset").toString().toStdString();
407 boost::archive::text_iarchive ia(ss);
408 ia >> boost::serialization::make_nvp("offset", offset);
409 // This also updates ruler_offset_
411 } catch (boost::archive::archive_exception&) {
412 qDebug() << "Could not restore the view offset";
416 if (settings.contains("splitter_state"))
417 splitter_->restoreState(settings.value("splitter_state").toByteArray());
419 if (settings.contains("segment_display_mode"))
420 set_segment_display_mode(
421 (Trace::SegmentDisplayMode)(settings.value("segment_display_mode").toInt()));
423 for (shared_ptr<Signal> signal : signals_) {
424 settings.beginGroup(signal->base()->internal_name());
425 signal->restore_settings(settings);
429 if (settings.contains("v_offset")) {
430 saved_v_offset_ = settings.value("v_offset").toInt();
431 set_v_offset(saved_v_offset_);
432 scroll_needs_defaults_ = false;
433 // Note: see eventFilter() for additional information
436 settings_restored_ = true;
437 suppress_zoom_to_fit_after_acq_ = true;
439 // Update the ruler so that it uses the new scale
440 calculate_tick_spacing();
443 vector< shared_ptr<TimeItem> > View::time_items() const
445 const vector<shared_ptr<Flag>> f(flags());
446 vector<shared_ptr<TimeItem>> items(f.begin(), f.end());
449 items.push_back(cursors_);
450 items.push_back(cursors_->first());
451 items.push_back(cursors_->second());
454 for (auto trigger_marker : trigger_markers_)
455 items.push_back(trigger_marker);
460 double View::scale() const
465 void View::set_scale(double scale)
467 if (scale_ != scale) {
473 void View::set_offset(const pv::util::Timestamp& offset, bool force_update)
475 if ((offset_ != offset) || force_update) {
477 ruler_offset_ = offset_ + ruler_shift_;
482 const Timestamp& View::offset() const
487 const Timestamp& View::ruler_offset() const
489 return ruler_offset_;
492 void View::set_zero_position(pv::util::Timestamp& position)
494 ruler_shift_ = -position;
496 // Force an immediate update of the offsets
497 set_offset(offset_, true);
501 void View::reset_zero_position()
505 // Force an immediate update of the offsets
506 set_offset(offset_, true);
510 int View::owner_visual_v_offset() const
512 return -scrollarea_->verticalScrollBar()->sliderPosition();
515 void View::set_v_offset(int offset)
517 scrollarea_->verticalScrollBar()->setSliderPosition(offset);
522 unsigned int View::depth() const
527 uint32_t View::current_segment() const
529 return current_segment_;
532 pv::util::SIPrefix View::tick_prefix() const
537 void View::set_tick_prefix(pv::util::SIPrefix tick_prefix)
539 if (tick_prefix_ != tick_prefix) {
540 tick_prefix_ = tick_prefix;
541 tick_prefix_changed();
545 unsigned int View::tick_precision() const
547 return tick_precision_;
550 void View::set_tick_precision(unsigned tick_precision)
552 if (tick_precision_ != tick_precision) {
553 tick_precision_ = tick_precision;
554 tick_precision_changed();
558 const pv::util::Timestamp& View::tick_period() const
563 unsigned int View::minor_tick_count() const
565 return minor_tick_count_;
568 void View::set_tick_period(const pv::util::Timestamp& tick_period)
570 if (tick_period_ != tick_period) {
571 tick_period_ = tick_period;
572 tick_period_changed();
576 TimeUnit View::time_unit() const
581 void View::set_time_unit(pv::util::TimeUnit time_unit)
583 if (time_unit_ != time_unit) {
584 time_unit_ = time_unit;
589 void View::set_current_segment(uint32_t segment_id)
591 current_segment_ = segment_id;
593 for (shared_ptr<Signal> signal : signals_)
594 signal->set_current_segment(current_segment_);
596 for (shared_ptr<DecodeTrace> dt : decode_traces_)
597 dt->set_current_segment(current_segment_);
600 vector<util::Timestamp> triggers = session_.get_triggers(current_segment_);
602 trigger_markers_.clear();
603 for (util::Timestamp timestamp : triggers)
604 trigger_markers_.push_back(make_shared<TriggerMarker>(*this, timestamp));
606 // When enabled, the first trigger for this segment is used as the zero position
607 GlobalSettings settings;
608 bool trigger_is_zero_time = settings.value(GlobalSettings::Key_View_TriggerIsZeroTime).toBool();
610 if (trigger_is_zero_time && (triggers.size() > 0))
611 set_zero_position(triggers.front());
615 segment_changed(segment_id);
618 bool View::segment_is_selectable() const
620 return segment_selectable_;
623 Trace::SegmentDisplayMode View::segment_display_mode() const
625 return segment_display_mode_;
628 void View::set_segment_display_mode(Trace::SegmentDisplayMode mode)
630 segment_display_mode_ = mode;
632 for (shared_ptr<Signal> signal : signals_)
633 signal->set_segment_display_mode(mode);
635 uint32_t last_segment = session_.get_segment_count() - 1;
638 case Trace::ShowLastSegmentOnly:
639 if (current_segment_ != last_segment)
640 set_current_segment(last_segment);
643 case Trace::ShowLastCompleteSegmentOnly:
644 // Do nothing if we only have one segment so far
645 if (last_segment > 0) {
646 // If the last segment isn't complete, the previous one must be
647 uint32_t segment_id =
648 (session_.all_segments_complete(last_segment)) ?
649 last_segment : last_segment - 1;
651 if (current_segment_ != segment_id)
652 set_current_segment(segment_id);
656 case Trace::ShowSingleSegmentOnly:
657 case Trace::ShowAllSegments:
658 case Trace::ShowAccumulatedIntensity:
660 // Current segment remains as-is
664 segment_selectable_ = true;
666 if ((mode == Trace::ShowAllSegments) || (mode == Trace::ShowAccumulatedIntensity))
667 segment_selectable_ = false;
671 segment_display_mode_changed((int)mode, segment_selectable_);
674 void View::zoom(double steps)
676 zoom(steps, viewport_->width() / 2);
679 void View::zoom(double steps, int offset)
681 set_zoom(scale_ * pow(3.0 / 2.0, -steps), offset);
684 void View::zoom_fit(bool gui_state)
686 // Act as one-shot when stopped, toggle along with the GUI otherwise
687 if (session_.get_capture_state() == Session::Stopped) {
688 always_zoom_to_fit_ = false;
689 always_zoom_to_fit_changed(false);
691 always_zoom_to_fit_ = gui_state;
692 always_zoom_to_fit_changed(gui_state);
695 const pair<Timestamp, Timestamp> extents = get_time_extents();
696 const Timestamp delta = extents.second - extents.first;
697 if (delta < Timestamp("1e-12"))
701 const int w = viewport_->width();
705 const Timestamp scale = max(min(delta / w, MaxScale), MinScale);
706 set_scale_offset(scale.convert_to<double>(), extents.first);
709 void View::set_scale_offset(double scale, const Timestamp& offset)
711 // Disable sticky scrolling / always zoom to fit when acquisition runs
712 // and user drags the viewport
713 if ((scale_ == scale) && (offset_ != offset) &&
714 (session_.get_capture_state() == Session::Running)) {
716 if (sticky_scrolling_) {
717 sticky_scrolling_ = false;
718 sticky_scrolling_changed(false);
721 if (always_zoom_to_fit_) {
722 always_zoom_to_fit_ = false;
723 always_zoom_to_fit_changed(false);
730 calculate_tick_spacing();
737 set< shared_ptr<SignalData> > View::get_visible_data() const
739 // Make a set of all the visible data objects
740 set< shared_ptr<SignalData> > visible_data;
741 for (const shared_ptr<Signal> sig : signals_)
743 visible_data.insert(sig->data());
748 pair<Timestamp, Timestamp> View::get_time_extents() const
750 boost::optional<Timestamp> left_time, right_time;
751 const set< shared_ptr<SignalData> > visible_data = get_visible_data();
752 for (const shared_ptr<SignalData> d : visible_data) {
753 const vector< shared_ptr<Segment> > segments = d->segments();
754 for (const shared_ptr<Segment> &s : segments) {
755 double samplerate = s->samplerate();
756 samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;
758 const Timestamp start_time = s->start_time();
759 left_time = left_time ?
760 min(*left_time, start_time) :
762 right_time = right_time ?
763 max(*right_time, start_time + d->max_sample_count() / samplerate) :
764 start_time + d->max_sample_count() / samplerate;
768 if (!left_time || !right_time)
769 return make_pair(0, 0);
771 assert(*left_time < *right_time);
772 return make_pair(*left_time, *right_time);
775 void View::enable_show_sampling_points(bool state)
782 void View::enable_show_analog_minor_grid(bool state)
789 void View::enable_colored_bg(bool state)
795 bool View::colored_bg() const
800 bool View::cursors_shown() const
802 return show_cursors_;
805 void View::show_cursors(bool show)
807 show_cursors_ = show;
808 cursor_state_changed(show);
813 void View::centre_cursors()
816 const double time_width = scale_ * viewport_->width();
817 cursors_->first()->set_time(offset_ + time_width * 0.4);
818 cursors_->second()->set_time(offset_ + time_width * 0.6);
825 shared_ptr<CursorPair> View::cursors() const
830 void View::add_flag(const Timestamp& time)
832 flags_.push_back(make_shared<Flag>(*this, time,
833 QString("%1").arg(next_flag_text_)));
835 next_flag_text_ = (next_flag_text_ >= 'Z') ? 'A' :
836 (next_flag_text_ + 1);
838 time_item_appearance_changed(true, true);
841 void View::remove_flag(shared_ptr<Flag> flag)
844 time_item_appearance_changed(true, true);
847 vector< shared_ptr<Flag> > View::flags() const
849 vector< shared_ptr<Flag> > flags(flags_.begin(), flags_.end());
850 stable_sort(flags.begin(), flags.end(),
851 [](const shared_ptr<Flag> &a, const shared_ptr<Flag> &b) {
852 return a->time() < b->time();
858 const QPoint& View::hover_point() const
863 int64_t View::get_nearest_level_change(const QPoint &p)
865 // Is snapping disabled?
866 if (snap_distance_ == 0)
870 entry_t(shared_ptr<Signal> s) :
871 signal(s), delta(numeric_limits<int64_t>::max()), sample(-1), is_dense(false) {}
872 shared_ptr<Signal> signal;
878 vector<entry_t> list;
880 // Create list of signals to consider
881 if (signal_under_mouse_cursor_)
882 list.emplace_back(signal_under_mouse_cursor_);
884 for (shared_ptr<Signal> s : signals_) {
888 list.emplace_back(s);
891 // Get data for listed signals
892 for (entry_t &e : list) {
893 // Calculate sample number from cursor position
894 const double samples_per_pixel = e.signal->base()->get_samplerate() * scale();
895 const int64_t x_offset = offset().convert_to<double>() / scale();
896 const int64_t sample_num = max(((x_offset + p.x()) * samples_per_pixel), 0.0);
898 vector<data::LogicSegment::EdgePair> edges =
899 e.signal->get_nearest_level_changes(sample_num);
905 const int64_t first_sample_delta = abs(sample_num - edges.front().first);
906 const int64_t first_delta = first_sample_delta / samples_per_pixel;
907 e.delta = first_delta;
908 e.sample = edges.front().first;
910 // Check second edge if available
911 if (edges.size() == 2) {
912 // Note: -1 because this is usually the right edge and sample points are left-aligned
913 const int64_t second_sample_delta = abs(sample_num - edges.back().first - 1);
914 const int64_t second_delta = second_sample_delta / samples_per_pixel;
916 // If both edges are too close, we mark this signal as being dense
917 if ((first_delta + second_delta) <= snap_distance_)
920 if (second_delta < first_delta) {
921 e.delta = second_delta;
922 e.sample = edges.back().first;
927 // Look for the best match: non-dense first, then dense
928 entry_t *match = nullptr;
930 for (entry_t &e : list) {
931 if (e.delta > snap_distance_ || e.is_dense)
935 if (e.delta < match->delta)
942 for (entry_t &e : list) {
947 if (e.delta < match->delta)
955 // Somewhat ugly hack to make TimeItem::drag_by() work
956 signal_under_mouse_cursor_ = match->signal;
958 return match->sample;
964 void View::restack_all_trace_tree_items()
966 // Make a list of owners that is sorted from deepest first
967 const vector<shared_ptr<TraceTreeItem>> items(
968 list_by_type<TraceTreeItem>());
969 set< TraceTreeItemOwner* > owners;
970 for (const auto &r : items)
971 owners.insert(r->owner());
972 vector< TraceTreeItemOwner* > sorted_owners(owners.begin(), owners.end());
973 sort(sorted_owners.begin(), sorted_owners.end(),
974 [](const TraceTreeItemOwner* a, const TraceTreeItemOwner *b) {
975 return a->depth() > b->depth(); });
977 // Restack the items recursively
978 for (auto &o : sorted_owners)
981 // Animate the items to their destination
982 for (const auto &i : items)
983 i->animate_to_layout_v_offset();
986 int View::header_width() const
988 return header_->extended_size_hint().width();
991 void View::on_setting_changed(const QString &key, const QVariant &value)
993 if (key == GlobalSettings::Key_View_TriggerIsZeroTime)
994 on_settingViewTriggerIsZeroTime_changed(value);
996 if (key == GlobalSettings::Key_View_SnapDistance) {
997 GlobalSettings settings;
998 snap_distance_ = settings.value(GlobalSettings::Key_View_SnapDistance).toInt();
1002 void View::trigger_event(int segment_id, util::Timestamp location)
1004 // TODO This doesn't work if we're showing multiple segments at once
1005 if ((uint32_t)segment_id != current_segment_)
1008 // Set zero location if the Key_View_TriggerIsZeroTime setting is set and
1009 // if this is the first trigger for this segment.
1010 GlobalSettings settings;
1011 bool trigger_is_zero_time = settings.value(GlobalSettings::Key_View_TriggerIsZeroTime).toBool();
1013 size_t trigger_count = session_.get_triggers(current_segment_).size();
1015 if (trigger_is_zero_time && trigger_count == 1)
1016 set_zero_position(location);
1018 trigger_markers_.push_back(make_shared<TriggerMarker>(*this, location));
1021 void View::get_scroll_layout(double &length, Timestamp &offset) const
1023 const pair<Timestamp, Timestamp> extents = get_time_extents();
1024 length = ((extents.second - extents.first) / scale_).convert_to<double>();
1025 offset = offset_ / scale_;
1028 void View::set_zoom(double scale, int offset)
1030 // Reset the "always zoom to fit" feature as the user changed the zoom
1031 always_zoom_to_fit_ = false;
1032 always_zoom_to_fit_changed(false);
1034 const Timestamp cursor_offset = offset_ + scale_ * offset;
1035 const Timestamp new_scale = max(min(Timestamp(scale), MaxScale), MinScale);
1036 const Timestamp new_offset = cursor_offset - new_scale * offset;
1037 set_scale_offset(new_scale.convert_to<double>(), new_offset);
1040 void View::calculate_tick_spacing()
1042 const double SpacingIncrement = 10.0f;
1043 const double MinValueSpacing = 40.0f;
1045 // Figure out the highest numeric value visible on a label
1046 const QSize areaSize = viewport_->size();
1047 const Timestamp max_time = max(fabs(offset_),
1048 fabs(offset_ + scale_ * areaSize.width()));
1050 double min_width = SpacingIncrement;
1051 double label_width, tick_period_width;
1053 QFontMetrics m(QApplication::font());
1055 // Copies of the member variables with the same name, used in the calculation
1056 // and written back afterwards, so that we don't emit signals all the time
1057 // during the calculation.
1058 pv::util::Timestamp tick_period = tick_period_;
1059 pv::util::SIPrefix tick_prefix = tick_prefix_;
1060 unsigned tick_precision = tick_precision_;
1063 const double min_period = scale_ * min_width;
1065 const int order = (int)floorf(log10f(min_period));
1066 const pv::util::Timestamp order_decimal =
1067 pow(pv::util::Timestamp(10), order);
1069 // Allow for a margin of error so that a scale unit of 1 can be used.
1070 // Otherwise, for a SU of 1 the tick period will almost always be below
1071 // the min_period by a small amount - and thus skipped in favor of 2.
1072 // Note: margin assumes that SU[0] and SU[1] contain the smallest values
1073 double tp_margin = (ScaleUnits[0] + ScaleUnits[1]) / 2.0;
1074 double tp_with_margin;
1075 unsigned int unit = 0;
1078 tp_with_margin = order_decimal.convert_to<double>() *
1079 (ScaleUnits[unit++] + tp_margin);
1080 } while (tp_with_margin < min_period && unit < countof(ScaleUnits));
1082 minor_tick_count_ = (unit == 2) ? 4 : 5;
1083 tick_period = order_decimal * ScaleUnits[unit - 1];
1084 tick_prefix = static_cast<pv::util::SIPrefix>(
1085 (order - pv::util::exponent(pv::util::SIPrefix::yocto)) / 3);
1087 // Precision is the number of fractional digits required, not
1088 // taking the prefix into account (and it must never be negative)
1089 tick_precision = max(ceil(log10(1 / tick_period)).convert_to<int>(), 0);
1091 tick_period_width = (tick_period / scale_).convert_to<double>();
1093 const QString label_text = Ruler::format_time_with_distance(
1094 tick_period, max_time, tick_prefix, time_unit_, tick_precision);
1096 label_width = m.boundingRect(0, 0, INT_MAX, INT_MAX,
1097 Qt::AlignLeft | Qt::AlignTop, label_text).width() +
1100 min_width += SpacingIncrement;
1101 } while (tick_period_width < label_width);
1103 set_tick_period(tick_period);
1104 set_tick_prefix(tick_prefix);
1105 set_tick_precision(tick_precision);
1108 void View::adjust_top_margin()
1112 const QSize areaSize = viewport_->size();
1114 const pair<int, int> extents = v_extents();
1115 const int top_margin = owner_visual_v_offset() + extents.first;
1116 const int trace_bottom = owner_visual_v_offset() + extents.first + extents.second;
1118 // Do we have empty space at the top while the last trace goes out of screen?
1119 if ((top_margin > 0) && (trace_bottom > areaSize.height())) {
1120 const int trace_height = extents.second - extents.first;
1122 // Center everything vertically if there is enough space
1123 if (areaSize.height() >= trace_height)
1124 set_v_offset(extents.first -
1125 ((areaSize.height() - trace_height) / 2));
1127 // Remove the top margin to make as many traces fit on screen as possible
1128 set_v_offset(extents.first);
1132 void View::update_scroll()
1135 QScrollBar *hscrollbar = scrollarea_->horizontalScrollBar();
1136 QScrollBar *vscrollbar = scrollarea_->verticalScrollBar();
1138 const QSize areaSize = viewport_->size();
1140 // Set the horizontal scroll bar
1143 get_scroll_layout(length, offset);
1144 length = max(length - areaSize.width(), 0.0);
1146 int major_tick_distance = (tick_period_ / scale_).convert_to<int>();
1148 hscrollbar->setPageStep(areaSize.width() / 2);
1149 hscrollbar->setSingleStep(major_tick_distance);
1151 updating_scroll_ = true;
1153 if (length < MaxScrollValue) {
1154 hscrollbar->setRange(0, length);
1155 hscrollbar->setSliderPosition(offset.convert_to<double>());
1157 hscrollbar->setRange(0, MaxScrollValue);
1158 hscrollbar->setSliderPosition(
1159 (offset_ * MaxScrollValue / (scale_ * length)).convert_to<double>());
1162 updating_scroll_ = false;
1164 // Set the vertical scrollbar
1165 vscrollbar->setPageStep(areaSize.height());
1166 vscrollbar->setSingleStep(areaSize.height() / 8);
1168 const pair<int, int> extents = v_extents();
1170 // Don't change the scrollbar range if there are no traces
1171 if (extents.first != extents.second)
1172 vscrollbar->setRange(extents.first - areaSize.height(),
1175 if (scroll_needs_defaults_) {
1176 set_scroll_default();
1177 scroll_needs_defaults_ = false;
1181 void View::reset_scroll()
1183 scrollarea_->verticalScrollBar()->setRange(0, 0);
1186 void View::set_scroll_default()
1190 const QSize areaSize = viewport_->size();
1192 const pair<int, int> extents = v_extents();
1193 const int trace_height = extents.second - extents.first;
1195 // Do all traces fit in the view?
1196 if (areaSize.height() >= trace_height)
1197 // Center all traces vertically
1198 set_v_offset(extents.first -
1199 ((areaSize.height() - trace_height) / 2));
1201 // Put the first trace at the top, letting the bottom ones overflow
1202 set_v_offset(extents.first);
1205 void View::determine_if_header_was_shrunk()
1207 const int header_pane_width = splitter_->sizes().front();
1209 // Allow for a slight margin of error so that we also accept
1210 // slight differences when e.g. a label name change increased
1211 // the overall width
1212 header_was_shrunk_ = (header_pane_width < (header_width() - 10));
1215 void View::resize_header_to_fit()
1217 // Setting the maximum width of the header widget doesn't work as
1218 // expected because the splitter would allow the user to make the
1219 // pane wider than that, creating empty space as a result.
1220 // To make this work, we stricly enforce the maximum width by
1221 // expanding the header unless the user shrunk it on purpose.
1222 // As we're then setting the width of the header pane, we set the
1223 // splitter to the maximum allowed position.
1225 int splitter_area_width = 0;
1226 for (int w : splitter_->sizes())
1227 splitter_area_width += w;
1229 // Make sure the header has enough horizontal space to show all labels fully
1230 QList<int> pane_sizes;
1231 pane_sizes.push_back(header_->extended_size_hint().width());
1232 pane_sizes.push_back(splitter_area_width - header_->extended_size_hint().width());
1233 splitter_->setSizes(pane_sizes);
1236 void View::update_layout()
1241 TraceTreeItemOwner* View::find_prevalent_trace_group(
1242 const shared_ptr<sigrok::ChannelGroup> &group,
1243 const unordered_map<shared_ptr<data::SignalBase>, shared_ptr<Signal> >
1248 unordered_set<TraceTreeItemOwner*> owners;
1249 vector<TraceTreeItemOwner*> owner_list;
1251 // Make a set and a list of all the owners
1252 for (const auto &channel : group->channels()) {
1253 for (auto entry : signal_map) {
1254 if (entry.first->channel() == channel) {
1255 TraceTreeItemOwner *const o = (entry.second)->owner();
1256 owner_list.push_back(o);
1262 // Iterate through the list of owners, and find the most prevalent
1263 size_t max_prevalence = 0;
1264 TraceTreeItemOwner *prevalent_owner = nullptr;
1265 for (TraceTreeItemOwner *owner : owners) {
1266 const size_t prevalence = count_if(
1267 owner_list.begin(), owner_list.end(),
1268 [&](TraceTreeItemOwner *o) { return o == owner; });
1269 if (prevalence > max_prevalence) {
1270 max_prevalence = prevalence;
1271 prevalent_owner = owner;
1275 return prevalent_owner;
1278 vector< shared_ptr<Trace> > View::extract_new_traces_for_channels(
1279 const vector< shared_ptr<sigrok::Channel> > &channels,
1280 const unordered_map<shared_ptr<data::SignalBase>, shared_ptr<Signal> >
1282 set< shared_ptr<Trace> > &add_list)
1284 vector< shared_ptr<Trace> > filtered_traces;
1286 for (const auto &channel : channels) {
1287 for (auto entry : signal_map) {
1288 if (entry.first->channel() == channel) {
1289 shared_ptr<Trace> trace = entry.second;
1290 const auto list_iter = add_list.find(trace);
1291 if (list_iter == add_list.end())
1294 filtered_traces.push_back(trace);
1295 add_list.erase(list_iter);
1300 return filtered_traces;
1303 void View::determine_time_unit()
1305 // Check whether we know the sample rate and hence can use time as the unit
1306 if (time_unit_ == util::TimeUnit::Samples) {
1307 // Check all signals but...
1308 for (const shared_ptr<Signal> signal : signals_) {
1309 const shared_ptr<SignalData> data = signal->data();
1311 // ...only check first segment of each
1312 const vector< shared_ptr<Segment> > segments = data->segments();
1313 if (!segments.empty())
1314 if (segments[0]->samplerate()) {
1315 set_time_unit(util::TimeUnit::Time);
1322 bool View::eventFilter(QObject *object, QEvent *event)
1324 const QEvent::Type type = event->type();
1325 if (type == QEvent::MouseMove) {
1327 const QMouseEvent *const mouse_event = (QMouseEvent*)event;
1328 if (object == viewport_)
1329 hover_point_ = mouse_event->pos();
1330 else if (object == ruler_)
1331 // Adjust the hover point's y coordinate so that it's relative to
1332 // the top of the viewport. The result may be negative.
1333 hover_point_ = QPoint(mouse_event->pos().x(),
1334 mouse_event->pos().y() - ruler_->sizeHint().height());
1335 else if (object == header_)
1336 hover_point_ = QPoint(0, mouse_event->y());
1338 hover_point_ = QPoint(-1, -1);
1340 update_hover_point();
1342 } else if (type == QEvent::Leave) {
1343 hover_point_ = QPoint(-1, -1);
1344 update_hover_point();
1345 } else if (type == QEvent::Show) {
1347 // This is somewhat of a hack, unfortunately. We cannot use
1348 // set_v_offset() from within restore_settings() as the view
1349 // at that point is neither visible nor properly sized.
1350 // This is the least intrusive workaround I could come up
1351 // with: set the vertical offset (or scroll defaults) when
1352 // the view is shown, which happens after all widgets were
1353 // resized to their final sizes.
1356 if (settings_restored_)
1357 determine_if_header_was_shrunk();
1359 resize_header_to_fit();
1361 if (scroll_needs_defaults_) {
1362 set_scroll_default();
1363 scroll_needs_defaults_ = false;
1366 if (saved_v_offset_) {
1367 set_v_offset(saved_v_offset_);
1368 saved_v_offset_ = 0;
1372 return QObject::eventFilter(object, event);
1375 void View::contextMenuEvent(QContextMenuEvent *event)
1377 QPoint pos = event->pos() - QPoint(0, ruler_->sizeHint().height());
1379 const shared_ptr<ViewItem> r = viewport_->get_mouse_over_item(pos);
1383 QMenu *menu = r->create_view_context_menu(this, pos);
1385 menu->popup(event->globalPos());
1388 void View::resizeEvent(QResizeEvent* event)
1390 // Only adjust the top margin if we shrunk vertically
1391 if (event->size().height() < event->oldSize().height())
1392 adjust_top_margin();
1397 void View::update_hover_point()
1399 // Determine signal that the mouse cursor is hovering over
1400 signal_under_mouse_cursor_.reset();
1401 for (shared_ptr<Signal> s : signals_) {
1402 const pair<int, int> extents = s->v_extents();
1403 const int top = s->get_visual_y() + extents.first;
1404 const int btm = s->get_visual_y() + extents.second;
1405 if ((hover_point_.y() >= top) && (hover_point_.y() <= btm)
1406 && s->base()->enabled())
1407 signal_under_mouse_cursor_ = s;
1410 // Update all trace tree items
1411 const vector<shared_ptr<TraceTreeItem>> trace_tree_items(
1412 list_by_type<TraceTreeItem>());
1413 for (shared_ptr<TraceTreeItem> r : trace_tree_items)
1414 r->hover_point_changed(hover_point_);
1416 // Notify any other listeners
1417 hover_point_changed(hover_point_);
1420 void View::row_item_appearance_changed(bool label, bool content)
1425 viewport_->update();
1428 void View::time_item_appearance_changed(bool label, bool content)
1433 // Make sure the header pane width is updated, too
1438 viewport_->update();
1441 void View::extents_changed(bool horz, bool vert)
1444 (horz ? TraceTreeItemHExtentsChanged : 0) |
1445 (vert ? TraceTreeItemVExtentsChanged : 0);
1447 lazy_event_handler_.stop();
1448 lazy_event_handler_.start();
1451 void View::on_signal_name_changed()
1453 if (!header_was_shrunk_)
1454 resize_header_to_fit();
1457 void View::on_splitter_moved()
1459 // The header can only shrink when the splitter is moved manually
1460 determine_if_header_was_shrunk();
1462 if (!header_was_shrunk_)
1463 resize_header_to_fit();
1466 void View::h_scroll_value_changed(int value)
1468 if (updating_scroll_)
1471 // Disable sticky scrolling when user moves the horizontal scroll bar
1472 // during a running acquisition
1473 if (sticky_scrolling_ && (session_.get_capture_state() == Session::Running)) {
1474 sticky_scrolling_ = false;
1475 sticky_scrolling_changed(false);
1478 const int range = scrollarea_->horizontalScrollBar()->maximum();
1479 if (range < MaxScrollValue)
1480 set_offset(scale_ * value);
1484 get_scroll_layout(length, offset);
1485 set_offset(scale_ * length * value / MaxScrollValue);
1489 viewport_->update();
1492 void View::v_scroll_value_changed()
1495 viewport_->update();
1498 void View::signals_changed()
1500 using sigrok::Channel;
1502 vector< shared_ptr<Channel> > channels;
1503 shared_ptr<sigrok::Device> sr_dev;
1504 bool signals_added_or_removed = false;
1506 // Do we need to set the vertical scrollbar to its default position later?
1507 // We do if there are no traces, i.e. the scroll bar has no range set
1508 bool reset_scrollbar =
1509 (scrollarea_->verticalScrollBar()->minimum() ==
1510 scrollarea_->verticalScrollBar()->maximum());
1512 if (!session_.device()) {
1516 sr_dev = session_.device()->device();
1518 channels = sr_dev->channels();
1521 vector< shared_ptr<TraceTreeItem> > new_top_level_items;
1523 // Make a list of traces that are being added, and a list of traces
1524 // that are being removed
1525 const vector<shared_ptr<Trace>> prev_trace_list = list_by_type<Trace>();
1526 const set<shared_ptr<Trace>> prev_traces(
1527 prev_trace_list.begin(), prev_trace_list.end());
1529 set< shared_ptr<Trace> > traces(signals_.begin(), signals_.end());
1531 #ifdef ENABLE_DECODE
1532 traces.insert(decode_traces_.begin(), decode_traces_.end());
1535 set< shared_ptr<Trace> > add_traces;
1536 set_difference(traces.begin(), traces.end(),
1537 prev_traces.begin(), prev_traces.end(),
1538 inserter(add_traces, add_traces.begin()));
1540 set< shared_ptr<Trace> > remove_traces;
1541 set_difference(prev_traces.begin(), prev_traces.end(),
1542 traces.begin(), traces.end(),
1543 inserter(remove_traces, remove_traces.begin()));
1545 // Make a look-up table of sigrok Channels to pulseview Signals
1546 unordered_map<shared_ptr<data::SignalBase>, shared_ptr<Signal> >
1548 for (const shared_ptr<Signal> &sig : signals_)
1549 signal_map[sig->base()] = sig;
1551 // Populate channel groups
1553 for (auto entry : sr_dev->channel_groups()) {
1554 const shared_ptr<sigrok::ChannelGroup> &group = entry.second;
1556 if (group->channels().size() <= 1)
1559 // Find best trace group to add to
1560 TraceTreeItemOwner *owner = find_prevalent_trace_group(
1563 // If there is no trace group, create one
1564 shared_ptr<TraceGroup> new_trace_group;
1566 new_trace_group.reset(new TraceGroup());
1567 owner = new_trace_group.get();
1570 // Extract traces for the trace group, removing them from
1572 const vector< shared_ptr<Trace> > new_traces_in_group =
1573 extract_new_traces_for_channels(group->channels(),
1574 signal_map, add_traces);
1576 // Add the traces to the group
1577 const pair<int, int> prev_v_extents = owner->v_extents();
1578 int offset = prev_v_extents.second - prev_v_extents.first;
1579 for (shared_ptr<Trace> trace : new_traces_in_group) {
1581 owner->add_child_item(trace);
1583 const pair<int, int> extents = trace->v_extents();
1584 if (trace->enabled())
1585 offset += -extents.first;
1586 trace->force_to_v_offset(offset);
1587 if (trace->enabled())
1588 offset += extents.second;
1591 if (new_trace_group) {
1592 // Assign proper vertical offsets to each channel in the group
1593 new_trace_group->restack_items();
1595 // If this is a new group, enqueue it in the new top level
1597 if (!new_traces_in_group.empty())
1598 new_top_level_items.push_back(new_trace_group);
1602 // Enqueue the remaining logic channels in a group
1603 vector< shared_ptr<Channel> > logic_channels;
1604 copy_if(channels.begin(), channels.end(), back_inserter(logic_channels),
1605 [](const shared_ptr<Channel>& c) {
1606 return c->type() == sigrok::ChannelType::LOGIC; });
1608 const vector< shared_ptr<Trace> > non_grouped_logic_signals =
1609 extract_new_traces_for_channels(logic_channels, signal_map, add_traces);
1611 if (non_grouped_logic_signals.size() > 0) {
1612 const shared_ptr<TraceGroup> non_grouped_trace_group(
1613 make_shared<TraceGroup>());
1614 for (shared_ptr<Trace> trace : non_grouped_logic_signals)
1615 non_grouped_trace_group->add_child_item(trace);
1617 non_grouped_trace_group->restack_items();
1618 new_top_level_items.push_back(non_grouped_trace_group);
1621 // Enqueue the remaining channels as free ungrouped traces
1622 const vector< shared_ptr<Trace> > new_top_level_signals =
1623 extract_new_traces_for_channels(channels, signal_map, add_traces);
1624 new_top_level_items.insert(new_top_level_items.end(),
1625 new_top_level_signals.begin(), new_top_level_signals.end());
1627 // Enqueue any remaining traces i.e. decode traces
1628 new_top_level_items.insert(new_top_level_items.end(),
1629 add_traces.begin(), add_traces.end());
1631 // Remove any removed traces
1632 for (shared_ptr<Trace> trace : remove_traces) {
1633 TraceTreeItemOwner *const owner = trace->owner();
1635 owner->remove_child_item(trace);
1636 signals_added_or_removed = true;
1639 // Remove any empty trace groups
1640 for (shared_ptr<TraceGroup> group : list_by_type<TraceGroup>())
1641 if (group->child_items().size() == 0) {
1642 remove_child_item(group);
1646 // Add and position the pending top levels items
1647 int offset = v_extents().second;
1648 for (auto item : new_top_level_items) {
1649 add_child_item(item);
1651 // Position the item after the last item or at the top if there is none
1652 const pair<int, int> extents = item->v_extents();
1654 if (item->enabled())
1655 offset += -extents.first;
1657 item->force_to_v_offset(offset);
1659 if (item->enabled())
1660 offset += extents.second;
1661 signals_added_or_removed = true;
1665 if (signals_added_or_removed && !header_was_shrunk_)
1666 resize_header_to_fit();
1671 viewport_->update();
1673 if (reset_scrollbar)
1674 set_scroll_default();
1677 void View::capture_state_updated(int state)
1679 GlobalSettings settings;
1681 if (state == Session::Running) {
1682 set_time_unit(util::TimeUnit::Samples);
1684 trigger_markers_.clear();
1686 scale_at_acq_start_ = scale_;
1687 offset_at_acq_start_ = offset_;
1689 // Activate "always zoom to fit" if the setting is enabled and we're
1690 // the main view of this session (other trace views may be used for
1691 // zooming and we don't want to mess them up)
1692 bool state = settings.value(GlobalSettings::Key_View_ZoomToFitDuringAcq).toBool();
1693 if (is_main_view_ && state) {
1694 always_zoom_to_fit_ = true;
1695 always_zoom_to_fit_changed(always_zoom_to_fit_);
1698 // Enable sticky scrolling if the setting is enabled
1699 sticky_scrolling_ = settings.value(GlobalSettings::Key_View_StickyScrolling).toBool();
1701 // Reset all traces to segment 0
1702 current_segment_ = 0;
1703 set_current_segment(current_segment_);
1706 if (state == Session::Stopped) {
1707 // After acquisition has stopped we need to re-calculate the ticks once
1708 // as it's otherwise done when the user pans or zooms, which is too late
1709 calculate_tick_spacing();
1711 // Reset "always zoom to fit", the acquisition has stopped
1712 if (always_zoom_to_fit_) {
1713 // Perform a final zoom-to-fit before disabling
1714 zoom_fit(always_zoom_to_fit_);
1715 always_zoom_to_fit_ = false;
1716 always_zoom_to_fit_changed(always_zoom_to_fit_);
1719 bool zoom_to_fit_after_acq =
1720 settings.value(GlobalSettings::Key_View_ZoomToFitAfterAcq).toBool();
1722 // Only perform zoom-to-fit if the user hasn't altered the viewport and
1723 // we didn't restore settings in the meanwhile
1724 if (zoom_to_fit_after_acq &&
1725 !suppress_zoom_to_fit_after_acq_ &&
1726 (scale_ == scale_at_acq_start_) &&
1727 (offset_ == offset_at_acq_start_))
1728 zoom_fit(false); // We're stopped, so the GUI state doesn't matter
1730 suppress_zoom_to_fit_after_acq_ = false;
1734 void View::on_new_segment(int new_segment_id)
1736 on_segment_changed(new_segment_id);
1739 void View::on_segment_completed(int segment_id)
1741 on_segment_changed(segment_id);
1744 void View::on_segment_changed(int segment)
1746 switch (segment_display_mode_) {
1747 case Trace::ShowLastSegmentOnly:
1748 case Trace::ShowSingleSegmentOnly:
1749 set_current_segment(segment);
1752 case Trace::ShowLastCompleteSegmentOnly:
1753 // Only update if all segments are complete
1754 if (session_.all_segments_complete(segment))
1755 set_current_segment(segment);
1758 case Trace::ShowAllSegments:
1759 case Trace::ShowAccumulatedIntensity:
1765 void View::on_settingViewTriggerIsZeroTime_changed(const QVariant new_value)
1767 if (new_value.toBool()) {
1768 // The first trigger for this segment is used as the zero position
1769 vector<util::Timestamp> triggers = session_.get_triggers(current_segment_);
1770 if (triggers.size() > 0)
1771 set_zero_position(triggers.front());
1773 reset_zero_position();
1776 void View::perform_delayed_view_update()
1778 if (always_zoom_to_fit_) {
1780 } else if (sticky_scrolling_) {
1781 // Make right side of the view sticky
1784 get_scroll_layout(length, offset);
1786 const QSize areaSize = viewport_->size();
1787 length = max(length - areaSize.width(), 0.0);
1789 set_offset(scale_ * length);
1792 determine_time_unit();
1795 viewport_->update();
1798 void View::process_sticky_events()
1800 if (sticky_events_ & TraceTreeItemHExtentsChanged)
1802 if (sticky_events_ & TraceTreeItemVExtentsChanged) {
1803 restack_all_trace_tree_items();
1807 // Clear the sticky events
1811 } // namespace trace
1812 } // namespace views