diff --git a/krita/data/paintoppresets/CMakeLists.txt b/krita/data/paintoppresets/CMakeLists.txt index 17150370b4..ebfd55c4d4 100644 --- a/krita/data/paintoppresets/CMakeLists.txt +++ b/krita/data/paintoppresets/CMakeLists.txt @@ -1,131 +1,132 @@ install( FILES Airbrush_eraser.kpp Airbrush_linear.kpp Airbrush_linear_noisy.kpp Airbrush_pressure.kpp Basic_circle.kpp Basic_mix.kpp Basic_mix_soft.kpp Basic_tip_default.kpp Basic_tip_gaussian.kpp Basic_tip_soft.kpp Basic_wet.kpp Basic_wet_soft.kpp Block_basic.kpp Block_bristles.kpp Block_fuzzy.kpp Block_mix_tilt.kpp Block_tilt.kpp Block_wet_tilt.kpp Bristle_frottis.kpp Bristles_hairy.kpp Bristles_mix.kpp Bristles_textured.kpp Bristles_wet.kpp Chalk_brush.kpp Clone_tool.kpp Curve_curvy.kpp Curve_ink.kpp Curve_recurvy.kpp Curve_smooth.kpp Eraser_circle.kpp Eraser_hard.kpp Eraser_soft.kpp FX_blur_light.kpp FX_color_HSY.kpp FX_explode.kpp FX_glow_add.kpp FX_overlay.kpp FX_splat_starfield.kpp Fill_block.kpp Fill_circle.kpp Grid_square_25.kpp Bristle_Details.kpp Bristle_Large.kpp Bristle_Special_Blender.kpp Bristle_Squared.kpp Bristle_Tapered.kpp Bristle_Texture.kpp Hatch_crispy.kpp Hatch_cross_regular.kpp Hatch_cross_small.kpp Hatch_diag_S.kpp Hatch_diag_fat.kpp Hatch_moire.kpp Hatch_noisy.kpp Ink_ballpen.kpp Ink_brush_25.kpp Ink_circle_05.kpp Ink_circle_10.kpp Ink_gpen_10.kpp Ink_gpen_25.kpp Ink_tilt_10.kpp Ink_tilt_20.kpp Layout_block.kpp Layout_circle_soft.kpp Layout_oval.kpp Layout_pen.kpp Move_tool.kpp Pastel_texture_large.kpp Pastel_texture_thin.kpp Pencil_2B.kpp Pencil_HB.kpp Pencil_texture.kpp Pencil_tilt.kpp Quick_circle_big.kpp Quick_circle_huge.kpp Quick_circle_layout.kpp Rake_bristle_dry.kpp Rake_texture.kpp Screentones.kpp Screentones_eraser.kpp Shape_fill.kpp Shape_smooth.kpp Sketch.kpp Sketch_chrome.kpp Sketch_fur.kpp Sketch_ink_big.kpp Sketch_ink_small.kpp Sketch_line.kpp Sketch_shade.kpp Sketch_shade_wash.kpp Sketch_speedpaint.kpp Sketch_speedpaint_shade.kpp Sketch_wires.kpp Smudge_block_tilt.kpp Smudge_rake.kpp Smudge_rake_2.kpp Smudge_soft.kpp Smudge_textured.kpp Smudge_water.kpp Sparkle_wet.kpp Sparkle_wet_soft.kpp Special_dyna_dots.kpp Special_FuzzyColor.kpp Special_particles_crazy.kpp Splat_mix_cells.kpp Splat_texture.kpp Splat_texture_2.kpp Splat_wet_cells.kpp Splatter_thin.kpp Sponge_texture.kpp Spray_splat.kpp Tangent_normal_basic.kpp Tangent_normal_drawing_angle.kpp Tangent_normal_hairy.kpp Tangent_normal_pixel.kpp Tangent_normal_y_inverted.kpp Texture_fuzzy.kpp Texture_hair.kpp Texture_leaves_fuzzy.kpp ink_precision_03.kpp pixel1.kpp Pixelart_dither.kpp Pixelart_round.kpp Pixelart_square.kpp +Simple-watercolor.kpp DESTINATION ${DATA_INSTALL_DIR}/krita/paintoppresets) install( FILES kis_paintoppresets_tags.xml DESTINATION ${DATA_INSTALL_DIR}/krita/tags) diff --git a/krita/data/paintoppresets/Simple-watercolor.kpp b/krita/data/paintoppresets/Simple-watercolor.kpp new file mode 100644 index 0000000000..a0e4efa97c Binary files /dev/null and b/krita/data/paintoppresets/Simple-watercolor.kpp differ diff --git a/krita/data/paintoppresets/kis_paintoppresets_tags.xml b/krita/data/paintoppresets/kis_paintoppresets_tags.xml index cc7337730a..2f50cb1a92 100644 --- a/krita/data/paintoppresets/kis_paintoppresets_tags.xml +++ b/krita/data/paintoppresets/kis_paintoppresets_tags.xml @@ -1,227 +1,230 @@ ink paint sketch sketch sketch demo ink demo demo demo demo paint demo demo demo ink paint demo paint demo Block Block Wet Block Mix FX Mix FX Ink Erasers Erasers Wet Circle Ink Block Block Smudge Mix Circle Wet FX Mix FX Circle Smudge Block Mix Circle Block Block Ink Wet Ink Erasers Ink Smudge Smudge Block Ink Circle Ink Circle Ink Wet Erasers Erasers Smudge Wet Circle FX Ink Wet Circle FX PixelArt PixelArt PixelArt PixelArt + + Watercolor + diff --git a/plugins/paintops/watercolor/kis_splat.cpp b/plugins/paintops/watercolor/kis_splat.cpp index 340302a146..cd4815e4a5 100644 --- a/plugins/paintops/watercolor/kis_splat.cpp +++ b/plugins/paintops/watercolor/kis_splat.cpp @@ -1,209 +1,205 @@ /* This file is part of the KDE project * * Copyright (C) 2017 Grigory Tantsevov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_splat.h" #include "kis_random_generator.h" #include #include #define START_OPACITY 100 #define STANDART_LIFETIME 30 double get_random(qreal min, qreal max) { return (qreal)rand() / RAND_MAX*(max - min) + min; } -KisSplat::KisSplat(QPointF offset, int width, KoColor splatColor) +KisSplat::KisSplat(QPointF offset, int width) : m_life(STANDART_LIFETIME), m_roughness(1.f), m_flow(1.f), - m_motionBias(QPointF(0.f, 0.f)), m_initColor(splatColor) + m_motionBias(QPointF(0.f, 0.f)) { m_fix = 8*STANDART_LIFETIME; - m_initColor.setOpacity(quint8(START_OPACITY)); int r = width / 2; int n = 128; qreal dt = 2.f * M_PI / n; QPointF p; for (int i = 0; i < n; i++) { p.setX(cos(i * dt)); p.setY(sin(i * dt)); m_vertices.push_back(QPointF(static_cast (r * p.x()) + offset.x(), static_cast (r * p.y()) + offset.y())); m_velocities.push_back(QPointF(2.f * p.x(), 2.f * p.y())); } m_initSize = CalcSize(); m_startTime = QTime::currentTime(); } KisSplat::KisSplat(QPointF offset, QPointF velocityBias, int width, int life, - qreal roughness, qreal flow, qreal radialSpeed, KoColor splatColor) + qreal roughness, qreal flow, qreal radialSpeed) : m_life(life), m_roughness(roughness), m_flow(flow), - m_motionBias(velocityBias), m_initColor(splatColor) + m_motionBias(velocityBias) { m_fix = 8*STANDART_LIFETIME; - m_initColor.setOpacity(quint8(START_OPACITY)); int r = width / 2; int n = 128; qreal dt = 2.f * M_PI / n; QPointF p; for (int i = 0; i < n; i++) { p.setX(cos(i * dt)); p.setY(sin(i * dt)); m_vertices.push_back(QPointF(static_cast (r * p.x()) + offset.x(), static_cast (r * p.y()) + offset.y())); m_velocities.push_back(QPointF(radialSpeed * p.x(), radialSpeed * p.y())); } m_initSize = CalcSize(); m_startTime = QTime::currentTime(); } qreal KisSplat::CalcSize() { if (m_vertices.length() < 3) return 0.f; QPointF v0 = m_vertices[0]; qreal v0x = v0.x(); qreal v0y = v0.y(); QPointF e0 = m_vertices[1] - v0; qreal e0x = e0.x(); qreal e0y = e0.y(); qreal s = 0.f; int length = m_vertices.length(); for (int i = 2; i < length; i++) { QPointF v2 = m_vertices[i]; qreal e1x = v2.x() - v0x; qreal e1y = v2.y() - v0y; s += e0x * e1y - e0y * e1x; e0x = e1x; e0y = e1y; } return s >= 0 ? s : -s; } void KisSplat::doPaint(KisPainter *painter) { - painter->setPaintColor(m_initColor); - qreal multiply = m_initSize / CalcSize(); if (multiply < 0.f || multiply > 1.f) multiply = 1; - painter->setOpacity(m_initColor.opacityU8() * multiply); + painter->setOpacity(START_OPACITY * multiply); painter->setFillStyle(KisPainter::FillStyleForegroundColor); painter->fillPainterPath(this->shape()); } QPainterPath KisSplat::shape() const { QPainterPath path; int len = m_vertices.length(); path = *(new QPainterPath(m_vertices[0])); for (int i = 0; i < len-2; i+=2) { path.quadTo(m_vertices[i+1], m_vertices[i+2]); } path.quadTo(m_vertices[len-1], m_vertices[0]); return path; } QRectF KisSplat::boundingRect() const { return m_vertices.boundingRect(); } int KisSplat::update(KisWetMap *wetMap) { if (m_life <= 0) { if (m_fix <= 0) { return KisSplat::Dried; } else { m_fix--; return KisSplat::Fixed; } } m_life--; QVector newVertices; for (int i = 0; i < m_vertices.length(); i++) { QPointF x = m_vertices[i]; QPointF v = m_velocities[i]; QPointF d = (1.f - alpha) * m_motionBias + alpha / get_random(1.f, 1.f + m_roughness) * v; QPointF x1 = x + m_flow * d; + QPointF(get_random(-m_roughness, m_roughness), get_random(-m_roughness, m_roughness)); newVertices.push_back(x1); } QVector wetPoints = wetMap->getWater(newVertices); for (int i = 0; i < wetPoints.size(); i++) { if (wetPoints.at(i) > 0) m_vertices[i] = newVertices.at(i); } if (!m_life) { for (int i = 0; i < m_vertices.length(); i++) { m_velocities[i] = QPointF(0, 0); } } return KisSplat::Flowing; } int KisSplat::rewet(KisWetMap *wetMap, QPointF pos, qreal radius) { QVector vertNum; QVector vertUpdate; for (int i = 0; i < m_vertices.size(); i++) { QVector2D vec(m_vertices.at(i) - pos); if (vec.length() <= radius) { vertNum.push_back(i); vertUpdate.push_back(m_vertices[i]); } } if (vertNum.size() > 0) { QVector newSpeed = wetMap->getSpeed(vertUpdate); for (int i = 0; i < vertNum.size(); i++) { int num = vertNum.at(i); m_velocities[num] = newSpeed.at(i); } m_life = STANDART_LIFETIME; m_fix = 8*STANDART_LIFETIME; return KisSplat::Flowing; } else return KisSplat::Fixed; } diff --git a/plugins/paintops/watercolor/kis_splat.h b/plugins/paintops/watercolor/kis_splat.h index 38f78ec433..5c6fac95ba 100644 --- a/plugins/paintops/watercolor/kis_splat.h +++ b/plugins/paintops/watercolor/kis_splat.h @@ -1,80 +1,80 @@ /* This file is part of the KDE project * * Copyright (C) 2017 Grigory Tantsevov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_SPLAT_H #define KIS_SPLAT_H #include #include #include #include #include #include "kis_wetmap.h" #include "kis_random_generator.h" #include "kritawatercolorpaintop_export.h" #include "kis_painter.h" double get_random(qreal min, qreal max); class WATERCOLORPAINT_EXPORT KisSplat { public: enum SplatState { Flowing, Fixed, Dried }; - KisSplat(QPointF offset, int width, KoColor splatColor); + KisSplat(QPointF offset, int width); KisSplat(QPointF offset, QPointF velocityBias, int width, int life, - qreal roughness, qreal flow, qreal radialSpeed, KoColor splatColor); + qreal roughness, qreal flow, qreal radialSpeed); void doPaint(KisPainter *painter); QPainterPath shape() const; QRectF boundingRect() const; int update(KisWetMap *wetMap); int rewet(KisWetMap *wetMap, QPointF pos, qreal radius); private: qreal CalcSize(); const float alpha = 0.33f; QPolygonF m_vertices; QVector m_velocities; int m_life; qreal m_roughness; qreal m_flow; QPointF m_motionBias; QTime m_startTime; qreal m_initSize; - KoColor m_initColor; +// KoColor m_initColor; int m_fix; }; #endif diff --git a/plugins/paintops/watercolor/kis_splat_generator.cpp b/plugins/paintops/watercolor/kis_splat_generator.cpp index e5dcbb5cb5..4b0c902dbf 100644 --- a/plugins/paintops/watercolor/kis_splat_generator.cpp +++ b/plugins/paintops/watercolor/kis_splat_generator.cpp @@ -1,71 +1,71 @@ /* This file is part of the KDE project * * Copyright (C) 2017 Grigory Tantsevov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_splat_generator.h" #include "kis_painter.h" SplatGenerator::SplatGenerator(int width, KoColor clr, KisPaintDeviceSP dev) : m_width(width), m_color(clr), m_device(dev) { m_wetMap = new KisWetMap(); m_flowing = new QVector(); m_fixed = new QVector(); m_dried = new QVector(); } void SplatGenerator::generateFromPoints(QVector points, int msec) { foreach (QPointF pnt, points) { - m_flowing->push_back(new KisSplat(pnt, 2*m_width, m_color)); + m_flowing->push_back(new KisSplat(pnt, 2*m_width)); m_wetMap->addWater(pnt.toPoint(), m_width); } KisPainter *painter = new KisPainter(m_device); for (int i = 0; i <= msec; i +=33) { foreach (KisSplat *splat, *m_flowing) { if (splat->update(m_wetMap) == KisSplat::Fixed) { m_fixed->push_back(splat); m_flowing->removeOne(splat); } } foreach (KisSplat *splat, *m_fixed) { if (splat->update(m_wetMap) == KisSplat::Dried) { m_dried->push_back(splat); m_fixed->removeOne(splat); } } m_wetMap->update(); } foreach (KisSplat *splat, *m_flowing) { splat->doPaint(painter); } foreach (KisSplat *splat, *m_fixed) { splat->doPaint(painter); } foreach (KisSplat *splat, *m_dried) { splat->doPaint(painter); } } diff --git a/plugins/paintops/watercolor/kis_splat_generator_strategy.cpp b/plugins/paintops/watercolor/kis_splat_generator_strategy.cpp index bec720074f..75800fe7af 100644 --- a/plugins/paintops/watercolor/kis_splat_generator_strategy.cpp +++ b/plugins/paintops/watercolor/kis_splat_generator_strategy.cpp @@ -1,108 +1,124 @@ +/* This file is part of the KDE project + * + * Copyright (C) 2017 Grigory Tantsevov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + #include "kis_splat_generator_strategy.h" +#include -void KisSimpleBrushGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) +void KisSimpleBrushGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius) { - KisSplat *newSplat = new KisSplat(pos, radius, color); - wetMap->addWater(pos, radius); + KisSplat *newSplat = new KisSplat(pos, radius); + wetMap->addWater(pos.toPoint(), radius); flowing->insert(newSplat->boundingRect(), newSplat); } -void KisWetOnDryGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) +void KisWetOnDryGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius) { - wetMap->addWater(pos, radius); + wetMap->addWater(pos.toPoint(), radius); /// 1 splat in center, 6 around qreal radialSpeed = 2.f; int d = radius / 2; int r = d / 2; QVector2D offset; - KisSplat *splat = new KisSplat(pos, radius, color); + KisSplat *splat = new KisSplat(pos, radius); flowing->insert(splat->boundingRect(), splat); for (int i = 0; i < 6; i++) { qreal theta = i * M_PI / 3; offset.setX(r * cos(theta)); offset.setY(r * sin(theta)); - splat = new KisSplat(pos + offset, + splat = new KisSplat(pos + offset.toPointF(), 0.1f * radialSpeed * offset.normalized().toPointF(), d, 30, 0.5f * radialSpeed, 1.f, - radialSpeed, - color); + radialSpeed); flowing->insert(splat->boundingRect(), splat); } } -void KisCrunchyGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) +void KisCrunchyGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius) { - wetMap->addWater(pod, radius); + wetMap->addWater(pos.toPoint(), radius); KisSplat *splat = new KisSplat(pos, QPointF(0, 0), radius, - 15, 5, 0.25f, 2.f, - color); + 15, 5, 0.25f, 2.f); flowing->insert(splat->boundingRect(), splat); } -void KisWetOnWetGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) +void KisWetOnWetGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius) { - wetMap->addWater(pod, radius); + wetMap->addWater(pos.toPoint(), radius); int smallD = radius / 2; int bigD = 3 * radius / 2; KisSplat *splat = new KisSplat(pos, QPointF(0, 0), bigD, - 15, 5, 1.f, 2.f, - color); + 15, 5, 1.f, 2.f); flowing->insert(splat->boundingRect(), splat); splat = new KisSplat(pos, QPointF(0, 0), smallD, - 15, 5, 1.f, 2.f, - color); + 15, 5, 1.f, 2.f); flowing->insert(splat->boundingRect(), splat); } -void KisBlobbyGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) +void KisBlobbyGenerator::generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius) { - wetMap->addWater(pos, radius); + wetMap->addWater(pos.toPoint(), radius); qreal firstD = (qreal) radius / 3; qreal lastD = (qreal) radius; KisSplat *splat; for (int i = 0; i < 4; i++) { qreal size = get_random(firstD, lastD); QPointF posN; switch (i) { case 0: posN = pos + QPointF(0, (radius - size) / 2); break; case 1: posN = pos + QPointF((radius - size) / 2, 0); case 2: posN = pos - QPointF(0, (radius - size) / 2); break; case 3: posN = pos - QPointF((radius - size) / 2, 0); default: break; } splat = new KisSplat(posN, QPointF(0, 0), size, - 15, 5, 1.f, 2.f, - color); + 15, 5, 1.f, 2.f); flowing->insert(splat->boundingRect(), splat); } } diff --git a/plugins/paintops/watercolor/kis_splat_generator_strategy.h b/plugins/paintops/watercolor/kis_splat_generator_strategy.h index 552ce956b4..dfad8c5ce5 100644 --- a/plugins/paintops/watercolor/kis_splat_generator_strategy.h +++ b/plugins/paintops/watercolor/kis_splat_generator_strategy.h @@ -1,46 +1,66 @@ +/* This file is part of the KDE project + * + * Copyright (C) 2017 Grigory Tantsevov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + #ifndef KIS_SPLAT_GENERATOR_STRATEGY_H #define KIS_SPLAT_GENERATOR_STRATEGY_H #include #include "kis_splat.h" #include "kis_wetmap.h" class KisSplatGeneratorStrategy { public: virtual ~KisSplatGeneratorStrategy(){} - virtual void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) = 0; + virtual void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius/*, KoColor color*/) = 0; }; class KisSimpleBrushGenerator : public KisSplatGeneratorStrategy { public: - void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) override; + void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius/*, KoColor color*/) override; }; class KisWetOnDryGenerator : public KisSplatGeneratorStrategy { public: - void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) override; + void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius) override; }; class KisCrunchyGenerator : public KisSplatGeneratorStrategy { public: - void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) override; + void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius) override; }; class KisWetOnWetGenerator : public KisSplatGeneratorStrategy { public: - void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) override; + void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius) override; }; class KisBlobbyGenerator : public KisSplatGeneratorStrategy { public: - void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius, KoColor color) override; + void generate(KoRTree *flowing, KisWetMap *wetMap, QPointF pos, qreal radius) override; }; #endif // KIS_SPLAT_GENERATOR_STRATEGY_H diff --git a/plugins/paintops/watercolor/kis_watercolor_base_items.cpp b/plugins/paintops/watercolor/kis_watercolor_base_items.cpp index 84b65b9803..211076cd55 100644 --- a/plugins/paintops/watercolor/kis_watercolor_base_items.cpp +++ b/plugins/paintops/watercolor/kis_watercolor_base_items.cpp @@ -1,57 +1,93 @@ +/* This file is part of the KDE project + * + * Copyright (C) 2017 Grigory Tantsevov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + #include "kis_watercolor_base_items.h" #include "kis_splat_generator_strategy.h" -void KisWatercolorBaseItems::paint(QPointF pos, qreal radius, KoColor color, int brushType) +#include + +void KisWatercolorBaseItems::paint(QPointF pos, qreal radius, int brushType) { KisSplatGeneratorStrategy *strategy; switch (brushType) { case 0: strategy = new KisSimpleBrushGenerator(); break; case 1: strategy = new KisWetOnDryGenerator(); break; case 2: strategy = new KisWetOnWetGenerator(); break; case 3: strategy = new KisBlobbyGenerator(); break; case 4: strategy = new KisCrunchyGenerator(); break; default: break; } - strategy->generate(m_flowing, m_wetMap, pos, radius, color); + strategy->generate(&m_flowing, m_wetMap, pos, radius); +} + +void KisWatercolorBaseItems::repaint(KisPainter *painter) +{ + + foreach (KisSplat *splat, m_flowing.values()) { + splat->doPaint(painter); + } + + foreach (KisSplat *splat, m_fixed.values()) { + splat->doPaint(painter); + } + + foreach (KisSplat *splat, m_dried.values()) { + splat->doPaint(painter); + } } void KisWatercolorBaseItems::update() { QList list = m_flowing.values(); foreach (KisSplat *splat, list) { if (splat->update(m_wetMap) == KisSplat::Fixed) { m_fixed.insert(splat->boundingRect(), splat); m_flowing.remove(splat); } } list = m_fixed.values(); foreach (KisSplat *splat, list) { if (splat->update(m_wetMap) == KisSplat::Dried) { m_dried.insert(splat->boundingRect(), splat); m_fixed.remove(splat); } } m_wetMap->update(); } KisWatercolorBaseItems::KisWatercolorBaseItems() : m_flowing(4, 2), m_fixed(4, 2), m_dried(4, 2) { m_wetMap = new KisWetMap(); - m_updater.start(33); - connect(&m_updater, SIGNAL(timeout()), SLOT(update())); } diff --git a/plugins/paintops/watercolor/kis_watercolor_base_items.h b/plugins/paintops/watercolor/kis_watercolor_base_items.h index beb03f8a89..321d9d8c40 100644 --- a/plugins/paintops/watercolor/kis_watercolor_base_items.h +++ b/plugins/paintops/watercolor/kis_watercolor_base_items.h @@ -1,41 +1,60 @@ +/* This file is part of the KDE project + * + * Copyright (C) 2017 Grigory Tantsevov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + #ifndef KIS_WATERCOLOR_BASE_ITEMS_H #define KIS_WATERCOLOR_BASE_ITEMS_H #include #include "kis_splat.h" #include "kis_wetmap.h" -#include +#include #include +#include "kis_painter.h" class KisWatercolorBaseItems : public QObject { Q_OBJECT -public Q_SLOTS: +public: void update(); public: static KisWatercolorBaseItems* instance() { static KisWatercolorBaseItems instance; return &instance; } - void paint(QPointF pos, qreal radius, KoColor color, int brushType); + void paint(QPointF pos, qreal radius, int brushType); + + void repaint(KisPainter *painter); private: static KisWatercolorBaseItems * p_instance; KisWatercolorBaseItems(); KisWatercolorBaseItems( const KisWatercolorBaseItems& ); KisWatercolorBaseItems& operator=( KisWatercolorBaseItems& ); KisWetMap *m_wetMap; KoRTree m_flowing; KoRTree m_fixed; KoRTree m_dried; - - QTimer m_updater; - - KisPaintDeviceSP m_paintDev; }; #endif // KIS_WATERCOLOR_BASE_ITEMS_H diff --git a/plugins/paintops/watercolor/kis_watercolor_paintop.cpp b/plugins/paintops/watercolor/kis_watercolor_paintop.cpp index e4f697c7bb..94b358ae90 100644 --- a/plugins/paintops/watercolor/kis_watercolor_paintop.cpp +++ b/plugins/paintops/watercolor/kis_watercolor_paintop.cpp @@ -1,44 +1,60 @@ /* This file is part of the KDE project * * Copyright (C) 2017 Grigory Tantsevov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_watercolor_paintop.h" #include "kis_watercolor_base_items.h" #include #include -#include "kis_image.h" + +#include "KoCompositeOps.h" KisWatercolorPaintOp::KisWatercolorPaintOp(const KisPaintOpSettingsSP settings, KisPainter *painter, KisNodeSP node, KisImageSP image) : KisPaintOp(painter) { + Q_UNUSED(image); + Q_UNUSED(node); m_watercolorOption.readOptionSetting(settings); + m_lastTime = 0; + m_timer.start(); } KisWatercolorPaintOp::~KisWatercolorPaintOp() { } KisSpacingInformation KisWatercolorPaintOp::paintAt(const KisPaintInformation &info) { - KisWatercolorBaseItems::instance()->paint(info.pos(), 25, painter()->paintColor(), m_watercolorOption.type); + qint16 time = m_timer.elapsed(); + qint16 timeGone = time - m_lastTime; + KisWatercolorBaseItems::instance()->paint(info.pos(), m_watercolorOption.radius, m_watercolorOption.type); + for (int i = 0; i < timeGone / 33; i++) { + KisWatercolorBaseItems::instance()->update(); + } + + m_lastTime = time - time % 33; + + + painter()->device()->clear(); + KisWatercolorBaseItems::instance()->repaint(painter()); - return KisSpacingInformation(1.0); + return KisSpacingInformation(m_watercolorOption.radius / 3); } diff --git a/plugins/paintops/watercolor/kis_watercolor_paintop.h b/plugins/paintops/watercolor/kis_watercolor_paintop.h index 021579ee9d..55147fa9b0 100644 --- a/plugins/paintops/watercolor/kis_watercolor_paintop.h +++ b/plugins/paintops/watercolor/kis_watercolor_paintop.h @@ -1,47 +1,51 @@ /* This file is part of the KDE project * * Copyright (C) 2017 Grigory Tantsevov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_EXPERIMENT_PAINTOP_H_ #define KIS_EXPERIMENT_PAINTOP_H_ #include #include #include #include "kis_paint_information.h" #include "kis_watercolorop_option.h" +#include + class KisPainter; class KisWatercolorPaintOp : public KisPaintOp { public: KisWatercolorPaintOp(const KisPaintOpSettingsSP settings, KisPainter *painter, KisNodeSP node, KisImageSP image); ~KisWatercolorPaintOp(); KisSpacingInformation paintAt(const KisPaintInformation& info); private: WatercolorOption m_watercolorOption; + QElapsedTimer m_timer; + qint16 m_lastTime; }; #endif // KIS_EXPERIMENT_PAINTOP_H_ diff --git a/plugins/paintops/watercolor/kis_watercolor_paintop_settings.cpp b/plugins/paintops/watercolor/kis_watercolor_paintop_settings.cpp index b0b380fc2d..f0783e5723 100644 --- a/plugins/paintops/watercolor/kis_watercolor_paintop_settings.cpp +++ b/plugins/paintops/watercolor/kis_watercolor_paintop_settings.cpp @@ -1,155 +1,201 @@ /* This file is part of the KDE project * * Copyright (C) 2017 Grigory Tantsevov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_watercolor_paintop_settings.h" +#include "kis_watercolorop_option.h" struct KisWatercolorPaintOpSettings::Private { QList uniformProperties; }; KisWatercolorPaintOpSettings::KisWatercolorPaintOpSettings() : m_d(new Private) { } KisWatercolorPaintOpSettings::~KisWatercolorPaintOpSettings() { } bool KisWatercolorPaintOpSettings::paintIncremental() { /** * The watercolor brush supports working in the * WASH mode only! */ - return false; + return true; +} + +void KisWatercolorPaintOpSettings::setPaintOpSize(qreal value) +{ + WatercolorOption op; + op.readOptionSettingImpl(this); + op.radius = qRound(0.5 * value); + op.writeOptionSettingImpl(this); +} + +qreal KisWatercolorPaintOpSettings::paintOpSize() const +{ + WatercolorOption op; + op.readOptionSettingImpl(this); + return op.radius; + } #include #include "kis_paintop_preset.h" #include "kis_paintop_settings_update_proxy.h" #include "kis_watercolorop_option.h" #include "kis_standard_uniform_properties_factory.h" QList KisWatercolorPaintOpSettings::uniformProperties(KisPaintOpSettingsSP settings) { QList props = listWeakToStrong(m_d->uniformProperties); if (props.isEmpty()) { { KisDoubleSliderBasedPaintOpPropertyCallback *prop = new KisDoubleSliderBasedPaintOpPropertyCallback( KisDoubleSliderBasedPaintOpPropertyCallback::Double, "watercolor_gravityX", i18n("GravityX"), settings, 0); prop->setRange(-10.0, 10.0); prop->setSingleStep(1.0); prop->setReadCallback( [](KisUniformPaintOpProperty *prop) { WatercolorOption option; - option.readOptionSetting(prop->settings().data()); + option.readOptionSettingImpl(prop->settings().data()); prop->setValue(qreal(option.gravityX)); }); prop->setWriteCallback( [](KisUniformPaintOpProperty *prop) { WatercolorOption option; - option.readOptionSetting(prop->settings().data()); + option.readOptionSettingImpl(prop->settings().data()); option.gravityX = prop->value().toDouble(); option.writeOptionSetting(prop->settings().data()); }); QObject::connect(preset()->updateProxy(), SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue())); prop->requestReadValue(); props << toQShared(prop); } { KisDoubleSliderBasedPaintOpPropertyCallback *prop = new KisDoubleSliderBasedPaintOpPropertyCallback( KisDoubleSliderBasedPaintOpPropertyCallback::Double, "watercolor_gravityY", i18n("GravityY"), settings, 0); prop->setRange(-10.0, 10.0); prop->setSingleStep(1.0); prop->setReadCallback( [](KisUniformPaintOpProperty *prop) { WatercolorOption option; - option.readOptionSetting(prop->settings().data()); + option.readOptionSettingImpl(prop->settings().data()); prop->setValue(qreal(option.gravityY)); }); prop->setWriteCallback( [](KisUniformPaintOpProperty *prop) { WatercolorOption option; - option.readOptionSetting(prop->settings().data()); + option.readOptionSettingImpl(prop->settings().data()); option.gravityY = prop->value().toDouble(); - option.writeOptionSetting(prop->settings().data()); + option.writeOptionSettingImpl(prop->settings().data()); }); QObject::connect(preset()->updateProxy(), SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue())); prop->requestReadValue(); props << toQShared(prop); } { KisUniformPaintOpPropertyCallback *prop = new KisUniformPaintOpPropertyCallback( KisUniformPaintOpPropertyCallback::Int, "watercolor_brushType", i18n("BrushType"), settings, 0); prop->setReadCallback( [](KisUniformPaintOpProperty *prop) { WatercolorOption option; - option.readOptionSetting(prop->settings().data()); + option.readOptionSettingImpl(prop->settings().data()); prop->setValue(int(option.type)); }); prop->setWriteCallback( [](KisUniformPaintOpProperty *prop) { WatercolorOption option; - option.readOptionSetting(prop->settings().data()); + option.readOptionSettingImpl(prop->settings().data()); option.type = prop->value().toInt(); - option.writeOptionSetting(prop->settings().data()); + option.writeOptionSettingImpl(prop->settings().data()); + }); + + QObject::connect(preset()->updateProxy(), SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue())); + prop->requestReadValue(); + props << toQShared(prop); + } + + { + KisDoubleSliderBasedPaintOpPropertyCallback *prop = + new KisDoubleSliderBasedPaintOpPropertyCallback( + KisDoubleSliderBasedPaintOpPropertyCallback::Double, + "watercolor_radius", + i18n("Radius"), + settings, 0); + prop->setRange(0, 1000.0); + prop->setSingleStep(1.0); + prop->setReadCallback( + [](KisUniformPaintOpProperty *prop) { + WatercolorOption option; + option.readOptionSettingImpl(prop->settings().data()); + + prop->setValue(qreal(option.radius)); + }); + prop->setWriteCallback( + [](KisUniformPaintOpProperty *prop) { + WatercolorOption option; + option.readOptionSettingImpl(prop->settings().data()); + option.radius = prop->value().toDouble(); + option.writeOptionSettingImpl(prop->settings().data()); }); QObject::connect(preset()->updateProxy(), SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue())); prop->requestReadValue(); props << toQShared(prop); } } { using namespace KisStandardUniformPropertiesFactory; Q_FOREACH (KisUniformPaintOpPropertySP prop, KisPaintOpSettings::uniformProperties(settings)) { if (prop->id() == opacity.id()) { props.prepend(prop); } } } return props; } diff --git a/plugins/paintops/watercolor/kis_watercolor_paintop_settings.h b/plugins/paintops/watercolor/kis_watercolor_paintop_settings.h index 742b57ada1..7390be4634 100644 --- a/plugins/paintops/watercolor/kis_watercolor_paintop_settings.h +++ b/plugins/paintops/watercolor/kis_watercolor_paintop_settings.h @@ -1,42 +1,45 @@ /* This file is part of the KDE project * * Copyright (C) 2017 Grigory Tantsevov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_WATERCOLOR_PAINTOP_SETTINGS_H_ #define KIS_WATERCOLOR_PAINTOP_SETTINGS_H_ -#include +#include #include -class KisWatercolorPaintOpSettings : public KisNoSizePaintOpSettings +class KisWatercolorPaintOpSettings : public KisPaintOpSettings { public: KisWatercolorPaintOpSettings(); virtual ~KisWatercolorPaintOpSettings(); bool paintIncremental(); + void setPaintOpSize(qreal value) override; + qreal paintOpSize() const override; + QList uniformProperties(KisPaintOpSettingsSP settings); private: struct Private; const QScopedPointer m_d; }; #endif diff --git a/plugins/paintops/watercolor/kis_watercolor_paintop_settings_widget.cpp b/plugins/paintops/watercolor/kis_watercolor_paintop_settings_widget.cpp index 47d095b22c..809ba17c52 100644 --- a/plugins/paintops/watercolor/kis_watercolor_paintop_settings_widget.cpp +++ b/plugins/paintops/watercolor/kis_watercolor_paintop_settings_widget.cpp @@ -1,23 +1,43 @@ +/* This file is part of the KDE project + * + * Copyright (C) 2017 Grigory Tantsevov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + #include "kis_watercolor_paintop_settings_widget.h" #include "kis_watercolorop_option.h" #include "kis_watercolor_paintop_settings.h" #include KisWatercolorPaintOpSettingsWidget::KisWatercolorPaintOpSettingsWidget(QWidget *parent) : KisPaintOpSettingsWidget(parent) { addPaintOpOption(new KisWatercolorOpOption(), i18n("Watercolor option")); addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); } KisPropertiesConfigurationSP KisWatercolorPaintOpSettingsWidget::configuration() const { KisWatercolorPaintOpSettings* config = new KisWatercolorPaintOpSettings(); config->setOptionsWidget(const_cast(this)); config->setProperty("paintop", "watercolorbrush"); // XXX: make this a const id string writeConfiguration(config); return config; } diff --git a/plugins/paintops/watercolor/kis_watercolorop_option.cpp b/plugins/paintops/watercolor/kis_watercolorop_option.cpp index 491e6ee623..63e76ab349 100644 --- a/plugins/paintops/watercolor/kis_watercolorop_option.cpp +++ b/plugins/paintops/watercolor/kis_watercolorop_option.cpp @@ -1,86 +1,99 @@ /* This file is part of the KDE project * * Copyright (C) 2017 Grigory Tantsevov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_watercolorop_option.h" #include #include #include #include "ui_wdgwatercoloroptions.h" class KisWatercolorOpOptionsWidget: public QWidget, public Ui::WdgWatercolorOptions { public: KisWatercolorOpOptionsWidget(QWidget *parent = 0) : QWidget(parent) { setupUi(this); gravityX->setRange(-10.0, 10.0); gravityX->setValue(0); gravityX->setSingleStep(1.0); gravityY->setRange(-10.0, 10.0); gravityY->setValue(0); gravityY->setSingleStep(1.0); + + radius->setRange(0.0, 1000.0); + radius->setPrefix("px"); + radius->setValue(25); + radius->setSingleStep(1.0); } }; KisWatercolorOpOption::KisWatercolorOpOption() : KisPaintOpOption(KisPaintOpOption::GENERAL, false) { setObjectName("KisWatercolorOpOption"); m_checkable = false; m_options = new KisWatercolorOpOptionsWidget(); connect(m_options->gravityX, SIGNAL(valueChanged(qreal)), SLOT(emitSettingChanged())); connect(m_options->gravityY, SIGNAL(valueChanged(qreal)), SLOT(emitSettingChanged())); connect(m_options->brushType, SIGNAL(currentIndexChanged(QString)), SLOT(emitSettingChanged())); + connect(m_options->radius, SIGNAL(valueChanged(qreal)), SLOT(emitSettingChanged())); setConfigurationPage(m_options); } KisWatercolorOpOption::~KisWatercolorOpOption() { delete m_options; } void KisWatercolorOpOption::writeOptionSetting(KisPropertiesConfigurationSP setting) const { - WatercolorOption op; + setting->setProperty(WATERCOLOR_GRAVITY_X, m_options->gravityX->value()); + setting->setProperty(WATERCOLOR_GRAVITY_Y, m_options->gravityY->value()); + setting->setProperty(WATERCOLOR_TYPE, m_options->brushType->currentIndex()); + setting->setProperty(WATERCOLOR_RADIUS, m_options->radius->value()); +// WatercolorOption op; + +// op.gravityX = m_options->gravityX->value(); +// op.gravityY = m_options->gravityY->value(); - op.gravityX = m_options->gravityX->value(); - op.gravityY = m_options->gravityY->value(); +// op.type = m_options->brushType->currentIndex(); - op.type = m_options->brushType->currentIndex(); +// op.radius = m_options->radius->value(); - op.writeOptionSetting(setting); +// op.writeOptionSettingImpl(setting); } void KisWatercolorOpOption::readOptionSetting(const KisPropertiesConfigurationSP setting) { - WatercolorOption op; - op.readOptionSetting(setting); +// WatercolorOption op; +// op.readOptionSettingImpl(setting); - m_options->gravityX->setValue(op.gravityX); - m_options->gravityY->setValue(op.gravityY); - m_options->brushType->setCurrentIndex(op.type); + m_options->gravityX->setValue(setting->getDouble(WATERCOLOR_GRAVITY_X)); + m_options->gravityY->setValue(setting->getDouble(WATERCOLOR_GRAVITY_Y)); + m_options->brushType->setCurrentIndex(setting->getInt(WATERCOLOR_TYPE)); + m_options->radius->setValue(setting->getDouble(WATERCOLOR_RADIUS)); } diff --git a/plugins/paintops/watercolor/kis_watercolorop_option.h b/plugins/paintops/watercolor/kis_watercolorop_option.h index dfb53d93e6..c96433a11d 100644 --- a/plugins/paintops/watercolor/kis_watercolorop_option.h +++ b/plugins/paintops/watercolor/kis_watercolorop_option.h @@ -1,64 +1,68 @@ /* This file is part of the KDE project * * Copyright (C) 2017 Grigory Tantsevov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_WATERCOLOROP_OPTION_H #define KIS_WATERCOLOROP_OPTION_H #include const QString WATERCOLOR_TYPE = "Watercolor/type"; const QString WATERCOLOR_GRAVITY_X = "Watercolor/gravityX"; const QString WATERCOLOR_GRAVITY_Y = "Watercolor/gravityY"; +const QString WATERCOLOR_RADIUS = "Watercolor/radius"; class KisWatercolorOpOptionsWidget; class KisWatercolorOpOption : public KisPaintOpOption { public: KisWatercolorOpOption(); ~KisWatercolorOpOption(); void writeOptionSetting(KisPropertiesConfigurationSP setting) const; void readOptionSetting(const KisPropertiesConfigurationSP setting); private: KisWatercolorOpOptionsWidget *m_options; }; -class WatercolorOption +class WatercolorOption : public KisBaseOption { public: int type; qreal gravityX, gravityY; + qreal radius; - void readOptionSetting(const KisPropertiesConfigurationSP setting) { + void readOptionSettingImpl(const KisPropertiesConfiguration *setting) { type = setting->getInt(WATERCOLOR_TYPE); gravityX = setting->getDouble(WATERCOLOR_GRAVITY_X); gravityY = setting->getDouble(WATERCOLOR_GRAVITY_Y); + radius = setting->getDouble(WATERCOLOR_RADIUS); } - void writeOptionSetting(KisPropertiesConfigurationSP setting) const { + void writeOptionSettingImpl(KisPropertiesConfiguration *setting) const { setting->setProperty(WATERCOLOR_TYPE, type); setting->setProperty(WATERCOLOR_GRAVITY_X, gravityX); setting->setProperty(WATERCOLOR_GRAVITY_Y, gravityY); + setting->setProperty(WATERCOLOR_RADIUS, radius); } }; #endif diff --git a/plugins/paintops/watercolor/wdgwatercoloroptions.ui b/plugins/paintops/watercolor/wdgwatercoloroptions.ui index 0c70ec97f0..df137a32aa 100644 --- a/plugins/paintops/watercolor/wdgwatercoloroptions.ui +++ b/plugins/paintops/watercolor/wdgwatercoloroptions.ui @@ -1,118 +1,132 @@ WdgWatercolorOptions 0 0 425 328 255 255 425 290 + + + + + + Radius + + + + + + + + Gravity vector: x y Brush type: Simple Wet-on-dry Wet-on-wet Blobby Crunchy Qt::Vertical 20 40 KisDoubleSliderSpinBox QWidget
kis_slider_spin_box.h
1