From: Joel Holdsworth Date: Mon, 31 Dec 2012 13:58:02 +0000 (+0000) Subject: Add decoder after decoder dialog X-Git-Tag: pulseview-0.2.0~314 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=82c7f64018db2a90f44704e55ba469151522762f;p=pulseview.git Add decoder after decoder dialog --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index aa06601c..0397c7f4 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -392,7 +392,10 @@ void MainWindow::add_decoder(QObject *action) _session.get_signals(); dialogs::Decoder dlg(this, dec, sigs); - dlg.exec(); + if(dlg.exec() != QDialog::Accepted) + return; + + _session.add_decoder(dec); } void MainWindow::run_stop() diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index e9349bba..c2c2dc98 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -25,7 +25,9 @@ #include "data/analogsnapshot.h" #include "data/logic.h" #include "data/logicsnapshot.h" + #include "view/analogsignal.h" +#include "view/decodesignal.h" #include "view/logicsignal.h" #include @@ -194,6 +196,15 @@ boost::shared_ptr SigSession::get_data() return _logic_data; } +void SigSession::add_decoder(srd_decoder *const dec) +{ + { + shared_ptr d(new view::DecodeSignal(*this, dec)); + _decode_traces.push_back(d); + } + signals_changed(); +} + void SigSession::set_capture_state(capture_state state) { lock_guard lock(_sampling_mutex); @@ -287,6 +298,9 @@ void SigSession::update_signals(const sr_dev_inst *const sdi) unsigned int logic_probe_count = 0; unsigned int analog_probe_count = 0; + // Clear the decode traces + _decode_traces.clear(); + // Detect what data types we will receive if(sdi) { for (const GSList *l = sdi->probes; l; l = l->next) { diff --git a/pv/sigsession.h b/pv/sigsession.h index 88c603e2..50768e6c 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -34,6 +34,8 @@ #include +struct srd_decoder; + namespace pv { class DeviceManager; @@ -46,6 +48,7 @@ class LogicSnapshot; } namespace view { +class DecodeSignal; class Signal; } @@ -89,6 +92,8 @@ public: boost::shared_ptr get_data(); + void add_decoder(srd_decoder *const dec); + private: void set_capture_state(capture_state state); @@ -147,6 +152,8 @@ private: */ struct sr_dev_inst *_sdi; + std::vector< boost::shared_ptr > _decode_traces; + mutable boost::mutex _sampling_mutex; capture_state _capture_state; diff --git a/pv/view/decodesignal.cpp b/pv/view/decodesignal.cpp index 3e28d493..1e534275 100644 --- a/pv/view/decodesignal.cpp +++ b/pv/view/decodesignal.cpp @@ -37,6 +37,11 @@ DecodeSignal::DecodeSignal(pv::SigSession &session, srd_decoder *const dec) : _colour = Qt::red; } +void DecodeSignal::init_context_bar_actions(QWidget *parent) +{ + (void)parent; +} + bool DecodeSignal::enabled() const { return true; diff --git a/pv/view/decodesignal.h b/pv/view/decodesignal.h index 7e1410e8..e52c7947 100644 --- a/pv/view/decodesignal.h +++ b/pv/view/decodesignal.h @@ -33,6 +33,8 @@ class DecodeSignal : public Trace public: DecodeSignal(pv::SigSession &session, srd_decoder *const dec); + void init_context_bar_actions(QWidget *parent); + bool enabled() const; /**