void QgsComposerArrow::setSceneRect( const QRectF& rectangle ) { //update rect for data defined size and position QRectF evaluatedRect = evalItemRect( rectangle ); if ( evaluatedRect.width() < 0 ) { mStartXIdx = 1 - mStartXIdx; } if ( evaluatedRect.height() < 0 ) { mStartYIdx = 1 - mStartYIdx; } double margin = computeMarkerMargin(); // Ensure the rectangle is at least as large as needed to include the markers QRectF rect = rectangle.united( QRectF( evaluatedRect.x(), evaluatedRect.y(), 2. * margin, 2. * margin ) ); // Compute new start and stop positions double x[2] = {rect.x(), rect.x() + rect.width()}; double y[2] = {rect.y(), rect.y() + rect.height()}; double xsign = x[mStartXIdx] < x[1 - mStartXIdx] ? 1.0 : -1.0; double ysign = y[mStartYIdx] < y[1 - mStartYIdx] ? 1.0 : -1.0; mStartPoint = QPointF( x[mStartXIdx] + xsign * margin, y[mStartYIdx] + ysign * margin ); mStopPoint = QPointF( x[1 - mStartXIdx] - xsign * margin, y[1 - mStartYIdx] - ysign * margin ); QgsComposerItem::setSceneRect( rect ); }
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 ); }
void QgsLayoutItemPolyline::updateBoundingRect() { QRectF br = rect(); double margin = std::max( mMaxSymbolBleed, computeMarkerMargin() ); if ( mEndMarker == ArrowHead ) { margin += 0.5 * mArrowHeadWidth; } br.adjust( -margin, -margin, margin, margin ); mCurrentRectangle = br; // update prepareGeometryChange(); update(); }