本文整理汇总了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);
}
示例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));
}
示例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);
}
示例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);
}
}
示例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());
}
示例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 );
}
}
示例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);
}
示例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);
}
示例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() );
}
}
示例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 );
}
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}