2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <libsigrokdecode/libsigrokdecode.h>
25 #include "decodesignal.h"
27 #include <pv/data/decoder.h>
28 #include <pv/view/view.h>
29 #include <pv/view/decode/annotation.h>
31 using namespace boost;
37 DecodeSignal::DecodeSignal(pv::SigSession &session,
38 boost::shared_ptr<pv::data::Decoder> decoder) :
39 Trace(session, QString(decoder->get_decoder()->name)),
47 void DecodeSignal::init_context_bar_actions(QWidget *parent)
52 bool DecodeSignal::enabled() const
57 void DecodeSignal::set_view(pv::view::View *view)
60 Trace::set_view(view);
63 void DecodeSignal::paint(QPainter &p, int left, int right)
65 using namespace pv::view::decode;
68 const int y = _v_offset - _view->v_offset();
70 const double scale = _view->scale();
73 double samplerate = _decoder->get_samplerate();
75 // Show sample rate as 1Hz when it is unknown
76 if (samplerate == 0.0)
79 const double pixels_offset = (_view->offset() -
80 _decoder->get_start_time()) / scale;
81 const double samples_per_pixel = samplerate * scale;
84 vector< shared_ptr<Annotation> > annotations(_decoder->annotations());
85 BOOST_FOREACH(shared_ptr<Annotation> a, annotations) {
87 a->paint(p, left, right, samples_per_pixel, pixels_offset, y);
91 const list<QAction*> DecodeSignal::get_context_bar_actions()
93 list<QAction*> actions;