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


C++ QRect::intersect方法代码示例

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


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

示例1: write

static void write(QTextStream &ts, RenderLayer &l,
                  const QRect& layerBounds, const QRect& backgroundClipRect, const QRect& clipRect,
                  int layerType = 0, int indent = 0)
{
    writeIndent(ts, indent);
    
    ts << "layer";
    ts << " " << layerBounds;

    if (layerBounds != layerBounds.intersect(backgroundClipRect))
        ts << " backgroundClip " << backgroundClipRect;
    if (layerBounds != layerBounds.intersect(clipRect))
        ts << " clip " << clipRect;

    if (l.renderer()->hasOverflowClip()) {
        if (l.scrollXOffset())
            ts << " scrollX " << l.scrollXOffset();
        if (l.scrollYOffset())
            ts << " scrollY " << l.scrollYOffset();
        if (l.renderer()->clientWidth() != l.scrollWidth())
            ts << " scrollWidth " << l.scrollWidth();
        if (l.renderer()->clientHeight() != l.scrollHeight())
            ts << " scrollHeight " << l.scrollHeight();
    }

    if (layerType == -1)
        ts << " layerType: background only";
    else if (layerType == 1)
        ts << " layerType: foreground only";
    
    ts << "\n";

    if (layerType != -1)
        write(ts, *l.renderer(), indent + 1);
}
开发者ID:BackupTheBerlios,项目名称:wxwebcore-svn,代码行数:35,代码来源:KWQRenderTreeDebug.cpp

示例2: resizeRectFromEdgeCentered

QRect KstGfxMouseHandlerUtils::resizeRectFromEdgeCentered(const QRect& originalRect, const QPoint& anchorPoint, const QPoint& movePoint, const QPoint& pos, const QRect& bounds, bool maintainAspect) {
  QRect newRect;
  bool vertical;
  int newHalfWidth = abs((pos - anchorPoint).x());
  int newHalfHeight = abs((pos - anchorPoint).y());

  if (movePoint.x() == anchorPoint.x()) {
    vertical = true;
  } else {
    vertical = false;
  }

  if (maintainAspect) {
    QSize newSize(originalRect.size());

    if (vertical) {
      newHalfHeight = kMin(newHalfHeight, anchorPoint.y() - bounds.top());
      newHalfHeight = kMin(newHalfHeight, bounds.bottom() - anchorPoint.y());
      if (newHalfHeight > originalRect.height()/2) {
        newSize.scale(originalRect.width(), 2*newHalfHeight, QSize::ScaleMax);
      } else {
        newSize.scale(originalRect.width(), 2*newHalfHeight, QSize::ScaleMin);
      }
    } else {
      newHalfWidth = kMin(newHalfWidth, anchorPoint.x() - bounds.left());
      newHalfWidth = kMin(newHalfWidth, bounds.right() - anchorPoint.x());
      if (newHalfWidth > originalRect.width()/2) {
        newSize.scale(2*newHalfWidth, originalRect.height(), QSize::ScaleMax);
      } else {
        newSize.scale(2*newHalfWidth, originalRect.height(), QSize::ScaleMin);
      }
    }

    newRect.setSize(newSize);
    newRect.moveCenter(anchorPoint);
    newRect = newRect.intersect(bounds);
  } else {
    if (vertical) {
      newRect = QRect(0, 0, originalRect.width(), 2*newHalfHeight);
    } else {
      newRect = QRect(0, 0, 2*newHalfWidth, originalRect.height());
    }
    newRect.moveCenter(anchorPoint);
    newRect = newRect.intersect(bounds);
  }

  return newRect;
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:48,代码来源:kstgfxmousehandlerutils.cpp

示例3: fillRect

/*!
    Wrapper for QPainter::fillRect()
*/
void QwtPainter::fillRect(QPainter *painter,
    const QRect &rect, const QBrush &brush)
{
    if ( !rect.isValid() )
        return;

    QRect clipRect;
    const bool deviceClipping = isClippingNeeded(painter, clipRect);

#if QT_VERSION >= 0x040000
    /*
      Performance of Qt4 is horrible for non trivial brushs. Without
      clipping expect minutes or hours for repainting large rects
      (might result from zooming)
    */

    if ( deviceClipping )
        clipRect &= painter->window();
    else
        clipRect = painter->window();

    if ( painter->hasClipping() )
        clipRect &= painter->clipRegion().boundingRect();
#endif

    QRect r = d_metricsMap.layoutToDevice(rect, painter);
    if ( deviceClipping )
        r = r.intersect(clipRect);

    if ( r.isValid() )
        painter->fillRect(r, brush);
}
开发者ID:kuzavas,项目名称:qtiplot,代码行数:35,代码来源:qwt_painter.cpp

示例4: maskImage

QImage KisPixelSelection::maskImage(const QRect & rc) const
{
    // If part of a KisAdjustmentLayer, there may be no parent device.
    QImage img;
    QRect bounds;
    if (m_d->parentPaintDevice) {
        bounds = m_d->parentPaintDevice->exactBounds();
        bounds = bounds.intersect(rc);
        img = QImage(bounds.width(), bounds.height(), QImage::Format_RGB32);
    } else {
        bounds = rc;
        img = QImage(bounds.width(), bounds.height(), QImage::Format_RGB32);
    }

    KisHLineConstIteratorPixel it = createHLineConstIterator(bounds.x(), bounds.y(), bounds.width());
    for (int y2 = bounds.y(); y2 < bounds.height() - bounds.y(); ++y2) {
        int x2 = 0;
        while (!it.isDone()) {
            quint8 s = MAX_SELECTED - *(it.rawData());
            qint32 c = qRgb(s, s, s);
            img.setPixel(x2, y2, c);
            ++x2;
            ++it;
        }
        it.nextRow(); // XXX: Why wasn't this line here? Used to be
        // present in 1.6.
    }
    return img;
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例5: paintEvent

void PanelKMenu::paintEvent(QPaintEvent * e)
{
    if (sidePixmap.isNull()) {
        PanelServiceMenu::paintEvent(e);
        return;
    }

    QPainter p(this);
    p.setClipRegion(e->region());

    style().drawPrimitive( QStyle::PE_PanelPopup, &p,
                           QRect( 0, 0, width(), height() ),
                           colorGroup(), QStyle::Style_Default,
                           QStyleOption( frameWidth(), 0 ) );

    QRect r = sideImageRect();
    r.setBottom( r.bottom() - sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        p.drawTiledPixmap( r, sideTilePixmap );
    }

    r = sideImageRect();
    r.setTop( r.bottom() - sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        QRect drawRect = r.intersect( e->rect() );
        QRect pixRect = drawRect;
        pixRect.moveBy( -r.left(), -r.top() );
        p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect );
    }

    drawContents( &p );
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例6: applyFilter

void CGMainWindow::applyFilter(BaseFilter* filter)
{
    QMdiSubWindow *active = ui->mdiArea->activeSubWindow();
    if (active != NULL)
    {
        MdiElement* activeElement =
            dynamic_cast<MdiElement*> (active->widget());

        QImage image =  activeElement->pixmap().toImage();
        QImage result;
        if (!activeElement->isRubberBandVisible()) {
            result = filter->process(image);
        } else {
            QRectF selection = activeElement->getSelectionRect();
            QRect boundingRect = QRect(selection.left(), selection.top(), selection.width(), selection.height());
            boundingRect = boundingRect.intersect(image.rect());
            QImage toProcess = image.copy(boundingRect);
            QImage areaResult = filter->process(toProcess);
            result = image;
            for (int i = boundingRect.left(); i < boundingRect.right(); ++i) {
                for (int j = boundingRect.top(); j < boundingRect.bottom(); ++j) {
                    result.setPixel(i, j, areaResult.pixel(i - boundingRect.left(), j - boundingRect.top()));
                }
            }
            activeElement->hideRubberBand();

        }
        QPixmap pixmap = QPixmap::fromImage(result);
        activeElement->setPixmap(pixmap);

    }
}
开发者ID:itumashyk,项目名称:CG2012,代码行数:32,代码来源:cgmainwindow.cpp

示例7: select

void HTMLCell::select( KHTMLWidget *_htmlw, HTMLChain *_chain, QRect & _rect, int _tx, int _ty )
{
    HTMLObject *obj;

    QRect r( x + _tx, y - ascent + _ty, width, ascent + descent );

    _tx += x;
    _ty += y - ascent;

    bool sel = false;

    if ( _rect.contains( r ) )
    {
	sel = true;
    }
    else if ( !_rect.intersects( r ) )
    {
	sel = false;
    }
    else
    {
	QRect isect = _rect.intersect( r );
	if ( isect.width() > r.width()/2 && isect.height() > r.height()/2 )
	    sel = true;
    }

    _chain->push( this );

    for ( obj = head; obj != 0; obj = obj->next() )
	obj->select( _htmlw, _chain, sel, _tx, _ty );

    _chain->pop();
}
开发者ID:xwizard,项目名称:kde1,代码行数:33,代码来源:htmlclue.cpp

示例8: p

void
PrettyPopupMenu::paintEvent( QPaintEvent* e )
{
    generateSidePixmap();

    QPainter p( this );

    QRect r = sideImageRect();
    r.setTop( r.bottom() - s_sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        QRect drawRect = r.intersect( e->rect() ).intersect( sideImageRect() );
        QRect pixRect = drawRect;
        pixRect.moveBy( -r.left(), -r.top() );
        p.drawImage( drawRect.topLeft(), s_sidePixmap, pixRect );
    }

    p.setClipRegion( e->region() );


    //NOTE The order is important here. drawContents() must be called before drawPrimitive(),
    //     otherwise we get rendering glitches.

    drawContents( &p );

    style().drawPrimitive( QStyle::PE_PanelPopup, &p,
                           QRect( 0, 0, width(), height() ),
                           colorGroup(), QStyle::Style_Default,
                           QStyleOption( frameWidth(), 0 ) );
}
开发者ID:delight,项目名称:Pana,代码行数:30,代码来源:prettypopupmenu.cpp

示例9: endCapture

void ColourBrush::endCapture()
{
    if (mBrushBehavior != Capture)
        return;

    mBrushBehavior = Free;

    ColourLayer *colourLayer = currentColourLayer();
    Q_ASSERT(colourLayer);

    // Intersect with the layer and translate to layer coordinates
    QRect captured = capturedArea();
    captured.intersect(QRect(colourLayer->x(), colourLayer->y(),
                             colourLayer->width(), colourLayer->height()));

    if (captured.isValid()) {
        captured.translate(-colourLayer->x(), -colourLayer->y());
        ColourLayer *capture = colourLayer->copy(captured);
        emit currentTilesChanged(capture);
        // A copy will have been created, so delete this version
        delete capture;
    } else {
        updatePosition();
    }
}
开发者ID:JensRestemeier,项目名称:tiled,代码行数:25,代码来源:colourbrush.cpp

示例10: resizeRectFromCornerCentered

QRect KstGfxMouseHandlerUtils::resizeRectFromCornerCentered(const QRect& originalRect, const QPoint& pos, const QRect& bounds, bool maintainAspect) {
  QRect newRect;
  QPoint anchorPoint = originalRect.center();

  int newHalfWidth, newHalfHeight;

  newHalfWidth = abs((pos - anchorPoint).x());
  newHalfHeight = abs((pos - anchorPoint).y());

  if (maintainAspect) {
    newHalfWidth = kMin(newHalfWidth,anchorPoint.x() - bounds.left());
    newHalfWidth = kMin(newHalfWidth,bounds.right() - anchorPoint.x());

    newHalfHeight = kMin(newHalfHeight,anchorPoint.y() - bounds.top());
    newHalfHeight = kMin(newHalfHeight,bounds.bottom() - anchorPoint.y());

    QSize newSize(originalRect.size());
    newSize.scale(2*newHalfWidth, 2*newHalfHeight, QSize::ScaleMin);

    newRect.setSize(newSize);
    newRect.moveCenter(anchorPoint);
  } else {
    newRect = QRect(0, 0, 2*newHalfWidth, 2*newHalfHeight);
    newRect.moveCenter(anchorPoint);
    newRect = newRect.intersect(bounds);
  }

  return newRect;
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:29,代码来源:kstgfxmousehandlerutils.cpp

示例11: getViewableRect

QRect MyGraphicsView::getViewableRect() const
{
    if (mScene->items().size() == 0)
        return QRect();

    QRect r =
            mapToScene( viewport()->geometry() ).boundingRect().toRect();

    //qDebug() << "Rect " << r;

    if ( r.top() < 0 )
        r.setTop(0);

    if ( r.left() < 0 )
        r.setLeft(0);

    // get only intersection between pixmap and region
    #ifdef QT4
    r = r.intersect( mScene->sceneRect().toRect() );
    #else
    r = r.intersected( mScene->sceneRect().toRect() );
    #endif

    //qDebug() << "Rect2 " << r;

    return r;
}
开发者ID:quimnuss,项目名称:superannotator,代码行数:27,代码来源:mygraphicsview.cpp

示例12: paintEvent

void PanelKMenu::paintEvent(QPaintEvent * e)
{
    if (sidePixmap.isNull()) {
        PanelServiceMenu::paintEvent(e);
        return;
    }

    QPainter p(this);
    p.setClipRegion(e->region());

    QStyleOptionFrame frOpt;
    frOpt.init(this);
    frOpt.lineWidth    = frameWidth();
    frOpt.midLineWidth = 0;
    style()->drawPrimitive( QStyle::PE_FrameMenu, &frOpt, &p, this);

    QRect r = sideImageRect();
    r.setBottom( r.bottom() - sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        p.drawTiledPixmap( r, sideTilePixmap );
    }

    r = sideImageRect();
    r.setTop( r.bottom() - sidePixmap.height() );
    if ( r.intersects( e->rect() ) )
    {
        QRect drawRect = r.intersect( e->rect() );
        QRect pixRect = drawRect;
        pixRect.translate( -r.left(), -r.top() );
        p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect );
    }

    PanelServiceMenu::paintEvent( e );
}
开发者ID:jschwartzenberg,项目名称:kicker,代码行数:35,代码来源:k_mnu.cpp

示例13: paintEvent

/*!\reimp
*/
void QSlider::paintEvent( QPaintEvent * )
{

    QPainter p( this );
    const QRect & sliderR = sliderRect();
    const QColorGroup & g = colorGroup();
    int mid = thickness()/2;
    if ( ticks & Above )
	mid += style().sliderLength() / 8;
    if ( ticks & Below )
	mid -= style().sliderLength() / 8;
    if ( orient == Horizontal ) {
	style().drawSliderGroove(&p, 0, tickOffset, width(), thickness(),
				     g, mid, Horizontal );
// 	    p.fillRect( 0, 0, width(), tickOffset, g.background() );
// 	    p.fillRect( 0, tickOffset + thickness(),
// 			width(), height()/*###*/, g.background() );
	erase( 0, 0, width(), tickOffset );
	erase( 0, tickOffset + thickness(), width(), height() );
    }
    else {
	style().drawSliderGroove( &p, tickOffset, 0, thickness(), height(),
				      g, mid, Vertical );
// 	    p.fillRect( 0, 0,  tickOffset, height(), g.background() );
// 	    p.fillRect( tickOffset + thickness(), 0,
// 			width()/*###*/, height(), g.background() );
	erase( 0, 0,  tickOffset, height() );
	erase( tickOffset + thickness(), 0, width()/*###*/, height() );
    }

    int interval = tickInt;
    if ( interval <= 0 ) {
	interval = lineStep();
	if ( positionFromValue( interval ) - positionFromValue( 0 ) < 3 )
	    interval = pageStep();
    }
    if ( ticks & Above )
	drawTicks( &p, g, 0, tickOffset - 2, interval );

    if ( ticks & Below ) {
	int avail = (orient == Horizontal) ? height() : width();
	avail -= tickOffset + thickness();
	drawTicks( &p, g, tickOffset + thickness() + 1, avail - 2, interval );
    }
    if ( hasFocus() ) {
	QRect r;
	if ( orient == Horizontal )
	    r.setRect( 0, tickOffset-1, width(), thickness()+2 );
	else
	    r.setRect( tickOffset-1, 0, thickness()+2, height() );
	r = r.intersect( rect() );
	if (style() == MotifStyle)
	    style().drawFocusRect(&p, QRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2), g);
	else
	    style().drawFocusRect(&p, r, g);
    }
    paintSlider( &p, g, sliderR );

}
开发者ID:kthxbyte,项目名称:QT2-Linaro,代码行数:61,代码来源:qslider.cpp

示例14: alphaMaskRect

void
SegmentTip::moveTo(QPoint p, QWidget &canvas, bool placeAbove)
{
    //**** this function is very slow and seems to be visibly influenced by operations like mapFromGlobal() (who knows why!)
    //  ** so any improvements are much desired

    //TODO uints could improve the class
    p.rx() -= rect().center().x();
    p.ry() -= (placeAbove ? 8 + height() : m_cursorHeight - 8);

    const QRect screen = KGlobalSettings::desktopGeometry(parentWidget());

    const int x  = p.x();
    const int y  = p.y();
    const int x2 = x + width();
    const int y2 = y + height(); //how's it ever gunna get below screen height?! (well you never know I spose)
    const int sw = screen.width();
    const int sh = screen.height();

    if (x  < 0 ) p.setX(0);
    if (y  < 0 ) p.setY(0);
    if (x2 > sw) p.rx() -= x2 - sw;
    if (y2 > sh) p.ry() -= y2 - sh;


    //I'm using this QPoint to determine where to offset the bitBlt in m_pixmap
    QPoint offset = canvas.mapToGlobal(QPoint()) - p;
    if (offset.x() < 0) offset.setX(0);
    if (offset.y() < 0) offset.setY(0);


    const QRect alphaMaskRect(canvas.mapFromGlobal(p), size());
    const QRect intersection(alphaMaskRect.intersect(canvas.rect()));

    m_pixmap = QPixmap(size()); //move to updateTip once you are sure it can never be null

    const QColor c = QToolTip::palette().color(QPalette::Active, QPalette::Background);
    if (!m_backing_store)
        m_pixmap.fill(c);

    QPainter paint(&m_pixmap);
    paint.setPen(Qt::black);
    paint.setBrush(Qt::NoBrush);
    paint.drawRect(rect());
    paint.end();

    /* if (m_backing_store)
        m_pixmap = QPixmap::fromImage(Blitz::fade(m_pixmap.toImage() , 0.6f, c)); */ // TODO: reimplement this

    paint.begin(&m_pixmap);
    paint.drawText(rect(), Qt::AlignCenter, m_text);
    paint.end();

    p += screen.topLeft(); //for Xinerama users

    move(x, y);
    show();
    update();
}
开发者ID:sandsmark,项目名称:filelight,代码行数:59,代码来源:segmentTip.cpp

示例15: updateMask

/*!\reimp
 */
void QRadioButton::updateMask()
{
    QBitmap bm(width(),height());
    {
	bm.fill(color0);
	QPainter p( &bm, this );
	int x, y, w, h;
	GUIStyle gs = style();
	QFontMetrics fm = fontMetrics();
	QSize lsz = fm.size(ShowPrefix, text());
	QSize sz = style().exclusiveIndicatorSize();
	if ( gs == WindowsStyle )
	    sz.setWidth(sz.width()+1);
	y = 0;
	x = sz.width() + gutter;
	w = width() - x;
	h = height();

	QColorGroup cg(color1,color1, color1,color1,color1,color1,color1,color1, color0);

	style().drawItem( &p, x, y, w, h,
			  AlignLeft|AlignVCenter|ShowPrefix,
			  cg, TRUE,
			  pixmap(), text() );
	x = 0;
	y = (height() - lsz.height() + fm.height() - sz.height())/2;

	style().drawExclusiveIndicatorMask(&p, x, y, sz.width(), sz.height(), isOn() );

	if ( hasFocus() ) {
 	    y = 0;
 	    x = sz.width() + gutter;
 	    w = width() - x;
 	    h = height();
	    QRect br = style().itemRect( &p, x, y, w, h,
					 AlignLeft|AlignVCenter|ShowPrefix,
					 isEnabled(),
					 pixmap(), text() );
	    br.setLeft( br.left()-3 );
	    br.setRight( br.right()+2 );
	    br.setTop( br.top()-2 );
	    br.setBottom( br.bottom()+2);
	    br = br.intersect( QRect(0,0,width(),height()) );

	    if ( !text().isEmpty() )
		style().drawFocusRect( &p, br, cg );
	    else {
		br.setRight( br.left()-1 );
		br.setLeft( br.left()-16 );
		br.setTop( br.top() );
		br.setBottom( br.bottom() );
		style().drawFocusRect( &p, br, cg );
	    }

	}
    }
    setMask(bm);
}
开发者ID:kthxbyte,项目名称:QT2-Linaro,代码行数:60,代码来源:qradiobutton.cpp


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