diff options
Diffstat (limited to 'src/gui/painting/qpolygon.cpp')
-rw-r--r-- | src/gui/painting/qpolygon.cpp | 91 |
1 files changed, 21 insertions, 70 deletions
diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp index d601dcdb0c..d615245eb4 100644 --- a/src/gui/painting/qpolygon.cpp +++ b/src/gui/painting/qpolygon.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qpolygon.h" #include "qrect.h" @@ -263,13 +227,16 @@ void QPolygon::point(int index, int *x, int *y) const */ /*! - \fn void QPolygon::setPoint(int index, int x, int y) - Sets the point at the given \a index to the point specified by (\a{x}, \a{y}). \sa point(), putPoints(), setPoints(), */ +void QPolygon::setPoint(int index, int x, int y) +{ + (*this)[index] = QPoint(x, y); +} + /*! Resizes the polygon to \a nPoints and populates it with the given @@ -439,15 +406,20 @@ QRect QPolygon::boundingRect() const return QRect(QPoint(minx,miny), QPoint(maxx,maxy)); } +/*! + \fn QPolygon::toPolygonF() const + \since 6.4 + + Returns this polygon as a polygon with floating point accuracy. + + \sa QPolygonF::toPolygon() +*/ + + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QPolygon &a) { - QDebugStateSaver saver(dbg); - dbg.nospace() << "QPolygon("; - for (int i = 0; i < a.count(); ++i) - dbg.nospace() << a.at(i); - dbg.nospace() << ')'; - return dbg; + return QtPrivate::printSequentialContainer(dbg, "QPolygon", a); } #endif @@ -725,13 +697,7 @@ QDataStream &operator>>(QDataStream &s, QPolygon &a) QDataStream &operator<<(QDataStream &s, const QPolygonF &a) { - quint32 len = a.size(); - uint i; - - s << len; - for (i = 0; i < len; ++i) - s << a.at(i); - return s; + return s << static_cast<const QList<QPointF> &>(a); } /*! @@ -746,29 +712,14 @@ QDataStream &operator<<(QDataStream &s, const QPolygonF &a) QDataStream &operator>>(QDataStream &s, QPolygonF &a) { - quint32 len; - uint i; - - s >> len; - a.reserve(a.size() + (int)len); - QPointF p; - for (i = 0; i < len; ++i) { - s >> p; - a.insert(i, p); - } - return s; + return s >> static_cast<QList<QPointF> &>(a); } #endif //QT_NO_DATASTREAM #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QPolygonF &a) { - QDebugStateSaver saver(dbg); - dbg.nospace() << "QPolygonF("; - for (int i = 0; i < a.count(); ++i) - dbg.nospace() << a.at(i); - dbg.nospace() << ')'; - return dbg; + return QtPrivate::printSequentialContainer(dbg, "QPolygonF", a); } #endif |