]>
Commit | Line | Data |
---|---|---|
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 | ||
21 | #ifndef PULSEVIEW_PV_VIEW_DECODETRACE_H | |
22 | #define PULSEVIEW_PV_VIEW_DECODETRACE_H | |
23 | ||
24 | #include "trace.h" | |
25 | ||
26 | #include <list> | |
27 | #include <map> | |
28 | ||
29 | #include <QSignalMapper> | |
30 | ||
31 | #include <boost/shared_ptr.hpp> | |
32 | ||
33 | #include <pv/prop/binding/decoderoptions.h> | |
34 | ||
35 | struct srd_probe; | |
36 | struct srd_decoder; | |
37 | ||
38 | class QComboBox; | |
39 | ||
40 | namespace pv { | |
41 | ||
42 | namespace data { | |
43 | class DecoderStack; | |
44 | ||
45 | namespace decode { | |
46 | class Annotation; | |
47 | class Decoder; | |
48 | } | |
49 | } | |
50 | ||
51 | namespace widgets { | |
52 | class DecoderGroupBox; | |
53 | } | |
54 | ||
55 | namespace view { | |
56 | ||
57 | class DecodeTrace : public Trace | |
58 | { | |
59 | Q_OBJECT | |
60 | ||
61 | private: | |
62 | struct ProbeSelector | |
63 | { | |
64 | const QComboBox *_combo; | |
65 | const boost::shared_ptr<pv::data::decode::Decoder> _decoder; | |
66 | const srd_probe *_probe; | |
67 | }; | |
68 | ||
69 | private: | |
70 | static const QColor DecodeColours[4]; | |
71 | static const QColor ErrorBgColour; | |
72 | static const QColor NoDecodeColour; | |
73 | ||
74 | static const double EndCapWidth; | |
75 | static const int DrawPadding; | |
76 | ||
77 | static const QColor Colours[7]; | |
78 | ||
79 | public: | |
80 | DecodeTrace(pv::SigSession &session, | |
81 | boost::shared_ptr<pv::data::DecoderStack> decoder_stack, | |
82 | int index); | |
83 | ||
84 | bool enabled() const; | |
85 | ||
86 | const boost::shared_ptr<pv::data::DecoderStack>& decoder() const; | |
87 | ||
88 | void set_view(pv::view::View *view); | |
89 | ||
90 | /** | |
91 | * Paints the background layer of the trace with a QPainter | |
92 | * @param p the QPainter to paint into. | |
93 | * @param left the x-coordinate of the left edge of the signal. | |
94 | * @param right the x-coordinate of the right edge of the signal. | |
95 | **/ | |
96 | void paint_back(QPainter &p, int left, int right); | |
97 | ||
98 | /** | |
99 | * Paints the mid-layer of the trace with a QPainter | |
100 | * @param p the QPainter to paint into. | |
101 | * @param left the x-coordinate of the left edge of the signal | |
102 | * @param right the x-coordinate of the right edge of the signal | |
103 | **/ | |
104 | void paint_mid(QPainter &p, int left, int right); | |
105 | ||
106 | void populate_popup_form(QWidget *parent, QFormLayout *form); | |
107 | ||
108 | QMenu* create_context_menu(QWidget *parent); | |
109 | ||
110 | void delete_pressed(); | |
111 | ||
112 | private: | |
113 | void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p, | |
114 | QColor text_colour, int text_height, int left, int right, | |
115 | double samples_per_pixel, double pixels_offset, int y, | |
116 | unsigned int row_index) const; | |
117 | ||
118 | void draw_instant(const pv::data::decode::Annotation &a, QPainter &p, | |
119 | QColor fill, QColor outline, QColor text_color, int h, double x, | |
120 | int y) const; | |
121 | ||
122 | void draw_range(const pv::data::decode::Annotation &a, QPainter &p, | |
123 | QColor fill, QColor outline, QColor text_color, int h, double start, | |
124 | double end, int y) const; | |
125 | ||
126 | void draw_error(QPainter &p, const QString &message, | |
127 | int left, int right); | |
128 | ||
129 | void draw_unresolved_period(QPainter &p, int h, int left, | |
130 | int right, double samples_per_pixel, double pixels_offset); | |
131 | ||
132 | void create_decoder_form(int index, | |
133 | boost::shared_ptr<pv::data::decode::Decoder> &dec, | |
134 | QWidget *parent, QFormLayout *form); | |
135 | ||
136 | QComboBox* create_probe_selector(QWidget *parent, | |
137 | const boost::shared_ptr<pv::data::decode::Decoder> &dec, | |
138 | const srd_probe *const probe); | |
139 | ||
140 | void commit_decoder_probes( | |
141 | boost::shared_ptr<data::decode::Decoder> &dec); | |
142 | ||
143 | void commit_probes(); | |
144 | ||
145 | private slots: | |
146 | void on_new_decode_data(); | |
147 | ||
148 | void on_delete(); | |
149 | ||
150 | void on_probe_selected(int); | |
151 | ||
152 | void on_stack_decoder(srd_decoder *decoder); | |
153 | ||
154 | void on_delete_decoder(int index); | |
155 | ||
156 | void on_show_hide_decoder(int index); | |
157 | ||
158 | private: | |
159 | boost::shared_ptr<pv::data::DecoderStack> _decoder_stack; | |
160 | ||
161 | uint64_t _decode_start, _decode_end; | |
162 | ||
163 | std::list< boost::shared_ptr<pv::prop::binding::DecoderOptions> > | |
164 | _bindings; | |
165 | ||
166 | std::list<ProbeSelector> _probe_selectors; | |
167 | std::vector<pv::widgets::DecoderGroupBox*> _decoder_forms; | |
168 | ||
169 | QSignalMapper _delete_mapper, _show_hide_mapper; | |
170 | }; | |
171 | ||
172 | } // namespace view | |
173 | } // namespace pv | |
174 | ||
175 | #endif // PULSEVIEW_PV_VIEW_DECODETRACE_H |