Coverage Report

Created: 2026-03-31 07:41

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