Esempio n. 1
0
KisRecordedAction* KisRecordedPathPaintActionFactory::fromXML(const QDomElement& elt, const KisRecordedActionLoadContext* context)
{
    KisNodeQueryPath pathnode = nodeQueryPathFromXML(elt);

    // Decode pressets
    KisPaintOpPresetSP paintOpPreset = paintOpPresetFromXML(elt);

    KisRecordedPathPaintAction* rplpa = new KisRecordedPathPaintAction(pathnode, paintOpPreset);

    setupPaintAction(rplpa, elt, context);

    QDomElement wpElt = elt.firstChildElement("Slices");
    if (!wpElt.isNull()) {
        QDomNode nWp = wpElt.firstChild();
        while (!nWp.isNull()) {
            QDomElement eWp = nWp.toElement();
            if (!eWp.isNull()) {
                if( eWp.tagName() == "Point") {
                    rplpa->addPoint(KisPaintInformation::fromXML(eWp));
                } else if(eWp.tagName() == "Line") {
                    rplpa->addLine(KisPaintInformation::fromXML(eWp.firstChildElement("Point1")),
                                    KisPaintInformation::fromXML(eWp.firstChildElement("Point2")));
                } else if( eWp.tagName() == "Curve") {
                    QDomElement control1Elt = eWp.firstChildElement("Control1");
                    QDomElement control2Elt = eWp.firstChildElement("Control2");
                    rplpa->addCurve(KisPaintInformation::fromXML(eWp.firstChildElement("Point1")),
                                    QPointF(control1Elt.attribute("x", "0.0").toDouble(),
                                            control1Elt.attribute("y", "0.0").toDouble()),
                                    QPointF(control2Elt.attribute("x", "0.0").toDouble(),
                                            control2Elt.attribute("y", "0.0").toDouble()),
                                    KisPaintInformation::fromXML(eWp.firstChildElement("Point2")));
                } else {
                    dbgImage << "Unsupported <" << eWp.tagName() << " /> element";
                }
            }
            nWp = nWp.nextSibling();
        }
    } else {
        dbgImage << "Warning: no <Waypoints /> found";
    }
    return rplpa;
}
Esempio n. 2
0
KisRecordedAction* KisRecordedShapePaintActionFactory::fromXML(const QDomElement& elt, const KisRecordedActionLoadContext* context)
{
    KisNodeQueryPath pathnode = nodeQueryPathFromXML(elt);

    // Decode pressets
    KisPaintOpPresetSP paintOpPreset = paintOpPresetFromXML(elt);

    QDomElement ellipseElt = elt.firstChildElement("Rectangle");
    qreal x, y, width, height;
    if (!ellipseElt.isNull()) {
        x = ellipseElt.attribute("x", "0.0").toDouble();
        y = ellipseElt.attribute("y", "0.0").toDouble();
        width = ellipseElt.attribute("width", "0.0").toDouble();
        height = ellipseElt.attribute("height", "0.0").toDouble();
    } else {
        x = 0;
        y = 0;
        width = 0;
        height = 0;
        dbgImage << "Warning: no <Rectangle /> found";
    }

    KisRecordedShapePaintAction::Shape shape = KisRecordedShapePaintAction::Ellipse;
    QString shapeStr = elt.attribute("shape", "Ellipse");
    if (shapeStr == "Ellipse")
    {
        shape = KisRecordedShapePaintAction::Ellipse;
    } else { // shapeStr == "Rectangle"
        shape = KisRecordedShapePaintAction::Rectangle;
    }

    KisRecordedShapePaintAction* rplpa = new KisRecordedShapePaintAction(pathnode, paintOpPreset, shape, QRectF(x, y, width, height));

    setupPaintAction(rplpa, elt, context);
    return rplpa;
}