Coverage Report

Created: 2026-02-10 07:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/prefix/include/QtGui/qpolygon.h
Line
Count
Source
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#ifndef QPOLYGON_H
5
#define QPOLYGON_H
6
7
#include <QtGui/qtguiglobal.h>
8
#include <QtCore/qlist.h>
9
#include <QtCore/qpoint.h>
10
#include <QtCore/qrect.h>
11
12
QT_BEGIN_NAMESPACE
13
14
class QTransform;
15
class QRect;
16
class QVariant;
17
18
class QPolygonF;
19
20
// We export each out-of-line method individually to prevent MSVC from
21
// exporting the whole QList class.
22
class QPolygon : public QList<QPoint>
23
{
24
public:
25
    using QList<QPoint>::QList;
26
    QPolygon() = default;
27
0
    Q_IMPLICIT QPolygon(const QList<QPoint> &v) : QList<QPoint>(v) { }
28
0
    Q_IMPLICIT QPolygon(QList<QPoint> &&v) noexcept : QList<QPoint>(std::move(v)) { }
29
    Q_IMPLICIT Q_GUI_EXPORT QPolygon(const QRect &r, bool closed=false);
30
    Q_GUI_EXPORT QPolygon(int nPoints, const int *points);
31
0
    void swap(QPolygon &other) noexcept { QList<QPoint>::swap(other); } // prevent QList<QPoint><->QPolygon swaps
32
33
    Q_GUI_EXPORT operator QVariant() const;
34
35
    Q_GUI_EXPORT void translate(int dx, int dy);
36
    void translate(const QPoint &offset);
37
38
    [[nodiscard]] Q_GUI_EXPORT QPolygon translated(int dx, int dy) const;
39
    [[nodiscard]] inline QPolygon translated(const QPoint &offset) const;
40
41
    Q_GUI_EXPORT QRect boundingRect() const;
42
43
    Q_GUI_EXPORT void point(int i, int *x, int *y) const;
44
    QPoint point(int i) const;
45
    Q_GUI_EXPORT void setPoint(int index, int x, int y);
46
    inline void setPoint(int index, const QPoint &p);
47
    Q_GUI_EXPORT void setPoints(int nPoints, const int *points);
48
    Q_GUI_EXPORT void setPoints(int nPoints, int firstx, int firsty, ...);
49
    Q_GUI_EXPORT void putPoints(int index, int nPoints, const int *points);
50
    Q_GUI_EXPORT void putPoints(int index, int nPoints, int firstx, int firsty, ...);
51
    Q_GUI_EXPORT void putPoints(int index, int nPoints, const QPolygon & from, int fromIndex=0);
52
53
    Q_GUI_EXPORT bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const;
54
55
    [[nodiscard]] Q_GUI_EXPORT QPolygon united(const QPolygon &r) const;
56
    [[nodiscard]] Q_GUI_EXPORT QPolygon intersected(const QPolygon &r) const;
57
    [[nodiscard]] Q_GUI_EXPORT QPolygon subtracted(const QPolygon &r) const;
58
59
    Q_GUI_EXPORT bool intersects(const QPolygon &r) const;
60
61
    [[nodiscard]] inline QPolygonF toPolygonF() const;
62
};
63
Q_DECLARE_SHARED(QPolygon)
64
65
#ifndef QT_NO_DEBUG_STREAM
66
Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygon &);
67
#endif
68
69
/*****************************************************************************
70
  QPolygon stream functions
71
 *****************************************************************************/
72
#ifndef QT_NO_DATASTREAM
73
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygon &polygon);
74
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygon &polygon);
75
#endif
76
77
/*****************************************************************************
78
  Misc. QPolygon functions
79
 *****************************************************************************/
80
81
inline void QPolygon::setPoint(int index, const QPoint &pt)
82
0
{ setPoint(index, pt.x(), pt.y()); }
83
84
inline QPoint QPolygon::point(int index) const
85
0
{ return at(index); }
86
87
inline void QPolygon::translate(const QPoint &offset)
88
0
{ translate(offset.x(), offset.y()); }
89
90
inline QPolygon QPolygon::translated(const QPoint &offset) const
91
0
{ return translated(offset.x(), offset.y()); }
92
93
class QRectF;
94
95
class QPolygonF : public QList<QPointF>
96
{
97
public:
98
    using QList<QPointF>::QList;
99
    QPolygonF() = default;
100
0
    Q_IMPLICIT QPolygonF(const QList<QPointF> &v) : QList<QPointF>(v) { }
101
0
    Q_IMPLICIT QPolygonF(QList<QPointF> &&v) noexcept : QList<QPointF>(std::move(v)) { }
102
    Q_IMPLICIT Q_GUI_EXPORT QPolygonF(const QRectF &r);
103
    Q_IMPLICIT Q_GUI_EXPORT QPolygonF(const QPolygon &a);
104
0
    inline void swap(QPolygonF &other) { QList<QPointF>::swap(other); } // prevent QList<QPointF><->QPolygonF swaps
105
106
    Q_GUI_EXPORT operator QVariant() const;
107
108
    inline void translate(qreal dx, qreal dy);
109
    void Q_GUI_EXPORT translate(const QPointF &offset);
110
111
    inline QPolygonF translated(qreal dx, qreal dy) const;
112
    [[nodiscard]] Q_GUI_EXPORT QPolygonF translated(const QPointF &offset) const;
113
114
    QPolygon Q_GUI_EXPORT toPolygon() const;
115
116
0
    bool isClosed() const { return !isEmpty() && first() == last(); }
117
118
    QRectF Q_GUI_EXPORT boundingRect() const;
119
120
    Q_GUI_EXPORT bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
121
122
    [[nodiscard]] Q_GUI_EXPORT QPolygonF united(const QPolygonF &r) const;
123
    [[nodiscard]] Q_GUI_EXPORT QPolygonF intersected(const QPolygonF &r) const;
124
    [[nodiscard]] Q_GUI_EXPORT QPolygonF subtracted(const QPolygonF &r) const;
125
126
    Q_GUI_EXPORT bool intersects(const QPolygonF &r) const;
127
};
128
Q_DECLARE_SHARED(QPolygonF)
129
130
0
QPolygonF QPolygon::toPolygonF() const { return QPolygonF(*this); }
131
132
#ifndef QT_NO_DEBUG_STREAM
133
Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygonF &);
134
#endif
135
136
/*****************************************************************************
137
  QPolygonF stream functions
138
 *****************************************************************************/
139
#ifndef QT_NO_DATASTREAM
140
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygonF &array);
141
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygonF &array);
142
#endif
143
144
inline void QPolygonF::translate(qreal dx, qreal dy)
145
0
{ translate(QPointF(dx, dy)); }
146
147
inline QPolygonF QPolygonF::translated(qreal dx, qreal dy) const
148
0
{ return translated(QPointF(dx, dy)); }
149
150
QT_END_NAMESPACE
151
152
#endif // QPOLYGON_H