Store annotations as objects emplaced in the vector
[pulseview.git] / pv / view / decodetrace.cpp
index beb83b1f20634febe91707867fca8ca0af93c77f..e582d1a8e2042d1ba4d4f2dd1046940bd8067990 100644 (file)
@@ -27,6 +27,7 @@ extern "C" {
 #include <boost/foreach.hpp>
 
 #include <QAction>
+#include <QApplication>
 #include <QComboBox>
 #include <QFormLayout>
 #include <QLabel>
@@ -107,7 +108,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
        const double scale = _view->scale();
        assert(scale > 0);
 
-       double samplerate = _decoder_stack->get_samplerate();
+       double samplerate = _decoder_stack->samplerate();
 
        // Show sample rate as 1Hz when it is unknown
        if (samplerate == 0.0)
@@ -117,7 +118,8 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
                _decoder_stack->get_start_time()) / scale;
        const double samples_per_pixel = samplerate * scale;
 
-       const int h = (_text_size.height() * 5) / 4;
+       QFontMetrics m(QApplication::font());
+       const int h = (m.boundingRect(QRect(), 0, "Tg").height() * 5) / 4;
 
        assert(_decoder_stack);
        const QString err = _decoder_stack->error_message();
@@ -133,12 +135,10 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
        const int y = get_y();
 
        assert(_decoder_stack);
-       vector< shared_ptr<Annotation> > annotations(_decoder_stack->annotations());
-       BOOST_FOREACH(shared_ptr<Annotation> a, annotations) {
-               assert(a);
-               a->paint(p, get_text_colour(), h, left, right,
+       vector<Annotation> annotations(_decoder_stack->annotations());
+       BOOST_FOREACH(const Annotation &a, annotations)
+               a.paint(p, get_text_colour(), h, left, right,
                        samples_per_pixel, pixels_offset, y);
-       }
 
        draw_unresolved_period(p, h, left, right,
                samples_per_pixel, pixels_offset);
@@ -250,7 +250,7 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left,
        BOOST_FOREACH (const shared_ptr<Decoder> &dec, stack)
                if (dec && !dec->probes().empty() &&
                        ((logic_signal = (*dec->probes().begin()).second)) &&
-                       ((data = logic_signal->data())))
+                       ((data = logic_signal->logic_data())))
                        break;
 
        if (!data || data->get_snapshots().empty())