2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net>
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.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #ifndef PULSEVIEW_PV_DATA_SIGNALBASE_HPP
22 #define PULSEVIEW_PV_DATA_SIGNALBASE_HPP
29 #include <libsigrokcxx/libsigrokcxx.hpp>
31 using std::shared_ptr;
45 class SignalBase : public QObject
54 A2LChannel, // Analog converted to logic, joint representation
59 static const int ColourBGAlpha;
62 SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type);
63 virtual ~SignalBase() {}
67 * Returns the underlying SR channel.
69 shared_ptr<sigrok::Channel> channel() const;
72 * Returns enabled status of this channel.
77 * Sets the enabled status of this channel.
78 * @param value Boolean value to set.
80 void set_enabled(bool value);
83 * Gets the type of this channel.
85 ChannelType type() const;
88 * Gets the index number of this channel.
90 unsigned int index() const;
93 * Gets the name of this signal.
98 * Gets the internal name of this signal, i.e. how the device calls it.
100 QString internal_name() const;
103 * Sets the name of the signal.
105 virtual void set_name(QString name);
108 * Get the colour of the signal.
110 QColor colour() const;
113 * Set the colour of the signal.
115 void set_colour(QColor colour);
118 * Get the background colour of the signal.
120 QColor bgcolour() const;
123 * Sets the internal data object.
125 void set_data(shared_ptr<pv::data::SignalData> data);
128 * Get the internal data as analog data object in case of analog type.
130 shared_ptr<pv::data::Analog> analog_data() const;
133 * Get the internal data as logic data object in case of logic type.
135 shared_ptr<pv::data::Logic> logic_data() const;
138 bool is_decode_signal() const;
140 shared_ptr<pv::data::DecoderStack> decoder_stack() const;
142 void set_decoder_stack(shared_ptr<pv::data::DecoderStack> decoder_stack);
145 void save_settings(QSettings &settings) const;
147 void restore_settings(QSettings &settings);
150 void enabled_changed(const bool &value);
152 void name_changed(const QString &name);
154 void colour_changed(const QColor &colour);
157 shared_ptr<sigrok::Channel> channel_;
158 ChannelType channel_type_;
159 shared_ptr<pv::data::SignalData> data_;
162 shared_ptr<pv::data::DecoderStack> decoder_stack_;
165 QString internal_name_, name_;
166 QColor colour_, bgcolour_;
172 #endif // PULSEVIEW_PV_DATA_SIGNALBASE_HPP