]>
Commit | Line | Data |
---|---|---|
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 | ||
35 | struct srd_probe; | |
e563a7c0 | 36 | struct srd_decoder; |
4e5a4405 JH |
37 | |
38 | class QComboBox; | |
39 | ||
55d3603d | 40 | namespace pv { |
119aff65 JH |
41 | |
42 | namespace data { | |
6e89374a | 43 | class DecoderStack; |
7491a29f JH |
44 | |
45 | namespace decode { | |
06e810f2 | 46 | class Annotation; |
7491a29f JH |
47 | class Decoder; |
48 | } | |
119aff65 JH |
49 | } |
50 | ||
55d3603d JH |
51 | namespace view { |
52 | ||
b9329558 | 53 | class DecodeTrace : public Trace |
55d3603d | 54 | { |
e0fc5810 JH |
55 | Q_OBJECT |
56 | ||
7491a29f JH |
57 | private: |
58 | struct ProbeSelector | |
59 | { | |
60 | const QComboBox *_combo; | |
61 | const boost::shared_ptr<pv::data::decode::Decoder> _decoder; | |
62 | const srd_probe *_probe; | |
63 | }; | |
64 | ||
06bb4e6a JH |
65 | private: |
66 | static const QColor DecodeColours[4]; | |
ad50ac1a | 67 | static const QColor ErrorBgColour; |
5dfeb70f | 68 | static const QColor NoDecodeColour; |
06bb4e6a | 69 | |
06e810f2 JH |
70 | static const double EndCapWidth; |
71 | static const int DrawPadding; | |
72 | ||
73 | static const QColor Colours[7]; | |
74 | ||
55d3603d | 75 | public: |
b9329558 | 76 | DecodeTrace(pv::SigSession &session, |
6e89374a JH |
77 | boost::shared_ptr<pv::data::DecoderStack> decoder_stack, |
78 | int index); | |
55d3603d JH |
79 | |
80 | bool enabled() const; | |
81 | ||
6e89374a | 82 | const boost::shared_ptr<pv::data::DecoderStack>& decoder() const; |
b6b267bb | 83 | |
e0fc5810 JH |
84 | void set_view(pv::view::View *view); |
85 | ||
55d3603d | 86 | /** |
fe08b6e8 JH |
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. | |
91 | **/ | |
92 | void paint_back(QPainter &p, int left, int right); | |
93 | ||
94 | /** | |
95 | * Paints the mid-layer of the trace with a QPainter | |
55d3603d | 96 | * @param p the QPainter to paint into. |
55d3603d JH |
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 | |
55d3603d | 99 | **/ |
fe08b6e8 | 100 | void paint_mid(QPainter &p, int left, int right); |
55d3603d | 101 | |
4e5a4405 JH |
102 | void populate_popup_form(QWidget *parent, QFormLayout *form); |
103 | ||
c51482b3 JH |
104 | QMenu* create_context_menu(QWidget *parent); |
105 | ||
5ed1adf5 JH |
106 | void delete_pressed(); |
107 | ||
ad50ac1a | 108 | private: |
06e810f2 JH |
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) const; | |
112 | ||
113 | void draw_instant(const pv::data::decode::Annotation &a, QPainter &p, | |
114 | QColor fill, QColor outline, QColor text_color, int h, double x, | |
115 | int y) const; | |
116 | ||
117 | void draw_range(const pv::data::decode::Annotation &a, QPainter &p, | |
118 | QColor fill, QColor outline, QColor text_color, int h, double start, | |
119 | double end, int y) const; | |
120 | ||
ad50ac1a JH |
121 | void draw_error(QPainter &p, const QString &message, |
122 | int left, int right); | |
123 | ||
5dfeb70f JH |
124 | void draw_unresolved_period(QPainter &p, int h, int left, |
125 | int right, double samples_per_pixel, double pixels_offset); | |
126 | ||
613d097c | 127 | void create_decoder_form(int index, |
7491a29f JH |
128 | boost::shared_ptr<pv::data::decode::Decoder> &dec, |
129 | QWidget *parent, QFormLayout *form); | |
130 | ||
131 | QComboBox* create_probe_selector(QWidget *parent, | |
132 | const boost::shared_ptr<pv::data::decode::Decoder> &dec, | |
133 | const srd_probe *const probe); | |
134 | ||
135 | void commit_decoder_probes( | |
136 | boost::shared_ptr<data::decode::Decoder> &dec); | |
4e5a4405 JH |
137 | |
138 | void commit_probes(); | |
139 | ||
9cef9567 JH |
140 | private slots: |
141 | void on_new_decode_data(); | |
142 | ||
c51482b3 JH |
143 | void on_delete(); |
144 | ||
4e5a4405 JH |
145 | void on_probe_selected(int); |
146 | ||
7491a29f JH |
147 | void on_stack_decoder(srd_decoder *decoder); |
148 | ||
613d097c JH |
149 | void on_delete_decoder(int index); |
150 | ||
55d3603d | 151 | private: |
6e89374a | 152 | boost::shared_ptr<pv::data::DecoderStack> _decoder_stack; |
e0fc5810 JH |
153 | |
154 | uint64_t _decode_start, _decode_end; | |
4e5a4405 | 155 | |
7491a29f JH |
156 | std::list< boost::shared_ptr<pv::prop::binding::DecoderOptions> > |
157 | _bindings; | |
4e5a4405 | 158 | |
7491a29f | 159 | std::list<ProbeSelector> _probe_selectors; |
613d097c JH |
160 | |
161 | QSignalMapper _delete_mapper; | |
55d3603d JH |
162 | }; |
163 | ||
164 | } // namespace view | |
165 | } // namespace pv | |
166 | ||
b9329558 | 167 | #endif // PULSEVIEW_PV_VIEW_DECODETRACE_H |