X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fanalogsignal.cpp;h=a8d7b3e8113d6c514e9955fc9c897a65175977a3;hb=be9e7b4bb29b6594ec2b64442748ab135b684bf8;hp=7b49bbd2b7d454606d2ac5d51e482a331ca1b01c;hpb=e8d009288de28cb194bc7964f96677c2baf900c9;p=pulseview.git diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 7b49bbd..a8d7b3e 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -31,6 +31,7 @@ #include using std::max; +using std::make_pair; using std::min; using std::shared_ptr; using std::deque; @@ -40,6 +41,8 @@ using sigrok::Channel; namespace pv { namespace view { +const int AnalogSignal::NominalHeight = 80; + const QColor AnalogSignal::SignalColours[4] = { QColor(0xC4, 0xA0, 0x00), // Yellow QColor(0x87, 0x20, 0x7A), // Magenta @@ -49,9 +52,11 @@ const QColor AnalogSignal::SignalColours[4] = { const float AnalogSignal::EnvelopeThreshold = 256.0f; -AnalogSignal::AnalogSignal(shared_ptr channel, +AnalogSignal::AnalogSignal( + pv::SigSession &session, + shared_ptr channel, shared_ptr data) : - Signal(channel), + Signal(session, channel), _data(data), _scale(1.0f) { @@ -77,24 +82,32 @@ void AnalogSignal::set_scale(float scale) _scale = scale; } +std::pair AnalogSignal::v_extents() const +{ + return make_pair(-NominalHeight / 2, NominalHeight / 2); +} + void AnalogSignal::paint_back(QPainter &p, int left, int right) { if (_channel->enabled()) - paint_axis(p, get_y(), left, right); + paint_axis(p, get_visual_y(), left, right); } void AnalogSignal::paint_mid(QPainter &p, int left, int right) { assert(_data); assert(right >= left); + assert(_owner); + + const int y = get_visual_y(); - assert(_view); - const int y = _v_offset - _view->v_offset(); + const View *const view = _owner->view(); + assert(view); - const double scale = _view->scale(); + const double scale = view->scale(); assert(scale > 0); - const double offset = _view->offset(); + const double offset = view->offset(); if (!_channel->enabled()) return;