]>
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 | * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | */ | |
21 | ||
22 | #ifndef PULSEVIEW_PV_DATA_SIGNALBASE_HPP | |
23 | #define PULSEVIEW_PV_DATA_SIGNALBASE_HPP | |
24 | ||
25 | #include <QColor> | |
26 | #include <QObject> | |
27 | #include <QString> | |
28 | ||
29 | #include <libsigrokcxx/libsigrokcxx.hpp> | |
30 | ||
31 | ||
32 | namespace sigrok { | |
33 | class Channel; | |
34 | class ChannelType; | |
35 | } | |
36 | ||
37 | namespace pv { | |
38 | namespace data { | |
39 | ||
40 | class Analog; | |
41 | class DecoderStack; | |
42 | class Logic; | |
43 | class SignalData; | |
44 | ||
45 | class SignalBase : public QObject | |
46 | { | |
47 | Q_OBJECT | |
48 | ||
49 | private: | |
50 | static const int ColourBGAlpha; | |
51 | ||
52 | public: | |
53 | SignalBase(std::shared_ptr<sigrok::Channel> channel); | |
54 | virtual ~SignalBase() {} | |
55 | ||
56 | public: | |
57 | /** | |
58 | * Returns the underlying SR channel. | |
59 | */ | |
60 | std::shared_ptr<sigrok::Channel> channel() const; | |
61 | ||
62 | /** | |
63 | * Returns enabled status of this channel. | |
64 | */ | |
65 | bool enabled() const; | |
66 | ||
67 | /** | |
68 | * Sets the enabled status of this channel. | |
69 | * @param value Boolean value to set. | |
70 | */ | |
71 | void set_enabled(bool value); | |
72 | ||
73 | /** | |
74 | * Gets the type of this channel. | |
75 | */ | |
76 | const sigrok::ChannelType *type() const; | |
77 | ||
78 | /** | |
79 | * Gets the index number of this channel. | |
80 | */ | |
81 | unsigned int index() const; | |
82 | ||
83 | /** | |
84 | * Gets the name of this signal. | |
85 | */ | |
86 | QString name() const; | |
87 | ||
88 | /** | |
89 | * Sets the name of the signal. | |
90 | */ | |
91 | virtual void set_name(QString name); | |
92 | ||
93 | /** | |
94 | * Get the colour of the signal. | |
95 | */ | |
96 | QColor colour() const; | |
97 | ||
98 | /** | |
99 | * Set the colour of the signal. | |
100 | */ | |
101 | void set_colour(QColor colour); | |
102 | ||
103 | /** | |
104 | * Get the background colour of the signal. | |
105 | */ | |
106 | QColor bgcolour() const; | |
107 | ||
108 | /** | |
109 | * Sets the internal data object. | |
110 | */ | |
111 | void set_data(std::shared_ptr<pv::data::SignalData> data); | |
112 | ||
113 | /** | |
114 | * Get the internal data as analog data object in case of analog type. | |
115 | */ | |
116 | std::shared_ptr<pv::data::Analog> analog_data() const; | |
117 | ||
118 | /** | |
119 | * Get the internal data as logic data object in case of logic type. | |
120 | */ | |
121 | std::shared_ptr<pv::data::Logic> logic_data() const; | |
122 | ||
123 | #ifdef ENABLE_DECODE | |
124 | bool is_decode_signal() const; | |
125 | ||
126 | std::shared_ptr<pv::data::DecoderStack> decoder_stack() const; | |
127 | ||
128 | void set_decoder_stack(std::shared_ptr<pv::data::DecoderStack> | |
129 | decoder_stack); | |
130 | #endif | |
131 | ||
132 | Q_SIGNALS: | |
133 | void enabled_changed(const bool &value); | |
134 | ||
135 | void name_changed(const QString &name); | |
136 | ||
137 | void colour_changed(const QColor &colour); | |
138 | ||
139 | private: | |
140 | std::shared_ptr<sigrok::Channel> channel_; | |
141 | std::shared_ptr<pv::data::SignalData> data_; | |
142 | ||
143 | #ifdef ENABLE_DECODE | |
144 | std::shared_ptr<pv::data::DecoderStack> decoder_stack_; | |
145 | #endif | |
146 | ||
147 | QString name_; | |
148 | QColor colour_, bgcolour_; | |
149 | }; | |
150 | ||
151 | } // namespace data | |
152 | } // namespace pv | |
153 | ||
154 | #endif // PULSEVIEW_PV_DATA_SIGNALBASE_HPP |