Render ruler and signals with sub-pixel accuracy
[pulseview.git] / pv / logicsignal.cpp
index fe5572d232d8184ebb25807c0bdc4b9755022232..a0dabe4a00ed1c39bf1d68c51a950238afc448f4 100644 (file)
@@ -54,8 +54,8 @@ const QColor LogicSignal::LogicSignalColours[10] = {
 LogicSignal::LogicSignal(QString name, shared_ptr<LogicData> data,
        int probe_index) :
        Signal(name),
-       _data(data),
-       _probe_index(probe_index)
+       _probe_index(probe_index),
+       _data(data)
 {
        assert(_probe_index >= 0);
 }
@@ -70,8 +70,8 @@ void LogicSignal::paint(QPainter &p, const QRect &rect, double scale,
        assert(scale > 0);
        assert(_data);
 
-       const float high_offset = rect.top() + Margin;
-       const float low_offset = rect.bottom() - Margin;
+       const float high_offset = rect.top() + Margin + 0.5f;
+       const float low_offset = rect.bottom() - Margin + 0.5f;
 
        const deque< shared_ptr<LogicDataSnapshot> > &snapshots =
                _data->get_snapshots();
@@ -102,7 +102,7 @@ void LogicSignal::paint(QPainter &p, const QRect &rect, double scale,
        for(vector<LogicDataSnapshot::EdgePair>::const_iterator i =
                        edges.begin() + 1;
                i != edges.end() - 1; i++) {
-               const int x = (int)((*i).first / samples_per_pixel -
+               const float x = ((*i).first / samples_per_pixel -
                        pixels_offset) + rect.left();
                *line++ = QLineF(x, high_offset, x, low_offset);
        }
@@ -125,10 +125,10 @@ void LogicSignal::paint(QPainter &p, const QRect &rect, double scale,
        delete[] cap_lines;
 }
 
-int LogicSignal::paint_caps(QPainter &p, QLineF *const lines,
+void LogicSignal::paint_caps(QPainter &p, QLineF *const lines,
        vector< pair<int64_t, bool> > &edges, bool level,
-       double samples_per_pixel, double pixels_offset, int x_offset,
-       int y_offset)
+       double samples_per_pixel, double pixels_offset, float x_offset,
+       float y_offset)
 {
        QLineF *line = lines;
 
@@ -136,9 +136,9 @@ int LogicSignal::paint_caps(QPainter &p, QLineF *const lines,
            i != (edges.end() - 1); i++)
                if((*i).second == level) {
                        *line++ = QLineF(
-                               (int)((*i).first / samples_per_pixel -
+                               ((*i).first / samples_per_pixel -
                                        pixels_offset) + x_offset, y_offset,
-                               (int)((*(i+1)).first / samples_per_pixel -
+                               ((*(i+1)).first / samples_per_pixel -
                                        pixels_offset) + x_offset, y_offset);
                }