QtPdWidgets  2.3.1
Parameter.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2023 Daniel Ramirez <dr@igh.de>
4  * 2023 Florian Pose <fp@igh.de>
5  *
6  * This file is part of the QtPdWidgets library.
7  *
8  * The QtPdWidgets library is free software: you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License as
10  * published by the Free Software Foundation, either version 3 of the License,
11  * or (at your option) any later version.
12  *
13  * The QtPdWidgets library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with the QtPdWidgets Library. If not, see
20  * <http://www.gnu.org/licenses/>.
21  *
22  ****************************************************************************/
23 
24 #ifndef PD_PARAMETER_H
25 #define PD_PARAMETER_H
26 
27 #include <pdcom5/Subscriber.h>
28 #include <pdcom5/Subscription.h>
29 #include <pdcom5/Variable.h>
30 
31 #include <QtPdCom1/Process.h>
32 
33 #include <QUrl>
34 #include <QJsonValue>
35 #include <QVariantList>
36 
37 namespace Pd
38 {
39  class ParameterSetWidget;
40 
41  class Parameter:
42  public QObject, public PdCom::Subscriber
43  {
44  Q_OBJECT
45 
46  public:
48  virtual ~Parameter();
49 
50  QUrl getUrl() const { return url; }
51  void setUrl(QUrl newUrl) { url = newUrl; }
52 
53  void fromJson(const QJsonValue &);
54 
55  void replaceUrl(const QUrl &, const QUrl &);
56 
57  PdCom::Subscription *getSubscription() { return &subscription; }
58  PdCom::Variable *getVariable() { return &pv; }
59 
60  bool hasData() const { return dataPresent; }
61  QVector<double> getCurrentValue() const { return currentItems; }
62  bool setCurrentValue(const QVector<double> &);
63 
64  bool hasSavedData() const { return savedDataPresent; }
65  QVector<double> getSavedValue() const { return savedItems; }
66  bool setSavedValue(const QVector<double> &);
67 
68  void connectParameter(QtPdCom::Process *);
69 
70  signals:
71  void dataChanged();
72 
73  private:
75 
76  QUrl url;
77  QString connectionPath;
78  PdCom::Subscription subscription;
79  PdCom::Variable pv;
80  QVector<double> savedItems;
81  QVector<double> currentItems;
82  double scale;
83  double offset;
86 
87  // virtual from PdCom::Subscriber
88  void newValues(std::chrono::nanoseconds) override;
89  void stateChanged(const PdCom::Subscription &) override;
90 
91  Parameter();
92  };
93 
94  /************************************************************************/
95 
96 } // namespace Pd
97 
98 #endif
Quick-selector widget for parameter sets.
Definition: ParameterSetWidget.h:88
double scale
Definition: Parameter.h:82
Definition: Parameter.h:41
Definition: Bar.h:36
Pd::ParameterSetWidget *const widget
Definition: Parameter.h:74
PdCom::Variable pv
Definition: Parameter.h:79
void connectParameter(QtPdCom::Process *)
Definition: Parameter.cpp:141
PdCom::Subscription * getSubscription()
Definition: Parameter.h:57
PdCom::Subscription subscription
Definition: Parameter.h:78
QString connectionPath
Definition: Parameter.h:77
virtual ~Parameter()
Definition: Parameter.cpp:52
void setUrl(QUrl newUrl)
Definition: Parameter.h:51
QUrl getUrl() const
Definition: Parameter.h:50
QUrl url
Definition: Parameter.h:76
QVector< double > savedItems
Definition: Parameter.h:80
QVector< double > currentItems
Definition: Parameter.h:81
void dataChanged()
QVector< double > getSavedValue() const
Definition: Parameter.h:65
bool savedDataPresent
Definition: Parameter.h:85
bool hasData() const
Definition: Parameter.h:60
PdCom::Variable * getVariable()
Definition: Parameter.h:58
void stateChanged(const PdCom::Subscription &) override
Definition: Parameter.cpp:207
bool setSavedValue(const QVector< double > &)
bool setCurrentValue(const QVector< double > &)
Definition: Parameter.cpp:167
void fromJson(const QJsonValue &)
Definition: Parameter.cpp:57
bool dataPresent
Definition: Parameter.h:84
double offset
Definition: Parameter.h:83
void replaceUrl(const QUrl &, const QUrl &)
Definition: Parameter.cpp:126
bool hasSavedData() const
Definition: Parameter.h:64
QVector< double > getCurrentValue() const
Definition: Parameter.h:61
void newValues(std::chrono::nanoseconds) override
Definition: Parameter.cpp:188