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


C++ QRectF::intersected方法代码示例

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


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

示例1: clipAndDrawPixmap

void QBlitterPaintEnginePrivate::clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr, bool opacity)
{
    Q_Q(QBlitterPaintEngine);
    QRectF intersectedRect = clip.intersected(target);
    if (intersectedRect.isEmpty())
        return;
    QRectF source = sr;
    if (intersectedRect.size() != target.size()) {
        if (sr.size() == target.size()) {
            // no resize
            qreal deltaTop = target.top() - intersectedRect.top();
            qreal deltaLeft = target.left() - intersectedRect.left();
            qreal deltaBottom = target.bottom() - intersectedRect.bottom();
            qreal deltaRight = target.right() - intersectedRect.right();
            source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
        } else {
            // resize case
            qreal hFactor = sr.size().width() / target.size().width();
            qreal vFactor = sr.size().height() / target.size().height();
            qreal deltaTop = (target.top() - intersectedRect.top()) * vFactor;
            qreal deltaLeft = (target.left() - intersectedRect.left()) * hFactor;
            qreal deltaBottom = (target.bottom() - intersectedRect.bottom()) * vFactor;
            qreal deltaRight = (target.right() - intersectedRect.right()) * hFactor;
            source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
        }
    }
    pmData->unmarkRasterOverlay(intersectedRect);
    if (opacity)
        pmData->blittable()->drawPixmapOpacity(intersectedRect, pm, source, q->state()->compositionMode(), q->state()->opacity);
    else
        pmData->blittable()->drawPixmap(intersectedRect, pm, source);
}
开发者ID:13W,项目名称:phantomjs,代码行数:32,代码来源:qpaintengine_blitter.cpp

示例2: drawBackground

void PlotGraph::drawBackground(QPainter *painter, const QRectF &rect)
{
    Q_UNUSED(rect);

    // Shadow
    QRectF sceneRect = this->sceneRect();

    // Fill
    QLinearGradient gradient(sceneRect.topLeft(), sceneRect.bottomRight());
    gradient.setColorAt(0, Qt::white);
    gradient.setColorAt(1, Qt::white);
    painter->setOpacity(0.7);
    painter->fillRect(rect.intersected(sceneRect), gradient);
    painter->setBrush(Qt::NoBrush);
    painter->drawRect(sceneRect);

    painter->setPen(QPen(Qt::black, 3));
    painter->drawLine(
                QPointF(xOrigin, yMax),
                QPointF(xOrigin, yOrigin + 10));
    painter->drawLine(
                QPointF(xOrigin - 5, yOrigin),
                QPointF(xMax, yOrigin));

}
开发者ID:vultor33,项目名称:BacteriaGraphic,代码行数:25,代码来源:PlotGraph.cpp

示例3: mouseMoveEvent

void BlurItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
  QGraphicsRectItem::mouseMoveEvent(event);

  const QPointF pos = event->scenePos();
  QRectF r;

  r.setTopLeft(m_point);
  r.setBottomRight(event->scenePos());

  if (r.width() < 0) {
    r.setLeft(pos.x());
    r.setRight(m_point.x());
  }

  if (r.height() < 0) {
    r.setTop(pos.y());
    r.setBottom(m_point.y());
  }

  r = r.intersected(m_item->scene()->sceneRect());

  setRect(r);
  setSelected(true);
  m_item->setOffset(r.topLeft());

  reload(m_pixmap);
}
开发者ID:impomezia,项目名称:screenpic,代码行数:28,代码来源:BlurItem.cpp

示例4: draw

