diff --git a/libs/brush/kis_auto_brush_factory.cpp b/libs/brush/kis_auto_brush_factory.cpp index d597c46930..d4aac14314 100644 --- a/libs/brush/kis_auto_brush_factory.cpp +++ b/libs/brush/kis_auto_brush_factory.cpp @@ -1,45 +1,49 @@ /* * Copyright (c) 2008 Boudewijn Rempt * Copyright (c) 2010-2011 Lukáš Tvrdý * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include //MSVC requires that Vc come first #include "kis_auto_brush_factory.h" #include #include "kis_auto_brush.h" #include "kis_mask_generator.h" #include KisBrushSP KisAutoBrushFactory::getOrCreateBrush(const QDomElement& brushDefinition, bool forceCopy) { Q_UNUSED(forceCopy); KisMaskGenerator* mask = KisMaskGenerator::fromXML(brushDefinition.firstChildElement("MaskGenerator")); double angle = KisDomUtils::toDouble(brushDefinition.attribute("angle", "0.0")); double randomness = KisDomUtils::toDouble(brushDefinition.attribute("randomness", "0.0")); qreal density = KisDomUtils::toDouble(brushDefinition.attribute("density", "1.0")); double spacing = KisDomUtils::toDouble(brushDefinition.attribute("spacing", "1.0")); bool useAutoSpacing = KisDomUtils::toInt(brushDefinition.attribute("useAutoSpacing", "0")); qreal autoSpacingCoeff = KisDomUtils::toDouble(brushDefinition.attribute("autoSpacingCoeff", "1.0")); + bool useTimedSpacing = KisDomUtils::toInt(brushDefinition.attribute("useTimedSpacing", "0")); + qreal timedSpacingRate = KisDomUtils::toDouble(brushDefinition.attribute("timedSpacingRate", + "10.0")); KisBrushSP brush = new KisAutoBrush(mask, angle, randomness, density); brush->setSpacing(spacing); brush->setAutoSpacing(useAutoSpacing, autoSpacingCoeff); + brush->setTimedSpacing(useTimedSpacing, timedSpacingRate); return brush; } diff --git a/libs/brush/kis_predefined_brush_factory.cpp b/libs/brush/kis_predefined_brush_factory.cpp index 4a2d32aa0a..cb822f01a5 100644 --- a/libs/brush/kis_predefined_brush_factory.cpp +++ b/libs/brush/kis_predefined_brush_factory.cpp @@ -1,82 +1,87 @@ /* * Copyright (c) 2013 Dmitry Kazakov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kis_predefined_brush_factory.h" #include #include "kis_brush_server.h" #include "kis_gbr_brush.h" #include KisPredefinedBrushFactory::KisPredefinedBrushFactory(const QString &brushType) : m_id(brushType) { } QString KisPredefinedBrushFactory::id() const { return m_id; } KisBrushSP KisPredefinedBrushFactory::getOrCreateBrush(const QDomElement& brushDefinition, bool forceCopy) { KisBrushResourceServer *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); if (forceCopy) { brush = brush->clone(); } double spacing = KisDomUtils::toDouble(brushDefinition.attribute("spacing", "0.25")); brush->setSpacing(spacing); bool useAutoSpacing = KisDomUtils::toInt(brushDefinition.attribute("useAutoSpacing", "0")); qreal autoSpacingCoeff = KisDomUtils::toDouble(brushDefinition.attribute("autoSpacingCoeff", "1.0")); brush->setAutoSpacing(useAutoSpacing, autoSpacingCoeff); + bool useTimedSpacing = KisDomUtils::toInt(brushDefinition.attribute("useTimedSpacing", "0")); + qreal timedSpacingRate = KisDomUtils::toDouble(brushDefinition.attribute("timedSpacingRate", + "10.0")); + brush->setTimedSpacing(useTimedSpacing, timedSpacingRate); + double angle = KisDomUtils::toDouble(brushDefinition.attribute("angle", "0.0")); brush->setAngle(angle); double scale = KisDomUtils::toDouble(brushDefinition.attribute("scale", "1.0")); brush->setScale(scale); if (m_id == "gbr_brush") { KisGbrBrush *gbrbrush = dynamic_cast(brush.data()); if (gbrbrush) { /** * WARNING: see comment in KisGbrBrush::setUseColorAsMask() */ gbrbrush->setUseColorAsMask((bool)brushDefinition.attribute("ColorAsMask").toInt()); } } return brush; }