]> sigrok.org Git - pulseview.git/blobdiff - pv/dialogs/decoder.cpp
Made Decoder dialog export a map of probes, and routed through to pv::data::Decoder
[pulseview.git] / pv / dialogs / decoder.cpp
index abd25041e795aa8c1ca1f534cd23792018a233f3..97df5d45f43c605f3d774d25848d4d0557247e93 100644 (file)
@@ -22,8 +22,15 @@ extern "C" {
 #include <libsigrokdecode/libsigrokdecode.h>
 }
 
+#include <utility>
+
+#include <boost/foreach.hpp>
+
+#include <QDebug>
+
 #include "decoder.h"
 
+#include <pv/view/logicsignal.h>
 #include <pv/view/signal.h>
 
 using namespace boost;
@@ -87,6 +94,9 @@ Decoder::Decoder(QWidget *parent, const srd_decoder *decoder,
 
                _probe_selector_map[p] = combo;
        }
+
+       _form_layout.addRow(new QLabel(
+               tr("<i>* Required Probes</i>"), &_form));
 }
 
 QComboBox* Decoder::create_probe_selector(
@@ -112,5 +122,28 @@ QComboBox* Decoder::create_probe_selector(
        return selector;
 }
 
+map<const srd_probe*, shared_ptr<view::Signal> > Decoder::get_probes()
+{
+       map<const srd_probe*, shared_ptr<view::Signal> > probe_map;
+       for(map<const srd_probe*, QComboBox*>::const_iterator i =
+               _probe_selector_map.begin();
+               i != _probe_selector_map.end(); i++)
+       {
+               const QComboBox *const combo = (*i).second;
+               const int probe_index =
+                       combo->itemData(combo->currentIndex()).value<int>();
+               if(probe_index >= 0) {
+                       shared_ptr<view::Signal> sig = _sigs[probe_index];
+                       if(dynamic_cast<pv::view::LogicSignal*>(sig.get()))
+                               probe_map[(*i).first] = sig;
+                       else
+                               qDebug() << "Currently only logic signals "
+                                       "are supported for decoding";
+               }
+       }
+
+       return probe_map;
+}
+
 } // namespace dialogs
 } // namespace pv