X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fruler.cpp;h=601e73b163a6ed84683ca8b3bcf9526ab3a8e048;hp=cd72a179cc72a84e46f4e9e65edb82750da42b0b;hb=3d79f521396c8e908fd237f5328153165099f5c3;hpb=97f712530f0f22461d16f7d34b5ff8bf6e4c3c7f diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index cd72a179..601e73b1 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -35,10 +35,10 @@ using std::vector; namespace pv { namespace view { -const float Ruler::RulerHeight = 2.5f; // x Text Height +const float Ruler::RulerHeight = 2.5f; // x Text Height const int Ruler::MinorTickSubdivision = 4; -const float Ruler::HoverArrowSize = 0.5f; // x Text Height +const float Ruler::HoverArrowSize = 0.5f; // x Text Height Ruler::Ruler(View &parent) : MarginWidget(parent) @@ -138,12 +138,12 @@ void Ruler::paintEvent(QPaintEvent*) this->view_.tick_precision()); }; - tick_position_cache_.emplace(calculate_tick_positions( + tick_position_cache_ = calculate_tick_positions( view_.tick_period(), view_.offset(), view_.scale(), width(), - ffunc)); + ffunc); } const int ValueMargin = 3; @@ -198,8 +198,7 @@ Ruler::TickPositions Ruler::calculate_tick_positions( { TickPositions tp; - const double minor_period = - (major_period / MinorTickSubdivision).convert_to(); + const pv::util::Timestamp minor_period = major_period / MinorTickSubdivision; const pv::util::Timestamp first_major_division = floor(offset / major_period); const pv::util::Timestamp first_minor_division = ceil(offset / minor_period); const pv::util::Timestamp t0 = first_major_division * major_period; @@ -214,7 +213,7 @@ Ruler::TickPositions Ruler::calculate_tick_positions( x = ((t - offset) / scale).convert_to(); if (division % MinorTickSubdivision == 0) { - // Recalculate 't' without using 'minor_period' which is of type double. + // Recalculate 't' without using 'minor_period' which is a fraction t = t0 + division / MinorTickSubdivision * major_period; tp.major.emplace_back(x, format_function(t)); } else {