QPainterPath KisLiquifyPaintop::brushOutline(const KisLiquifyProperties &props,
                                             const KisPaintInformation &info)
{
    const qreal diameter = props.size();
    const qreal reverseCoeff = props.reverseDirection() ? -1.0 : 1.0;

    QPainterPath outline;
    outline.addEllipse(-0.5 * diameter, -0.5 * diameter,
                       diameter, diameter);

    switch (props.mode()) {
    case KisLiquifyProperties::MOVE:
    case KisLiquifyProperties::SCALE:
        break;
    case KisLiquifyProperties::ROTATE: {
        QPainterPath p;
        p.lineTo(-3.0, 4.0);
        p.moveTo(0.0, 0.0);
        p.lineTo(-3.0, -4.0);

        QTransform S;
        if (diameter < 15.0) {
            const qreal scale = diameter / 15.0;
            S = QTransform::fromScale(scale, scale);
        }
        QTransform R;
        R.rotateRadians(-reverseCoeff * 0.5 * M_PI);
        QTransform T = QTransform::fromTranslate(0.5 * diameter, 0.0);

        p = (S * R * T).map(p);
        outline.addPath(p);

        break;
    }
    case KisLiquifyProperties::OFFSET: {
        qreal normalAngle = info.drawingAngle() + reverseCoeff * 0.5 * M_PI;

        QPainterPath p = KisAlgebra2D::smallArrow();

        const qreal offset = qMax(0.8 * diameter, 15.0);

        QTransform R;
        R.rotateRadians(normalAngle);
        QTransform T = QTransform::fromTranslate(offset, 0.0);
        p = (T * R).map(p);

        outline.addPath(p);

        break;
    }
    case KisLiquifyProperties::UNDO:
        break;
    case KisLiquifyProperties::N_MODES:
        qFatal("Not supported mode");
    }

    return outline;
}
Exemple #2
0
QPainterPath LineItem::grips() const {
  if (gripMode() == Move)
    return QPainterPath();

  QPainterPath grips;
  grips.addPath(leftMidGrip());
  grips.addPath(rightMidGrip());
  return grips;
}
Exemple #3
0
QPainterPath DimRadial::shape() const
{
    // Returns the shape of the radial dimension
    QPainterPath s;
    QPainterPathStroker stroker;
    QTransform t;
    t.scale(1, -1);
    t.translate(0, -2 * arrow->line.p2().y());
    s.addPath(arrow->getArrowPath());
    s.moveTo(extLine.p1());
    s.lineTo(extLine.p2());
    s.addPath(t.map(text));
    stroker.setWidth(10);
    return stroker.createStroke(s);
}
QPainterPath KisGridPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
{
    QPainterPath path;
    if (mode == CursorIsOutline || mode == CursorIsCircleOutline || mode == CursorTiltOutline) {
        qreal sizex = getInt(GRID_WIDTH) * getDouble(GRID_SCALE);
        qreal sizey = getInt(GRID_HEIGHT) * getDouble(GRID_SCALE);
        QRectF rc(0, 0, sizex, sizey);
        rc.translate(-rc.center());
        path.addRect(rc);
        
        QPainterPath tiltLine;
        QLineF tiltAngle(QPointF(0.0,0.0), QPointF(0.0,sizex));
        tiltAngle.setLength(qMax(sizex*0.5, 50.0) * (1 - info.tiltElevation(info, 60.0, 60.0, true)));
        tiltAngle.setAngle((360.0 - fmod(KisPaintInformation::tiltDirection(info, true) * 360.0 + 270.0, 360.0))-3.0);
        tiltLine.moveTo(tiltAngle.p1());
        tiltLine.lineTo(tiltAngle.p2());
        tiltAngle.setAngle((360.0 - fmod(KisPaintInformation::tiltDirection(info, true) * 360.0 + 270.0, 360.0))+3.0);
        tiltLine.lineTo(tiltAngle.p2());
        tiltLine.lineTo(tiltAngle.p1());

        path = outlineFetcher()->fetchOutline(info, this, path);
        
        if (mode == CursorTiltOutline) {
            path.addPath(outlineFetcher()->fetchOutline(info, this, tiltLine, 1.0, 0.0, true, 0, 0));
        }
    }
    return path;
}
Exemple #5
0
	QPainterPath FrameCd::marginPath( const Distance& size ) const
	{
		Distance wReal = (mW == 0) ? 2*mR1 : mW;
		Distance hReal = (mH == 0) ? 2*mR1 : mH;

		Distance r1 = mR1 - size;
		Distance r2 = mR2 + size;

		QPainterPath path;

		/*
		 * Construct outer subpath (may be clipped if it's a business card CD)
		 */
		QPainterPath outerPath;
		outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );

		QPainterPath clipPath;
		clipPath.addRect( size.pt(), size.pt(), (wReal-2*size).pt(), (hReal-2*size).pt() );

		path.addPath( outerPath & clipPath );
		path.closeSubpath();

		/*
		 * Add inner subpath
		 */
		path.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );

		return path;
	}
