]> sigrok.org Git - pulseview.git/blobdiff - pv/view/decodetrace.cpp
Update description for Trace::get_label_rect()
[pulseview.git] / pv / view / decodetrace.cpp
index c3bc1dff0a4981170e86b748fe8f45c1a7206b33..c8a20dc3c9c6cf7eb3888080351e624ba38349c7 100644 (file)
@@ -24,7 +24,6 @@ extern "C" {
 
 #include <extdef.h>
 
-#include <boost/foreach.hpp>
 #include <boost/functional/hash.hpp>
 
 #include <QAction>
@@ -48,12 +47,12 @@ extern "C" {
 #include <pv/widgets/decodergroupbox.h>
 #include <pv/widgets/decodermenu.h>
 
-using boost::dynamic_pointer_cast;
-using boost::shared_ptr;
+using std::dynamic_pointer_cast;
 using std::list;
 using std::max;
 using std::map;
 using std::min;
+using std::shared_ptr;
 using std::vector;
 
 namespace pv {
@@ -112,7 +111,7 @@ const QColor DecodeTrace::OutlineColours[16] = {
 };
 
 DecodeTrace::DecodeTrace(pv::SigSession &session,
-       boost::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) :
+       std::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) :
        Trace(QString::fromUtf8(
                decoder_stack->stack().front()->decoder()->name)),
        _session(session),
@@ -137,7 +136,7 @@ bool DecodeTrace::enabled() const
        return true;
 }
 
-const boost::shared_ptr<pv::data::DecoderStack>& DecodeTrace::decoder() const
+const std::shared_ptr<pv::data::DecoderStack>& DecodeTrace::decoder() const
 {
        return _decoder_stack;
 }
@@ -214,7 +213,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
                _decoder_stack->get_annotation_subset(annotations, row,
                        start_sample, end_sample);
                if (!annotations.empty()) {
-                       BOOST_FOREACH(const Annotation &a, annotations)
+                       for (const Annotation &a : annotations)
                                draw_annotation(a, p, get_text_colour(),
                                        annotation_height, left, right,
                                        samples_per_pixel, pixels_offset, y,
@@ -289,7 +288,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
 
        // Add the decoder options
        _bindings.clear();
-       _probe_selectors.clear();
+       _channel_selectors.clear();
        _decoder_forms.clear();
 
        const list< shared_ptr<Decoder> >& stack = _decoder_stack->stack();
@@ -303,8 +302,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
        }
        else
        {
-               list< shared_ptr<Decoder> >::const_iterator iter =
-                       stack.begin();
+               auto iter = stack.cbegin();
                for (int i = 0; i < (int)stack.size(); i++, iter++) {
                        shared_ptr<Decoder> dec(*iter);
                        create_decoder_form(i, dec, parent, form);
@@ -373,7 +371,7 @@ void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &
 {
        const QString text = a.annotations().empty() ?
                QString() : a.annotations().back();
-       const double w = min(p.boundingRect(QRectF(), 0, text).width(),
+       const double w = min((double)p.boundingRect(QRectF(), 0, text).width(),
                0.0) + h;
        const QRectF rect(x - w / 2, y - h / 2, w, h);
 
@@ -430,7 +428,7 @@ void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p,
        QString best_annotation;
        int best_width = 0;
 
-       BOOST_FOREACH(const QString &a, annotations) {
+       for (const QString &a : annotations) {
                const int w = p.boundingRect(QRectF(), 0, a).width();
                if (w <= rect.width() && w > best_width)
                        best_annotation = a, best_width = w;
@@ -478,10 +476,10 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left,
 
        const list< shared_ptr<Decoder> > &stack = _decoder_stack->stack();
 
-       // We get the logic data of the first probe in the list.
+       // We get the logic data of the first channel in the list.
        // This works because we are currently assuming all
        // LogicSignals have the same data/snapshot
-       BOOST_FOREACH (const shared_ptr<Decoder> &dec, stack)
+       for (const shared_ptr<Decoder> &dec : stack)
                if (dec && !dec->channels().empty() &&
                        ((logic_signal = (*dec->channels().begin()).second)) &&
                        ((data = logic_signal->logic_data())))
@@ -546,30 +544,30 @@ void DecodeTrace::create_decoder_form(int index,
        for(l = decoder->channels; l; l = l->next) {
                const struct srd_channel *const pdch =
                        (struct srd_channel *)l->data;
-               QComboBox *const combo = create_probe_selector(parent, dec, pdch);
+               QComboBox *const combo = create_channel_selector(parent, dec, pdch);
                connect(combo, SIGNAL(currentIndexChanged(int)),
-                       this, SLOT(on_probe_selected(int)));
+                       this, SLOT(on_channel_selected(int)));
                decoder_form->addRow(tr("<b>%1</b> (%2) *")
                        .arg(QString::fromUtf8(pdch->name))
                        .arg(QString::fromUtf8(pdch->desc)), combo);
 
-               const ProbeSelector s = {combo, dec, pdch};
-               _probe_selectors.push_back(s);
+               const ChannelSelector s = {combo, dec, pdch};
+               _channel_selectors.push_back(s);
        }
 
        // Add the optional channels
        for(l = decoder->opt_channels; l; l = l->next) {
                const struct srd_channel *const pdch =
                        (struct srd_channel *)l->data;
-               QComboBox *const combo = create_probe_selector(parent, dec, pdch);
+               QComboBox *const combo = create_channel_selector(parent, dec, pdch);
                connect(combo, SIGNAL(currentIndexChanged(int)),
-                       this, SLOT(on_probe_selected(int)));
+                       this, SLOT(on_channel_selected(int)));
                decoder_form->addRow(tr("<b>%1</b> (%2)")
                        .arg(QString::fromUtf8(pdch->name))
                        .arg(QString::fromUtf8(pdch->desc)), combo);
 
-               const ProbeSelector s = {combo, dec, pdch};
-               _probe_selectors.push_back(s);
+               const ChannelSelector s = {combo, dec, pdch};
+               _channel_selectors.push_back(s);
        }
 
        // Add the options
@@ -583,7 +581,7 @@ void DecodeTrace::create_decoder_form(int index,
        _decoder_forms.push_back(group);
 }
 
-QComboBox* DecodeTrace::create_probe_selector(
+QComboBox* DecodeTrace::create_channel_selector(
        QWidget *parent, const shared_ptr<data::decode::Decoder> &dec,
        const srd_channel *const pdch)
 {
@@ -592,15 +590,13 @@ QComboBox* DecodeTrace::create_probe_selector(
        const vector< shared_ptr<Signal> > sigs = _session.get_signals();
 
        assert(_decoder_stack);
-       const map<const srd_channel*,
-               shared_ptr<LogicSignal> >::const_iterator probe_iter =
-               dec->channels().find(pdch);
+       const auto channel_iter = dec->channels().find(pdch);
 
        QComboBox *selector = new QComboBox(parent);
 
        selector->addItem("-", qVariantFromValue((void*)NULL));
 
-       if (probe_iter == dec->channels().end())
+       if (channel_iter == dec->channels().end())
                selector->setCurrentIndex(0);
 
        for(size_t i = 0; i < sigs.size(); i++) {
@@ -611,7 +607,7 @@ QComboBox* DecodeTrace::create_probe_selector(
                {
                        selector->addItem(s->get_name(),
                                qVariantFromValue((void*)s.get()));
-                       if ((*probe_iter).second == s)
+                       if ((*channel_iter).second == s)
                                selector->setCurrentIndex(i + 1);
                }
        }
@@ -619,14 +615,14 @@ QComboBox* DecodeTrace::create_probe_selector(
        return selector;
 }
 
-void DecodeTrace::commit_decoder_probes(shared_ptr<data::decode::Decoder> &dec)
+void DecodeTrace::commit_decoder_channels(shared_ptr<data::decode::Decoder> &dec)
 {
        assert(dec);
 
-       map<const srd_channel*, shared_ptr<LogicSignal> > probe_map;
+       map<const srd_channel*, shared_ptr<LogicSignal> > channel_map;
        const vector< shared_ptr<Signal> > sigs = _session.get_signals();
 
-       BOOST_FOREACH(const ProbeSelector &s, _probe_selectors)
+       for (const ChannelSelector &s : _channel_selectors)
        {
                if(s._decoder != dec)
                        break;
@@ -635,23 +631,22 @@ void DecodeTrace::commit_decoder_probes(shared_ptr<data::decode::Decoder> &dec)
                        (LogicSignal*)s._combo->itemData(
                                s._combo->currentIndex()).value<void*>();
 
-               BOOST_FOREACH(shared_ptr<Signal> sig, sigs)
+               for (shared_ptr<Signal> sig : sigs)
                        if(sig.get() == selection) {
-                               probe_map[s._pdch] =
+                               channel_map[s._pdch] =
                                        dynamic_pointer_cast<LogicSignal>(sig);
                                break;
                        }
        }
 
-       dec->set_probes(probe_map);
+       dec->set_channels(channel_map);
 }
 
-void DecodeTrace::commit_probes()
+void DecodeTrace::commit_channels()
 {
        assert(_decoder_stack);
-       BOOST_FOREACH(shared_ptr<data::decode::Decoder> dec,
-               _decoder_stack->stack())
-               commit_decoder_probes(dec);
+       for (shared_ptr<data::decode::Decoder> dec : _decoder_stack->stack())
+               commit_decoder_channels(dec);
 
        _decoder_stack->begin_decode();
 }
@@ -672,9 +667,9 @@ void DecodeTrace::on_delete()
        _session.remove_decode_signal(this);
 }
 
-void DecodeTrace::on_probe_selected(int)
+void DecodeTrace::on_channel_selected(int)
 {
-       commit_probes();
+       commit_channels();
 }
 
 void DecodeTrace::on_stack_decoder(srd_decoder *decoder)
@@ -705,7 +700,7 @@ void DecodeTrace::on_show_hide_decoder(int index)
        const list< shared_ptr<Decoder> > stack(_decoder_stack->stack());
 
        // Find the decoder in the stack
-       list< shared_ptr<Decoder> >::const_iterator iter = stack.begin();
+       auto iter = stack.cbegin();
        for(int i = 0; i < index; i++, iter++)
                assert(iter != stack.end());