src/gui/painting/qpolygon.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the QtGui module of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ****************************************************************************/
00023 
00024 #ifndef QPOLYGON_H
00025 #define QPOLYGON_H
00026 
00027 #include <QtCore/qvector.h>
00028 #include <QtCore/qpoint.h>
00029 #include <QtCore/qrect.h>
00030 
00031 QT_BEGIN_HEADER
00032 
00033 QT_MODULE(Gui)
00034 
00035 class QMatrix;
00036 class QRect;
00037 class QVariant;
00038 
00039 class Q_GUI_EXPORT QPolygon : public QVector<QPoint>
00040 {
00041 public:
00042     inline QPolygon() {}
00043     inline ~QPolygon() {}
00044     inline QPolygon(int size);
00045     inline QPolygon(const QPolygon &a) : QVector<QPoint>(a) {}
00046     inline QPolygon(const QVector<QPoint> &v) : QVector<QPoint>(v) {}
00047     QPolygon(const QRect &r, bool closed=false);
00048     QPolygon(int nPoints, const int *points);
00049     operator QVariant() const;
00050 
00051     void translate(int dx, int dy);
00052     void translate(const QPoint &offset);
00053     QRect boundingRect() const;
00054 
00055     void point(int i, int *x, int *y) const;
00056     QPoint point(int i) const;
00057     void setPoint(int index, int x, int y);
00058     void setPoint(int index, const QPoint &p);
00059     void setPoints(int nPoints, const int *points);
00060     void setPoints(int nPoints, int firstx, int firsty, ...);
00061     void putPoints(int index, int nPoints, const int *points);
00062     void putPoints(int index, int nPoints, int firstx, int firsty, ...);
00063     void putPoints(int index, int nPoints, const QPolygon & from, int fromIndex=0);
00064 };
00065 
00066 inline QPolygon::QPolygon(int asize) : QVector<QPoint>(asize) {}
00067 
00068 #ifndef QT_NO_DEBUG_STREAM
00069 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygon &);
00070 #endif
00071 
00072 /*****************************************************************************
00073   Misc. QPolygon functions
00074  *****************************************************************************/
00075 
00076 inline void QPolygon::setPoint(int index, const QPoint &pt)
00077 { (*this)[index] = pt; }
00078 
00079 inline void QPolygon::setPoint(int index, int x, int y)
00080 { (*this)[index] = QPoint(x, y); }
00081 
00082 inline QPoint QPolygon::point(int index) const
00083 { return at(index); }
00084 
00085 inline void QPolygon::translate(const QPoint &offset)
00086 { translate(offset.x(), offset.y()); }
00087 
00088 class QRectF;
00089 
00090 class Q_GUI_EXPORT QPolygonF : public QVector<QPointF>
00091 {
00092 public:
00093     inline QPolygonF() {}
00094     inline ~QPolygonF() {}
00095     inline QPolygonF(int size);
00096     inline QPolygonF(const QPolygonF &a) : QVector<QPointF>(a) {}
00097     inline QPolygonF(const QVector<QPointF> &v) : QVector<QPointF>(v) {}
00098     QPolygonF(const QRectF &r);
00099     QPolygonF(const QPolygon &a);
00100 
00101     inline void translate(qreal dx, qreal dy);
00102     void translate(const QPointF &offset);
00103 
00104     QPolygon toPolygon() const;
00105 
00106     bool isClosed() const { return !isEmpty() && first() == last(); }
00107 
00108     QRectF boundingRect() const;
00109 };
00110 
00111 inline QPolygonF::QPolygonF(int asize) : QVector<QPointF>(asize) {}
00112 
00113 #ifndef QT_NO_DEBUG_STREAM
00114 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygonF &);
00115 #endif
00116 
00117 /*****************************************************************************
00118   QPolygonF stream functions
00119  *****************************************************************************/
00120 #ifndef QT_NO_DATASTREAM
00121 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygonF &array);
00122 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygonF &array);
00123 #endif
00124 
00125 inline void QPolygonF::translate(qreal dx, qreal dy)
00126 { translate(QPointF(dx, dy)); }
00127 
00128 QT_END_HEADER
00129 
00130 #endif // QPOLYGON_H

Generated on Thu Mar 15 11:55:34 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1