⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qregion.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                    break;                case QRGN_SUB:                    rgn = r1.subtracted(r2);                    break;                case QRGN_XOR:                    rgn = r1.xored(r2);                    break;            }        } else if (id == QRGN_RECTS) {            // (This is the only form used in Qt 2.0)            quint32 n;            s >> n;            QRect r;            for (int i=0; i<(int)n; i++) {                s >> r;                rgn = rgn.united(QRegion(r));            }        }    }    *this = rgn;}/*****************************************************************************  QRegion stream functions *****************************************************************************//*!    \relates QRegion    Writes the region \a r to the stream \a s and returns a reference    to the stream.    \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/QDataStream &operator<<(QDataStream &s, const QRegion &r){    QVector<QRect> a = r.rects();    if (a.isEmpty()) {        s << (quint32)0;    } else {        if (s.version() == 1) {            int i;            for (i = a.size() - 1; i > 0; --i) {                s << (quint32)(12 + i * 24);                s << (int)QRGN_OR;            }            for (i = 0; i < a.size(); ++i) {                s << (quint32)(4+8) << (int)QRGN_SETRECT << a[i];            }        } else {            s << (quint32)(4 + 4 + 16 * a.size()); // 16: storage size of QRect            s << (qint32)QRGN_RECTS;            s << a;        }    }    return s;}/*!    \relates QRegion    Reads a region from the stream \a s into \a r and returns a    reference to the stream.    \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/QDataStream &operator>>(QDataStream &s, QRegion &r){    QByteArray b;    s >> b;    r.exec(b, s.version());    return s;}#endif //QT_NO_DATASTREAM#ifndef QT_NO_DEBUG_STREAMQDebug operator<<(QDebug s, const QRegion &r){    QVector<QRect> rects = r.rects();    s.nospace() << "QRegion(size=" << rects.size() << "), "                << "bounds = " << r.boundingRect() << "\n";    for (int i=0; i<rects.size(); ++i)        s << "- " << i << rects.at(i) << "\n";    return s;}#endif// These are not inline - they can be implemented better on some platforms//  (eg. Windows at least provides 3-variable operations).  For now, simple./*!    Applies the united() function to this region and \a r. \c r1|r2 is    equivalent to \c r1.united(r2).    \sa united(), operator+()*/const QRegion QRegion::operator|(const QRegion &r) const    { return united(r); }/*!    Applies the united() function to this region and \a r. \c r1+r2 is    equivalent to \c r1.united(r2).    \sa united(), operator|()*/const QRegion QRegion::operator+(const QRegion &r) const    { return united(r); }/*!    Applies the intersected() function to this region and \a r. \c r1&r2    is equivalent to \c r1.intersected(r2).    \sa intersected()*/const QRegion QRegion::operator&(const QRegion &r) const    { return intersected(r); }/*!    Applies the subtracted() function to this region and \a r. \c r1-r2    is equivalent to \c r1.subtracted(r2).    \sa subtracted()*/const QRegion QRegion::operator-(const QRegion &r) const    { return subtracted(r); }/*!    Applies the xored() function to this region and \a r. \c r1^r2 is    equivalent to \c r1.xored(r2).    \sa xored()*/const QRegion QRegion::operator^(const QRegion &r) const    { return xored(r); }/*!    Applies the united() function to this region and \a r and assigns    the result to this region. \c r1|=r2 is equivalent to \c    {r1 = r1.united(r2)}.    \sa united()*/QRegion& QRegion::operator|=(const QRegion &r)    { return *this = *this | r; }/*!    \fn QRegion& QRegion::operator+=(const QRegion &r)    Applies the united() function to this region and \a r and assigns    the result to this region. \c r1+=r2 is equivalent to \c    {r1 = r1.united(r2)}.    \sa intersected()*//*!  \fn QRegion& QRegion::operator&=(const QRegion &r)  Applies the intersected() function to this region and \a r and  assigns the result to this region. \c r1&=r2 is equivalent to \c  r1 = r1.intersected(r2).    \sa intersected()*/#ifndef Q_WS_WINQRegion& QRegion::operator&=(const QRegion &r)    { return *this = *this & r; }#endif/*!  \fn QRegion& QRegion::operator-=(const QRegion &r)    Applies the subtracted() function to this region and \a r and  assigns the result to this region. \c r1-=r2 is equivalent to \c  {r1 = r1.subtracted(r2)}.    \sa subtracted()*/#ifndef Q_WS_WINQRegion& QRegion::operator-=(const QRegion &r)    { return *this = *this - r; }#endif/*!    Applies the xored() function to this region and \a r and    assigns the result to this region. \c r1^=r2 is equivalent to \c    {r1 = r1.xored(r2)}.    \sa xored()*/QRegion& QRegion::operator^=(const QRegion &r)    { return *this = *this ^ r; }/*!    \fn bool QRegion::operator!=(const QRegion &other) const    Returns true if this region is different from the \a other region;    otherwise returns false.*//*!   Returns the region as a QVariant*/QRegion::operator QVariant() const{    return QVariant(QVariant::Region, this);}/*!    \fn bool QRegion::isNull() const    Use isEmpty() instead.*//*!    \fn QRegion QRegion::translated(const QPoint &p) const    \overload    \since 4.1    Returns a copy of the regtion that is translated \a{p}\e{.x()}    along the x axis and \a{p}\e{.y()} along the y axis, relative to    the current position.  Positive values move the rectangle to the    right and down.    \sa translate()*//*!    \since 4.1    Returns a copy of the region that is translated \a dx along the    x axis and \a dy along the y axis, relative to the current    position. Positive values move the region to the right and    down.    \sa translate()*/QRegionQRegion::translated(int dx, int dy) const{    QRegion ret(*this);    ret.translate(dx, dy);    return ret;}inline bool rect_intersects(const QRect &r1, const QRect &r2){    return qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right())        && qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom());}/*!    \since 4.2    Returns true if this region intersects with \a region, otherwise    returns false.*/bool QRegion::intersects(const QRegion &region) const{    const QVector<QRect> myRects = rects();    const QVector<QRect> otherRects = region.rects();    for (QVector<QRect>::const_iterator i1 = myRects.begin(); i1 < myRects.end(); ++i1)        for (QVector<QRect>::const_iterator i2 = otherRects.begin(); i2 < otherRects.end(); ++i2)            if (rect_intersects(*i1, *i2))                return true;    return false;}/*!    \since 4.2    Returns true if this region intersects with \a rect, otherwise    returns false.*/bool QRegion::intersects(const QRect &rect) const{    QRect r = rect.normalized();    const QVector<QRect> myRects = rects();    for (QVector<QRect>::const_iterator it = myRects.begin(); it < myRects.end(); ++it)        if (rect_intersects(r, *it))            return true;    return false;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -