Debian Codegraph @

examples/widgets/painting/transformations/renderarea.h

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4 #ifndef RENDERAREA_H
5 #define RENDERAREA_H
6
7 #include <QList>
8 #include <QPainterPath>
9 #include <QRect>
10 #include <QWidget>
11
12 QT_BEGIN_NAMESPACE
13 class QPaintEvent;
14 QT_END_NAMESPACE
15
16 //! [0]
17 enum Operation { NoTransformation, Translate, Rotate, Scale };
18 //! [0]
19
20 //! [1]
21 class RenderArea : public QWidget
22 {
23 Q_OBJECT
24
25 public:
26 RenderArea(QWidget *parent = nullptr);
27
28 void setOperations(const QList<Operation> &operations);
29 void setShape(const QPainterPath &shape);
30
31 QSize minimumSizeHint() const override;
32 QSize sizeHint() const override;
33
34 protected:
35 void paintEvent(QPaintEvent *event) override;
36 //! [1]
37
38 //! [2]
39 private:
40 void drawCoordinates(QPainter &painter);
41 void drawOutline(QPainter &painter);
42 void drawShape(QPainter &painter);
43 void transformPainter(QPainter &painter);
44
45 QList<Operation> operations;
46 QPainterPath shape;
47 QRect xBoundingRect;
48 QRect yBoundingRect;
49 };
50 //! [2]
51
52 #endif // RENDERAREA_H