QtPdWidgets  2.3.1
Bar.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2012 Florian Pose <fp@igh-essen.com>
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_BAR_H
24 #define PD_BAR_H
25 
26 #include <QWidget>
27 #include <QPixmap>
28 
29 #include "Export.h"
30 
31 #include <QtPdCom1/ScalarSubscriber.h>
32 #include <QtPdCom1/Transmission.h>
33 
34 #include <QScopedPointer>
35 
36 namespace Pd {
37 
38 class BarPrivate;
39 
40 /****************************************************************************/
41 
44 class PD_PUBLIC Bar: public QWidget
45 {
46  Q_OBJECT
47  Q_ENUMS(Orientation Style Origin)
48  Q_PROPERTY(Orientation orientation
49  READ getOrientation WRITE setOrientation RESET resetOrientation)
50  Q_PROPERTY(Style style
51  READ getStyle WRITE setStyle RESET resetStyle)
53  Q_PROPERTY(bool showScale
54  READ getShowScale WRITE setShowScale RESET resetShowScale)
56  Q_PROPERTY(double scaleMin
57  READ getScaleMin WRITE setScaleMin RESET resetScaleMin)
59  Q_PROPERTY(double scaleMax
60  READ getScaleMax WRITE setScaleMax RESET resetScaleMax)
61  Q_PROPERTY(Origin origin
62  READ getOrigin WRITE setOrigin RESET resetOrigin)
63  Q_PROPERTY(int borderWidth
64  READ getBorderWidth WRITE setBorderWidth RESET resetBorderWidth)
65  Q_PROPERTY(QColor backgroundColor
66  READ getBackgroundColor WRITE setBackgroundColor
67  RESET resetBackgroundColor)
68  Q_PROPERTY(bool autoBarWidth
69  READ getAutoBarWidth WRITE setAutoBarWidth
70  RESET resetAutoBarWidth)
71 
72  public:
73  Bar(QWidget *parent = 0);
74  virtual ~Bar();
75 
77  enum Orientation {
79  Horizontal
80  };
81  Orientation getOrientation() const;
82  void setOrientation(Orientation);
83  void resetOrientation();
84 
86  enum Style {
89  MultiColorBar
90  };
91  Style getStyle() const;
92  void setStyle(Style);
93  void resetStyle();
94 
95  bool getShowScale() const;
96  void setShowScale(bool);
97  void resetShowScale();
98 
99  double getScaleMin() const;
100  void setScaleMin(double);
101  void resetScaleMin();
102 
103  double getScaleMax() const;
104  void setScaleMax(double);
105  void resetScaleMax();
106 
111  enum Origin {
113  OriginMinimum,
118  OriginMaximum,
123  };
124  Origin getOrigin() const;
125  void setOrigin(Origin);
126  void resetOrigin();
127 
128  int getBorderWidth() const;
129  void setBorderWidth(int);
130  void resetBorderWidth();
131 
132  QColor getBackgroundColor() const;
133  void setBackgroundColor(QColor);
134  void resetBackgroundColor();
135 
136  bool getAutoBarWidth() const;
137  void setAutoBarWidth(bool);
138  void resetAutoBarWidth();
139 
140  QSize sizeHint() const override;
141 
151  void addVariable(
152  PdCom::Variable pv,
153  const PdCom::Selector &selector = {},
154  const QtPdCom::Transmission & = QtPdCom::event_mode,
155  double scale = 1.0,
156  double offset = 0.0,
157  double tau = 0.0,
160  QColor color = Qt::blue
161  );
162  void addVariable(
163  PdCom::Process *process,
164  const QString &path,
165  const PdCom::Selector &selector = {},
166  const QtPdCom::Transmission & = QtPdCom::event_mode,
167  double scale = 1.0,
168  double offset = 0.0,
169  double tau = 0.0,
172  QColor color = Qt::blue
173  );
174 
183  void addStackedVariable(
184  PdCom::Variable pv,
185  const PdCom::Selector &selector = {},
186  const QtPdCom::Transmission & = QtPdCom::event_mode,
187  double scale = 1.0,
188  double offset = 0.0,
189  double tau = 0.0,
192  QColor color = Qt::blue
193  );
194  void addStackedVariable(
195  PdCom::Process *process,
196  const QString &path,
197  const PdCom::Selector &selector = {},
198  const QtPdCom::Transmission & = QtPdCom::event_mode,
199  double scale = 1.0,
200  double offset = 0.0,
201  double tau = 0.0,
204  QColor color = Qt::blue
205  );
206 
209  void clearVariables();
210 
216  void setVariable(
217  PdCom::Variable pv,
218  const PdCom::Selector &selector = {},
219  const QtPdCom::Transmission & = QtPdCom::event_mode,
220  double scale = 1.0,
221  double offset = 0.0,
222  double tau = 0.0,
225  QColor color = Qt::blue
226  );
227  void setVariable(
228  PdCom::Process *process,
229  const QString &path,
230  const PdCom::Selector &selector = {},
231  const QtPdCom::Transmission & = QtPdCom::event_mode,
232  double scale = 1.0,
233  double offset = 0.0,
234  double tau = 0.0,
237  QColor color = Qt::blue
238  );
239  void clearData();
240 
241  void setGradientStops(const QGradientStops &);
242  const QPair<double, double> getGradientLimits() const;
243 
244  protected:
245  bool event(QEvent *) override;
246  void resizeEvent(QResizeEvent *) override;
247  void paintEvent(QPaintEvent *event) override;
248 
249  private:
250  Q_DECLARE_PRIVATE(Bar)
251 
252  QScopedPointer<BarPrivate> const d_ptr;
253 };
254 
255 /****************************************************************************/
256 
257 
258 } // namespace Pd
259 
260 #endif
Definition: Bar.h:36
Orientation
Orientation of the bar widget.
Definition: Bar.h:77
Style
Style of the bar widget.
Definition: Bar.h:86
Bar graph widget.
Definition: Bar.h:44
#define PD_PUBLIC
Definition: Export.h:33
Display colored bars over a plain background.
Definition: Bar.h:87
Origin
Bar origin mode.
Definition: Bar.h:111
Display arrows over a colored background.
Definition: Bar.h:88
Vertical bar with scale on the left.
Definition: Bar.h:78
Bar graph widget.
Definition: Bar_p.h:43
Draw bars originating from zero.
Definition: Bar.h:112