void ListItemCache::draw(QPainter * painter) 
{
    QRectF irect = sourceBoundingRect(Qt::LogicalCoordinates);
    QRectF vrect = painter->clipPath().boundingRect();

    if (vrect.intersects(irect)) {
        QRectF newVisibleRect = irect.intersected(vrect);
        QPixmap pixmap;

        if (!QPixmapCache::find(m_cacheKey, &pixmap) ||
            m_visibleRect.toRect() != newVisibleRect.toRect()) {
            //qDebug() << "ListItemCache: caching" << m_visibleRect
            //    << "->" << newVisibleRect;

            pixmap = QPixmap(sourceBoundingRect().toRect().size());
            pixmap.fill(Qt::transparent);

            QPainter pixmapPainter(&pixmap);
            drawSource(&pixmapPainter);
            pixmapPainter.end();
            m_cacheKey = QPixmapCache::insert(pixmap);

            m_visibleRect = newVisibleRect;
        }

        //qDebug() << "ListItemCache: blitting" << m_visibleRect;
        painter->drawPixmap(0, 0, pixmap);
    } 
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:29,代码来源:listitemcache.cpp

示例5: paint

//virtual
void DemoGoggles::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
{
	//map myself into the scene
	QRectF sceneRect = mapRectToScene(boundingRect());
	QRectF sourceRect = sceneRect.intersected(m_sceneBgViewrect).translated(-m_sceneBgViewrect.topLeft());
	m_qp_backgroundPmo->paint(painter,boundingRect().toRect(),sourceRect.toRect());
}
开发者ID:ctbrowser,项目名称:luna-sysmgr,代码行数:8,代码来源:demogoggles.cpp

示例6: paint

void QgsTextAnnotationItem::paint( QPainter * painter )
{
  if ( !painter || !mDocument )
  {
    return;
  }

  drawFrame( painter );
  if ( mMapPositionFixed )
  {
    drawMarkerSymbol( painter );
  }
  double frameWidth = mFrameBorderWidth;
  mDocument->setTextWidth( mFrameSize.width() );

  painter->save();
  painter->translate( mOffsetFromReferencePoint.x() + frameWidth / 2.0,
                      mOffsetFromReferencePoint.y() + frameWidth / 2.0 );

  QRectF clipRect = QRectF( 0, 0, mFrameSize.width() - frameWidth / 2.0, mFrameSize.height() - frameWidth / 2.0 );
  if ( painter->hasClipping() )
  {
    //QTextDocument::drawContents will draw text outside of the painter's clip region
    //when it is passed a clip rectangle. So, we need to intersect it with the
    //painter's clip region to prevent text drawn outside clipped region (eg, outside composer maps, see #10400)
    clipRect = clipRect.intersected( painter->clipRegion().boundingRect() );
  }
  //draw text document
  mDocument->drawContents( painter, clipRect );
  painter->restore();
  if ( isSelected() )
  {
    drawSelectionBoxes( painter );
  }
}
开发者ID:NyakudyaA,项目名称:QGIS,代码行数:35,代码来源:qgstextannotationitem.cpp

示例7: inv_transform

void
PixmapRenderer::drawPixmapNoXRender(QPainter& painter, QPixmap const& pixmap)
{
	QTransform const inv_transform(painter.worldTransform().inverted());
	QRectF const src_rect(inv_transform.map(QRectF(painter.viewport())).boundingRect());
	QRectF const bounded_src_rect(src_rect.intersected(pixmap.rect()));
	painter.drawPixmap(bounded_src_rect, pixmap, bounded_src_rect);
}
开发者ID:DikBSD,项目名称:STE,代码行数:8,代码来源:PixmapRenderer.cpp

示例8: positionVisibility

qreal ItemSpace::positionVisibility (const QRectF& geom)
{
    QRectF visibleArea = QRectF(QPointF(), workingGeom);
    QRectF visibleItemPart = visibleArea.intersected(geom);
    qreal itemSurface = geom.width() * geom.height();
    qreal itemVisibleSurface = visibleItemPart.width() * visibleItemPart.height();
    return (itemVisibleSurface / itemSurface);
}
开发者ID:d42,项目名称:cashewless-desktop,代码行数:8,代码来源:itemspace.cpp

示例9: selectionChanged

void HotPointView::selectionChanged( const QRectF& rect )
{
	if (!item) return;	  
	if ( rect.isNull() && m_selection ) {
		graphicsView->scene()->removeItem( m_selection );
		delete m_selection;
		m_selection = 0;
	}

	if ( !rect.isNull() && !m_selection ) {
		m_selection = graphicsView->scene()->addRect( rect.intersected(item->boundingRect()).normalized(), QPen(Qt::DashDotLine), QBrush::QBrush(Qt::DiagCrossPattern));
		m_selection->setParentItem(item);
	}

	if ( !rect.isNull() && m_selection ) {
		m_selection->setRect( rect.intersected(item->boundingRect()).normalized() );
	}
}
开发者ID:mmalicki2,项目名称:QOczko,代码行数:18,代码来源:HotPointView.cpp

示例10: drawBackground

void InsideBase::drawBackground( QPainter * painter, const QRectF& rect )
{
	if( _background ) {
		painter->fillRect( rect, Qt::black );
		QRectF tmp = rect.intersected( sceneRect() );
		painter->drawPixmap( tmp, * _background, tmp );
	} else {
		painter->fillRect( rect, Qt::black );
	}
}
开发者ID:q4a,项目名称:attal,代码行数:10,代码来源:insideBase.cpp

示例11: paint

void CanvasRect::paint(QPainter *painter, const QTransform &tran, const QRectF &limits)
{
    QRectF plotRect = bounds();
    // Let's not waste time here...
    if (!limits.intersects(plotRect)) return;

    // TODO: This boilerplate style stuff to a CanvasShape::applyStyle(QPainter*) func?
    QPen pen;
    LineSpec *ln = lineSpec();
    pen.setColor(ln->color());
    pen.setWidthF(ln->width());

    QString style = ln->style();
    if (style == ".") {
        pen.setStyle(Qt::SolidLine);
    } else {
        pen.setStyle( LineSpec::styleMap[style] );
    }

    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    brush.setColor(fillSpec()->color());

    painter->setRenderHint(QPainter::Antialiasing);

    // Only draw the part of the rect in the view
    QRectF rect = limits.intersected(plotRect);
    // Figure out which sides still need lines...
    QVector<QLineF> lines;
    if (rect.left() == plotRect.left())
        lines << QLineF(rect.bottomLeft(), rect.topLeft());
    if (rect.right() == plotRect.right())
        lines << QLineF(rect.bottomRight(), rect.topRight());
    if (rect.top() == plotRect.top())
        lines << QLineF(rect.topLeft(), rect.topRight());
    if (rect.bottom() == plotRect.bottom())
        lines << QLineF(rect.bottomLeft(), rect.bottomRight());

    // Map the fill and lines
    QRectF mappedRect = tran.mapRect(rect);
    for (int i=0; i<lines.length(); ++i) {
        lines[i] = tran.map(lines[i]);
    }

    // Draw the rect
    painter->setPen(Qt::NoPen);
    painter->setBrush(brush);
    painter->drawRect(mappedRect);

    // Draw the outline
    painter->setBrush(Qt::NoBrush);
    painter->setPen(pen);
    painter->drawLines(lines);
}
开发者ID:pjmahoney,项目名称:nutmeg,代码行数:54,代码来源:canvasrect.cpp

示例12: drawBackground

void FormEditorGraphicsView::drawBackground(QPainter *painter, const QRectF &rectangle)
{
    painter->save();
    painter->setBrushOrigin(0, 0);

    painter->fillRect(rectangle.intersected(rootItemRect()), backgroundBrush());
    // paint rect around editable area
    painter->setPen(Qt::black);
    painter->drawRect( rootItemRect());
    painter->restore();
}
开发者ID:yinyunqiao,项目名称:qtcreator,代码行数:11,代码来源:formeditorgraphicsview.cpp

示例13: drawBackground

void FormEditorGraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
{
    painter->save();
    painter->setBrushOrigin(0, 0);
    painter->fillRect(rect.intersected(sceneRect()), backgroundBrush());
    // paint rect around editable area
    painter->setPen(Qt::black);
    QRectF frameRect = sceneRect().adjusted(0, 0, 0, 0);
    painter->drawRect(frameRect);
    painter->restore();
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:11,代码来源:formeditorgraphicsview.cpp

示例14: clipAndDrawPixmap

 void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr) {
     QRectF intersectedRect = clip.intersected(target);
     if (intersectedRect.isEmpty())
         return;
     QRectF source = sr;
     if(intersectedRect.size() != target.size()) {
         qreal deltaTop = target.top() - intersectedRect.top();
         qreal deltaLeft = target.left() - intersectedRect.left();
         qreal deltaBottom = target.bottom() - intersectedRect.bottom();
         qreal deltaRight = target.right() - intersectedRect.right();
         source.adjust(-deltaLeft,-deltaTop,-deltaRight,-deltaBottom);
     }
     pmData->unmarkRasterOverlay(intersectedRect);
     pmData->blittable()->drawPixmap(intersectedRect, pm, source);
 }
开发者ID:Blizzard,项目名称:qt4,代码行数:15,代码来源:qpaintengine_blitter.cpp

示例15: drawBackground

void widget::drawBackground(QPainter *painter, const QRectF &rect)
{
    Q_UNUSED(rect);

    // Shadow
    QRectF sceneRect = this->sceneRect();

    // Fill
    QLinearGradient gradient(sceneRect.topLeft(), sceneRect.bottomRight());
    gradient.setColorAt(0, Qt::white);
    gradient.setColorAt(1, Qt::blue);
    painter->setOpacity(0.7);
    painter->fillRect(rect.intersected(sceneRect), gradient);
    painter->setBrush(Qt::NoBrush);
    painter->drawRect(sceneRect);
}
开发者ID:vultor33,项目名称:Bacterial,代码行数:16,代码来源:widget.cpp


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