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

Last change on this file since 180 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** 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 are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
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 QRect boundingRect() const;
75
76 void point(int i, int *x, int *y) const;
77 QPoint point(int i) const;
78 void setPoint(int index, int x, int y);
79 void setPoint(int index, const QPoint &p);
80 void setPoints(int nPoints, const int *points);
81 void setPoints(int nPoints, int firstx, int firsty, ...);
82 void putPoints(int index, int nPoints, const int *points);
83 void putPoints(int index, int nPoints, int firstx, int firsty, ...);
84 void putPoints(int index, int nPoints, const QPolygon & from, int fromIndex=0);
85
86 bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const;
87
88 QPolygon united(const QPolygon &r) const;
89 QPolygon intersected(const QPolygon &r) const;
90 QPolygon subtracted(const QPolygon &r) const;
91};
92
93inline QPolygon::QPolygon(int asize) : QVector<QPoint>(asize) {}
94
95#ifndef QT_NO_DEBUG_STREAM
96Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygon &);
97#endif
98
99/*****************************************************************************
100 QPolygon stream functions
101 *****************************************************************************/
102#ifndef QT_NO_DATASTREAM
103Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygon &polygon);
104Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygon &polygon);
105#endif
106
107/*****************************************************************************
108 Misc. QPolygon functions
109 *****************************************************************************/
110
111inline void QPolygon::setPoint(int index, const QPoint &pt)
112{ (*this)[index] = pt; }
113
114inline void QPolygon::setPoint(int index, int x, int y)
115{ (*this)[index] = QPoint(x, y); }
116
117inline QPoint QPolygon::point(int index) const
118{ return at(index); }
119
120inline void QPolygon::translate(const QPoint &offset)
121{ translate(offset.x(), offset.y()); }
122
123class QRectF;
124
125class Q_GUI_EXPORT QPolygonF : public QVector<QPointF>
126{
127public:
128 inline QPolygonF() {}
129 inline ~QPolygonF() {}
130 inline QPolygonF(int size);
131 inline QPolygonF(const QPolygonF &a) : QVector<QPointF>(a) {}
132 inline QPolygonF(const QVector<QPointF> &v) : QVector<QPointF>(v) {}
133 QPolygonF(const QRectF &r);
134 QPolygonF(const QPolygon &a);
135
136 inline void translate(qreal dx, qreal dy);
137 void translate(const QPointF &offset);
138
139 QPolygon toPolygon() const;
140
141 bool isClosed() const { return !isEmpty() && first() == last(); }
142
143 QRectF boundingRect() const;
144
145 bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
146
147 QPolygonF united(const QPolygonF &r) const;
148 QPolygonF intersected(const QPolygonF &r) const;
149 QPolygonF subtracted(const QPolygonF &r) const;
150};
151
152inline QPolygonF::QPolygonF(int asize) : QVector<QPointF>(asize) {}
153
154#ifndef QT_NO_DEBUG_STREAM
155Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygonF &);
156#endif
157
158/*****************************************************************************
159 QPolygonF stream functions
160 *****************************************************************************/
161#ifndef QT_NO_DATASTREAM
162Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygonF &array);
163Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygonF &array);
164#endif
165
166inline void QPolygonF::translate(qreal dx, qreal dy)
167{ translate(QPointF(dx, dy)); }
168
169QT_END_NAMESPACE
170
171QT_END_HEADER
172
173#endif // QPOLYGON_H
Note: See TracBrowser for help on using the repository browser.