Exemplo n.º 1
0
FloatRect RenderSVGShape::calculateStrokeBoundingBox() const
{
    ASSERT(m_path);
    FloatRect strokeBoundingBox = m_fillBoundingBox;

    const SVGRenderStyle& svgStyle = style().svgStyle();
    if (svgStyle.hasStroke()) {
        BoundingRectStrokeStyleApplier strokeStyle(*this);
        if (hasNonScalingStroke()) {
            AffineTransform nonScalingTransform = nonScalingStrokeTransform();
            if (Optional<AffineTransform> inverse = nonScalingTransform.inverse()) {
                Path* usePath = nonScalingStrokePath(m_path.get(), nonScalingTransform);
                FloatRect strokeBoundingRect = usePath->strokeBoundingRect(&strokeStyle);
                strokeBoundingRect = inverse.value().mapRect(strokeBoundingRect);
                strokeBoundingBox.unite(strokeBoundingRect);
            }
        } else
            strokeBoundingBox.unite(path().strokeBoundingRect(&strokeStyle));
    }

    if (!m_markerPositions.isEmpty())
        strokeBoundingBox.unite(markerRect(strokeWidth()));

    return strokeBoundingBox;
}
Exemplo n.º 2
0
QRectF QgsGCPCanvasItem::boundingRect() const
{
  double residualLeft, residualRight, residualTop, residualBottom;

  QPointF residual;
  if ( mDataPoint )
  {
    residual = mDataPoint->residual();
  }

  //only considering screen resolution is ok for the bounding box function
  double rf = residualToScreenFactor();

  if ( residual.x() > 0 )
  {
    residualRight = residual.x() * rf + mResidualPen.widthF();
    residualLeft = -mResidualPen.widthF();
  }
  else
  {
    residualLeft = residual.x() * rf - mResidualPen.widthF();
    residualRight = mResidualPen.widthF();
  }
  if ( residual.y() > 0 )
  {
    residualBottom = residual.y() * rf + mResidualPen.widthF();
    residualTop = -mResidualPen.widthF();
  }
  else
  {
    residualBottom = mResidualPen.widthF();
    residualTop = residual.y() * rf - mResidualPen.widthF();
  }

  QRectF residualArrowRect( QPointF( residualLeft, residualTop ), QPointF( residualRight, residualBottom ) );
  QRectF markerRect( -2, -2, mTextBounds.width() + 6, mTextBounds.height() + 6 );
  QRectF boundingRect =  residualArrowRect.united( markerRect );
  if ( !mTextBoxRect.isNull() )
  {
    boundingRect = boundingRect.united( mTextBoxRect );
  }
  return boundingRect;
}
Exemplo n.º 3
0
bool MapWidget::eventFilter(QObject *object, QEvent *ev)
{
    if (ev->type() == QEvent::ToolTip) {
        QHelpEvent *event = static_cast<QHelpEvent *>(ev);
        QPoint mousePosition = event->pos();

        //check if mouse is intercepting some marker and show country name as tooltip
        for (const MapMarker &marker : markers) {
            QPointF markerPosition = getMarkerScreenCoordinate(marker);
            QRectF markerRect(markerPosition.x() - 2.5, markerPosition.y() - 2.5, 5, 5);
            if (markerRect.contains(QPointF(mousePosition))) {
                QToolTip::showText(event->globalPos(), marker.getCountryName());
                return true;
            }else {
                QToolTip::hideText();
                event->ignore();
            }
        }
    }
    return QWidget::eventFilter(object, ev);
}