From 769a79b51a3c042770e97bb3303d0b8a20f5c648 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sat, 3 Oct 2015 16:29:30 -0600 Subject: [PATCH] View: Place non-grouped logic channels in a TraceGroup --- pv/view/view.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/pv/view/view.cpp b/pv/view/view.cpp index d21b75ab..99a28e4d 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -65,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; @@ -72,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; @@ -868,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(); @@ -877,6 +882,9 @@ 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 vector> prev_trace_list = list_by_type(); @@ -955,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()); -- 2.30.2