]> sigrok.org Git - pulseview.git/blame - pv/view/signal.hpp
Prefer std::make_shared().
[pulseview.git] / pv / view / signal.hpp
CommitLineData
28a4c9c5 1/*
b3f22de0 2 * This file is part of the PulseView project.
28a4c9c5
JH
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
efdec55a 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
28a4c9c5
JH
18 */
19
f4e57597
SA
20#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNAL_HPP
21#define PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNAL_HPP
640d091b 22
f9abf97e 23#include <memory>
9a0cd293 24
9e40e83d 25#include <QComboBox>
9e40e83d 26#include <QWidgetAction>
e3f65ace 27
28a4c9c5
JH
28#include <stdint.h>
29
f1626bb8 30#include "signalscalehandle.hpp"
2acdb232 31#include "trace.hpp"
4b5782e1 32#include "viewitemowner.hpp"
e0e90d80 33
51e77110
JH
34namespace pv {
35
2b81ae46 36class Session;
b86aa8f4 37
1b1ec774 38namespace data {
bf0edd2b 39class SignalBase;
28a4c9c5 40class SignalData;
1b1ec774 41}
28a4c9c5 42
f4e57597
SA
43namespace views {
44namespace TraceView {
a2f71ef0 45
4b5782e1 46class Signal : public Trace, public ViewItemOwner
28a4c9c5 47{
2a2512b2
JH
48 Q_OBJECT
49
28a4c9c5 50protected:
2b81ae46 51 Signal(pv::Session &session,
bf0edd2b 52 std::shared_ptr<data::SignalBase> channel);
28a4c9c5
JH
53
54public:
49f8ff3f
JH
55 /**
56 * Sets the name of the signal.
57 */
bf0edd2b 58 virtual void set_name(QString name);
49f8ff3f 59
f9abf97e 60 virtual std::shared_ptr<pv::data::SignalData> data() const = 0;
9a0cd293 61
b3b57abc 62 /**
931f20b0 63 * Returns true if the trace is visible and enabled.
a29bb7fb 64 */
931f20b0 65 bool enabled() const;
a29bb7fb 66
73a25a6e 67 std::shared_ptr<data::SignalBase> base() const;
632ba77e 68
3a21afa6
SA
69 virtual void save_settings(QSettings &settings) const;
70
71 virtual void restore_settings(QSettings &settings);
72
4b5782e1
JH
73 /**
74 * Returns a list of row items owned by this object.
75 */
76 const item_list& child_items() const;
77
99af6802
SA
78 void paint_back(QPainter &p, const ViewItemPaintParams &pp);
79
0c0218fd
JH
80 virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
81
86e823ca
JH
82 QMenu* create_context_menu(QWidget *parent);
83
5ed1adf5
JH
84 void delete_pressed();
85
214470fc
JH
86 /**
87 * Returns the offset to show the drag handle.
88 */
89 virtual int scale_handle_offset() const = 0;
90
91 /**
92 * Handles the scale handle being dragged to an offset.
93 * @param offset the offset the scale handle was dragged to.
94 */
95 virtual void scale_handle_dragged(int offset) = 0;
96
97 /**
98 * Handles the scale handle being being released.
99 */
100 virtual void scale_handle_released() {};
101
bf0edd2b
SA
102protected Q_SLOTS:
103 virtual void on_name_changed(const QString &text);
104
86e823ca
JH
105 void on_disable();
106
a45b9b9e
SA
107 void on_enabled_changed(bool enabled);
108
28a4c9c5 109protected:
2b81ae46 110 pv::Session &session_;
cec48d16 111
f1626bb8 112 const std::shared_ptr<SignalScaleHandle> scale_handle_;
4b5782e1
JH
113 const item_list items_;
114
8dbbc7f0 115 QComboBox *name_widget_;
28a4c9c5 116};
51e77110 117
f4e57597
SA
118} // namespace TraceView
119} // namespace views
51e77110 120} // namespace pv
640d091b 121
f4e57597 122#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNAL_HPP