void EPGItem::paint( QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*) { // Draw in view's coordinates painter->setWorldMatrixEnabled( false ); // Draw high-quality items //painter->setRenderHint( QPainter::Antialiasing ); // Get the transformations required to map the text on the viewport QTransform viewPortTransform = m_view->viewportTransform(); QRectF mapped = deviceTransform( viewPortTransform ).mapRect( boundingRect() ); if ( m_current ) { painter->setBrush( QBrush( QColor( 244, 102, 146 ) ) ); painter->setPen( QPen( QColor( 244, 102, 146 ) ) ); } else { painter->setBrush( QBrush( QColor( 201, 217, 242 ) ) ); painter->setPen( QPen( QColor( 201, 217, 242 ) ) ); } mapped.adjust( 1, 2, -1, -2 ); painter->drawRoundedRect( mapped, 10, 10 ); /* Draw text */ // Setup the font QFont f = painter->font(); // Get the font metrics QFontMetrics fm = painter->fontMetrics(); // Adjust the drawing rect mapped.adjust( 6, 6, -6, -6 ); painter->setPen( Qt::black ); /* Draw the title. */ painter->drawText( mapped, Qt::AlignTop | Qt::AlignLeft, fm.elidedText( m_name, Qt::ElideRight, mapped.width() ) ); mapped.adjust( 0, 20, 0, 0 ); QDateTime m_end = m_start.addSecs( m_duration ); f.setPixelSize( 10 ); f.setItalic( true ); painter->setFont( f ); /* Draw the hours. */ painter->drawText( mapped, Qt::AlignTop | Qt::AlignLeft, fm.elidedText( m_start.toString( "hh:mm" ) + " - " + m_end.toString( "hh:mm" ), Qt::ElideRight, mapped.width() ) ); }
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); }
QRectF UBGraphicsPathItem::boundingRect() const { QRectF rect = path().boundingRect(); int enlarge = 0; if (strokeProperty()) { int thickness = strokeProperty()->width(); enlarge = thickness/2; } if (mIsInCreationMode)//gérer les poignées aux extrémités enlarge += HANDLE_SIZE/2; rect.adjust(-enlarge, -enlarge, enlarge, enlarge); if(mMultiClickState >= 1){ qreal r = mHandles.first()->radius(); rect.adjust(-r, -r, r, r); } return rect; }
void GInstructionView::FitInstructionInView() { if(!m_pInstruction || !m_pInsScene) return; // setSceneRect(m_pInstruction->BoundingSceneRect()); fitInView(&m_pInstruction->m_GraphicsItem); QRectF SceneRect = sceneRect(); if(!SceneRect.isValid()) return; // we don't want blank areas at the beginning or at the ending of the G_old_Instruction in the QGraphicsView // so here is what we are going to do: we will see what is the viewport coordinate in the scene,... // then, we will add 1 or so, and change the scene coordinate so that it corresponds to the beginning/ending of the G_old_Instruction fitInView(SceneRect); QRect geomView = geometry(); int Xini = -1; int Xfin = geomView.width() - 3; if(Xfin <= 2) return; double Xiniscene = mapToScene(Xini, 0).rx(); double Xfinscene = mapToScene(Xfin, 0).rx() - m_pInstruction->Duration(); SceneRect.adjust(- Xiniscene, 0, - Xfinscene, 0); setSceneRect(SceneRect); fitInView(SceneRect); }
inline QRectF scaledBoundingRect( double sx, double sy, bool scalePens ) const { if ( sx == 1.0 && sy == 1.0 ) return d_boundingRect; QTransform transform; transform.scale( sx, sy ); QRectF rect; if ( scalePens && d_scalablePen ) { rect = transform.mapRect( d_boundingRect ); } else { rect = transform.mapRect( d_pointRect ); const double l = qAbs( d_pointRect.left() - d_boundingRect.left() ); const double r = qAbs( d_pointRect.right() - d_boundingRect.right() ); const double t = qAbs( d_pointRect.top() - d_boundingRect.top() ); const double b = qAbs( d_pointRect.bottom() - d_boundingRect.bottom() ); rect.adjust( -l, -t, r, b ); } return rect; }
void PieChart::paint(QPainter *painter) { painter->setRenderHints(QPainter::Antialiasing, true); //Обчислення області для малювання QRectF fillRect = boundingRect(); if(fillRect.height() > fillRect.width()){ fillRect.setY(fillRect.y() + (fillRect.height()-fillRect.width())/2); fillRect.setHeight(fillRect.width()); } else { fillRect.setX(fillRect.x() + (fillRect.width()-fillRect.height())/2); fillRect.setWidth(fillRect.height()); } fillRect.adjust(pStrokePen->width(), pStrokePen->width(), -pStrokePen->width(), -pStrokePen->width()); //Малювання сегментів painter->setPen(pStrokePen->getPen()); double beginAngle = pAngleOffset; double segmentAngle; for(PieSlice* i:slicesList){ painter->setBrush(QBrush(i->color())); segmentAngle = 5760.0 * fabs(i->value())/sumSliceValue; painter->drawPie(fillRect, beginAngle, segmentAngle); beginAngle += segmentAngle; } }
QRectF dmz::QtCanvasObjectText::_outline_rect () const { QRectF rect; if (_text.length ()) { const int Padding (8); QFontMetricsF metrics = qApp->font (); rect.setSize (metrics.size (0, _text)); if (_drawBackground) { rect.adjust (-Padding, -Padding, Padding, Padding); } if (_alignment == Qt::AlignLeft) { rect.translate (0, -rect.center ().y ()); } else if (_alignment == Qt::AlignRight) { rect.translate (-rect.width (), -rect.center ().y ()); } else { rect.translate (-rect.center ()); } } return rect; }
void CSceneWidget::mousePressEvent(QMouseEvent *event) { if(event->button() != Qt::LeftButton) { QGraphicsView::mousePressEvent(event); return; } if(QGraphicsItem *item = itemAt(event->pos())) { _currentItem = qgraphicsitem_cast<CGraphicsItem*>(item); if(_currentItem != 0 && !_currentItem->isEditMode()) { _currentItem = 0; return; } QRectF rect = _currentItem->sceneBoundingRect(); rect.adjust(0,0,rect.x() -RESIZE_BOX, rect.y() -RESIZE_BOX); QPoint point = mapFromScene(rect.width(),rect.height()); if(point.x() < event->pos().x() && point.y() < event->pos().y()) { _resizeBegin = true; } _offsetMove = event->pos() - item->pos(); } QGraphicsView::mousePressEvent(event); }
void SelectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); // delay load song info loadSong(); QRectF rect = boundingRect().adjusted(BAR_PAD,BAR_PAD,0 - BAR_PAD,0 - BAR_PAD); // draw header QRectF rectHead = QRectF(rect.topLeft(),QSizeF(rect.width(),HEAD_HEIGHT)); painter->fillRect(rectHead,backColor_); // draw body QRectF rectBody = QRectF(rectHead.bottomLeft(),QSizeF(rect.width(),rect.height() - HEAD_HEIGHT)); painter->drawPixmap( rectBody.left(),rectBody.top(), barLeftPixmap_.width(),rectBody.height(), barLeftPixmap_); painter->drawPixmap( rectBody.right() - barRightPixmap_.width(),rectBody.top(), barRightPixmap_.width(),rectBody.height(), barRightPixmap_); painter->drawPixmap( rectBody.left() + barLeftPixmap_.width(),rectBody.top(), rectBody.width() - barLeftPixmap_.width() - barRightPixmap_.width(),rectBody.height(), barMidPixmap_); rectBody.adjust(BAR_MARGIN,BAR_MARGIN,0 - BAR_MARGIN,0 - BAR_MARGIN); painter->setFont(QFont(Ts::GUI_FONT_NAME,15)); if (rect_.width() == Ts::BAR_EXPAND) { painter->setPen(foreColor_); painter->drawText(rectHead,Qt::AlignCenter,QString("%1/%2").arg(index_).arg(total_)); painter->setPen(Qt::black); painter->drawText( rectBody.right() - 30,rectBody.top(),30,rectBody.height(), Qt::AlignHCenter,title_); painter->drawText( rectBody.right() - 60,rectBody.top(),30,rectBody.height(), Qt::AlignHCenter | Qt::AlignBottom,subTitle_); // show courses courses_.show(); } else { painter->setPen(foreColor_); painter->drawText(rectHead,Qt::AlignCenter,QString::number(index_)); painter->setPen(Qt::black); painter->drawText(rectBody,Qt::AlignCenter,title_); courses_.hide(); } }
void KisCoordinatesConverter::getQPainterCheckersInfo(QTransform *transform, QPointF *brushOrigin, QPolygonF *polygon) const { /** * Qt has different rounding for QPainter::drawRect/drawImage. * The image is rounded mathematically, while rect in aligned * to the next integer. That causes transparent line appear on * the canvas. * * See: https://bugreports.qt.nokia.com/browse/QTBUG-22827 */ QRectF imageRect = imageRectInViewportPixels(); imageRect.adjust(0,0,-0.5,-0.5); KisConfig cfg; if (cfg.scrollCheckers()) { *transform = viewportToWidgetTransform(); *polygon = imageRect; *brushOrigin = imageToViewport(QPointF(0,0)); } else { *transform = QTransform(); *polygon = viewportToWidgetTransform().map(imageRect); *brushOrigin = QPoint(0,0); } }
void MContainerHeaderView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_UNUSED(event); style().setModeDefault(); if (!expectMouseReleaseEvent) { return; } QPointF touch = event->scenePos(); qreal distanceFromPressPoint = (touch - pressScenePos).manhattanLength(); QRectF rect = controller->sceneBoundingRect(); rect.adjust(-M_RELEASE_MISS_DELTA, -M_RELEASE_MISS_DELTA, M_RELEASE_MISS_DELTA, M_RELEASE_MISS_DELTA); if (distanceFromPressPoint > style()->maxDistanceForClick() || !rect.contains(touch)) { // Too far: cancel expectMouseReleaseEvent = false; QApplication::postEvent(controller, new MCancelEvent); return; } update(); }
void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item) { QGraphicsItem *prevItem = m_currentItem; m_currentItem = item; if (!m_currentItem) return; QRect viewRect = m_inspector->declarativeView()->rect(); viewRect = m_inspector->declarativeView()->mapToScene(viewRect).boundingRect().toRect(); QRectF itemRect = item->boundingRect() | item->childrenBoundingRect(); itemRect = item->mapRectToScene(itemRect); // if updating the same item as before, resize the rectangle only bigger, not smaller. if (prevItem == item && prevItem != 0) { m_itemPolyRect = resizeRect(itemRect, m_itemPolyRect); } else { m_itemPolyRect = itemRect; } QRectF borderRect = m_itemPolyRect; borderRect.adjust(-1, -1, 1, 1); m_borderRect->setRect(borderRect); const QRegion externalRegion = QRegion(viewRect).subtracted(m_itemPolyRect.toRect()); setPolygon(regionToPolygon(externalRegion)); }
QRectF ArrowItem::boundingRect() const { QRectF br = p.boundingRect(); qreal pw = pen().widthF(); br.adjust(-pw/2, -pw/2, pw/2, pw/2); return t.mapRect(br); }
void DesignerGUIUtils::paintSamplesArrow(QPainter* painter) { QPen pen(Qt::darkGray); pen.setWidthF(2); painter->setPen(pen); painter->setRenderHint(QPainter::SmoothPixmapTransform); QFont f = painter->font(); painter->resetTransform(); f.setFamily("Times New Roman"); f.setPointSizeF(20); f.setItalic(true); painter->setFont(f); QRectF approx(50,50, 400, 400); QString txt = QObject::tr("Select a sample to start"); QRectF res = painter->boundingRect(approx, Qt::AlignLeft | Qt::AlignTop, txt); res.adjust(-5,-3,15,3); QPainterPath p(QPointF(5, res.center().y())); p.lineTo(res.topLeft()); p.lineTo(res.topRight()); p.lineTo(res.bottomRight()); p.lineTo(res.bottomLeft()); p.closeSubpath(); QColor yc = QColor(255,255,160);//QColor(Qt::yellow).lighter();yc.setAlpha(127); painter->fillPath(p, QBrush(yc)); painter->drawPath(p); painter->setPen(Qt::black); painter->drawText(approx, Qt::AlignLeft | Qt::AlignTop, txt); }
void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const QByteArray& previous) { Q_UNUSED(previous); QGraphicsView* parent = scene()->views()[0]; if (current.isEmpty() || !parent || current != "text") { if (m_roleEditor) { emit roleEditingCanceled(index(), current, data().value(current)); disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant))); disconnect(m_roleEditor, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant))); m_roleEditor->deleteLater(); m_roleEditor = 0; } return; } Q_ASSERT(!m_roleEditor); const TextInfo* textInfo = m_textInfo.value("text"); m_roleEditor = new KItemListRoleEditor(parent); m_roleEditor->setIndex(index()); m_roleEditor->setRole(current); m_roleEditor->setFont(styleOption().font); const QString text = data().value(current).toString(); m_roleEditor->setPlainText(text); QTextOption textOption = textInfo->staticText.textOption(); m_roleEditor->document()->setDefaultTextOption(textOption); const int textSelectionLength = selectionLength(text); if (textSelectionLength > 0) { QTextCursor cursor = m_roleEditor->textCursor(); cursor.movePosition(QTextCursor::StartOfBlock); cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, textSelectionLength); m_roleEditor->setTextCursor(cursor); } connect(m_roleEditor, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant))); connect(m_roleEditor, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant))); // Adjust the geometry of the editor QRectF rect = roleEditingRect(current); const int frameWidth = m_roleEditor->frameWidth(); rect.adjust(-frameWidth, -frameWidth, frameWidth, frameWidth); rect.translate(pos()); if (rect.right() > parent->width()) { rect.setWidth(parent->width() - rect.left()); } m_roleEditor->setGeometry(rect.toRect()); m_roleEditor->show(); m_roleEditor->setFocus(); }
void QUProfileController::drawLoadingMessage(QPainter & p) { if( avail() < m_total || m_total == 0) { p.save(); p.setFont ( m_captionFont); p.setOpacity(1); QString txt = QString( "Loading %1/%2").arg( avail()).arg(m_total); QRectF anchor( m_buffer.width()/2.0, m_buffer.height()/2.0, 1, 1); QRectF brect = p.boundingRect( anchor, Qt::AlignCenter | Qt::TextDontClip, txt); brect.adjust( -3, -3, 3, 3); QColor bg( 255, 255, 255, 225); QColor border( 128, 0, 0, 225); p.setPen( border); p.setBrush( bg); p.drawRoundedRect( brect, 5, 5); p.setPen( QColor(0, 0, 0)); p.drawText(anchor, Qt::AlignCenter | Qt::TextDontClip, txt); p.setPen( QPen(QColor( 0, 0, 0, 128), 1, Qt::DashLine)); p.restore(); } }
/*! \reimp */ void QGraphicsLinearLayout::setGeometry(const QRectF &rect) { Q_D(QGraphicsLinearLayout); QGraphicsLayout::setGeometry(rect); QRectF effectiveRect = geometry(); qreal left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); Qt::LayoutDirection visualDir = d->visualDirection(); d->engine.setVisualDirection(visualDir); if (visualDir == Qt::RightToLeft) qSwap(left, right); effectiveRect.adjust(+left, +top, -right, -bottom); #ifdef QT_DEBUG if (qt_graphicsLayoutDebug()) { static int counter = 0; qDebug() << counter++ << "QGraphicsLinearLayout::setGeometry - " << rect; dump(1); } #endif d->engine.setGeometries(d->styleInfo(), effectiveRect); #ifdef QT_DEBUG if (qt_graphicsLayoutDebug()) { qDebug() << "post dump"; dump(1); } #endif }
QRectF GGPageItem::boundingRect() const { const qreal penWidth = editScene()->pageBorderWidth(); QRectF ret = innerBoundingRect(); ret.adjust(-penWidth/2, -penWidth/2, penWidth/2, penWidth/2); return ret; }
/*! Print the canvas into a given rectangle. \param plot Plot widget \param painter Painter \param map Maps mapping between plot and paint device coordinates \param canvasRect Canvas rectangle */ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot, QPainter *painter, const QRectF &canvasRect, const QwtScaleMap *map ) const { painter->save(); QRectF r = canvasRect.adjusted( 0.0, 0.0, -1.0, -1.0 ); if ( d_data->layoutFlags & FrameWithScales ) { r.adjust( -1.0, -1.0, 1.0, 1.0 ); painter->setPen( QPen( Qt::black ) ); } else painter->setPen( Qt::NoPen ); if ( !( d_data->discardFlags & DiscardCanvasBackground ) ) { const QBrush bgBrush = plot->canvas()->palette().brush( plot->backgroundRole() ); painter->setBrush( bgBrush ); } QwtPainter::drawRect( painter, r ); painter->restore(); painter->save(); painter->setClipRect( canvasRect ); plot->drawItems( painter, canvasRect, map ); painter->restore(); }
void GraphicsMovieItem::paintTitle( QPainter* painter, const QStyleOptionGraphicsItem* option ) { Q_UNUSED( option ); // Disable the matrix transformations painter->setWorldMatrixEnabled( false ); // Setup the font QFont f = painter->font(); f.setPointSize( 8 ); painter->setFont( f ); // Initiate the font metrics calculation QFontMetrics fm( painter->font() ); QString text = m_clipHelper->clip()->getMedia()->fileName(); // Get the transformations required to map the text on the viewport QTransform viewPortTransform = Timeline::getInstance()->tracksView()->viewportTransform(); // Do the transformation QRectF mapped = deviceTransform( viewPortTransform ).mapRect( boundingRect() ); // Create an inner rect mapped.adjust( 2, 2, -2, -2 ); painter->setPen( Qt::white ); painter->drawText( mapped, Qt::AlignVCenter, fm.elidedText( text, Qt::ElideRight, mapped.width() ) ); }
/*! Draw a dotted round circle, if !isReadOnly() \param painter Painter */ void QwtDial::drawFocusIndicator( QPainter *painter ) const { if ( !isReadOnly() ) { QRectF focusRect = innerRect(); const int margin = 2; focusRect.adjust( margin, margin, -margin, -margin ); QColor color = palette().color( QPalette::Base ); if ( color.isValid() ) { const QColor gray( Qt::gray ); int h, s, v; color.getHsv( &h, &s, &v ); color = ( v > 128 ) ? gray.dark( 120 ) : gray.light( 120 ); } else color = Qt::darkGray; painter->save(); painter->setBrush( Qt::NoBrush ); painter->setPen( QPen( color, 0, Qt::DotLine ) ); painter->drawEllipse( focusRect ); painter->restore(); } }
void MButtonView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(MButtonView); if (!d->expectMouseReleaseEvent) { // The usual mouse-press -> mouse-move -> mouse-release cycle // has been interrupted by a cancel event. return; } QPointF touch = event->scenePos(); QRectF rect = d->controller->sceneBoundingRect(); rect.adjust(-M_RELEASE_MISS_DELTA, -M_RELEASE_MISS_DELTA, M_RELEASE_MISS_DELTA, M_RELEASE_MISS_DELTA); if (rect.contains(touch)) { if (!model()->down()) { model()->setDown(true); } } else { if (model()->down()) { d->eventCancelled = true; model()->setDown(false); } } }
QVariant ComplexControlModel::doData(int row, int column, int role) const { if (role == Qt::DecorationRole) { QPixmap pixmap(m_interface->cellSizeHint()); QPainter painter(&pixmap); Util::drawTransparencyPattern(&painter, pixmap.rect()); painter.scale(m_interface->cellZoom(), m_interface->cellZoom()); QScopedPointer<QStyleOptionComplex> opt( qstyleoption_cast<QStyleOptionComplex*>(complexControlElements[row].styleOptionFactory())); Q_ASSERT(opt); fillStyleOption(opt.data(), column); m_style->drawComplexControl(complexControlElements[row].control, opt.data(), &painter); int colorIndex = 7; for (int i = 0; i < 32; ++i) { QStyle::SubControl sc = static_cast<QStyle::SubControl>(1 << i); if (sc & complexControlElements[row].subControls) { QRectF scRect = m_style->subControlRect(complexControlElements[row].control, opt.data(), sc); scRect.adjust(0, 0, -1.0 / m_interface->cellZoom(), -1.0 / m_interface->cellZoom()); if (scRect.isValid() && !scRect.isEmpty()) { // HACK: add some real color mapping painter.setPen(static_cast<Qt::GlobalColor>(colorIndex++)); painter.drawRect(scRect); } } } return pixmap; } return AbstractStyleElementStateTable::doData(row, column, role); }
void MapObjectLabel::syncWithMapObject(MapRenderer *renderer) { const bool nameVisible = mObject->isVisible() && !mObject->name().isEmpty(); setVisible(nameVisible); if (!nameVisible) return; const QFontMetricsF metrics(QGuiApplication::font()); QRectF boundingRect = metrics.boundingRect(mObject->name()); boundingRect.translate(-boundingRect.width() / 2, -labelDistance); boundingRect.adjust(-labelMargin*2, -labelMargin, labelMargin*2, labelMargin); QPointF pixelPos = renderer->pixelToScreenCoords(mObject->position()); QRectF bounds = objectBounds(mObject, renderer); // Adjust the bounding box for object rotation QTransform transform; transform.translate(pixelPos.x(), pixelPos.y()); transform.rotate(mObject->rotation()); transform.translate(-pixelPos.x(), -pixelPos.y()); bounds = transform.mapRect(bounds); // Center the object name on the object bounding box QPointF pos((bounds.left() + bounds.right()) / 2, bounds.top()); setPos(pos + mObject->objectGroup()->offset()); if (mBoundingRect != boundingRect) { prepareGeometryChange(); mBoundingRect = boundingRect; } }
QRectF QgsComposerLabel::boundingRect() const { QRectF rectangle = rect(); double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0; rectangle.adjust( -penWidth, -penWidth, penWidth, penWidth ); if ( mMarginX < 0 ) { rectangle.adjust( mMarginX, 0, -mMarginX, 0 ); } if ( mMarginY < 0 ) { rectangle.adjust( 0, mMarginY, 0, -mMarginY ); } return rectangle; }
/** * The points are used for the bounding rect. The reason is, * that for splines the control points are further away from the path. * @return The bounding rectangle for the AssociationLine. */ QRectF AssociationLine::boundingRect() const { QPolygonF polygon(m_points); QRectF rect = polygon.boundingRect(); const qreal margin(5.0); rect.adjust(-margin, -margin, margin, margin); return rect; }
QRectF Annotation::boundingRect() const { QFontMetricsF metrics(font); QRectF rect = metrics.boundingRect(str); rect.moveCenter(QPointF(0, y)); rect.adjust(-4, 0, +4, 0); return rect; }
void CCJKShapeLine::ScaleComplex(const QRectF& cmplxRect, const QRectF& cmplxOldRect) { CJK_D(CCJKShapeLine); SaveOldRect(); double dValue = (d->pen.widthF() + d->pathWidth) / 2.0; QRectF tmpNewCmplxRect = cmplxRect; tmpNewCmplxRect.adjust(dValue, dValue, -dValue, -dValue); QRectF tmpOldCmplxRect = cmplxOldRect; tmpOldCmplxRect.adjust(dValue, dValue, -dValue, -dValue); QPointF ptTarget1; QPointF ptTarget2; CCJKPointMath::ScalePoint(ptTarget1, tmpNewCmplxRect, d->line.p1(), tmpOldCmplxRect); d->line.setP1(ptTarget1); CCJKPointMath::ScalePoint(ptTarget2, tmpNewCmplxRect, d->line.p2(), tmpOldCmplxRect); d->line.setP2(ptTarget2); }
QRectF QgsLayoutItemLabel::boundingRect() const { QRectF rectangle = rect(); double penWidth = frameEnabled() ? ( pen().widthF() / 2.0 ) : 0; rectangle.adjust( -penWidth, -penWidth, penWidth, penWidth ); if ( mMarginX < 0 ) { rectangle.adjust( mMarginX, 0, -mMarginX, 0 ); } if ( mMarginY < 0 ) { rectangle.adjust( 0, mMarginY, 0, -mMarginY ); } return rectangle; }
void QgsComposerArrow::adaptItemSceneRect() { //rectangle containing start and end point QRectF rect = QRectF( qMin( mStartPoint.x(), mStopPoint.x() ), qMin( mStartPoint.y(), mStopPoint.y() ), qAbs( mStopPoint.x() - mStartPoint.x() ), qAbs( mStopPoint.y() - mStartPoint.y() ) ); double enlarge = computeMarkerMargin(); rect.adjust( -enlarge, -enlarge, enlarge, enlarge ); QgsComposerItem::setSceneRect( rect ); }