QtPdWidgets  2.3.1
Image.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2009 - 2023 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_IMAGE_H
24 #define PD_IMAGE_H
25 
26 #include "Export.h"
27 
28 #include <QtPdCom1/ScalarSubscriber.h>
29 
30 #include <QFrame>
31 #include <QHash>
32 
33 namespace Pd {
34 
35 /****************************************************************************/
36 
45  public QFrame, public QtPdCom::ScalarSubscriber
46 {
47  Q_OBJECT
48  Q_PROPERTY(QPixmap defaultPixmap READ getDefaultPixmap
49  WRITE setDefaultPixmap RESET resetDefaultPixmap)
50  Q_PROPERTY(qreal angle READ getAngle WRITE setAngle RESET resetAngle)
51  Q_PROPERTY(bool scaledContents READ hasScaledContents
52  WRITE setScaledContents RESET resetScaledContents)
53 
54  public:
55  Image(QWidget *parent = 0);
56  virtual ~Image();
57 
58  void clearData(); // pure-virtual from ScalarSubscriber
59 
60  int getValue() const;
61  void setValue(int);
62 
68  typedef QHash<int, QPixmap> PixmapHash;
69  void setPixmapHash(const PixmapHash *);
70 
71  const QPixmap &getDefaultPixmap() const;
72  void setDefaultPixmap(const QPixmap &);
73  void resetDefaultPixmap();
74 
75  qreal getAngle() const;
76  void setAngle(qreal);
77  void resetAngle();
78 
79  bool hasScaledContents() const;
80  void setScaledContents(bool);
81  void resetScaledContents();
82 
83  void clearTransformations();
84  void translate(qreal, qreal);
85  enum Axis {X, Y};
86  void translate(
87  Axis axis,
88  PdCom::Variable pv,
89  const PdCom::Selector &selector = {},
90  const QtPdCom::Transmission & = QtPdCom::event_mode,
91  double scale = 1.0,
92  double offset = 0.0,
93  double tau = 0.0
96  );
97  void translate(
98  Axis axis,
99  PdCom::Process *p,
100  const QString &path,
101  const PdCom::Selector &selector = {},
102  const QtPdCom::Transmission & = QtPdCom::event_mode,
103  double scale = 1.0,
104  double offset = 0.0,
105  double tau = 0.0
108  );
109  void rotate(qreal);
110  void rotate(
111  PdCom::Variable pv,
112  const PdCom::Selector &selector = {},
113  const QtPdCom::Transmission & = QtPdCom::event_mode,
114  double scale = 1.0,
115  double offset = 0.0,
116  double tau = 0.0
119  );
120  void rotate(
121  PdCom::Process *process,
122  const QString &path,
123  const PdCom::Selector &selector = {},
124  const QtPdCom::Transmission & = QtPdCom::event_mode,
125  double scale = 1.0,
126  double offset = 0.0,
127  double tau = 0.0
130  );
131 
132  protected:
133  bool event(QEvent *) override;
134  void paintEvent(QPaintEvent *) override;
135 
136  private:
137  struct PD_PRIVATE Impl;
138  std::unique_ptr<Impl> impl;
139 
140  PD_PRIVATE void newValues(std::chrono::nanoseconds) override;
141 };
142 
143 /****************************************************************************/
144 
145 } // namespace
146 
147 #endif
Definition: Bar.h:36
#define PD_PRIVATE
Definition: Export.h:28
Definition: Image.cpp:30
#define PD_PUBLIC
Definition: Export.h:33
Axis
Definition: Image.h:85
QHash< int, QPixmap > PixmapHash
Pixmap hash type.
Definition: Image.h:68
The vertical axis.
Definition: XYGraph.cpp:47
std::unique_ptr< Impl > impl
Definition: Image.h:138
The Horizontal axis.
Definition: XYGraph.cpp:46
Image display widget.
Definition: Image.h:44