]> sigrok.org Git - pulseview.git/blob - pv/data/signalbase.hpp
Move signal data to SignalBase and adjust view::AnalogSignal
[pulseview.git] / pv / data / signalbase.hpp
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 Logic;
42 class SignalData;
43
44 class SignalBase : public QObject
45 {
46         Q_OBJECT
47
48 private:
49         static const int ColourBGAlpha;
50
51 public:
52         SignalBase(std::shared_ptr<sigrok::Channel> channel);
53         virtual ~SignalBase() {}
54
55 public:
56         /**
57          * Returns the underlying SR channel.
58          */
59         std::shared_ptr<sigrok::Channel> channel() const;
60
61         /**
62          * Returns enabled status of this channel.
63          */
64         bool enabled() const;
65
66         /**
67          * Sets the enabled status of this channel.
68          * @param value Boolean value to set.
69          */
70         void set_enabled(bool value);
71
72         /**
73          * Gets the type of this channel.
74          */
75         const sigrok::ChannelType *type() const;
76
77         /**
78          * Gets the index number of this channel.
79          */
80         unsigned int index() const;
81
82         /**
83          * Gets the name of this signal.
84          */
85         QString name() const;
86
87         /**
88          * Sets the name of the signal.
89          */
90         virtual void set_name(QString name);
91
92         /**
93          * Get the colour of the signal.
94          */
95         QColor colour() const;
96
97         /**
98          * Set the colour of the signal.
99          */
100         void set_colour(QColor colour);
101
102         /**
103          * Get the background colour of the signal.
104          */
105         QColor bgcolour() const;
106
107         /**
108          * Sets the internal data object.
109          */
110         void set_data(std::shared_ptr<pv::data::SignalData> data);
111
112         /**
113          * Get the internal data as analog data object in case of analog type.
114          */
115         std::shared_ptr<pv::data::Analog> analog_data() const;
116
117         /**
118          * Get the internal data as logic data object in case of logic type.
119          */
120         std::shared_ptr<pv::data::Logic> logic_data() const;
121
122
123 Q_SIGNALS:
124         void enabled_changed(const bool &value);
125
126         void name_changed(const QString &name);
127
128         void colour_changed(const QColor &colour);
129
130 private:
131         std::shared_ptr<sigrok::Channel> channel_;
132         std::shared_ptr<pv::data::SignalData> data_;
133
134         QString name_;
135         QColor colour_, bgcolour_;
136 };
137
138 } // namespace data
139 } // namespace pv
140
141 #endif // PULSEVIEW_PV_DATA_SIGNALBASE_HPP