X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fruler.cpp;h=a442901c3e9c76645e44da9a5a9bd5dd18ca8df9;hp=bbafdb0f22cdce854fb52322a7a666b82bdac039;hb=3f96c34aa5735b72a8c2a48d24ad38b1d9898933;hpb=ca4ec3eab886e62c0f9d0cc91636383a74ad5d7b diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index bbafdb0f..a442901c 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -76,10 +76,9 @@ void Ruler::paintEvent(QPaintEvent *event) do { tick_period = order_decimal * ScaleUnits[unit++]; - } while(tick_period < min_period && unit < countof(ScaleUnits)); + } while (tick_period < min_period && unit < countof(ScaleUnits)); const unsigned int prefix = (order - FirstSIPrefixPower) / 3; - assert(prefix >= 0); assert(prefix < countof(SIPrefixes)); const double multiplier = pow(10.0, - prefix * 3 - FirstSIPrefixPower); @@ -99,15 +98,15 @@ void Ruler::paintEvent(QPaintEvent *event) int division = (int)round(first_minor_division - first_major_division * MinorTickSubdivision); - while(1) + while (1) { const double t = t0 + division * minor_tick_period; const double x = (t - _view.offset()) / _view.scale(); - if(x >= width()) + if (x >= width()) break; - if(division % MinorTickSubdivision == 0) + if (division % MinorTickSubdivision == 0) { // Draw a major tick QString s; @@ -139,7 +138,7 @@ void Ruler::paintEvent(QPaintEvent *event) void Ruler::mouseMoveEvent(QMouseEvent *e) { - if(!_grabbed_marker) + if (!_grabbed_marker) return; _grabbed_marker->set_time(_view.offset() + @@ -148,16 +147,16 @@ void Ruler::mouseMoveEvent(QMouseEvent *e) void Ruler::mousePressEvent(QMouseEvent *e) { - if(e->buttons() & Qt::LeftButton) { + if (e->buttons() & Qt::LeftButton) { _grabbed_marker = NULL; - if(_view.cursors_shown()) { + if (_view.cursors_shown()) { std::pair &cursors = _view.cursors(); - if(cursors.first.get_label_rect( + if (cursors.first.get_label_rect( rect()).contains(e->pos())) _grabbed_marker = &cursors.first; - else if(cursors.second.get_label_rect( + else if (cursors.second.get_label_rect( rect()).contains(e->pos())) _grabbed_marker = &cursors.second; } @@ -171,7 +170,7 @@ void Ruler::mouseReleaseEvent(QMouseEvent *) void Ruler::draw_cursors(QPainter &p) { - if(!_view.cursors_shown()) + if (!_view.cursors_shown()) return; const QRect r = rect(); @@ -183,7 +182,8 @@ void Ruler::draw_cursors(QPainter &p) void Ruler::draw_hover_mark(QPainter &p) { const int x = _view.hover_point().x(); - if(x == -1 || _grabbed_marker) + + if (x == -1 || _grabbed_marker) return; p.setPen(QPen(Qt::NoPen));