X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fcursorpair.cpp;h=8aba0abd1274a7fc778d89a70d8df06fe67347a3;hp=d319a7b1bffc3b69e67e937c46a3b0a38aee1747;hb=4c8a6a6d03e2a12f67d910a83589072b478114cb;hpb=f9abf97e78bc4825d80926b0ebc6cbaef40768b1 diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index d319a7b1..8aba0abd 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -18,10 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "cursorpair.h" +#include "cursorpair.hpp" -#include "view.h" -#include "pv/util.h" +#include "view.hpp" +#include "pv/util.hpp" #include #include @@ -38,27 +38,27 @@ namespace view { const int CursorPair::DeltaPadding = 8; CursorPair::CursorPair(View &view) : - _first(new Cursor(view, 0.0)), - _second(new Cursor(view, 1.0)), - _view(view) + first_(new Cursor(view, 0.0)), + second_(new Cursor(view, 1.0)), + view_(view) { } shared_ptr CursorPair::first() const { - return _first; + return first_; } shared_ptr CursorPair::second() const { - return _second; + return second_; } QRectF CursorPair::get_label_rect(const QRect &rect) const { const QSizeF label_size( - _text_size.width() + View::LabelPadding.width() * 2, - _text_size.height() + View::LabelPadding.height() * 2); + text_size_.width() + View::LabelPadding.width() * 2, + text_size_.height() + View::LabelPadding.height() * 2); const pair offsets(get_cursor_offsets()); const pair normal_offsets( (offsets.first < offsets.second) ? offsets : @@ -74,11 +74,12 @@ QRectF CursorPair::get_label_rect(const QRect &rect) const right - left, height); } -void CursorPair::draw_markers(QPainter &p, - const QRect &rect, unsigned int prefix) +void CursorPair::draw_markers(QPainter &p, const QRect &rect) { - assert(_first); - assert(_second); + assert(first_); + assert(second_); + + const unsigned int prefix = view_.tick_prefix(); compute_text_size(p, prefix); QRectF delta_rect(get_label_rect(rect)); @@ -86,7 +87,7 @@ void CursorPair::draw_markers(QPainter &p, const int radius = delta_rect.height() / 2; const QRectF text_rect(delta_rect.intersected( rect).adjusted(radius, 0, -radius, 0)); - if(text_rect.width() >= _text_size.width()) + if(text_rect.width() >= text_size_.width()) { const int highlight_radius = delta_rect.height() / 2 - 2; @@ -100,12 +101,12 @@ void CursorPair::draw_markers(QPainter &p, p.setPen(Cursor::TextColour); p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter, - pv::util::format_time(_second->time() - _first->time(), prefix, 2)); + pv::util::format_time(second_->time() - first_->time(), prefix, 2)); } // Paint the cursor markers - _first->paint_label(p, rect, prefix); - _second->paint_label(p, rect, prefix); + first_->paint_label(p, rect); + second_->paint_label(p, rect); } void CursorPair::draw_viewport_background(QPainter &p, @@ -126,30 +127,30 @@ void CursorPair::draw_viewport_background(QPainter &p, void CursorPair::draw_viewport_foreground(QPainter &p, const QRect &rect) { - assert(_first); - assert(_second); + assert(first_); + assert(second_); - _first->paint(p, rect); - _second->paint(p, rect); + first_->paint(p, rect); + second_->paint(p, rect); } void CursorPair::compute_text_size(QPainter &p, unsigned int prefix) { - assert(_first); - assert(_second); + assert(first_); + assert(second_); - _text_size = p.boundingRect(QRectF(), 0, pv::util::format_time( - _second->time() - _first->time(), prefix, 2)).size(); + text_size_ = p.boundingRect(QRectF(), 0, pv::util::format_time( + second_->time() - first_->time(), prefix, 2)).size(); } pair CursorPair::get_cursor_offsets() const { - assert(_first); - assert(_second); + assert(first_); + assert(second_); return pair( - (_first->time() - _view.offset()) / _view.scale(), - (_second->time() - _view.offset()) / _view.scale()); + (first_->time() - view_.offset()) / view_.scale(), + (second_->time() - view_.offset()) / view_.scale()); } } // namespace view