]> sigrok.org Git - pulseview.git/blobdiff - pv/view/view.cpp
Replaced boost::shared_ptr with std::shared_ptr
[pulseview.git] / pv / view / view.cpp
index 2b0f04a5952983ec3c4909fed12e112c4a34fc3e..d33d4ec95065a7eaae9ea2570d5eff5f3795c876 100644 (file)
@@ -26,8 +26,6 @@
 #include <limits.h>
 #include <math.h>
 
-#include <boost/foreach.hpp>
-
 #include <QEvent>
 #include <QMouseEvent>
 #include <QScrollBar>
@@ -43,8 +41,6 @@
 #include "pv/data/logic.h"
 #include "pv/data/logicsnapshot.h"
 
-using boost::shared_ptr;
-using boost::weak_ptr;
 using pv::data::SignalData;
 using std::deque;
 using std::list;
@@ -53,7 +49,9 @@ using std::make_pair;
 using std::min;
 using std::pair;
 using std::set;
+using std::shared_ptr;
 using std::vector;
+using std::weak_ptr;
 
 namespace pv {
 namespace view {
@@ -92,7 +90,9 @@ View::View(SigSession &session, QWidget *parent) :
 
        connect(&_session, SIGNAL(signals_changed()),
                this, SLOT(signals_changed()));
-       connect(&_session, SIGNAL(data_updated()),
+       connect(&_session, SIGNAL(data_received()),
+               this, SLOT(data_updated()));
+       connect(&_session, SIGNAL(frame_ended()),
                this, SLOT(data_updated()));
 
        connect(_cursors.first().get(), SIGNAL(time_changed()),
@@ -121,6 +121,8 @@ View::View(SigSession &session, QWidget *parent) :
        _ruler->installEventFilter(this);
        _header->installEventFilter(this);
 
+       // Trigger the initial event manually. The default device has signals
+       // which were created before this object came into being
        signals_changed();
 }
 
@@ -188,7 +190,7 @@ void View::zoom_one_to_one()
                return;
 
        double samplerate = 0.0;
-       BOOST_FOREACH(const shared_ptr<SignalData> d, visible_data) {
+       for (const shared_ptr<SignalData> d : visible_data) {
                assert(d);
                samplerate = max(samplerate, d->samplerate());
        }
@@ -228,7 +230,7 @@ vector< shared_ptr<Trace> > View::get_traces() const
        vector< shared_ptr<Trace> > traces(sigs.size());
 #endif
 
-       vector< shared_ptr<Trace> >::iterator i = traces.begin();
+       auto i = traces.begin();
        i = copy(sigs.begin(), sigs.end(), i);
 #ifdef ENABLE_DECODE
        i = copy(decode_sigs.begin(), decode_sigs.end(), i);
@@ -244,7 +246,7 @@ list<weak_ptr<SelectableItem> > View::selected_items() const
 
        // List the selected signals
        const vector< shared_ptr<Trace> > traces(get_traces());
-       BOOST_FOREACH (shared_ptr<Trace> t, traces) {
+       for (shared_ptr<Trace> t : traces) {
                assert(t);
                if (t->selected())
                        items.push_back(t);
@@ -266,7 +268,7 @@ set< shared_ptr<SignalData> > View::get_visible_data() const
 
        // Make a set of all the visible data objects
        set< shared_ptr<SignalData> > visible_data;
-       BOOST_FOREACH(const shared_ptr<Signal> sig, sigs)
+       for (const shared_ptr<Signal> sig : sigs)
                if (sig->enabled())
                        visible_data.insert(sig->data());
 
@@ -280,7 +282,7 @@ pair<double, double> View::get_time_extents() const
                return make_pair(0.0, 0.0);
 
        double left_time = DBL_MAX, right_time = DBL_MIN;
-       BOOST_FOREACH(const shared_ptr<SignalData> d, visible_data)
+       for (const shared_ptr<SignalData> d : visible_data)
        {
                const double start_time = d->get_start_time();
                double samplerate = d->samplerate();
@@ -336,11 +338,11 @@ void View::normalize_layout()
        const vector< shared_ptr<Trace> > traces(get_traces());
 
        int v_min = INT_MAX;
-       BOOST_FOREACH(const shared_ptr<Trace> t, traces)
+       for (const shared_ptr<Trace> t : traces)
                v_min = min(t->get_v_offset(), v_min);
 
        const int delta = -min(v_min, 0);
-       BOOST_FOREACH(shared_ptr<Trace> t, traces)
+       for (shared_ptr<Trace> t : traces)
                t->set_v_offset(t->get_v_offset() + delta);
 
        verticalScrollBar()->setSliderPosition(_v_offset + delta);
@@ -495,7 +497,7 @@ void View::signals_changed()
 {
        int offset = SignalMargin + SignalHeight;
        const vector< shared_ptr<Trace> > traces(get_traces());
-       BOOST_FOREACH(shared_ptr<Trace> t, traces) {
+       for (shared_ptr<Trace> t : traces) {
                t->set_view(this);
                t->set_v_offset(offset);
                offset += SignalHeight + 2 * SignalMargin;