- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qpolygon.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QPOLYGON_H
    00043 #define QPOLYGON_H
    00044
    00045 #include <QtCore/qvector.h>
    00046 #include <QtCore/qpoint.h>
    00047 #include <QtCore/qrect.h>
    00048
    00049 QT_BEGIN_HEADER
    00050
    00051 QT_BEGIN_NAMESPACE
    00052
    00053 QT_MODULE(Gui)
    00054
    00055 class QMatrix;
    00056 class QTransform;
    00057 class QRect;
    00058 class QVariant;
    00059
    00060 class Q_GUI_EXPORT QPolygon : public QVector<QPoint>
    00061 {
    00062 public:
    00063     inline QPolygon() {}
    00064     inline ~QPolygon() {}
    00065     inline QPolygon(int size);
    00066     inline QPolygon(const QPolygon &a) : QVector<QPoint>(a) {}
    00067     inline QPolygon(const QVector<QPoint> &v) : QVector<QPoint>(v) {}
    00068     QPolygon(const QRect &r, bool closed=false);
    00069     QPolygon(int nPoints, const int *points);
    00070     operator QVariant() const;
    00071
    00072     void translate(int dx, int dy);
    00073     void translate(const QPoint &offset);
    00074
    00075     QPolygon translated(int dx, int dy) const;
    00076     inline QPolygon translated(const QPoint &offset) const;
    00077
    00078     QRect boundingRect() const;
    00079
    00080     void point(int i, int *x, int *y) const;
    00081     QPoint point(int i) const;
    00082     void setPoint(int index, int x, int y);
    00083     void setPoint(int index, const QPoint &p);
    00084     void setPoints(int nPoints, const int *points);
    00085     void setPoints(int nPoints, int firstx, int firsty, ...);
    00086     void putPoints(int index, int nPoints, const int *points);
    00087     void putPoints(int index, int nPoints, int firstx, int firsty, ...);
    00088     void putPoints(int index, int nPoints, const QPolygon & from, int fromIndex=0);
    00089
    00090     bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const;
    00091
    00092     QPolygon united(const QPolygon &r) const;
    00093     QPolygon intersected(const QPolygon &r) const;
    00094     QPolygon subtracted(const QPolygon &r) const;
    00095 };
    00096
    00097 inline QPolygon::QPolygon(int asize) : QVector<QPoint>(asize) {}
    00098
    00099 #ifndef QT_NO_DEBUG_STREAM
    00100 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygon &);
    00101 #endif
    00102
    00103 /*****************************************************************************
    00104   QPolygon stream functions
    00105  *****************************************************************************/
    00106 #ifndef QT_NO_DATASTREAM
    00107 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygon &polygon);
    00108 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygon &polygon);
    00109 #endif
    00110
    00111 /*****************************************************************************
    00112   Misc. QPolygon functions
    00113  *****************************************************************************/
    00114
    00115 inline void QPolygon::setPoint(int index, const QPoint &pt)
    00116 { (*this)[index] = pt; }
    00117
    00118 inline void QPolygon::setPoint(int index, int x, int y)
    00119 { (*this)[index] = QPoint(x, y); }
    00120
    00121 inline QPoint QPolygon::point(int index) const
    00122 { return at(index); }
    00123
    00124 inline void QPolygon::translate(const QPoint &offset)
    00125 { translate(offset.x(), offset.y()); }
    00126
    00127 inline QPolygon QPolygon::translated(const QPoint &offset) const
    00128 { return translated(offset.x(), offset.y()); }
    00129
    00130 class QRectF;
    00131
    00132 class Q_GUI_EXPORT QPolygonF : public QVector<QPointF>
    00133 {
    00134 public:
    00135     inline QPolygonF() {}
    00136     inline ~QPolygonF() {}
    00137     inline QPolygonF(int size);
    00138     inline QPolygonF(const QPolygonF &a) : QVector<QPointF>(a) {}
    00139     inline QPolygonF(const QVector<QPointF> &v) : QVector<QPointF>(v) {}
    00140     QPolygonF(const QRectF &r);
    00141     QPolygonF(const QPolygon &a);
    00142
    00143     inline void translate(qreal dx, qreal dy);
    00144     void translate(const QPointF &offset);
    00145
    00146     inline QPolygonF translated(qreal dx, qreal dy) const;
    00147     QPolygonF translated(const QPointF &offset) const;
    00148
    00149     QPolygon toPolygon() const;
    00150
    00151     bool isClosed() const { return !isEmpty() && first() == last(); }
    00152
    00153     QRectF boundingRect() const;
    00154
    00155     bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
    00156
    00157     QPolygonF united(const QPolygonF &r) const;
    00158     QPolygonF intersected(const QPolygonF &r) const;
    00159     QPolygonF subtracted(const QPolygonF &r) const;
    00160 };
    00161
    00162 inline QPolygonF::QPolygonF(int asize) : QVector<QPointF>(asize) {}
    00163
    00164 #ifndef QT_NO_DEBUG_STREAM
    00165 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygonF &);
    00166 #endif
    00167
    00168 /*****************************************************************************
    00169   QPolygonF stream functions
    00170  *****************************************************************************/
    00171 #ifndef QT_NO_DATASTREAM
    00172 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygonF &array);
    00173 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygonF &array);
    00174 #endif
    00175
    00176 inline void QPolygonF::translate(qreal dx, qreal dy)
    00177 { translate(QPointF(dx, dy)); }
    00178
    00179 inline QPolygonF QPolygonF::translated(qreal dx, qreal dy) const
    00180 { return translated(QPointF(dx, dy)); }
    00181
    00182 QT_END_NAMESPACE
    00183
    00184 QT_END_HEADER
    00185
    00186 #endif // QPOLYGON_H