source: trunk/src/gui/painting/qpolygon.h@ 890

Last change on this file since 890 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 6.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QPOLYGON_H
43#define QPOLYGON_H
44
45#include <QtCore/qvector.h>
46#include <QtCore/qpoint.h>
47#include <QtCore/qrect.h>
48
49QT_BEGIN_HEADER
50
51QT_BEGIN_NAMESPACE
52
53QT_MODULE(Gui)
54
55class QMatrix;
56class QTransform;
57class QRect;
58class QVariant;
59
60class Q_GUI_EXPORT QPolygon : public QVector<QPoint>
61{
62public:
63 inline QPolygon() {}
64 inline ~QPolygon() {}
65 inline QPolygon(int size);
66 inline QPolygon(const QPolygon &a) : QVector<QPoint>(a) {}
67 inline QPolygon(const QVector<QPoint> &v) : QVector<QPoint>(v) {}
68 QPolygon(const QRect &r, bool closed=false);
69 QPolygon(int nPoints, const int *points);
70 operator QVariant() const;
71
72 void translate(int dx, int dy);
73 void translate(const QPoint &offset);
74
75 QPolygon translated(int dx, int dy) const;
76 inline QPolygon translated(const QPoint &offset) const;
77
78 QRect boundingRect() const;
79
80 void point(int i, int *x, int *y) const;
81 QPoint point(int i) const;
82 void setPoint(int index, int x, int y);
83 void setPoint(int index, const QPoint &p);
84 void setPoints(int nPoints, const int *points);
85 void setPoints(int nPoints, int firstx, int firsty, ...);
86 void putPoints(int index, int nPoints, const int *points);
87 void putPoints(int index, int nPoints, int firstx, int firsty, ...);
88 void putPoints(int index, int nPoints, const QPolygon & from, int fromIndex=0);
89
90 bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const;
91
92 QPolygon united(const QPolygon &r) const;
93 QPolygon intersected(const QPolygon &r) const;
94 QPolygon subtracted(const QPolygon &r) const;
95};
96
97inline QPolygon::QPolygon(int asize) : QVector<QPoint>(asize) {}
98
99#ifndef QT_NO_DEBUG_STREAM
100Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygon &);
101#endif
102
103/*****************************************************************************
104 QPolygon stream functions
105 *****************************************************************************/
106#ifndef QT_NO_DATASTREAM
107Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygon &polygon);
108Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygon &polygon);
109#endif
110
111/*****************************************************************************
112 Misc. QPolygon functions
113 *****************************************************************************/
114
115inline void QPolygon::setPoint(int index, const QPoint &pt)
116{ (*this)[index] = pt; }
117
118inline void QPolygon::setPoint(int index, int x, int y)
119{ (*this)[index] = QPoint(x, y); }
120
121inline QPoint QPolygon::point(int index) const
122{ return at(index); }
123
124inline void QPolygon::translate(const QPoint &offset)
125{ translate(offset.x(), offset.y()); }
126
127inline QPolygon QPolygon::translated(const QPoint &offset) const
128{ return translated(offset.x(), offset.y()); }
129
130class QRectF;
131
132class Q_GUI_EXPORT QPolygonF : public QVector<QPointF>
133{
134public:
135 inline QPolygonF() {}
136 inline ~QPolygonF() {}
137 inline QPolygonF(int size);
138 inline QPolygonF(const QPolygonF &a) : QVector<QPointF>(a) {}
139 inline QPolygonF(const QVector<QPointF> &v) : QVector<QPointF>(v) {}
140 QPolygonF(const QRectF &r);
141 QPolygonF(const QPolygon &a);
142
143 inline void translate(qreal dx, qreal dy);
144 void translate(const QPointF &offset);
145
146 inline QPolygonF translated(qreal dx, qreal dy) const;
147 QPolygonF translated(const QPointF &offset) const;
148
149 QPolygon toPolygon() const;
150
151 bool isClosed() const { return !isEmpty() && first() == last(); }
152
153 QRectF boundingRect() const;
154
155 bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
156
157 QPolygonF united(const QPolygonF &r) const;
158 QPolygonF intersected(const QPolygonF &r) const;
159 QPolygonF subtracted(const QPolygonF &r) const;
160};
161
162inline QPolygonF::QPolygonF(int asize) : QVector<QPointF>(asize) {}
163
164#ifndef QT_NO_DEBUG_STREAM
165Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygonF &);
166#endif
167
168/*****************************************************************************
169 QPolygonF stream functions
170 *****************************************************************************/
171#ifndef QT_NO_DATASTREAM
172Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygonF &array);
173Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygonF &array);
174#endif
175
176inline void QPolygonF::translate(qreal dx, qreal dy)
177{ translate(QPointF(dx, dy)); }
178
179inline QPolygonF QPolygonF::translated(qreal dx, qreal dy) const
180{ return translated(QPointF(dx, dy)); }
181
182QT_END_NAMESPACE
183
184QT_END_HEADER
185
186#endif // QPOLYGON_H
Note: See TracBrowser for help on using the repository browser.