- // Make the Signals list
- {
- unique_lock<shared_mutex> lock(signals_mutex_);
-
- unordered_set< shared_ptr<view::Signal> > prev_sigs(signals_);
- signals_.clear();
-
- for (auto channel : device->channels()) {
- shared_ptr<view::Signal> signal;
-
- // Find the channel in the old signals
- const auto iter = std::find_if(
- prev_sigs.cbegin(), prev_sigs.cend(),
- [&](const shared_ptr<view::Signal> &s) {
- return s->channel() == channel;
- });
- if (iter != prev_sigs.end()) {
- // Copy the signal from the old set to the new
- signal = *iter;
- auto logic_signal = dynamic_pointer_cast<
- view::LogicSignal>(signal);
- if (logic_signal)
- logic_signal->set_logic_data(
- logic_data_);
- } else {
- // Create a new signal
- switch(channel->type()->id()) {
- case SR_CHANNEL_LOGIC:
- signal = shared_ptr<view::Signal>(
- new view::LogicSignal(*this,
- device, channel,
- logic_data_));
- break;
-
- case SR_CHANNEL_ANALOG:
- {
- shared_ptr<data::Analog> data(
- new data::Analog());
- signal = shared_ptr<view::Signal>(
- new view::AnalogSignal(
- *this, channel, data));
- break;
- }
-
- default:
- assert(0);
- break;
+ // Make the signals list
+ for (shared_ptr<views::ViewBase> viewbase : views_) {
+ views::TraceView::View *trace_view =
+ qobject_cast<views::TraceView::View*>(viewbase.get());
+
+ if (trace_view) {
+ unordered_set< shared_ptr<views::TraceView::Signal> >
+ prev_sigs(trace_view->signals());
+ trace_view->clear_signals();
+
+ for (auto channel : sr_dev->channels()) {
+ shared_ptr<data::SignalBase> signalbase;
+ shared_ptr<views::TraceView::Signal> signal;
+
+ // Find the channel in the old signals
+ const auto iter = find_if(
+ prev_sigs.cbegin(), prev_sigs.cend(),
+ [&](const shared_ptr<views::TraceView::Signal> &s) {
+ return s->base()->channel() == channel;
+ });
+ if (iter != prev_sigs.end()) {
+ // Copy the signal from the old set to the new
+ signal = *iter;
+ trace_view->add_signal(signal);
+ } else {
+ // Find the signalbase for this channel if possible
+ signalbase.reset();
+ for (const shared_ptr<data::SignalBase> b : signalbases_)
+ if (b->channel() == channel)
+ signalbase = b;
+
+ switch(channel->type()->id()) {
+ case SR_CHANNEL_LOGIC:
+ if (!signalbase) {
+ signalbase = make_shared<data::SignalBase>(channel,
+ data::SignalBase::LogicChannel);
+ signalbases_.insert(signalbase);
+
+ all_signal_data_.insert(logic_data_);
+ signalbase->set_data(logic_data_);
+
+ connect(this, SIGNAL(capture_state_changed(int)),
+ signalbase.get(), SLOT(on_capture_state_changed(int)));
+ }
+
+ signal = shared_ptr<views::TraceView::Signal>(
+ new views::TraceView::LogicSignal(*this,
+ device_, signalbase));
+ trace_view->add_signal(signal);
+ break;
+
+ case SR_CHANNEL_ANALOG:
+ {
+ if (!signalbase) {
+ signalbase = make_shared<data::SignalBase>(channel,
+ data::SignalBase::AnalogChannel);
+ signalbases_.insert(signalbase);
+
+ shared_ptr<data::Analog> data(new data::Analog());
+ all_signal_data_.insert(data);
+ signalbase->set_data(data);
+
+ connect(this, SIGNAL(capture_state_changed(int)),
+ signalbase.get(), SLOT(on_capture_state_changed(int)));
+ }
+
+ signal = shared_ptr<views::TraceView::Signal>(
+ new views::TraceView::AnalogSignal(
+ *this, signalbase));
+ trace_view->add_signal(signal);
+ break;
+ }
+
+ default:
+ assert(false);
+ break;
+ }