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_back(QPainter &p, int left, int right)
65 paint_axis(p, get_y(), left, right);
68 void DecodeSignal::paint_mid(QPainter &p, int left, int right)
70 using namespace pv::view::decode;
73 const int y = get_y();
75 const double scale = _view->scale();
78 double samplerate = _decoder->get_samplerate();
80 // Show sample rate as 1Hz when it is unknown
81 if (samplerate == 0.0)
84 const double pixels_offset = (_view->offset() -
85 _decoder->get_start_time()) / scale;
86 const double samples_per_pixel = samplerate * scale;
89 vector< shared_ptr<Annotation> > annotations(_decoder->annotations());
90 BOOST_FOREACH(shared_ptr<Annotation> a, annotations) {
92 a->paint(p, _colour, _colour.darker(), get_text_colour(),
93 _text_size.height(), left, right, samples_per_pixel,
98 const list<QAction*> DecodeSignal::get_context_bar_actions()
100 list<QAction*> actions;