]> sigrok.org Git - pulseview.git/blame - pv/view/decodetrace.h
Removed SigSession from Trace
[pulseview.git] / pv / view / decodetrace.h
CommitLineData
55d3603d
JH
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
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.
10 *
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.
15 *
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
19 */
20
b9329558
JH
21#ifndef PULSEVIEW_PV_VIEW_DECODETRACE_H
22#define PULSEVIEW_PV_VIEW_DECODETRACE_H
55d3603d
JH
23
24#include "trace.h"
25
7491a29f 26#include <list>
4e5a4405
JH
27#include <map>
28
613d097c
JH
29#include <QSignalMapper>
30
55d3603d
JH
31#include <boost/shared_ptr.hpp>
32
4e5a4405
JH
33#include <pv/prop/binding/decoderoptions.h>
34
35struct srd_probe;
e563a7c0 36struct srd_decoder;
4e5a4405
JH
37
38class QComboBox;
39
55d3603d 40namespace pv {
119aff65 41
83c23cc9
JH
42class SigSession;
43
119aff65 44namespace data {
6e89374a 45class DecoderStack;
7491a29f
JH
46
47namespace decode {
06e810f2 48class Annotation;
7491a29f 49class Decoder;
287d607f 50class Row;
7491a29f 51}
119aff65
JH
52}
53
dd048a7e
JH
54namespace widgets {
55class DecoderGroupBox;
56}
57
55d3603d
JH
58namespace view {
59
b9329558 60class DecodeTrace : public Trace
55d3603d 61{
e0fc5810
JH
62 Q_OBJECT
63
7491a29f
JH
64private:
65 struct ProbeSelector
66 {
67 const QComboBox *_combo;
68 const boost::shared_ptr<pv::data::decode::Decoder> _decoder;
69 const srd_probe *_probe;
70 };
71
06bb4e6a
JH
72private:
73 static const QColor DecodeColours[4];
ad50ac1a 74 static const QColor ErrorBgColour;
5dfeb70f 75 static const QColor NoDecodeColour;
06bb4e6a 76
06e810f2
JH
77 static const double EndCapWidth;
78 static const int DrawPadding;
79
287d607f
JH
80 static const QColor Colours[16];
81 static const QColor OutlineColours[16];
06e810f2 82
55d3603d 83public:
b9329558 84 DecodeTrace(pv::SigSession &session,
6e89374a
JH
85 boost::shared_ptr<pv::data::DecoderStack> decoder_stack,
86 int index);
55d3603d
JH
87
88 bool enabled() const;
89
6e89374a 90 const boost::shared_ptr<pv::data::DecoderStack>& decoder() const;
b6b267bb 91
e0fc5810
JH
92 void set_view(pv::view::View *view);
93
55d3603d 94 /**
fe08b6e8
JH
95 * Paints the background 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.
99 **/
100 void paint_back(QPainter &p, int left, int right);
101
102 /**
103 * Paints the mid-layer of the trace with a QPainter
55d3603d 104 * @param p the QPainter to paint into.
55d3603d
JH
105 * @param left the x-coordinate of the left edge of the signal
106 * @param right the x-coordinate of the right edge of the signal
55d3603d 107 **/
fe08b6e8 108 void paint_mid(QPainter &p, int left, int right);
55d3603d 109
4e5a4405
JH
110 void populate_popup_form(QWidget *parent, QFormLayout *form);
111
c51482b3
JH
112 QMenu* create_context_menu(QWidget *parent);
113
5ed1adf5
JH
114 void delete_pressed();
115
ad50ac1a 116private:
06e810f2
JH
117 void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p,
118 QColor text_colour, int text_height, int left, int right,
bf51365c 119 double samples_per_pixel, double pixels_offset, int y,
287d607f 120 size_t base_colour) const;
06e810f2
JH
121
122 void draw_instant(const pv::data::decode::Annotation &a, QPainter &p,
123 QColor fill, QColor outline, QColor text_color, int h, double x,
124 int y) const;
125
126 void draw_range(const pv::data::decode::Annotation &a, QPainter &p,
127 QColor fill, QColor outline, QColor text_color, int h, double start,
128 double end, int y) const;
129
ad50ac1a
JH
130 void draw_error(QPainter &p, const QString &message,
131 int left, int right);
132
5dfeb70f
JH
133 void draw_unresolved_period(QPainter &p, int h, int left,
134 int right, double samples_per_pixel, double pixels_offset);
135
613d097c 136 void create_decoder_form(int index,
7491a29f
JH
137 boost::shared_ptr<pv::data::decode::Decoder> &dec,
138 QWidget *parent, QFormLayout *form);
139
140 QComboBox* create_probe_selector(QWidget *parent,
141 const boost::shared_ptr<pv::data::decode::Decoder> &dec,
142 const srd_probe *const probe);
143
144 void commit_decoder_probes(
145 boost::shared_ptr<data::decode::Decoder> &dec);
4e5a4405
JH
146
147 void commit_probes();
148
9cef9567
JH
149private slots:
150 void on_new_decode_data();
151
c51482b3
JH
152 void on_delete();
153
4e5a4405
JH
154 void on_probe_selected(int);
155
7491a29f
JH
156 void on_stack_decoder(srd_decoder *decoder);
157
613d097c
JH
158 void on_delete_decoder(int index);
159
dd048a7e
JH
160 void on_show_hide_decoder(int index);
161
55d3603d 162private:
83c23cc9 163 pv::SigSession &_session;
6e89374a 164 boost::shared_ptr<pv::data::DecoderStack> _decoder_stack;
e0fc5810
JH
165
166 uint64_t _decode_start, _decode_end;
4e5a4405 167
7491a29f
JH
168 std::list< boost::shared_ptr<pv::prop::binding::DecoderOptions> >
169 _bindings;
4e5a4405 170
7491a29f 171 std::list<ProbeSelector> _probe_selectors;
dd048a7e 172 std::vector<pv::widgets::DecoderGroupBox*> _decoder_forms;
613d097c 173
dd048a7e 174 QSignalMapper _delete_mapper, _show_hide_mapper;
55d3603d
JH
175};
176
177} // namespace view
178} // namespace pv
179
b9329558 180#endif // PULSEVIEW_PV_VIEW_DECODETRACE_H