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;
46 class SignalBase : public QObject
51 static const int ColourBGAlpha;
54 SignalBase(shared_ptr<sigrok::Channel> channel);
55 virtual ~SignalBase() {}
59 * Returns the underlying SR channel.
61 shared_ptr<sigrok::Channel> channel() const;
64 * Returns enabled status of this channel.
69 * Sets the enabled status of this channel.
70 * @param value Boolean value to set.
72 void set_enabled(bool value);
75 * Gets the type of this channel.
77 const sigrok::ChannelType *type() const;
80 * Gets the index number of this channel.
82 unsigned int index() const;
85 * Gets the name of this signal.
90 * Gets the internal name of this signal, i.e. how the device calls it.
92 QString internal_name() const;
95 * Sets the name of the signal.
97 virtual void set_name(QString name);
100 * Get the colour of the signal.
102 QColor colour() const;
105 * Set the colour of the signal.
107 void set_colour(QColor colour);
110 * Get the background colour of the signal.
112 QColor bgcolour() const;
115 * Sets the internal data object.
117 void set_data(shared_ptr<pv::data::SignalData> data);
120 * Get the internal data as analog data object in case of analog type.
122 shared_ptr<pv::data::Analog> analog_data() const;
125 * Get the internal data as logic data object in case of logic type.
127 shared_ptr<pv::data::Logic> logic_data() const;
130 bool is_decode_signal() const;
132 shared_ptr<pv::data::DecoderStack> decoder_stack() const;
134 void set_decoder_stack(shared_ptr<pv::data::DecoderStack> decoder_stack);
137 void save_settings(QSettings &settings) const;
139 void restore_settings(QSettings &settings);
142 void enabled_changed(const bool &value);
144 void name_changed(const QString &name);
146 void colour_changed(const QColor &colour);
149 shared_ptr<sigrok::Channel> channel_;
150 shared_ptr<pv::data::SignalData> data_;
153 shared_ptr<pv::data::DecoderStack> decoder_stack_;
156 QString internal_name_, name_;
157 QColor colour_, bgcolour_;
163 #endif // PULSEVIEW_PV_DATA_SIGNALBASE_HPP