コード例 #1
0
KisBrushSP KisPredefinedBrushFactory::getOrCreateBrush(const QDomElement& brushDefinition)
{
    KoResourceServer<KisBrush> *rServer = KisBrushServer::instance()->brushServer();
    QString brushFileName = brushDefinition.attribute("filename", "");
    KisBrushSP brush = rServer->resourceByFilename(brushFileName);

    //Fallback for files that still use the old format
    if(!brush) {
        QFileInfo info(brushFileName);
        brush = rServer->resourceByFilename(info.fileName());
    }

    if(!brush) {
        brush = rServer->resources().first();
    }

    Q_ASSERT(brush);

    double spacing = brushDefinition.attribute("spacing", "0.25").toDouble();
    brush->setSpacing(spacing);

    double angle = brushDefinition.attribute("angle", "0.0").toDouble();
    brush->setAngle(angle);

    double scale = brushDefinition.attribute("scale", "1.0").toDouble();
    brush->setScale(scale);

    return brush;
}
コード例 #2
0
KisBrushSP KisBrush::fromXML(const QDomElement& element)
{
    KisBrushSP brush = KisBrushRegistry::instance()->getOrCreateBrush(element);
    if (brush && element.attribute("BrushVersion", "1") == "1") {
        brush->setScale(brush->scale() * 2.0);
    }
    return brush;
}