+ ruler_->update();
+ viewport_->update();
+ scale_offset_changed();
+}
+
+set< shared_ptr<SignalData> > View::get_visible_data() const
+{
+ shared_lock<shared_mutex> lock(session().signals_mutex());
+ const unordered_set< shared_ptr<Signal> > &sigs(session().signals());
+
+ // Make a set of all the visible data objects
+ set< shared_ptr<SignalData> > visible_data;
+ for (const shared_ptr<Signal> sig : sigs)
+ if (sig->enabled())
+ visible_data.insert(sig->data());
+
+ return visible_data;
+}
+
+pair<double, double> View::get_time_extents() const
+{
+ double left_time = DBL_MAX, right_time = DBL_MIN;
+ const set< shared_ptr<SignalData> > visible_data = get_visible_data();
+ for (const shared_ptr<SignalData> d : visible_data)
+ {
+ const vector< shared_ptr<Segment> > segments =
+ d->segments();
+ for (const shared_ptr<Segment> &s : segments) {
+ double samplerate = s->samplerate();
+ samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;
+
+ const double start_time = s->start_time();
+ left_time = min(left_time, start_time);
+ right_time = max(right_time, start_time +
+ d->max_sample_count() / samplerate);
+ }
+ }
+
+ if (left_time == DBL_MAX && right_time == DBL_MIN)
+ return make_pair(0.0, 0.0);
+
+ assert(left_time < right_time);
+ return make_pair(left_time, right_time);
+}
+
+bool View::cursors_shown() const
+{
+ return show_cursors_;
+}
+
+void View::show_cursors(bool show)
+{
+ show_cursors_ = show;
+ ruler_->update();
+ viewport_->update();
+}
+
+void View::centre_cursors()
+{
+ const double time_width = scale_ * viewport_->width();
+ cursors_->first()->set_time(offset_ + time_width * 0.4);
+ cursors_->second()->set_time(offset_ + time_width * 0.6);
+ ruler_->update();
+ viewport_->update();
+}
+
+std::shared_ptr<CursorPair> View::cursors() const
+{
+ return cursors_;
+}
+
+void View::add_flag(double time)
+{
+ flags_.push_back(shared_ptr<Flag>(new Flag(*this, time,
+ QString("%1").arg(next_flag_text_))));
+ next_flag_text_ = (next_flag_text_ >= 'Z') ? 'A' :
+ (next_flag_text_ + 1);
+ time_item_appearance_changed(true, true);
+}
+
+void View::remove_flag(std::shared_ptr<Flag> flag)
+{
+ flags_.remove(flag);
+ time_item_appearance_changed(true, true);
+}
+
+vector< std::shared_ptr<Flag> > View::flags() const
+{
+ vector< std::shared_ptr<Flag> > flags(flags_.begin(), flags_.end());
+ stable_sort(flags.begin(), flags.end(),
+ [](const shared_ptr<Flag> &a, const shared_ptr<Flag> &b) {
+ return a->time() < b->time();
+ });
+
+ return flags;
+}
+
+const QPoint& View::hover_point() const
+{
+ return hover_point_;
+}
+
+void View::update_viewport()
+{
+ assert(viewport_);
+ viewport_->update();
+ header_->update();
+}
+
+void View::restack_all_row_items()
+{
+ // Make a list of owners that is sorted from deepest first
+ const auto owners = list_row_item_owners();
+ vector< RowItemOwner* > sorted_owners(owners.begin(), owners.end());
+ sort(sorted_owners.begin(), sorted_owners.end(),
+ [](const RowItemOwner* a, const RowItemOwner *b) {
+ return a->depth() > b->depth(); });
+
+ // Restack the items recursively
+ for (auto &o : sorted_owners)
+ o->restack_items();
+
+ // Animate the items to their destination
+ for (const auto &r : *this)
+ r->animate_to_layout_v_offset();