当前位置: 首页>>代码示例>>C++>>正文


C++ QRegion类代码示例

本文整理汇总了C++中QRegion的典型用法代码示例。如果您正苦于以下问题:C++ QRegion类的具体用法?C++ QRegion怎么用?C++ QRegion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mergeWith

bool PaintTilelayer::mergeWith(const QUndoCommand *other) {
    const PaintTilelayer *o = static_cast<const PaintTilelayer*>(other);
    if (!(mMapEditor == o->mMapEditor &&
          mTarget == o->mTarget &&
          o->mMergeable))
        return false;

    const QRegion newRegion = o->mPaintedRegion.subtracted(mPaintedRegion);
    const QRegion combinedRegion = mPaintedRegion.united(o->mPaintedRegion);
    const QRect bounds = QRect(mX, mY, mSource->width(), mSource->height());
    const QRect combinedBounds = combinedRegion.boundingRect();

    //resize the erased tiles and source layers when necessary
    if (bounds != combinedBounds) {
        const QPoint shift = bounds.topLeft() - combinedBounds.topLeft();
        mErased->resize(combinedBounds.size(), shift);
        mSource->resize(combinedBounds.size(), shift);
    }

    mX = combinedBounds.left();
    mY = combinedBounds.top();
    mPaintedRegion = combinedRegion;

    // Copy the painted tiles from the other command over
    const QPoint pos = QPoint(o->mX, o->mY) - combinedBounds.topLeft();
    mSource->merge(pos, o->mSource);

    // Copy the newly erased tiles from the other command over
    foreach (const QRect &rect, newRegion.rects())
        for (int y = rect.top(); y <= rect.bottom(); ++y)
            for (int x = rect.left(); x <= rect.right(); ++x)
                mErased->setCell(x - mX,
                                 y - mY,
                                 o->mErased->cellAt(x - o->mX, y - o->mY));

    return true;
}
开发者ID:ATSOTECK,项目名称:Aurora-Game-Editor,代码行数:37,代码来源:paintTilelayer.cpp

示例2: painter

void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event)
{
    QPainter painter(m_widget);

    if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) {
        QRegion borderRegion = event->region();
        borderRegion = borderRegion.subtracted(m_boundingRect);

        QBrush brush = m_widget->palette().window();

        QVector<QRect> rects = borderRegion.rects();
        for (QVector<QRect>::iterator it = rects.begin(), end = rects.end(); it != end; ++it) {
            painter.fillRect(*it, brush);
        }
    }

    if (m_surface->isActive() && m_boundingRect.intersects(event->rect())) {
        m_surface->paint(&painter, m_boundingRect, m_sourceRect);

        m_surface->setReady(true);
    } else {
 #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
        if (m_updatePaintDevice && (painter.paintEngine()->type() == QPaintEngine::OpenGL
                || painter.paintEngine()->type() == QPaintEngine::OpenGL2)) {
            m_updatePaintDevice = false;

            m_surface->setGLContext(const_cast<QGLContext *>(QGLContext::currentContext()));
            if (m_surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) {
                m_surface->setShaderType(QPainterVideoSurface::GlslShader);
            } else {
                m_surface->setShaderType(QPainterVideoSurface::FragmentProgramShader);
            }
        }
#endif
    }

}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:37,代码来源:qvideowidget.cpp

示例3: window

