X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fview.cpp;h=99a28e4d7ee187b805490699ace737428cc31e1f;hb=769a79b51a3c042770e97bb3303d0b8a20f5c648;hp=540b90e14cffb17021e698549b780475e689f280;hpb=af503b104d890a357c736c678bb00296d889c090;p=pulseview.git diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 540b90e..99a28e4 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -32,6 +32,8 @@ #include #include +#include + #include #include #include @@ -63,6 +65,8 @@ using pv::data::Segment; using pv::util::TimeUnit; using pv::util::Timestamp; +using std::back_inserter; +using std::copy_if; using std::deque; using std::dynamic_pointer_cast; using std::inserter; @@ -70,6 +74,7 @@ using std::list; using std::lock_guard; using std::max; using std::make_pair; +using std::make_shared; using std::min; using std::pair; using std::set; @@ -394,8 +399,7 @@ void View::set_scale_offset(double scale, const Timestamp& offset) set< shared_ptr > View::get_visible_data() const { - shared_lock lock(session().signals_mutex()); - const unordered_set< shared_ptr > &sigs(session().signals()); + const unordered_set< shared_ptr > sigs(session().signals()); // Make a set of all the visible data objects set< shared_ptr > visible_data; @@ -507,7 +511,11 @@ void View::update_viewport() void View::restack_all_trace_tree_items() { // Make a list of owners that is sorted from deepest first - const auto owners = list_row_item_owners(); + const vector> items( + list_by_type()); + set< TraceTreeItemOwner* > owners; + for (const auto &r : items) + owners.insert(r->owner()); vector< TraceTreeItemOwner* > sorted_owners(owners.begin(), owners.end()); sort(sorted_owners.begin(), sorted_owners.end(), [](const TraceTreeItemOwner* a, const TraceTreeItemOwner *b) { @@ -518,8 +526,8 @@ void View::restack_all_trace_tree_items() o->restack_items(); // Animate the items to their destination - for (const auto &r : *this) - r->animate_to_layout_v_offset(); + for (const auto &i : items) + i->animate_to_layout_v_offset(); } void View::get_scroll_layout(double &length, Timestamp &offset) const @@ -739,8 +747,7 @@ void View::determine_time_unit() { // Check whether we know the sample rate and hence can use time as the unit if (time_unit_ == util::TimeUnit::Samples) { - shared_lock lock(session().signals_mutex()); - const unordered_set< shared_ptr > &sigs(session().signals()); + const unordered_set< shared_ptr > sigs(session().signals()); // Check all signals but... for (const shared_ptr signal : sigs) { @@ -864,6 +871,8 @@ void View::v_scroll_value_changed() void View::signals_changed() { + using sigrok::Channel; + vector< shared_ptr > new_top_level_items; const auto device = session_.device(); @@ -873,12 +882,16 @@ void View::signals_changed() shared_ptr sr_dev = device->device(); assert(sr_dev); + const vector< shared_ptr > channels( + sr_dev->channels()); + // Make a list of traces that are being added, and a list of traces // that are being removed - const set> prev_traces = list_by_type(); + const vector> prev_trace_list = list_by_type(); + const set> prev_traces( + prev_trace_list.begin(), prev_trace_list.end()); - shared_lock lock(session_.signals_mutex()); - const unordered_set< shared_ptr > &sigs(session_.signals()); + const unordered_set< shared_ptr > sigs(session_.signals()); set< shared_ptr > traces(sigs.begin(), sigs.end()); @@ -950,9 +963,23 @@ void View::signals_changed() new_top_level_items.push_back(new_trace_group); } + // Enqueue the remaining logic channels in a group + vector< shared_ptr > logic_channels; + copy_if(channels.begin(), channels.end(), back_inserter(logic_channels), + [](const shared_ptr& c) { + return c->type() == sigrok::ChannelType::LOGIC; }); + const vector< shared_ptr > non_grouped_logic_signals = + extract_new_traces_for_channels(logic_channels, + signal_map, add_traces); + const shared_ptr non_grouped_trace_group( + make_shared()); + for (shared_ptr trace : non_grouped_logic_signals) + non_grouped_trace_group->add_child_item(trace); + new_top_level_items.push_back(non_grouped_trace_group); + // Enqueue the remaining channels as free ungrouped traces const vector< shared_ptr > new_top_level_signals = - extract_new_traces_for_channels(sr_dev->channels(), + extract_new_traces_for_channels(channels, signal_map, add_traces); new_top_level_items.insert(new_top_level_items.end(), new_top_level_signals.begin(), new_top_level_signals.end()); @@ -1057,7 +1084,9 @@ void View::process_sticky_events() void View::on_hover_point_changed() { - for (shared_ptr r : *this) + const vector> trace_tree_items( + list_by_type()); + for (shared_ptr r : trace_tree_items) r->hover_point_changed(); }