QtPdWidgets  2.3.1
Tank.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2009 - 2019 Florian Pose <fp@igh.de>
4  *
5  * This file is part of the QtPdWidgets library.
6  *
7  * The QtPdWidgets library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of the License,
10  * or (at your option) any later version.
11  *
12  * The QtPdWidgets library 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 GNU Lesser
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with the QtPdWidgets Library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  *
21  ****************************************************************************/
22 
23 #ifndef PD_TANK_H
24 #define PD_TANK_H
25 
26 #include <QtPdCom1/Transmission.h>
27 
28 #include <pdcom5/Variable.h>
29 #include <pdcom5/Subscription.h>
30 
31 #include <QFrame>
32 
33 #include "Export.h"
34 #include <memory>
35 
36 namespace Pd {
37 
38 class Tank;
39 
40 /****************************************************************************/
41 
43 {
44  friend class Tank;
45 
46  public:
47  TankMedium(Tank *);
48  ~TankMedium();
49 
52  void setLevelVariable(
53  PdCom::Variable pv,
54  const PdCom::Selector &selector = {},
55  const QtPdCom::Transmission & = QtPdCom::event_mode,
56  double scale = 1.0,
57  double offset = 0.0,
58  double tau = 0.0
61  );
62 
65  void setLevelVariable(
66  PdCom::Process *process,
67  const QString &path,
68  const PdCom::Selector &selector = {},
69  const QtPdCom::Transmission & = QtPdCom::event_mode,
70  double scale = 1.0,
71  double offset = 0.0,
72  double tau = 0.0
75  );
76 
79  void setVolumeVariable(
80  PdCom::Variable pv,
81  const PdCom::Selector &selector = {},
82  const QtPdCom::Transmission & = QtPdCom::event_mode,
83  double scale = 1.0,
84  double offset = 0.0,
85  double tau = 0.0
88  );
89 
92  void setVolumeVariable(
93  PdCom::Process *process,
94  const QString &path,
95  const PdCom::Selector &selector = {},
96  const QtPdCom::Transmission & = QtPdCom::event_mode,
97  double scale = 1.0,
98  double offset = 0.0,
99  double tau = 0.0
102  );
103 
104  void clearLevelVariable();
105  void clearVolumeVariable();
106 
107  QColor getColor() const;
108  void setColor(QColor);
109 
110  private:
111  struct PD_PRIVATE Impl;
112  std::unique_ptr<Impl> impl;
113 };
114 
115 /****************************************************************************/
116 
117 class Q_DECL_EXPORT Tank:
118  public QFrame
119 {
120  friend class TankMedium;
121 
122  Q_OBJECT
123  Q_ENUMS(LabelPosition Style)
124  Q_PROPERTY(Style style
125  READ getStyle WRITE setStyle RESET resetStyle)
126  Q_PROPERTY(int labelWidth
127  READ getLabelWidth WRITE setLabelWidth RESET resetLabelWidth)
128  Q_PROPERTY(LabelPosition labelPosition
129  READ getLabelPosition WRITE setLabelPosition
130  RESET resetLabelPosition)
131  Q_PROPERTY(int capHeight
132  READ getCapHeight WRITE setCapHeight RESET resetCapHeight)
133  Q_PROPERTY(double maxLevel
134  READ getMaxLevel WRITE setMaxLevel RESET resetMaxLevel)
135  Q_PROPERTY(double maxVolume
136  READ getMaxVolume WRITE setMaxVolume RESET resetMaxVolume)
137  Q_PROPERTY(int levelDecimals READ getLevelDecimals WRITE setLevelDecimals
138  RESET resetLevelDecimals)
139  Q_PROPERTY(int volumeDecimals READ getVolumeDecimals
140  WRITE setVolumeDecimals RESET resetVolumeDecimals)
141  Q_PROPERTY(QColor backgroundColor READ getBackgroundColor
142  WRITE setBackgroundColor RESET resetBackgroundColor)
143  Q_PROPERTY(QString levelSuffix READ getLevelSuffix
144  WRITE setLevelSuffix RESET resetLevelSuffix)
145  Q_PROPERTY(QString volumeSuffix READ getVolumeSuffix
146  WRITE setVolumeSuffix RESET resetVolumeSuffix)
147 
148  public:
149  Tank(QWidget * = 0);
150  virtual ~Tank();
151 
152  QSize sizeHint() const;
153 
154  enum Style {
157  Cuboid
158  };
159  Style getStyle() const;
160  void setStyle(Style);
161  void resetStyle();
162 
163  int getLabelWidth() const;
164  void setLabelWidth(int);
165  void resetLabelWidth();
166 
169  Left
170  };
171  LabelPosition getLabelPosition() const;
172  void setLabelPosition(LabelPosition);
173  void resetLabelPosition();
174 
175  int getCapHeight() const;
176  void setCapHeight(int);
177  void resetCapHeight();
178 
179  double getMaxLevel() const;
180  void setMaxLevel(double);
181  void resetMaxLevel();
182 
183  double getMaxVolume() const;
184  void setMaxVolume(double);
185  void resetMaxVolume();
186 
187  int getLevelDecimals() const;
188  void setLevelDecimals(int);
189  void resetLevelDecimals();
190 
191  int getVolumeDecimals() const;
192  void setVolumeDecimals(int);
193  void resetVolumeDecimals();
194 
195  QColor getBackgroundColor() const;
196  void setBackgroundColor(QColor);
197  void resetBackgroundColor();
198 
199  QString getLevelSuffix() const;
200  void setLevelSuffix(const QString &);
201  void resetLevelSuffix();
202 
203  QString getVolumeSuffix() const;
204  void setVolumeSuffix(const QString &);
205  void resetVolumeSuffix();
206 
207  TankMedium *addMedium();
208  void clearMedia();
209 
210  private:
211  struct PD_PRIVATE Impl;
212  std::unique_ptr<Impl> impl;
213 
214  PD_PRIVATE bool event(QEvent *) override;
215  PD_PRIVATE void resizeEvent(QResizeEvent *) override;
216  PD_PRIVATE void paintEvent(QPaintEvent *) override;
217 };
218 
219 } // namespace
220 
221 /****************************************************************************/
222 
223 #endif
Style
Definition: Tank.h:154
Definition: Bar.h:36
Definition: Tank.h:156
Definition: Tank.h:42
Definition: Tank.cpp:52
#define PD_PRIVATE
Definition: Export.h:28
LabelPosition
Definition: Tank.h:167
std::unique_ptr< Impl > impl
Definition: Tank.h:212
#define PD_PUBLIC
Definition: Export.h:33
Definition: Tank.h:155
Definition: Tank.h:168
std::unique_ptr< Impl > impl
Definition: Tank.h:112
Definition: Tank.h:117
Definition: Tank.cpp:89