void QWSLocalMemSurface::setGeometry(const QRect &rect)
{
    QSize size = rect.size();

    QWidget *win = window();
    if (win && !win->mask().isEmpty()) {
        const QRegion region = win->mask()
                               & rect.translated(-win->geometry().topLeft());
        size = region.boundingRect().size();
    }

    uchar *deleteLater = 0;
    // In case of a Hide event we need to delete the memory after sending the
    // event to the server in order to let the server animate the event.
    if (size.isEmpty()) {
        deleteLater = mem;
        mem = 0;
    }

    if (img.size() != size) {
        delete[] mem;
        if (size.isEmpty()) {
            mem = 0;
            img = QImage();
        } else {
            const QImage::Format format = preferredImageFormat(win);
            const int bpl = nextMulOf4(bytesPerPixel(format) * size.width());
            const int memsize = bpl * size.height();
            mem = new uchar[memsize];
            img = QImage(mem, size.width(), size.height(), bpl, format);
            setImageMetrics(img, win);
        }
    }

    QWSWindowSurface::setGeometry(rect);
    delete[] deleteLater;
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:37,代码来源:qwindowsurface_qws.cpp

示例4: beginPaint

void QXlibWindowSurface::beginPaint(const QRegion &region)
{
    Q_UNUSED(region);
    resizeBuffer(size());

    if (shm_img.hasAlphaChannel()) {
        QPainter p(&shm_img);
        p.setCompositionMode(QPainter::CompositionMode_Source);
        const QVector<QRect> rects = region.rects();
        const QColor blank = Qt::transparent;
        for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
            p.fillRect(*it, blank);
        }
    }
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:15,代码来源:qxlibwindowsurface.cpp

示例5: frameGeometry

bool MainWindow::eventFilter(QObject* obj, QEvent* event)
{
   if (this->customStyleLoaded && obj == this->ui->grip)
   {
      if (event->type() == QEvent::MouseButtonPress && static_cast<QMouseEvent*>(event)->button() == Qt::LeftButton)
      {
         this->dragPosition = static_cast<QMouseEvent*>(event)->globalPos() - frameGeometry().topLeft();
      }
      if (event->type() == QEvent::MouseButtonRelease && static_cast<QMouseEvent*>(event)->button() == Qt::LeftButton)
      {
         this->dragPosition = QPoint();
      }
      else if (event->type() == QEvent::MouseMove && !this->isMaximized() && static_cast<QMouseEvent*>(event)->buttons() & Qt::LeftButton && !this->dragPosition.isNull())
      {
         move(static_cast<QMouseEvent*>(event)->globalPos() - this->dragPosition);
      }
      else if (event->type() == QEvent::Resize)
      {
         const QRegion maskedRegion(0, 0, this->ui->grip->width(), this->ui->grip->width());

         if (this->isMaximized())
            this->ui->grip->setMask(maskedRegion);
         else
         {
            const QRegion cornerTopRight = QRegion(this->ui->grip->width() - WINDOW_BORDER_RADIUS, 0, WINDOW_BORDER_RADIUS, WINDOW_BORDER_RADIUS).subtracted(QRegion(this->ui->grip->width() - 2 * WINDOW_BORDER_RADIUS, 0, 2 * WINDOW_BORDER_RADIUS, 2 * WINDOW_BORDER_RADIUS, QRegion::Ellipse));
            this->ui->grip->setMask(maskedRegion.subtracted(cornerTopRight));
         }
      }
      else if (event->type() == QEvent::MouseButtonDblClick && static_cast<QMouseEvent*>(event)->button() == Qt::LeftButton)
      {
         this->maximize();
      }
   }

   return QMainWindow::eventFilter(obj, event);
}
开发者ID:Fafou,项目名称:D-LAN,代码行数:36,代码来源:MainWindow.cpp

示例6: region

void tst_qregion::intersects_data()
{
    QTest::addColumn<QRegion>("region");
    QTest::addColumn<QRect>("rect");

    QRegion region(0, 0, 100, 100);
    QRegion complexRegion;
    complexRegion = complexRegion.united(QRect(0, 0, 100, 100));
    complexRegion = complexRegion.united(QRect(120, 20, 100, 100));

    {
        QRect rect(0, 0, 100, 100);
        QTest::newRow("same -- simple") << region << rect;
    }
    {
        QRect rect(10, 10, 10, 10);
        QTest::newRow("inside -- simple") << region << rect;
    }
    {
        QRect rect(110, 110, 10, 10);
        QTest::newRow("outside -- simple") << region << rect;
    }

    {
        QRect rect(0, 0, 100, 100);
        QTest::newRow("same -- complex") << complexRegion << rect;
    }
    {
        QRect rect(10, 10, 10, 10);
        QTest::newRow("inside -- complex") << complexRegion << rect;
    }
    {
        QRect rect(110, 110, 10, 10);
        QTest::newRow("outside -- complex") << complexRegion << rect;
    }
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:36,代码来源:main.cpp

示例7: painter

void UIFrameBufferQImage::paintSeamless(QPaintEvent *pEvent)
{
    /* Get rectangle to paint: */
    QRect paintRect = pEvent->rect().intersected(m_img.rect());
    if (paintRect.isEmpty())
        return;

    /* Create painter: */
    QPainter painter(m_pMachineView->viewport());

    /* Determine the region to erase: */
    lock();
    QRegion regionToErase = (QRegion)paintRect - m_syncVisibleRegion;
    unlock();
    if (!regionToErase.isEmpty())
    {
        /* Optimize composition-mode: */
        painter.setCompositionMode(QPainter::CompositionMode_Clear);
        /* Erase required region, slowly, rectangle-by-rectangle: */
        foreach (const QRect &rect, regionToErase.rects())
            painter.eraseRect(rect);
        /* Restore composition-mode: */
        painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    }
开发者ID:etiago,项目名称:vbox,代码行数:24,代码来源:UIFrameBufferQImage.cpp

示例8:

bool QS60WindowSurface::scroll(const QRegion &area, int dx, int dy)
{
    QRect rect = area.boundingRect();

    if (dx == 0 && dy == 0)
        return false;

    if (d_ptr->device.isNull())
        return false;

    QS60PixmapData *data = static_cast<QS60PixmapData*>(d_ptr->device.data_ptr().data());
    data->scroll(dx, dy, rect);

    return true;
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:15,代码来源:qwindowsurface_s60.cpp

示例9: shotRect

void Bullet::moveShot(){
    cout << "moveShot" << endl;
    QRegion region = shotRect();

    QRect shotR = shotRect();

    /*if (battleField->isHit(shotR)) return;
    else {
        region = region.united(shotR);
    }*/

    battleField->isHit(shotR);
    if (battleField->invaderArmy->isHit(shotR)){
        battleField->autoShootTimer->stop();
        return;
    }
    else if(shotR.y() < 0){
        cout << "MISSED" << endl;
        battleField->autoShootTimer->stop();
    }
    else region = region.united(shotR);

    update(region);
}
开发者ID:xMoad,项目名称:ihm-spaceinvaders,代码行数:24,代码来源:bullet.cpp

示例10: paintableRegion

void TilePainter::drawCells(int x, int y, TileLayer *tileLayer)
{
    const QRegion region = paintableRegion(x, y,
                                           tileLayer->width(),
                                           tileLayer->height());
    if (region.isEmpty())
        return;

    foreach (const QRect &rect, region.rects()) {
        for (int _x = rect.left(); _x <= rect.right(); ++_x) {
            for (int _y = rect.top(); _y <= rect.bottom(); ++_y) {
                const Cell &cell = tileLayer->cellAt(_x - x, _y - y);
                if (cell.isEmpty())
                    continue;

                mTileLayer->setCell(_x - mTileLayer->x(),
                                    _y - mTileLayer->y(),
                                    cell);
            }
        }
    }

    mMapDocument->emitRegionChanged(region);
}
开发者ID:Alex-Jenkins,项目名称:tiled,代码行数:24,代码来源:tilepainter.cpp

示例11: updateBlurRegion

void BlurEffect::updateBlurRegion(EffectWindow *w) const
{
    QRegion region;

    const QByteArray value = w->readProperty(net_wm_blur_region, XCB_ATOM_CARDINAL, 32);
    if (value.size() > 0 && !(value.size() % (4 * sizeof(unsigned long)))) {
        const unsigned long *cardinals = reinterpret_cast<const unsigned long*>(value.constData());
        for (unsigned int i = 0; i < value.size() / sizeof(unsigned long);) {
            int x = cardinals[i++];
            int y = cardinals[i++];
            int w = cardinals[i++];
            int h = cardinals[i++];
            region += QRect(x, y, w, h);
        }
    }

    if (region.isEmpty() && !value.isNull()) {
        // Set the data to a dummy value.
        // This is needed to be able to distinguish between the value not
        // being set, and being set to an empty region.
        w->setData(WindowBlurBehindRole, 1);
    } else
        w->setData(WindowBlurBehindRole, region);
}
开发者ID:KDE,项目名称:kde-workspace,代码行数:24,代码来源:blur.cpp

示例12: shotRect

void CannonField::moveShot()
{
  QRegion region = shotRect();
  ++timerCount;
  
  QRect shotR = shotRect();
  
  if(shotR.intersects(targetRect()))
  {
    autoShootTimer->stop();
    emit hit();
  }
  else if(shotR.x() > width() || shotR.y() > height())
  {
    autoShootTimer->stop();
    emit missed();
  }
  else
  {
    region = region.unite(shotR);
  }
  update(region);
  return;
}
开发者ID:jschueths,项目名称:Qt_Cannon,代码行数:24,代码来源:cannonfield.cpp

示例13: paintScreen

void ThumbnailAsideEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
    {
    effects->paintScreen( mask, region, data );
    foreach( const Data& d, windows )
        {
        if( region.contains( d.rect ))
            {
            WindowPaintData data( d.window );
            data.opacity = opacity;
            QRect region;
            setPositionTransformations( data, region, d.window, d.rect, Qt::KeepAspectRatio );
            effects->drawWindow( d.window, PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSLUCENT | PAINT_WINDOW_TRANSFORMED,
                region, data );
            }
        }
    }
开发者ID:lmurray,项目名称:kwin,代码行数:16,代码来源:thumbnailaside.cpp

示例14: repaint

void QFbWindow::repaint(const QRegion &region)
{
    QRect currentGeometry = geometry();

    QRect dirtyClient = region.boundingRect();
    QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(),
                      currentGeometry.top() + dirtyClient.top(),
                      dirtyClient.width(),
                      dirtyClient.height());
    QRect mOldGeometryLocal = mOldGeometry;
    mOldGeometry = currentGeometry;
    // If this is a move, redraw the previous location
    if (mOldGeometryLocal != currentGeometry)
        platformScreen()->setDirty(mOldGeometryLocal);
    platformScreen()->setDirty(dirtyRegion);
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:16,代码来源:qfbwindow.cpp

示例15: wangIdFromSurroundings

WangId WangFiller::wangIdFromSurroundings(const TileLayer &back,
                                          const QRegion &fillRegion,
                                          QPoint point) const
{
    Cell surroundingCells[8];

    QPoint adjacentPoints[8];
    getSurroundingPoints(point, mStaggeredRenderer, mStaggerAxis, adjacentPoints);

    for (int i = 0; i < 8; ++i) {
        if (!fillRegion.contains(adjacentPoints[i]))
            surroundingCells[i] = back.cellAt(adjacentPoints[i]);
    }

    return mWangSet->wangIdFromSurrounding(surroundingCells);
}
开发者ID:aTom3333,项目名称:tiled,代码行数:16,代码来源:wangfiller.cpp


注:本文中的QRegion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。