QPainterPath KisDuplicateOpSettings::brushOutline(const QPointF& pos, KisPaintOpSettings::OutlineMode mode, qreal scale, qreal rotation) const
{
    QPainterPath path; 
    path = KisBrushBasedPaintOpSettings::brushOutline(QPointF(0.0,0.0),KisPaintOpSettings::CursorIsOutline, scale, rotation);
    
    QPainterPath copy(path);
    QRectF rect2 = copy.boundingRect();
    if (m_isOffsetNotUptodate) {
        copy.translate(m_position - pos);
    } else {
        copy.translate(-m_offset);
    }
    
    path.addPath(copy);
    
    QTransform m;
    m.scale(0.5,0.5);
    rect2 = m.mapRect(rect2);
    
    path.moveTo(rect2.topLeft());
    path.lineTo(rect2.bottomRight());
    
    path.moveTo(rect2.topRight());
    path.lineTo(rect2.bottomLeft());
    
    if (mode == CursorIsOutline){
        return path.translated(pos);
    } else {
        // workaround?
        //copy.addEllipse(QRectF(0,0,1,1));
        return copy.translated(pos);
    }
}
QPainterPath UBGraphicsProtractor::shape() const
{
    QPainterPath path = QGraphicsEllipseItem::shape();
    QPainterPath buttonPath;
    QRectF markerRect = markerButtonRect();

    QPointF center = rect().center();
    qreal centerX = center.x();
    qreal centerY = center.y();

    buttonPath.addRect(resizeButtonRect().adjusted(centerX, centerY, centerX, centerY));
    if (!resizeButtonRect().contains(markerRect))
    {
        buttonPath.addRect(markerRect.adjusted(centerX - markerRect.left() * 2 - markerRect.width(), centerY
                                               , centerX - markerRect.left() * 2 - markerRect.width(), centerY));
        buttonPath.addRect(markerRect.adjusted(centerX, centerY, centerX, centerY));
    }
    buttonPath.addRect(closeButtonRect().adjusted(centerX, centerY, centerX, centerY));
    buttonPath.addRect(resetButtonRect().adjusted(centerX, centerY, centerX, centerY));
    QTransform t;
    t.translate(centerX, centerY);
    t.rotate(-mStartAngle);
    t.translate(-centerX, -centerY);
    buttonPath = t.map(buttonPath);
    buttonPath = buttonPath.subtracted(path);
    path.addPath(buttonPath);

    return path;
}
Exemple #8
0
int PainterPath::addPath(lua_State * L) // ( const QPainterPath & path )
{
	QPainterPath* lhs = ValueInstaller2<QPainterPath>::check( L, 1 );
	QPainterPath* path = ValueInstaller2<QPainterPath>::check( L, 2 );
	lhs->addPath( *path );
	return 0;
}
QPainterPath GraphicsUtils::shapeFromPath(const QPainterPath &path, const QPen &pen, double shapeStrokeWidth, bool includeOriginalPath)
{
	// this function mostly copied from QGraphicsItem::qt_graphicsItem_shapeFromPath


    // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
    // if we pass a value of 0.0 to QPainterPathStroker::setWidth()
    static const double penWidthZero = double(0.00000001);

    if (path == QPainterPath())
        return path;
    QPainterPathStroker ps;
    ps.setCapStyle(pen.capStyle());
    //ps.setCapStyle(Qt::FlatCap);
    if (shapeStrokeWidth <= 0.0)
        ps.setWidth(penWidthZero);
    else
        ps.setWidth(shapeStrokeWidth);

    ps.setJoinStyle(pen.joinStyle());
    ps.setMiterLimit(pen.miterLimit());
    QPainterPath p = ps.createStroke(path);
	if (includeOriginalPath) {
		p.addPath(path);
	}
    return p;
}
Exemple #10
0
QPainterPath TextSymbol::painterPath(void)
{
  QPainterPath path;

  path.setFillRule(Qt::WindingFill);

  QString filename = ctx.loader->absPath("fonts/" + m_font);
  FontDataStore* ds = CachedFontParser::parse(filename);

  QMatrix mat(m_xsize / ds->xsize(), 0, 0, m_ysize / ds->ysize(), 0, 0);

  for (int i = 0; i < m_text.length(); ++i) {
    CharRecord* rec = ds->charRecord(m_text[i].toAscii());
    if (rec) {
      QPainterPath p = mat.map(rec->painterPath(m_width_factor));
      path.addPath(p);
    }
    mat.translate(ds->xsize() + ds->offset(), 0);
  }

  QRectF b = path.boundingRect();
  QMatrix mat2;
  mat2.translate(-b.x(), -(b.y() + b.height()));
  path = mat2.map(path);

  return path;
}
//!
//! Returns the shape of the item as QPainterPath.
//!
//! \param The shape of the item as QPainterPath.
//!
QPainterPath ConnectionGraphicsItem::shape () const
{
    QPainterPath result;
    result.addPath(m_mainPath);
    result.addPolygon(m_arrowHeadPolygon);
    return result;
}
Exemple #12
0
QGIFace* QGIViewPart::drawFace(TechDrawGeometry::Face* f, int idx)
{
    std::vector<TechDrawGeometry::Wire *> fWires = f->wires;
    QPainterPath facePath;
    for(std::vector<TechDrawGeometry::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
        QPainterPath wirePath;
        for(std::vector<TechDrawGeometry::BaseGeom *>::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) {
            //Save the start Position
            QPainterPath edgePath = drawPainterPath(*edge);
            // If the current end point matches the shape end point the new edge path needs reversing
            QPointF shapePos = (wirePath.currentPosition()- edgePath.currentPosition());
            if(sqrt(shapePos.x() * shapePos.x() + shapePos.y()*shapePos.y()) < 0.05) {    //magic tolerance
                edgePath = edgePath.toReversed();
            }
            wirePath.connectPath(edgePath);
        }
        //dumpPath("wirePath:",wirePath);
        facePath.addPath(wirePath);
    }
    facePath.setFillRule(Qt::OddEvenFill);

    QGIFace* gFace = new QGIFace(idx);
    addToGroup(gFace);
    gFace->setPos(0.0,0.0);
    gFace->setPath(facePath);
    //debug a path
    //std::stringstream faceId;
    //faceId << "facePath " << idx;
    //dumpPath(faceId.str().c_str(),facePath);

    return gFace;
}
Exemple #13
0
bool SmoothPathPlugin::run(ScribusDoc* doc, QString)
{
	ScribusDoc* currDoc = doc;
	if (currDoc == 0)
		currDoc = ScCore->primaryMainWindow()->doc;
	if (currDoc->m_Selection->count() > 0)
	{
		PageItem *currItem = currDoc->m_Selection->itemAt(0);
		QPainterPath pp;
		if (currItem->itemType() == PageItem::PolyLine)
			pp = currItem->PoLine.toQPainterPath(false);
		else
			pp = currItem->PoLine.toQPainterPath(true);
		QList<QPolygonF> polyList = pp.toSubpathPolygons();
		QPainterPath result;
		for (int a = 0; a < polyList.count(); a++)
		{
			result.addPath(bezierFit(polyList[a], 5.0));
		}
		currItem->PoLine.fromQPainterPath(result);
		currItem->ClipEdited = true;
		currItem->FrameType = 3;
		currDoc->AdjustItemSize(currItem);
		currItem->OldB2 = currItem->width();
		currItem->OldH2 = currItem->height();
		currItem->updateClip();
		currDoc->regionsChanged()->update(QRectF());
		currDoc->changed();
	}
	return true;
}
Exemple #14
0
void PaintCanvas::drawLineTo(const QPoint &endPoint)
{

//    std::cout<<"DRAWLINETO MyPenWidth=  "<<myPenWidth<<std::endl;
    QPainter painter(&image);
    painter.setPen(QPen(myPenColor, myPenWidth, Qt::SolidLine, Qt::RoundCap,
                        Qt::RoundJoin));
    painter.drawLine(lastPoint, endPoint);
    modified = true;
    int rad = (myPenWidth / 2) + 2;
    update(QRect(lastPoint, endPoint).normalized()
           .adjusted(-rad, -rad, +rad, +rad));

    //Path Test
    if(clickedToEndPath){
        QPainterPath invertPath;
        painter.setBrush(myBrushColor);

        invertPath.addRect(0,0,image.width(),image.height());
        invertPath.addPath(maskpath);

        painter.drawPath(invertPath);
    }
    //
    update();
    lastPoint = endPoint;
}
Exemple #15
0
QPainterPath PathDeformRenderer::lensDeform(const QPainterPath &source, const QPointF &offset)
{
    QPainterPath path;
    path.addPath(source);

    qreal flip = m_intensity / qreal(100);

    for (int i=0; i<path.elementCount(); ++i) {
        const QPainterPath::Element &e = path.elementAt(i);

        qreal x = e.x + offset.x();
        qreal y = e.y + offset.y();

        qreal dx = x - m_pos.x();
        qreal dy = y - m_pos.y();
        qreal len = m_radius - qSqrt(dx * dx + dy * dy);

        if (len > 0) {
            path.setElementPositionAt(i,
                                      x + flip * dx * len / m_radius,
                                      y + flip * dy * len / m_radius);
        } else {
            path.setElementPositionAt(i, x, y);
        }

    }

    return path;
}
QPainterPath KisBrushBasedPaintOpSettings::brushOutlineImpl(const KisPaintInformation &info,
                                                            OutlineMode mode,
                                                            qreal additionalScale,
                                                            bool forceOutline)
{
    QPainterPath path;

    if (forceOutline || mode == CursorIsOutline || mode == CursorIsCircleOutline || mode == CursorTiltOutline) {
        KisBrushSP brush = this->brush();
        if (!brush) return path;
        qreal finalScale = brush->scale() * additionalScale;

        QPainterPath realOutline = brush->outline();

        if (mode == CursorIsCircleOutline || mode == CursorTiltOutline ||
            (forceOutline && mode == CursorNoOutline)) {

            QPainterPath ellipse;
            ellipse.addEllipse(realOutline.boundingRect());
            realOutline = ellipse;
        }

        path = outlineFetcher()->fetchOutline(info, this, realOutline, finalScale, brush->angle());

        if (mode == CursorTiltOutline) {
            QPainterPath tiltLine = makeTiltIndicator(info,
                realOutline.boundingRect().center(),
                realOutline.boundingRect().width() * 0.5,
                3.0);
            path.addPath(outlineFetcher()->fetchOutline(info, this, tiltLine, finalScale, 0.0, true, realOutline.boundingRect().center().x(), realOutline.boundingRect().center().y()));
        }
    }

    return path;
}
void MyTextItem::updateShadow()
{
    QString text = toPlainText();
    if (text.isEmpty()) {
        m_shadow = QImage();
        return;
    }
    QFontMetrics metrics(font());
    //ADJUST TO CURRENT SETTING
    int lineSpacing = data(TitleDocument::LineSpacing).toInt() + metrics.lineSpacing();
    QPainterPath path;

    // Calculate line width
    QStringList lines = text.split('\n');
    double linePos = metrics.ascent();
    QRectF bounding = boundingRect();
    foreach(const QString &line, lines)
    {
        QPainterPath linePath;
        linePath.addText(0, linePos, font(), line);
        linePos += lineSpacing;
        if ( m_alignment == Qt::AlignHCenter ) {
            double offset = (bounding.width() - metrics.width(line)) / 2;
            linePath.translate(offset, 0);
        } else if ( m_alignment == Qt::AlignRight ) {
            double offset = (bounding.width() - metrics.width(line));
            linePath.translate(offset, 0);
        }
        path.addPath(linePath);
    }
/**
 * @brief RefreshGeometry  refresh item on scene.
 */
void VToolSpline::RefreshGeometry()
{
    this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
    const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
    QPainterPath path;
    path.addPath(spl->GetPath());
    path.setFillRule( Qt::WindingFill );
    this->setPath(path);
    QPointF splinePoint = VAbstractTool::data.GeometricObject<const VPointF *>(spl->GetP1().id())->toQPointF();
    QPointF controlPoint = spl->GetP2();
    emit RefreshLine(1, SplinePointPosition::FirstPoint, controlPoint, splinePoint);
    splinePoint = VAbstractTool::data.GeometricObject<const VPointF *>(spl->GetP4().id())->toQPointF();
    controlPoint = spl->GetP3();
    emit RefreshLine(1, SplinePointPosition::LastPoint, controlPoint, splinePoint);

    disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
            &VToolSpline::ControlPointChangePosition);
    disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
            &VToolSpline::ControlPointChangePosition);
    controlPoints[0]->setPos(spl->GetP2());
    controlPoints[1]->setPos(spl->GetP3());
    connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
            &VToolSpline::ControlPointChangePosition);
    connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
            &VToolSpline::ControlPointChangePosition);
}
QPainterPath KisDuplicateOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode)
{
    QPainterPath path;

    // clone tool should always show an outline
    path = KisBrushBasedPaintOpSettings::brushOutlineImpl(info, mode, 1.0, true);

    QPainterPath copy(path);
    QRectF rect2 = copy.boundingRect();
    if (m_isOffsetNotUptodate || !getBool(DUPLICATE_MOVE_SOURCE_POINT)) {
        copy.translate(m_position - info.pos());
    }
    else {
        copy.translate(-m_offset);
    }

    path.addPath(copy);

    qreal dx = rect2.width() / 4.0;
    qreal dy = rect2.height() / 4.0;
    rect2.adjust(dx, dy, -dx, -dy);

    path.moveTo(rect2.topLeft());
    path.lineTo(rect2.bottomRight());

    path.moveTo(rect2.topRight());
    path.lineTo(rect2.bottomLeft());

    return path;
}
Exemple #20
0
QImage Rotater::HideRollOutCorners(const QImage image)
{
    QImage destImage = QImage( image);

    QLine hline, vlineR, vlineL;
    int x0, y0, x1, y1;
    if (m_sign < 0)
    {
        x0 = 0, y0 = 0, x1 = m_width, y1 = 0;
    }
    else
    {
        x0 = 0, y0 = m_height, x1 = m_width, y1 = m_height;
    }

    hline = QLine(x0, y0, x1, y1);
    vlineR = QLine(m_width, 0, m_width, m_height);
    vlineL = QLine(0, 0, 0, m_height);

    QLine rvline = m_transform.map(vlineR);
    QPoint pa = get_line_cross_point(hline, rvline);
    QPoint pb = get_line_cross_point(vlineR, rvline);

    QLine rhline = m_transform.map(hline);
    QPoint pc = get_line_cross_point(vlineL, rhline);
    QPoint pd = get_line_cross_point(hline, rhline);

//    destImage = markOnImage( image, pa.x(), pa.y(), MarkType::CrossLines);
//    destImage = markOnImage( destImage, pb.x(), pb.y(), MarkType::CrossLines);
//    destImage = markOnImage( destImage, pc.x(), pc.y(), MarkType::CrossLines);
//    destImage = markOnImage( destImage, pd.x(), pd.y(), MarkType::CrossLines);

    QPolygonF triagle1, triagle2;
    triagle1 << pa << pb << QPointF(x1, y1);
    triagle2 << pc << pd << QPointF(x0, y0);

    QPainterPath myPath;
    myPath.addPolygon(triagle1);
    myPath.addPolygon(triagle2);

    QTransform transform;
    transform.translate(0, m_height * 0.5);
    transform.rotate(180, Qt::XAxis);
    transform.translate(0, -m_height * 0.5);
    QPainterPath myPath1 = transform.map(myPath);

    transform.reset();
    transform.translate(m_width * 0.5, 0);
    transform.rotate(180, Qt::YAxis);
    transform.translate(-m_width * 0.5, 0);
    myPath = transform.map(myPath);
    myPath.addPath(myPath1);

    QPainter painter(&destImage);
    painter.setBrush(Qt::SolidPattern);
    painter.drawPath(myPath);

    return destImage;
}
QPainterPath SquareThermalOpenCornersSymbol::painterPath(void)
{
  QPainterPath path;

  qreal angle_div = 360.0 / m_num_spokes;
  QPainterPath sub;
  QMatrix mat;

  // From what we seen in Genesis 2000, num_spokes can only be 1, 2, 4
  // angle can only be multiple of 45
  if ((m_num_spokes != 1 && m_num_spokes != 2 && m_num_spokes != 4) ||
      ((int)m_angle % 45 != 0)) {
    return path;
  }

  path.addRect(-m_od / 2, -m_od / 2, m_od, m_od);
  path.addRect(-m_id / 2, -m_id / 2, m_id, m_id);

  if ((int)m_angle % 90 == 0) {
    QPainterPath bar;
    bar.addRect(0, -m_gap / 2, m_od, m_gap);

    for (int i = 0; i < m_num_spokes; ++i) {
      sub.addPath(mat.map(bar));
      mat.rotate(-angle_div);
    }
  } else {
    qreal side = m_gap * qCos(M_PI / 4) + (m_od - m_id) / 2;
    qreal offset = (m_od - side) / 2;

    QPainterPath box;
    box.addRect(-side / 2, -side / 2, side, side);

    for (int i = 0; i < m_num_spokes; ++i) {
      QMatrix mat;
      mat.translate(offset * sign(qCos((m_angle + angle_div * i) * D2R)),
                    -offset * sign(qSin((m_angle + angle_div * i) * D2R)));
      sub.addPath(mat.map(box));
    }
  }

  path = path.subtracted(sub);

  return path;
}
Exemple #22
0
QPainterPath RelationItem::shape() const
{
    QPainterPath path;
    path.setFillRule(Qt::WindingFill);
    if (m_arrow) {
        path.addPath(m_arrow->shape().translated(m_arrow->pos()));
    }
    if (m_name) {
        path.addPath(m_name->shape().translated(m_name->pos()));
    }
    if (m_stereotypes) {
        path.addPath(m_stereotypes->shape().translated(m_stereotypes->pos()));
    }
    if (m_selectionHandles) {
        path.addPath(m_selectionHandles->shape().translated(m_selectionHandles->pos()));
    }
    return path;
}
Exemple #23
0
void QgsCompoundCurve::addToPainterPath( QPainterPath &path ) const
{
  QPainterPath pp;
  for ( const QgsCurve *curve : mCurves )
  {
    curve->addToPainterPath( pp );
  }
  path.addPath( pp );
}
Exemple #24
0
void KarbonBooleanCommand::redo()
{
    if (! d->resultingPath) {
        // transform input pathes to global coordinates
        QPainterPath pa = d->pathA->absoluteTransformation(0).map(d->pathA->outline());
        QPainterPath pb = d->pathB->absoluteTransformation(0).map(d->pathB->outline());
        QPainterPath pr;
        switch (d->operation) {
        case Intersection:
            pr = pa.intersected(pb);
            break;
        case Subtraction:
            pr = pa.subtracted(pb);
            break;
        case Exclusion:
            pr = pa.subtracted(pb);
            pr.addPath(pb.subtracted(pa));
            break;
        case Union:
            pr = pa.united(pb);
            break;
        }

        QTransform transformationA = d->pathA->absoluteTransformation(0);
        // transform resulting path to local coordinate system of input path A
        pr = transformationA.inverted().map(pr);
        // create a path shape from the resulting path in local coordinates
        d->resultingPath = KoPathShape::createShapeFromPainterPath(pr);
        d->resultingPath->setStroke(d->pathA->stroke());
        d->resultingPath->setBackground(d->pathA->background());
        d->resultingPath->setShapeId(d->pathA->shapeId());
        // the created shape has a transformation applied so we have to
        // apply the original transformation instead of replacing with it
        d->resultingPath->applyAbsoluteTransformation(transformationA);
        d->resultingPath->setName(d->pathA->name());
        d->resultingPath->setZIndex(d->pathA->zIndex());
        d->resultingPath->setFillRule(d->pathA->fillRule());

        KoShapeGroup * group = dynamic_cast<KoShapeGroup*>(d->pathA->parent());
        if (group) {
            QList<KoShape*> children;
            d->resultParentCmd = new KoShapeGroupCommand(group, children << d->resultingPath, this);
        }
    }

    if (d->shapeBasedDocument) {
        if (d->resultParent)
            d->resultParent->addShape(d->resultingPath);
        d->shapeBasedDocument->addShape(d->resultingPath);
    }

    KUndo2Command::redo();

    d->isExecuted = true;
}
void SectorItem::updatePath()
{
    if (this->_pathBuilder == NULL) return;

    QPainterPath newPath;
    newPath.addPath(this->_pathBuilder->inBound());

    QPainterPath exBound = this->_pathBuilder->exBound().toReversed();
    newPath.connectPath(exBound);
    this->setPath(newPath);
}
Exemple #26
0
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VSplinePath::GetPath(PathDirection direction) const
{
    QPainterPath painterPath;
    for (qint32 i = 1; i <= Count(); ++i)
    {
        VSpline spl(d->path.at(i-1).P(), d->path.at(i).P(), d->path.at(i-1).Angle2(), d->path.at(i).Angle1(),
                    d->path.at(i-1).KAsm2(), d->path.at(i).KAsm1(), d->kCurve);
        painterPath.addPath(spl.GetPath(direction));
    }
    return painterPath;
}
void tst_QPainterPath::testSimplified_data()
{
    QTest::addColumn<QPainterPath>("path");
    QTest::addColumn<int>("elements");

    QTest::newRow("rect") << rectPath(0, 0, 10, 10) << 5;

    QPainterPath twoRects = rectPath(0, 0, 10, 10);
    twoRects.addPath(rectPath(5, 0, 10, 10));
    QTest::newRow("two rects (odd)") << twoRects << 10;

    twoRects.setFillRule(Qt::WindingFill);
    QTest::newRow("two rects (winding)") << twoRects << 5;

    QPainterPath threeSteps = rectPath(0, 0, 10, 10);
    threeSteps.addPath(rectPath(0, 10, 20, 10));
    threeSteps.addPath(rectPath(0, 20, 30, 10));

    QTest::newRow("three rects (steps)") << threeSteps << 9;
}
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VSplinePath::GetPath() const
{
    QPainterPath painterPath;
    for (qint32 i = 1; i <= Count(); ++i)
    {
        VSpline spl(path.at(i-1).P(), path.at(i).P(), path.at(i-1).Angle2(), path.at(i).Angle1(),
                path.at(i-1).KAsm2(), path.at(i).KAsm1(), this->kCurve);
        painterPath.addPath(spl.GetPath());
    }
    return painterPath;
}
Exemple #29
0
QPainterPath ArrowItem::shape() const {
  QPainterPath selectPath;
  selectPath.setFillRule(Qt::WindingFill);
  selectPath.addPolygon(rect());
  selectPath.addPolygon(start);
  selectPath.addPolygon(end);
  if ((!isSelected() && !isHovering()) || (view()->mouseMode() == View::Create)) {
  } else {
    selectPath.addPath(grips());
  }
  return selectPath;
}
QPainterPath MWidgetController::shape() const
{
    Q_D(const MWidgetController);
    if (view()) {
        QPainterPath path;
        path.moveTo(d->view->marginLeft(), d->view->marginTop());
        path.addPath(d->view->shape());
        return path;
    } else {
        return QPainterPath();
    }
}