]> sigrok.org Git - pulseview.git/blame - pv/view/decodetrace.h
Added show/hide decoder button
[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
JH
41
42namespace data {
6e89374a 43class DecoderStack;
7491a29f
JH
44
45namespace decode {
06e810f2 46class Annotation;
7491a29f
JH
47class Decoder;
48}
119aff65
JH
49}
50
dd048a7e
JH
51namespace widgets {
52class DecoderGroupBox;
53}
54
55d3603d
JH
55namespace view {
56
b9329558 57class DecodeTrace : public Trace
55d3603d 58{
e0fc5810
JH
59 Q_OBJECT
60
7491a29f
JH
61private:
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
06bb4e6a
JH
69private:
70 static const QColor DecodeColours[4];
ad50ac1a 71 static const QColor ErrorBgColour;
5dfeb70f 72 static const QColor NoDecodeColour;
06bb4e6a 73
06e810f2
JH
74 static const double EndCapWidth;
75 static const int DrawPadding;
76
77 static const QColor Colours[7];
78
55d3603d 79public:
b9329558 80 DecodeTrace(pv::SigSession &session,
6e89374a
JH
81 boost::shared_ptr<pv::data::DecoderStack> decoder_stack,
82 int index);
55d3603d
JH
83
84 bool enabled() const;
85
6e89374a 86 const boost::shared_ptr<pv::data::DecoderStack>& decoder() const;
b6b267bb 87
e0fc5810
JH
88 void set_view(pv::view::View *view);
89
55d3603d 90 /**
fe08b6e8
JH
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
55d3603d 100 * @param p the QPainter to paint into.
55d3603d
JH
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
55d3603d 103 **/
fe08b6e8 104 void paint_mid(QPainter &p, int left, int right);
55d3603d 105
4e5a4405
JH
106 void populate_popup_form(QWidget *parent, QFormLayout *form);
107
c51482b3
JH
108 QMenu* create_context_menu(QWidget *parent);
109
5ed1adf5
JH
110 void delete_pressed();
111
ad50ac1a 112private:
06e810f2
JH
113 void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p,
114 QColor text_colour, int text_height, int left, int right,
bf51365c
JH
115 double samples_per_pixel, double pixels_offset, int y,
116 unsigned int row_index) const;
06e810f2
JH
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
ad50ac1a
JH
126 void draw_error(QPainter &p, const QString &message,
127 int left, int right);
128
5dfeb70f
JH
129 void draw_unresolved_period(QPainter &p, int h, int left,
130 int right, double samples_per_pixel, double pixels_offset);
131
613d097c 132 void create_decoder_form(int index,
7491a29f
JH
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);
4e5a4405
JH
142
143 void commit_probes();
144
9cef9567
JH
145private slots:
146 void on_new_decode_data();
147
c51482b3
JH
148 void on_delete();
149
4e5a4405
JH
150 void on_probe_selected(int);
151
7491a29f
JH
152 void on_stack_decoder(srd_decoder *decoder);
153
613d097c
JH
154 void on_delete_decoder(int index);
155
dd048a7e
JH
156 void on_show_hide_decoder(int index);
157
55d3603d 158private:
6e89374a 159 boost::shared_ptr<pv::data::DecoderStack> _decoder_stack;
e0fc5810
JH
160
161 uint64_t _decode_start, _decode_end;
4e5a4405 162
7491a29f
JH
163 std::list< boost::shared_ptr<pv::prop::binding::DecoderOptions> >
164 _bindings;
4e5a4405 165
7491a29f 166 std::list<ProbeSelector> _probe_selectors;
dd048a7e 167 std::vector<pv::widgets::DecoderGroupBox*> _decoder_forms;
613d097c 168
dd048a7e 169 QSignalMapper _delete_mapper, _show_hide_mapper;
55d3603d
JH
170};
171
172} // namespace view
173} // namespace pv
174
b9329558 175#endif // PULSEVIEW_PV_VIEW_DECODETRACE_H