Exemplo n.º 1
0
void KstViewArrow::paintSelf(KstPainter& p, const QRegion& bounds) {
  p.save();
  if (p.type() != KstPainter::P_PRINT && p.type() != KstPainter::P_EXPORT) {
    if (p.makingMask()) {
      p.setCompositionMode(QPainter::CompositionMode_Source);
    } else {
      const QRegion clip(clipRegion());
      KstViewLine::paintSelf(p, bounds - _myClipMask);
      p.setClipRegion(bounds & clip);
    }
  } else {
      KstViewLine::paintSelf(p, bounds);
  }
  
  if (hasArrow()) {
    QPoint to = KstViewLine::to();
    QPoint from = KstViewLine::from();    
    const int w = width() * p.lineWidthAdjustmentFactor();
    QPen pen(_foregroundColor, w);
    
    pen.setCapStyle(capStyle());
    p.setPen(pen);
    p.setBrush(_foregroundColor);
    
    if (_hasToArrow) {      
      paintArrow(p, to, from, w, _toArrowScaling);
    }
    if (_hasFromArrow) {      
      paintArrow(p, from, to, w, _fromArrowScaling);
    }
  }
  p.restore();
}
Exemplo n.º 2
0
void KoShapeStroke::strokeInsets(const KoShape *shape, KoInsets &insets) const
{
    Q_UNUSED(shape);
    qreal lineWidth = d->pen.widthF();
    if (lineWidth < 0)
        lineWidth = 1;
    lineWidth *= 0.5; // since we draw a line half inside, and half outside the object.

    // if we have square cap, we need a little more space
    // -> sqrt((0.5*penWidth)^2 + (0.5*penWidth)^2)
    if (capStyle() == Qt::SquareCap)
        lineWidth *= M_SQRT2;

    insets.top = lineWidth;
    insets.bottom = lineWidth;
    insets.left = lineWidth;
    insets.right = lineWidth;
}