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; }
KisBrushSP KisAutoBrushFactory::getOrCreateBrush(const QDomElement& brushDefinition) { KisMaskGenerator* mask = KisMaskGenerator::fromXML(brushDefinition.firstChildElement("MaskGenerator")); bool result; QLocale c(QLocale::German); double angle = brushDefinition.attribute("angle", "0.0").toDouble(&result); if (!result) { angle = c.toDouble(brushDefinition.attribute("angle")); } double randomness = brushDefinition.attribute("randomness", "0.0").toDouble(&result); if (!result) { randomness = c.toDouble(brushDefinition.attribute("randomness")); } qreal density = brushDefinition.attribute("density", "1.0").toDouble(&result); if (!result) { density = c.toDouble(brushDefinition.attribute("density")); } double spacing = brushDefinition.attribute("spacing", "1.0").toDouble(&result); if (!result) { spacing = c.toDouble(brushDefinition.attribute("spacing")); } KisBrushSP brush = new KisAutoBrush(mask, angle, randomness, density); brush->setSpacing(spacing); return brush; }
KisBrushSP KisAutoBrushFactory::getOrCreateBrush( const QDomElement& brushDefinition ) { KisMaskGenerator* mask = KisMaskGenerator::fromXML(brushDefinition); KisBrushSP brush = new KisAutoBrush( mask ); double spacing = brushDefinition.attribute("brush_spacing", "1.0").toDouble(); brush->setSpacing( spacing ); return brush; }
KisBrushSP KisAbrBrushFactory::getOrCreateBrush(const QDomElement& brushDefinition) { KoResourceServer<KisBrush>* rServer = KisBrushServer::instance()->brushServer(); QString brushName = brushDefinition.attribute("name", "test_1"); KisBrushSP brush = rServer->getResourceByName(brushName); if (!brush){ return 0; } double spacing = brushDefinition.attribute("spacing", "0.25").toDouble(); brush->setSpacing(spacing); return brush; }