From: Joel Holdsworth Date: Sat, 13 Jun 2015 09:19:14 +0000 (+0100) Subject: RowItemOwner: Added list_row_item_owners X-Git-Tag: pulseview-0.3.0~182 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=873cbed09a23679f39e955478d6c70429104ce40;p=pulseview.git RowItemOwner: Added list_row_item_owners --- diff --git a/pv/view/rowitemowner.cpp b/pv/view/rowitemowner.cpp index 8970f45a..ba2e1f48 100644 --- a/pv/view/rowitemowner.cpp +++ b/pv/view/rowitemowner.cpp @@ -27,6 +27,7 @@ using std::max; using std::make_pair; using std::min; using std::pair; +using std::set; using std::shared_ptr; using std::vector; @@ -92,6 +93,14 @@ RowItemOwner::const_iterator RowItemOwner::end() const return const_iterator(this); } +set< RowItemOwner* > RowItemOwner::list_row_item_owners() +{ + set< RowItemOwner* > owners; + for (const auto &r : *this) + owners.insert(r->owner()); + return owners; +} + pair RowItemOwner::v_extents() const { pair extents(INT_MAX, INT_MIN); diff --git a/pv/view/rowitemowner.hpp b/pv/view/rowitemowner.hpp index f5c2abd7..d72dddb2 100644 --- a/pv/view/rowitemowner.hpp +++ b/pv/view/rowitemowner.hpp @@ -118,6 +118,12 @@ public: */ const_iterator end() const; + /** + * Makes a list of row item owners of all the row items that are + * decendants of this item. + */ + std::set< RowItemOwner* > list_row_item_owners(); + /** * Computes the vertical extents of the contents of this row item owner. * @return A pair containing the minimum and maximum y-values. diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 8b805913..f7f9834d 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -401,12 +401,8 @@ void View::update_viewport() void View::restack_all_row_items() { - // Make a set of owners - unordered_set< RowItemOwner* > owners; - for (const auto &r : *this) - owners.insert(r->owner()); - - // Make a list that is sorted from deepest first + // 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) {