From: Joel Holdsworth Date: Sat, 8 Jun 2013 15:55:01 +0000 (+0100) Subject: Added skeleton pv::view::DecodeSignal X-Git-Tag: pulseview-0.2.0~315 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=55d3603d6a81995e613535a18a0949b3c469ac8a Added skeleton pv::view::DecodeSignal --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 58365a10..e7235970 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,6 +127,7 @@ set(pulseview_SOURCES pv/view/analogsignal.cpp pv/view/cursor.cpp pv/view/cursorpair.cpp + pv/view/decodesignal.cpp pv/view/header.cpp pv/view/marginwidget.cpp pv/view/logicsignal.cpp diff --git a/pv/view/decodesignal.cpp b/pv/view/decodesignal.cpp new file mode 100644 index 00000000..3e28d493 --- /dev/null +++ b/pv/view/decodesignal.cpp @@ -0,0 +1,64 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012 Joel Holdsworth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +extern "C" { +#include +} + +#include "decodesignal.h" + +using namespace boost; +using namespace std; + +namespace pv { +namespace view { + +DecodeSignal::DecodeSignal(pv::SigSession &session, srd_decoder *const dec) : + Trace(session, QString(dec->name)), + _decoder(dec) +{ + _colour = Qt::red; +} + +bool DecodeSignal::enabled() const +{ + return true; +} + +void DecodeSignal::paint(QPainter &p, int y, int left, int right, + double scale, double offset) +{ + (void)p; + (void)y; + (void)left; + (void)right; + (void)offset; + + assert(scale > 0); +} + +const list DecodeSignal::get_context_bar_actions() +{ + list actions; + return actions; +} + +} // namespace view +} // namespace pv diff --git a/pv/view/decodesignal.h b/pv/view/decodesignal.h new file mode 100644 index 00000000..7e1410e8 --- /dev/null +++ b/pv/view/decodesignal.h @@ -0,0 +1,68 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012 Joel Holdsworth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef PULSEVIEW_PV_DECODESIGNAL_H +#define PULSEVIEW_PV_DECODESIGNAL_H + +#include "trace.h" + +#include + +namespace pv { +namespace view { + +class DecodeSignal : public Trace +{ +public: + DecodeSignal(pv::SigSession &session, srd_decoder *const dec); + + bool enabled() const; + + /** + * Paints the trace with a QPainter + * @param p the QPainter to paint into. + * @param y the y-coordinate to draw the signal at + * @param left the x-coordinate of the left edge of the signal + * @param right the x-coordinate of the right edge of the signal + * @param scale the scale in seconds per pixel. + * @param offset the time to show at the left hand edge of + * the view in seconds. + **/ + void paint(QPainter &p, int y, int left, int right, + double scale, double offset); + + const std::list get_context_bar_actions(); + +private: + + /** + * When painting into the rectangle, calculate the y + * offset of the zero point. + **/ + int get_nominal_offset(const QRect &rect) const; + +private: + srd_decoder *const _decoder; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_DECODESIGNAL_H