MathSignal: Add config dialog
[pulseview.git] / pv / views / trace / mathsignal.hpp
blob4b8fcb180e15ddf5a7a9940869596bda8e2e6fda
1 /*
2 * This file is part of the PulseView project.
4 * Copyright (C) 2020 Soeren Apel <soeren@apelpie.net>
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef PULSEVIEW_PV_VIEWS_TRACE_MATHSIGNAL_HPP
21 #define PULSEVIEW_PV_VIEWS_TRACE_MATHSIGNAL_HPP
23 #include <QComboBox>
24 #include <QDialog>
25 #include <QString>
26 #include <QTimer>
28 #include <pv/data/mathsignal.hpp>
29 #include <pv/views/trace/analogsignal.hpp>
31 using std::shared_ptr;
33 namespace pv {
34 namespace views {
35 namespace trace {
37 class MathEditDialog : public QDialog
39 Q_OBJECT
41 public:
42 MathEditDialog(pv::Session &session, shared_ptr<pv::data::MathSignal> math_signal,
43 QWidget *parent = nullptr);
45 private Q_SLOTS:
46 void accept();
47 void reject();
49 private:
50 pv::Session &session_;
51 shared_ptr<pv::data::MathSignal> math_signal_;
52 QString expression_, old_expression_;
56 class MathSignal : public AnalogSignal
58 Q_OBJECT
60 public:
61 MathSignal(pv::Session &session, shared_ptr<data::SignalBase> base);
63 protected:
64 void populate_popup_form(QWidget *parent, QFormLayout *form);
66 shared_ptr<pv::data::MathSignal> math_signal_;
68 private Q_SLOTS:
69 void on_expression_changed(const QString &text);
70 void on_sample_count_changed(const QString &text);
72 void on_edit_clicked();
74 private:
75 QLineEdit *expression_edit_;
76 QComboBox *sample_count_cb_, *sample_rate_cb_;
77 QString sample_count_text_, sample_rate_text_;
78 QTimer delayed_expr_updater_, delayed_count_updater_, delayed_rate_updater_;
81 } // namespace trace
82 } // namespace views
83 } // namespace pv
85 #endif // PULSEVIEW_PV_VIEWS_TRACE_MATHSIGNAL_HPP