]> sigrok.org Git - pulseview.git/blobdiff - pv/view/ruler.cpp
Fixed timeline scale
[pulseview.git] / pv / view / ruler.cpp
index a2e280b6f2291cd57ac11ce65403fb1dac9fd99b..5dea19474c84714a3f653e8449ff099f0f700625 100644 (file)
@@ -56,7 +56,7 @@ void Ruler::paintEvent(QPaintEvent *event)
        const int order = (int)floorf(log10f(min_period));
        const double order_decimal = pow(10, order);
 
        const int order = (int)floorf(log10f(min_period));
        const double order_decimal = pow(10, order);
 
-       int unit = 0;
+       unsigned int unit = 0;
        double tick_period = 0.0f;
 
        do
        double tick_period = 0.0f;
 
        do
@@ -64,11 +64,11 @@ void Ruler::paintEvent(QPaintEvent *event)
                tick_period = order_decimal * ScaleUnits[unit++];
        } while(tick_period < min_period && unit < countof(ScaleUnits));
 
                tick_period = order_decimal * ScaleUnits[unit++];
        } while(tick_period < min_period && unit < countof(ScaleUnits));
 
-       const int prefix = (order - FirstSIPrefixPower) / 3;
+       const unsigned int prefix = (order - FirstSIPrefixPower) / 3;
        assert(prefix >= 0);
        assert(prefix < countof(SIPrefixes));
 
        assert(prefix >= 0);
        assert(prefix < countof(SIPrefixes));
 
-       const double multiplier = pow(0.1, prefix * 3 + FirstSIPrefixPower);
+       const double multiplier = pow(10.0, - prefix * 3 - FirstSIPrefixPower);
 
        const int text_height = p.boundingRect(0, 0, INT_MAX, INT_MAX,
                Qt::AlignLeft | Qt::AlignTop, "8").height();
 
        const int text_height = p.boundingRect(0, 0, INT_MAX, INT_MAX,
                Qt::AlignLeft | Qt::AlignTop, "8").height();