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
21 #ifndef PULSEVIEW_PV_VIEW_DECODETRACE_H
22 #define PULSEVIEW_PV_VIEW_DECODETRACE_H
29 #include <QSignalMapper>
31 #include <boost/shared_ptr.hpp>
33 #include <pv/prop/binding/decoderoptions.h>
53 class DecodeTrace : public Trace
60 const QComboBox *_combo;
61 const boost::shared_ptr<pv::data::decode::Decoder> _decoder;
62 const srd_probe *_probe;
66 static const QColor DecodeColours[4];
67 static const QColor ErrorBgColour;
68 static const QColor NoDecodeColour;
70 static const double EndCapWidth;
71 static const int DrawPadding;
73 static const QColor Colours[7];
76 DecodeTrace(pv::SigSession &session,
77 boost::shared_ptr<pv::data::DecoderStack> decoder_stack,
82 const boost::shared_ptr<pv::data::DecoderStack>& decoder() const;
84 void set_view(pv::view::View *view);
87 * Paints the background layer of the trace with a QPainter
88 * @param p the QPainter to paint into.
89 * @param left the x-coordinate of the left edge of the signal.
90 * @param right the x-coordinate of the right edge of the signal.
92 void paint_back(QPainter &p, int left, int right);
95 * Paints the mid-layer of the trace with a QPainter
96 * @param p the QPainter to paint into.
97 * @param left the x-coordinate of the left edge of the signal
98 * @param right the x-coordinate of the right edge of the signal
100 void paint_mid(QPainter &p, int left, int right);
102 void populate_popup_form(QWidget *parent, QFormLayout *form);
104 QMenu* create_context_menu(QWidget *parent);
106 void delete_pressed();
109 void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p,
110 QColor text_colour, int text_height, int left, int right,
111 double samples_per_pixel, double pixels_offset, int y,
112 unsigned int row_index) const;
114 void draw_instant(const pv::data::decode::Annotation &a, QPainter &p,
115 QColor fill, QColor outline, QColor text_color, int h, double x,
118 void draw_range(const pv::data::decode::Annotation &a, QPainter &p,
119 QColor fill, QColor outline, QColor text_color, int h, double start,
120 double end, int y) const;
122 void draw_error(QPainter &p, const QString &message,
123 int left, int right);
125 void draw_unresolved_period(QPainter &p, int h, int left,
126 int right, double samples_per_pixel, double pixels_offset);
128 void create_decoder_form(int index,
129 boost::shared_ptr<pv::data::decode::Decoder> &dec,
130 QWidget *parent, QFormLayout *form);
132 QComboBox* create_probe_selector(QWidget *parent,
133 const boost::shared_ptr<pv::data::decode::Decoder> &dec,
134 const srd_probe *const probe);
136 void commit_decoder_probes(
137 boost::shared_ptr<data::decode::Decoder> &dec);
139 void commit_probes();
142 void on_new_decode_data();
146 void on_probe_selected(int);
148 void on_stack_decoder(srd_decoder *decoder);
150 void on_delete_decoder(int index);
153 boost::shared_ptr<pv::data::DecoderStack> _decoder_stack;
155 uint64_t _decode_start, _decode_end;
157 std::list< boost::shared_ptr<pv::prop::binding::DecoderOptions> >
160 std::list<ProbeSelector> _probe_selectors;
162 QSignalMapper _delete_mapper;
168 #endif // PULSEVIEW_PV_VIEW_DECODETRACE_H