diff --git a/plugins/paintops/colorsmudge/kis_colorsmudgeop_settings_widget.cpp b/plugins/paintops/colorsmudge/kis_colorsmudgeop_settings_widget.cpp index 395d8b5339..286bcc7c1d 100644 --- a/plugins/paintops/colorsmudge/kis_colorsmudgeop_settings_widget.cpp +++ b/plugins/paintops/colorsmudge/kis_colorsmudgeop_settings_widget.cpp @@ -1,88 +1,88 @@ /* * Copyright (C) 2011 Silvio Heinrich * * 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_colorsmudgeop_settings_widget.h" #include "kis_brush_based_paintop_settings.h" #include "kis_overlay_mode_option.h" #include "kis_rate_option.h" #include "kis_smudge_option_widget.h" #include "kis_smudge_radius_option.h" #include #include #include #include #include #include #include #include #include #include #include #include "kis_texture_option.h" #include "kis_curve_option_widget.h" #include #include "kis_pressure_texture_strength_option.h" KisColorSmudgeOpSettingsWidget::KisColorSmudgeOpSettingsWidget(QWidget* parent): KisBrushBasedPaintopOptionWidget(parent) { setObjectName("brush option widget"); setPrecisionEnabled(true); addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size")); addPaintOpOption(new KisPressureSpacingOptionWidget(), i18n("Spacing")); addPaintOpOption(new KisPressureMirrorOptionWidget(), i18n("Mirror")); m_smudgeOptionWidget = new KisSmudgeOptionWidget(); addPaintOpOption(m_smudgeOptionWidget, i18n("Smudge Length")); addPaintOpOption(new KisCurveOptionWidget(new KisSmudgeRadiusOption(), i18n("0.0"), i18n("1.0")), i18n("Smudge Radius")); addPaintOpOption(new KisCurveOptionWidget(new KisRateOption("ColorRate", KisPaintOpOption::GENERAL, false), i18n("0.0"), i18n("1.0")), i18n("Color Rate")); - addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation")); + addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation")); addPaintOpOption(new KisPressureScatterOptionWidget(), i18n("Scatter")); addPaintOpOption(new KisOverlayModeOptionWidget(), i18n("Overlay Mode")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureGradientOption(), i18n("0%"), i18n("100%")), i18n("Gradient")); addPaintOpOption(new KisTextureOption(), i18n("Pattern")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureTextureStrengthOption(), i18n("Weak"), i18n("Strong")), i18n("Strength")); } KisColorSmudgeOpSettingsWidget::~KisColorSmudgeOpSettingsWidget() { } KisPropertiesConfiguration* KisColorSmudgeOpSettingsWidget::configuration() const { KisBrushBasedPaintOpSettings *config = new KisBrushBasedPaintOpSettings(); config->setOptionsWidget(const_cast(this)); config->setProperty("paintop", "colorsmudge"); writeConfiguration(config); return config; } void KisColorSmudgeOpSettingsWidget::notifyPageChanged() { KisBrushSP brush = this->brush(); bool pierced = brush ? brush->isPiercedApprox() : false; m_smudgeOptionWidget->updateBrushPierced(pierced); } diff --git a/plugins/paintops/colorsmudge/kis_rate_option.cpp b/plugins/paintops/colorsmudge/kis_rate_option.cpp index 33b5fccb80..48e1e9e7b3 100644 --- a/plugins/paintops/colorsmudge/kis_rate_option.cpp +++ b/plugins/paintops/colorsmudge/kis_rate_option.cpp @@ -1,47 +1,49 @@ /* This file is part of the KDE project * * Copyright (C) 2011 Silvio Heinrich * * 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_rate_option.h" #include #include #include #include #include KisRateOption::KisRateOption(const QString& name, KisPaintOpOption::PaintopCategory category, bool checked): KisCurveOption(name, category, checked) { } void KisRateOption::apply(KisPainter& painter, const KisPaintInformation& info, qreal scaleMin, qreal scaleMax, qreal multiplicator) const { if (!isChecked()) { painter.setOpacity((quint8)(scaleMax * 255.0)); return; } - qreal rate = scaleMin + (scaleMax - scaleMin) * multiplicator * computeValue(info); // scale m_rate into the range scaleMin - scaleMax + qreal value = computeSizeLikeValue(info); + + qreal rate = scaleMin + (scaleMax - scaleMin) * multiplicator * value; // scale m_rate into the range scaleMin - scaleMax quint8 opacity = qBound(OPACITY_TRANSPARENT_U8, (quint8)(rate * 255.0), OPACITY_OPAQUE_U8); painter.setOpacity(opacity); } diff --git a/plugins/paintops/colorsmudge/kis_smudge_option.cpp b/plugins/paintops/colorsmudge/kis_smudge_option.cpp index cca0399051..ebe142e2cd 100644 --- a/plugins/paintops/colorsmudge/kis_smudge_option.cpp +++ b/plugins/paintops/colorsmudge/kis_smudge_option.cpp @@ -1,61 +1,63 @@ /* This file is part of the KDE project * * Copyright (C) 2011 Silvio Heinrich * * 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_smudge_option.h" #include #include #include #include KisSmudgeOption::KisSmudgeOption(): KisRateOption("SmudgeRate", KisPaintOpOption::GENERAL, true), m_mode(SMEARING_MODE) { setValueRange(0.01, 1.0); } void KisSmudgeOption::apply(KisPainter& painter, const KisPaintInformation& info, qreal scaleMin, qreal scaleMax, qreal multiplicator) const { if (!isChecked()) { painter.setOpacity((quint8)(scaleMax * 255.0)); return; } - qreal rate = scaleMin + (scaleMax - scaleMin) * multiplicator * computeValue(info); // scale m_rate into the range scaleMin - scaleMax + qreal value = computeSizeLikeValue(info); + + qreal rate = scaleMin + (scaleMax - scaleMin) * multiplicator * value; // scale m_rate into the range scaleMin - scaleMax quint8 opacity = qBound(OPACITY_TRANSPARENT_U8, (quint8)(rate * 255.0), OPACITY_OPAQUE_U8); painter.setOpacity(opacity); } void KisSmudgeOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { KisRateOption::writeOptionSetting(setting); setting->setProperty(name() + "Mode", m_mode); } void KisSmudgeOption::readOptionSetting(const KisPropertiesConfiguration* setting) { KisRateOption::readOptionSetting(setting); m_mode = (Mode)setting->getInt(name() + "Mode", SMEARING_MODE); } diff --git a/plugins/paintops/colorsmudge/kis_smudge_radius_option.cpp b/plugins/paintops/colorsmudge/kis_smudge_radius_option.cpp index b1bf42e5b5..deece0b5a4 100644 --- a/plugins/paintops/colorsmudge/kis_smudge_radius_option.cpp +++ b/plugins/paintops/colorsmudge/kis_smudge_radius_option.cpp @@ -1,160 +1,163 @@ /* * Copyright (C) 2014 Mohit Goyal * * 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_smudge_radius_option.h" #include #include #include #include "kis_paint_device.h" #include "KoPointerEvent.h" #include "KoCanvasBase.h" #include "kis_random_accessor_ng.h" #include "KoColor.h" #include #include #include #include #include class KisRandomConstAccessorNG; KisSmudgeRadiusOption::KisSmudgeRadiusOption(): KisRateOption("SmudgeRadius", KisPaintOpOption::GENERAL, true) { setValueRange(0.0,300.0); } void KisSmudgeRadiusOption::apply(KisPainter& painter, const KisPaintInformation& info, qreal diameter, qreal posx, qreal posy, KisPaintDeviceSP dev) const { - double sliderValue = computeValue(info); + if (!isChecked()) return; + + qreal sliderValue = computeSizeLikeValue(info); + int smudgeRadius = ((sliderValue * diameter) * 0.5) / 100.0; KoColor color = painter.paintColor(); if (smudgeRadius == 1) { dev->pixel(posx, posy, &color); painter.setPaintColor(color); } else { const KoColorSpace* cs = dev->colorSpace(); int pixelSize = cs->pixelSize(); quint8* data = new quint8[pixelSize]; static quint8** pixels = new quint8*[2]; qint16* weights = new qint16[2]; pixels[1] = new quint8[pixelSize]; pixels[0] = new quint8[pixelSize]; int loop_increment = 1; if(smudgeRadius >= 8) { loop_increment = (2*smudgeRadius)/16; } int i = 0; int k = 0; int j = 0; KisRandomConstAccessorSP accessor = dev->createRandomConstAccessorNG(0, 0); KisCrossDeviceColorPickerInt colorPicker(painter.device(), color); colorPicker.pickColor(posx, posy, color.data()); for (int y = 0; y <= smudgeRadius; y = y + loop_increment) { for (int x = 0; x <= smudgeRadius; x = x + loop_increment) { for(j = 0;j < 2;j++) { if(j == 1) { y = y*(-1); } for(k = 0;k < 2;k++) { if(k == 1) { x = x*(-1); } accessor->moveTo(posx + x, posy + y); memcpy(pixels[1], accessor->rawDataConst(), pixelSize); if(i == 0) { memcpy(pixels[0],accessor->rawDataConst(),pixelSize); } if (x == 0 && y == 0) { // Because the sum of the weights must be 255, // we cheat a bit, and weigh the center pixel differently in order // to sum to 255 in total // It's -(counts -1), because we'll add the center one implicitly // through that calculation weights[1] = (255 - ((i + 1) * (255 /(i+2) )) ); } else { weights[1] = 255 /(i+2); } i++; if (i>smudgeRadius){i=0;} weights[0] = 255 - weights[1]; const quint8** cpixels = const_cast(pixels); cs->mixColorsOp()->mixColors(cpixels, weights,2, data); memcpy(pixels[0],data,pixelSize); } x = x*(-1); } y = y*(-1); } } KoColor color = KoColor(pixels[0],cs); painter.setPaintColor(color); for (int l = 0; l < 2; l++){ delete[] pixels[l]; } // delete[] pixels; delete[] data; } } void KisSmudgeRadiusOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { KisCurveOption::writeOptionSetting(setting); } void KisSmudgeRadiusOption::readOptionSetting(const KisPropertiesConfiguration* setting) { KisCurveOption::readOptionSetting(setting); } diff --git a/plugins/paintops/curvebrush/kis_curves_opacity_option.cpp b/plugins/paintops/curvebrush/kis_curves_opacity_option.cpp index fd1a7285a2..5961f060cc 100644 --- a/plugins/paintops/curvebrush/kis_curves_opacity_option.cpp +++ b/plugins/paintops/curvebrush/kis_curves_opacity_option.cpp @@ -1,34 +1,32 @@ /* * Copyright (c) 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 "kis_curves_opacity_option.h" #include KisCurvesOpacityOption::KisCurvesOpacityOption() : KisCurveOption("Curves opacity", KisPaintOpOption::GENERAL, false) { } qreal KisCurvesOpacityOption::apply(const KisPaintInformation & info, qreal opacity) const { - if (!isChecked()) { - return opacity; - } - return computeValue(info) * opacity; + if (!isChecked()) return opacity; + return computeSizeLikeValue(info) * opacity; } diff --git a/plugins/paintops/curvebrush/kis_linewidth_option.cpp b/plugins/paintops/curvebrush/kis_linewidth_option.cpp index 840e54d8d2..2b590c398f 100644 --- a/plugins/paintops/curvebrush/kis_linewidth_option.cpp +++ b/plugins/paintops/curvebrush/kis_linewidth_option.cpp @@ -1,34 +1,32 @@ /* * Copyright (c) 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 "kis_linewidth_option.h" #include "kis_paintop_option.h" KisLineWidthOption::KisLineWidthOption() : KisCurveOption("Line width", KisPaintOpOption::GENERAL, false) { } double KisLineWidthOption::apply(const KisPaintInformation & info, double lineWidth) const { - if (!isChecked()) { - return lineWidth; - } - return computeValue(info) * lineWidth; + if (!isChecked()) return lineWidth; + return computeSizeLikeValue(info) * lineWidth; } diff --git a/plugins/paintops/defaultpaintops/brush/kis_brushop_settings_widget.cpp b/plugins/paintops/defaultpaintops/brush/kis_brushop_settings_widget.cpp index f250414e45..ffe1a4ddd3 100644 --- a/plugins/paintops/defaultpaintops/brush/kis_brushop_settings_widget.cpp +++ b/plugins/paintops/defaultpaintops/brush/kis_brushop_settings_widget.cpp @@ -1,95 +1,95 @@ /* * Copyright (c) 2002 Patrick Julien * Copyright (c) 2004-2008 Boudewijn Rempt * Copyright (c) 2004 Clarence Dang * Copyright (c) 2004 Adrian Page * Copyright (c) 2004 Cyrille Berger * * 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_brushop_settings_widget.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_texture_option.h" #include "kis_curve_option_widget.h" #include #include "kis_pressure_texture_strength_option.h" KisBrushOpSettingsWidget::KisBrushOpSettingsWidget(QWidget* parent) : KisBrushBasedPaintopOptionWidget(parent) { setObjectName("brush option widget"); setPrecisionEnabled(true); // Brush tip options addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); addPaintOpOption(new KisFlowOpacityOptionWidget(), i18n("Opacity")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureFlowOption(), i18n("0%"), i18n("100%")), i18n("Flow")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size")); addPaintOpOption(new KisPressureSpacingOptionWidget(), i18n("Spacing")); addPaintOpOption(new KisPressureMirrorOptionWidget(), i18n("Mirror")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSoftnessOption(), i18n("Soft"), i18n("Hard")), i18n("Softness")); addPaintOpOption(new KisPressureSharpnessOptionWidget(), i18n("Sharpness")); - addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation")); + addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation")); addPaintOpOption(new KisPressureScatterOptionWidget(), i18n("Scatter")); // Colors options addPaintOpOption(new KisColorSourceOptionWidget(), i18n("Source")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureDarkenOption(), i18n("0.0"), i18n("1.0")), i18n("Darken")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureMixOption(), i18n("Foreground"), i18n("Background")), i18n("Mix")); addPaintOpOption(new KisCurveOptionWidget(KisPressureHSVOption::createHueOption(), KisPressureHSVOption::hueMinLabel(), KisPressureHSVOption::huemaxLabel()), i18n("Hue")); addPaintOpOption(new KisCurveOptionWidget(KisPressureHSVOption::createSaturationOption(), KisPressureHSVOption::saturationMinLabel(), KisPressureHSVOption::saturationmaxLabel()), i18n("Saturation")); addPaintOpOption(new KisCurveOptionWidget(KisPressureHSVOption::createValueOption(), KisPressureHSVOption::valueMinLabel(), KisPressureHSVOption::valuemaxLabel()), i18n("Value")); addPaintOpOption(new KisAirbrushOption(false), i18n("Airbrush")); addPaintOpOption(new KisPaintActionTypeOption(), i18n("Painting Mode")); addPaintOpOption(new KisTextureOption(), i18n("Pattern")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureTextureStrengthOption(), i18n("Weak"), i18n("Strong")), i18n("Strength")); } KisBrushOpSettingsWidget::~KisBrushOpSettingsWidget() { } KisPropertiesConfiguration* KisBrushOpSettingsWidget::configuration() const { KisBrushBasedPaintOpSettings *config = new KisBrushBasedPaintOpSettings(); config->setOptionsWidget(const_cast(this)); config->setProperty("paintop", "paintbrush"); // XXX: make this a const id string writeConfiguration(config); return config; } diff --git a/plugins/paintops/deform/kis_deform_paintop_settings_widget.cpp b/plugins/paintops/deform/kis_deform_paintop_settings_widget.cpp index e11ae3a92d..bb2f5199db 100644 --- a/plugins/paintops/deform/kis_deform_paintop_settings_widget.cpp +++ b/plugins/paintops/deform/kis_deform_paintop_settings_widget.cpp @@ -1,80 +1,80 @@ /* * Copyright (c) 2008,2009,2010 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 "kis_deform_paintop_settings.h" #include "kis_deform_paintop_settings_widget.h" #include "kis_deform_option.h" #include #include #include #include #include #include #include #include KisDeformPaintOpSettingsWidget::KisDeformPaintOpSettingsWidget(QWidget* parent) : KisPaintOpSettingsWidget(parent) { m_deformOption = new KisDeformOption(); m_brushSizeOption = new KisBrushSizeOption(); m_brushSizeOption->setDiameter(200); addPaintOpOption(m_brushSizeOption, i18n("Brush size")); addPaintOpOption(m_deformOption, i18n("Deform Options")); addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size")); - addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation")); + addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation")); addPaintOpOption(new KisAirbrushOption(), i18n("Airbrush")); } KisDeformPaintOpSettingsWidget::~ KisDeformPaintOpSettingsWidget() { } void KisDeformPaintOpSettingsWidget::changePaintOpSize(qreal x, qreal y) { // if the movement is more left<->right then up<->down if (qAbs(x) > qAbs(y)) { m_brushSizeOption->setDiameter(m_brushSizeOption->diameter() + qRound(x)); } else { // vice-versa // we can do something different, e.g. change deform mode or ... } } QSizeF KisDeformPaintOpSettingsWidget::paintOpSize() const { qreal height = m_brushSizeOption->diameter() * m_brushSizeOption->brushAspect(); return QSizeF(m_brushSizeOption->diameter(), height); } KisPropertiesConfiguration* KisDeformPaintOpSettingsWidget::configuration() const { KisDeformPaintOpSettings* config = new KisDeformPaintOpSettings(); config->setOptionsWidget(const_cast(this)); config->setProperty("paintop", "deformBrush"); writeConfiguration(config); return config; } diff --git a/plugins/paintops/filterop/kis_filterop_settings_widget.cpp b/plugins/paintops/filterop/kis_filterop_settings_widget.cpp index 7990263ad2..08f9d6658a 100644 --- a/plugins/paintops/filterop/kis_filterop_settings_widget.cpp +++ b/plugins/paintops/filterop/kis_filterop_settings_widget.cpp @@ -1,71 +1,71 @@ /* * Copyright (c) 2002 Patrick Julien * Copyright (c) 2004-2008 Boudewijn Rempt * Copyright (c) 2004 Clarence Dang * Copyright (c) 2004 Adrian Page * Copyright (c) 2004 Cyrille Berger * * 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_filterop_settings_widget.h" #include "kis_filterop_settings.h" #include #include #include #include #include #include #include #include #include #include #include #include "kis_texture_option.h" #include "kis_curve_option_widget.h" #include #include "kis_pressure_texture_strength_option.h" KisFilterOpSettingsWidget::KisFilterOpSettingsWidget(QWidget* parent) : KisBrushBasedPaintopOptionWidget(parent) { setObjectName("filter option widget"); setPrecisionEnabled(true); addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size")); - addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation")); + addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation")); addPaintOpOption(new KisPressureMirrorOptionWidget(), i18n("Mirror")); m_filterOption = new KisFilterOption(); addPaintOpOption(m_filterOption, i18nc("option name", "Filter")); } KisFilterOpSettingsWidget::~KisFilterOpSettingsWidget() { } KisPropertiesConfiguration* KisFilterOpSettingsWidget::configuration() const { KisFilterOpSettings *config = new KisFilterOpSettings(); config->setOptionsWidget(const_cast(this)); config->setProperty("paintop", "filter"); // XXX: make this a const id string writeConfiguration(config); return config; } diff --git a/plugins/paintops/hairy/kis_hairy_paintop_settings_widget.cpp b/plugins/paintops/hairy/kis_hairy_paintop_settings_widget.cpp index 19c67fe486..c692989ec6 100644 --- a/plugins/paintops/hairy/kis_hairy_paintop_settings_widget.cpp +++ b/plugins/paintops/hairy/kis_hairy_paintop_settings_widget.cpp @@ -1,59 +1,59 @@ /* * Copyright (c) 2008 Boudewijn Rempt * Copyright (c) 2008 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 "kis_hairy_paintop_settings_widget.h" #include "kis_hairy_paintop_settings.h" #include "kis_hairy_shape_option.h" #include "kis_hairy_ink_option.h" #include #include "kis_hairy_bristle_option.h" #include #include #include #include #include KisHairyPaintOpSettingsWidget:: KisHairyPaintOpSettingsWidget(QWidget* parent) : KisBrushBasedPaintopOptionWidget(parent) { //m_hairyShapeOption = new KisHairyShapeOption(); //addPaintOpOption(m_hairyShapeOption); addPaintOpOption(new KisHairyBristleOption(), i18n("Bristle options")); addPaintOpOption(new KisHairyInkOption(), i18n("Ink depletion")); addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size")); - addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation")); + addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation")); addPaintOpOption(new KisPaintActionTypeOption(), i18n("Painting Mode")); } KisHairyPaintOpSettingsWidget::~ KisHairyPaintOpSettingsWidget() { } KisPropertiesConfiguration* KisHairyPaintOpSettingsWidget::configuration() const { KisHairyPaintOpSettings* config = new KisHairyPaintOpSettings(); config->setOptionsWidget(const_cast(this)); config->setProperty("paintop", "hairybrush"); // XXX: make this a const id string writeConfiguration(config); return config; } diff --git a/plugins/paintops/hatching/kis_hatching_pressure_crosshatching_option.cpp b/plugins/paintops/hatching/kis_hatching_pressure_crosshatching_option.cpp index b2a20c00eb..b032fed497 100644 --- a/plugins/paintops/hatching/kis_hatching_pressure_crosshatching_option.cpp +++ b/plugins/paintops/hatching/kis_hatching_pressure_crosshatching_option.cpp @@ -1,36 +1,36 @@ /* * Copyright (c) 2010 José Luis Vergara * * 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_hatching_pressure_crosshatching_option.h" #include #include #include #include KisHatchingPressureCrosshatchingOption::KisHatchingPressureCrosshatchingOption() : KisCurveOption("Crosshatching", KisPaintOpOption::GENERAL, false) { } double KisHatchingPressureCrosshatchingOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return 0.5; - return computeValue(info); + return computeSizeLikeValue(info); } diff --git a/plugins/paintops/hatching/kis_hatching_pressure_separation_option.cpp b/plugins/paintops/hatching/kis_hatching_pressure_separation_option.cpp index 66ad0ad455..57abbb33fd 100644 --- a/plugins/paintops/hatching/kis_hatching_pressure_separation_option.cpp +++ b/plugins/paintops/hatching/kis_hatching_pressure_separation_option.cpp @@ -1,37 +1,37 @@ /* * Copyright (c) 2010 José Luis Vergara * * 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_hatching_pressure_separation_option.h" #include #include #include #include KisHatchingPressureSeparationOption::KisHatchingPressureSeparationOption() : KisCurveOption("Separation", KisPaintOpOption::GENERAL, true) { } double KisHatchingPressureSeparationOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return 0.5; - return computeValue(info); + return computeSizeLikeValue(info); } diff --git a/plugins/paintops/hatching/kis_hatching_pressure_thickness_option.cpp b/plugins/paintops/hatching/kis_hatching_pressure_thickness_option.cpp index 9b464a6447..a1a37f413a 100644 --- a/plugins/paintops/hatching/kis_hatching_pressure_thickness_option.cpp +++ b/plugins/paintops/hatching/kis_hatching_pressure_thickness_option.cpp @@ -1,37 +1,37 @@ /* * Copyright (c) 2010 José Luis Vergara * * 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_hatching_pressure_thickness_option.h" #include #include #include #include KisHatchingPressureThicknessOption::KisHatchingPressureThicknessOption() : KisCurveOption("Thickness", KisPaintOpOption::GENERAL, false) { } double KisHatchingPressureThicknessOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return 0.5; - return computeValue(info); + return computeSizeLikeValue(info); } diff --git a/plugins/paintops/libpaintop/kis_curve_option.cpp b/plugins/paintops/libpaintop/kis_curve_option.cpp index 24c7e55b6b..e7ab52212d 100644 --- a/plugins/paintops/libpaintop/kis_curve_option.cpp +++ b/plugins/paintops/libpaintop/kis_curve_option.cpp @@ -1,390 +1,391 @@ /* This file is part of the KDE project * Copyright (C) 2008 Boudewijn Rempt * Copyright (C) 2011 Silvio Heinrich * * 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_curve_option.h" #include KisCurveOption::KisCurveOption(const QString& name, KisPaintOpOption::PaintopCategory category, bool checked, qreal value, qreal min, qreal max) : m_name(name) , m_category(category) , m_checkable(true) , m_checked(checked) , m_useCurve(true) , m_useSameCurve(true) , m_separateCurveValue(false) { Q_FOREACH (const DynamicSensorType sensorType, KisDynamicSensor::sensorsTypes()) { KisDynamicSensorSP sensor = KisDynamicSensor::type2Sensor(sensorType); sensor->setActive(false); replaceSensor(sensor); } m_sensorMap[PRESSURE]->setActive(true); setValueRange(min, max); setValue(value); } KisCurveOption::~KisCurveOption() { m_curveCache.clear(); m_sensorMap.clear(); } const QString& KisCurveOption::name() const { return m_name; } KisPaintOpOption::PaintopCategory KisCurveOption::category() const { return m_category; } qreal KisCurveOption::minValue() const { return m_minValue; } qreal KisCurveOption::maxValue() const { return m_maxValue; } qreal KisCurveOption::value() const { return m_value; } void KisCurveOption::resetAllSensors() { Q_FOREACH (KisDynamicSensorSP sensor, m_sensorMap.values()) { if (sensor->isActive()) { sensor->reset(); } } } void KisCurveOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { if (m_checkable) { setting->setProperty("Pressure" + m_name, isChecked()); } if (activeSensors().size() == 1) { setting->setProperty(m_name + "Sensor", activeSensors().first()->toXML()); } else { QDomDocument doc = QDomDocument("params"); QDomElement root = doc.createElement("params"); doc.appendChild(root); root.setAttribute("id", "sensorslist"); Q_FOREACH (KisDynamicSensorSP sensor, activeSensors()) { QDomElement childelt = doc.createElement("ChildSensor"); sensor->toXML(doc, childelt); root.appendChild(childelt); } setting->setProperty(m_name + "Sensor", doc.toString()); } setting->setProperty(m_name + "UseCurve", m_useCurve); setting->setProperty(m_name + "UseSameCurve", m_useSameCurve); setting->setProperty(m_name + "Value", m_value); } void KisCurveOption::readOptionSetting(const KisPropertiesConfiguration* setting) { m_curveCache.clear(); readNamedOptionSetting(m_name, setting); } void KisCurveOption::lodLimitations(KisPaintopLodLimitations *l) const { Q_UNUSED(l); } void KisCurveOption::readNamedOptionSetting(const QString& prefix, const KisPropertiesConfiguration* setting) { if (!setting) return; //dbgKrita << "readNamedOptionSetting" << prefix; setting->dump(); if (m_checkable) { setChecked(setting->getBool("Pressure" + prefix, false)); } //dbgKrita << "\tPressure" + prefix << isChecked(); m_sensorMap.clear(); // Replace all sensors with the inactive defaults Q_FOREACH (const DynamicSensorType sensorType, KisDynamicSensor::sensorsTypes()) { replaceSensor(KisDynamicSensor::type2Sensor(sensorType)); } QString sensorDefinition = setting->getString(prefix + "Sensor"); if (!sensorDefinition.contains("sensorslist")) { KisDynamicSensorSP s = KisDynamicSensor::createFromXML(sensorDefinition); if (s) { replaceSensor(s); s->setActive(true); //dbgKrita << "\tsingle sensor" << s::id(s->sensorType()) << s->isActive() << "added"; } } else { QDomDocument doc; doc.setContent(sensorDefinition); QDomElement elt = doc.documentElement(); QDomNode node = elt.firstChild(); while (!node.isNull()) { if (node.isElement()) { QDomElement childelt = node.toElement(); if (childelt.tagName() == "ChildSensor") { KisDynamicSensorSP s = KisDynamicSensor::createFromXML(childelt); if (s) { replaceSensor(s); s->setActive(true); //dbgKrita << "\tchild sensor" << s::id(s->sensorType()) << s->isActive() << "added"; } } } node = node.nextSibling(); } } // Only load the old curve format if the curve wasn't saved by the sensor // This will give every sensor the same curve. //dbgKrita << ">>>>>>>>>>>" << prefix + "Sensor" << setting->getString(prefix + "Sensor"); if (!setting->getString(prefix + "Sensor").contains("curve")) { //dbgKrita << "\told format"; if (setting->getBool("Custom" + prefix, false)) { Q_FOREACH (KisDynamicSensorSP s, m_sensorMap.values()) { s->setCurve(setting->getCubicCurve("Curve" + prefix)); } } } // At least one sensor needs to be active if (activeSensors().size() == 0) { m_sensorMap[PRESSURE]->setActive(true); } m_value = setting->getDouble(m_name + "Value", m_maxValue); //dbgKrita << "\t" + m_name + "Value" << m_value; m_useCurve = setting->getBool(m_name + "UseCurve", true); //dbgKrita << "\t" + m_name + "UseCurve" << m_useSameCurve; m_useSameCurve = setting->getBool(m_name + "UseSameCurve", true); //dbgKrita << "\t" + m_name + "UseSameCurve" << m_useSameCurve; //dbgKrita << "-----------------"; } void KisCurveOption::replaceSensor(KisDynamicSensorSP s) { Q_ASSERT(s); m_sensorMap[s->sensorType()] = s; } KisDynamicSensorSP KisCurveOption::sensor(DynamicSensorType sensorType, bool active) const { if (m_sensorMap.contains(sensorType)) { if (!active) { return m_sensorMap[sensorType]; } else { if (m_sensorMap[sensorType]->isActive()) { return m_sensorMap[sensorType]; } } } return 0; } bool KisCurveOption::isRandom() const { - return (bool) sensor(FUZZY, true); + return bool(sensor(FUZZY_PER_DAB, true)) || + bool(sensor(FUZZY_PER_STROKE, true)); } bool KisCurveOption::isCurveUsed() const { return m_useCurve; } bool KisCurveOption::isSameCurveUsed() const { return m_useSameCurve; } void KisCurveOption::setSeparateCurveValue(bool separateCurveValue) { m_separateCurveValue = separateCurveValue; } bool KisCurveOption::isCheckable() { return m_checkable; } bool KisCurveOption::isChecked() const { return m_checked; } void KisCurveOption::setChecked(bool checked) { m_checked = checked; } void KisCurveOption::setCurveUsed(bool useCurve) { m_useCurve = useCurve; } void KisCurveOption::setCurve(DynamicSensorType sensorType, bool useSameCurve, const KisCubicCurve &curve) { // No switch in state, don't mess with the cache if (useSameCurve == m_useSameCurve) { if (useSameCurve) { Q_FOREACH (KisDynamicSensorSP s, m_sensorMap.values()) { s->setCurve(curve); } } else { KisDynamicSensorSP s = sensor(sensorType, false); if (s) { s->setCurve(curve); } } } else { // moving from not use same curve to use same curve: backup the custom curves if (!m_useSameCurve && useSameCurve) { // Copy the custom curves to the cache and set the new curve on all sensors, active or not m_curveCache.clear(); Q_FOREACH (KisDynamicSensorSP s, m_sensorMap.values()) { m_curveCache[s->sensorType()] = s->curve(); s->setCurve(curve); } } else { //if (m_useSameCurve && !useSameCurve) // Restore the cached curves KisDynamicSensorSP s = 0; Q_FOREACH (DynamicSensorType sensorType, m_curveCache.keys()) { if (m_sensorMap.contains(sensorType)) { s = m_sensorMap[sensorType]; } else { s = KisDynamicSensor::type2Sensor(sensorType); } s->setCurve(m_curveCache[sensorType]); m_sensorMap[sensorType] = s; } s = 0; // And set the current sensor to the current curve if (!m_sensorMap.contains(sensorType)) { s = KisDynamicSensor::type2Sensor(sensorType); } if (s) { s->setCurve(curve); s->setCurve(m_curveCache[sensorType]); } } m_useSameCurve = useSameCurve; } } void KisCurveOption::setValueRange(qreal min, qreal max) { m_minValue = qMin(min, max); m_maxValue = qMax(min, max); } void KisCurveOption::setValue(qreal value) { m_value = qBound(m_minValue, value, m_maxValue); } -double KisCurveOption::computeValue(const KisPaintInformation& info) const +KisCurveOption::ValueComponents KisCurveOption::computeValueComponents(const KisPaintInformation& info) const { - if (!m_useCurve) { - if (m_separateCurveValue) { - return 1.0; - } - else { - return m_value; - } - } - else { - qreal t = 1.0; + ValueComponents components; + if (m_useCurve) { QVector additiveSensors; Q_FOREACH (KisDynamicSensorSP s, m_sensorMap.values()) { if (s->isActive()) { - if (!s->isAdditive()) { - t *= s->parameter(info); + if (s->isAdditive()) { + components.additive += s->parameter(info); + components.hasAdditive = true; + } else if (s->isAbsoluteRotation()) { + components.absoluteOffset = s->parameter(info); + components.hasAbsoluteOffset =true; } else { - // additive sensors should be - // processed in the end - additiveSensors.append(s); + components.scaling *= s->parameter(info); + components.hasScaling = true; } } } + } - // add up addivite sensors to the result - Q_FOREACH (KisDynamicSensorSP s, additiveSensors) { - qreal t0 = t; - Q_UNUSED(t0) - qreal v = s->parameter(info); + if (!m_separateCurveValue) { + components.constant = m_value; + } - t = fmod(t + v, 1.0); - } + components.minSizeLikeValue = m_minValue; + components.maxSizeLikeValue = m_maxValue; - if (m_separateCurveValue) { - return t; - } - else { - return m_minValue + (m_value - m_minValue) * t; - } - } + return components; +} + +qreal KisCurveOption::computeSizeLikeValue(const KisPaintInformation& info) const +{ + const ValueComponents components = computeValueComponents(info); + return components.sizeLikeValue(); +} + +qreal KisCurveOption::computeRotationLikeValue(const KisPaintInformation& info, qreal baseValue) const +{ + const ValueComponents components = computeValueComponents(info); + return components.rotationLikeValue(baseValue); } QList KisCurveOption::sensors() { //dbgKrita << "ID" << name() << "has" << m_sensorMap.count() << "Sensors of which" << sensorList.count() << "are active."; return m_sensorMap.values(); } QList KisCurveOption::activeSensors() const { QList sensorList; Q_FOREACH (KisDynamicSensorSP sensor, m_sensorMap.values()) { if (sensor->isActive()) { sensorList << sensor; } } //dbgKrita << "ID" << name() << "has" << m_sensorMap.count() << "Sensors of which" << sensorList.count() << "are active."; return sensorList; } diff --git a/plugins/paintops/libpaintop/kis_curve_option.h b/plugins/paintops/libpaintop/kis_curve_option.h index db7f3fc1c6..c7b3c89257 100644 --- a/plugins/paintops/libpaintop/kis_curve_option.h +++ b/plugins/paintops/libpaintop/kis_curve_option.h @@ -1,118 +1,190 @@ /* This file is part of the KDE project * Copyright (C) 2008 Boudewijn Rempt * Copyright (C) 2011 Silvio Heinrich * * 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_CURVE_OPTION_H #define KIS_CURVE_OPTION_H #include #include #include "kis_paintop_option.h" #include "kis_global.h" #include "kis_paintop_option.h" #include #include "kritapaintop_export.h" #include "kis_dynamic_sensor.h" class KisDynamicSensor; /** * KisCurveOption is the base class for paintop options that are * defined through one or more curves. * * Note: it is NOT a KisPaintOpOption, even though the API is pretty similar! * */ class PAINTOP_EXPORT KisCurveOption { public: KisCurveOption(const QString& name, KisPaintOpOption::PaintopCategory category, bool checked, qreal value = 1.0, qreal min = 0.0, qreal max = 1.0); virtual ~KisCurveOption(); virtual void writeOptionSetting(KisPropertiesConfiguration* setting) const; virtual void readOptionSetting(const KisPropertiesConfiguration* setting); virtual void lodLimitations(KisPaintopLodLimitations *l) const; const QString& name() const; KisPaintOpOption::PaintopCategory category() const; qreal minValue() const; qreal maxValue() const; qreal value() const; void resetAllSensors(); KisDynamicSensorSP sensor(DynamicSensorType sensorType, bool active) const; void replaceSensor(KisDynamicSensorSP sensor); QList sensors(); QList activeSensors() const; bool isCheckable(); bool isChecked() const; bool isCurveUsed() const; bool isSameCurveUsed() const; bool isRandom() const; void setSeparateCurveValue(bool separateCurveValue); void setChecked(bool checked); void setCurveUsed(bool useCurve); void setCurve(DynamicSensorType sensorType, bool useSameCurve, const KisCubicCurve &curve); void setValue(qreal value); + struct ValueComponents { + + ValueComponents() + : constant(1.0), + scaling(1.0), + additive(0.0), + absoluteOffset(0.0), + hasAbsoluteOffset(false), + hasScaling(false), + hasAdditive(false) + { + } + + qreal constant; + qreal scaling; + qreal additive; + qreal absoluteOffset; + bool hasAbsoluteOffset; + bool hasScaling; + bool hasAdditive; + qreal minSizeLikeValue; + qreal maxSizeLikeValue; + + qreal rotationLikeValue(qreal baseAngle) const { + const qreal offset = + hasAbsoluteOffset ? absoluteOffset : baseAngle; + + const qreal realScalingPart = hasScaling ? KisDynamicSensor::scalingToAdditive(scaling) : 0.0; + const qreal realAdditivePart = hasAdditive ? additive : 0; + + return + wrapInRange( + 2 * offset + constant * realScalingPart + realAdditivePart, + -1.0, 1.0); + } + + qreal sizeLikeValue() const { + const qreal offset = + hasAbsoluteOffset ? absoluteOffset : 1.0; + + const qreal realScalingPart = hasScaling ? scaling : 1.0; + const qreal realAdditivePart = hasAdditive ? KisDynamicSensor::additiveToScaling(additive) : 1.0; + + return qBound(minSizeLikeValue, + constant * offset * realScalingPart * realAdditivePart, + maxSizeLikeValue); + } + + private: + static inline qreal wrapInRange(qreal x, qreal min, qreal max) { + const qreal range = max - min; + + x -= min; + + if (x < 0.0) { + x = range + fmod(x, range); + } + + if (x > range) { + x = fmod(x, range); + } + + return x + min; + } + }; + /** * Uses the curves set on the sensors to compute a single * double value that can control the parameters of a brush. + * + * This value is derives from the falues stored in + * ValuesComponents opject. */ - double computeValue(const KisPaintInformation& info) const; + ValueComponents computeValueComponents(const KisPaintInformation& info) const; + + qreal computeSizeLikeValue(const KisPaintInformation &info) const; + qreal computeRotationLikeValue(const KisPaintInformation& info, qreal baseValue) const; protected: void setValueRange(qreal min, qreal max); /** * Read the option using the prefix in argument */ void readNamedOptionSetting(const QString& prefix, const KisPropertiesConfiguration* setting); QString m_name; KisPaintOpOption::PaintopCategory m_category; bool m_checkable; bool m_checked; bool m_useCurve; bool m_useSameCurve; bool m_separateCurveValue; QMap m_sensorMap; QMap m_curveCache; private: qreal m_value; qreal m_minValue; qreal m_maxValue; }; #endif diff --git a/plugins/paintops/libpaintop/kis_dynamic_sensor.cc b/plugins/paintops/libpaintop/kis_dynamic_sensor.cc index e24c73af7c..803148aa2c 100644 --- a/plugins/paintops/libpaintop/kis_dynamic_sensor.cc +++ b/plugins/paintops/libpaintop/kis_dynamic_sensor.cc @@ -1,455 +1,478 @@ /* * Copyright (c) 2007 Cyrille Berger * Copyright (c) 2011 Lukáš Tvrdý * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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_dynamic_sensor.h" #include #include "kis_algebra_2d.h" #include "sensors/kis_dynamic_sensors.h" #include "sensors/kis_dynamic_sensor_distance.h" #include "sensors/kis_dynamic_sensor_drawing_angle.h" #include "sensors/kis_dynamic_sensor_time.h" #include "sensors/kis_dynamic_sensor_fade.h" #include "sensors/kis_dynamic_sensor_fuzzy.h" KisDynamicSensor::KisDynamicSensor(DynamicSensorType type) : m_length(-1) , m_type(type) , m_customCurve(false) , m_active(false) { } KisDynamicSensor::~KisDynamicSensor() { } QWidget* KisDynamicSensor::createConfigurationWidget(QWidget* parent, QWidget*) { Q_UNUSED(parent); return 0; } void KisDynamicSensor::reset() { } KisDynamicSensorSP KisDynamicSensor::id2Sensor(const KoID& id) { if (id.id() == PressureId.id()) { return new KisDynamicSensorPressure(); } else if (id.id() == PressureInId.id()) { return new KisDynamicSensorPressureIn(); } else if (id.id() == XTiltId.id()) { return new KisDynamicSensorXTilt(); } else if (id.id() == YTiltId.id()) { return new KisDynamicSensorYTilt(); } else if (id.id() == TiltDirectionId.id()) { return new KisDynamicSensorTiltDirection(); } else if (id.id() == TiltElevationId.id()) { return new KisDynamicSensorTiltElevation(); } else if (id.id() == SpeedId.id()) { return new KisDynamicSensorSpeed(); } else if (id.id() == DrawingAngleId.id()) { return new KisDynamicSensorDrawingAngle(); } else if (id.id() == RotationId.id()) { return new KisDynamicSensorRotation(); } else if (id.id() == DistanceId.id()) { return new KisDynamicSensorDistance(); } else if (id.id() == TimeId.id()) { return new KisDynamicSensorTime(); } - else if (id.id() == FuzzyId.id()) { - return new KisDynamicSensorFuzzy(); + else if (id.id() == FuzzyPerDabId.id()) { + return new KisDynamicSensorFuzzy(false); + } + else if (id.id() == FuzzyPerStrokeId.id()) { + return new KisDynamicSensorFuzzy(true); } else if (id.id() == FadeId.id()) { return new KisDynamicSensorFade(); } else if (id.id() == PerspectiveId.id()) { return new KisDynamicSensorPerspective(); } else if (id.id() == TangentialPressureId.id()) { return new KisDynamicSensorTangentialPressure(); } dbgPlugins << "Unknown transform parameter :" << id.id(); return 0; } DynamicSensorType KisDynamicSensor::id2Type(const KoID &id) { if (id.id() == PressureId.id()) { return PRESSURE; } else if (id.id() == PressureInId.id()) { return PRESSURE_IN; } else if (id.id() == XTiltId.id()) { return XTILT; } else if (id.id() == YTiltId.id()) { return YTILT; } else if (id.id() == TiltDirectionId.id()) { return TILT_DIRECTION; } else if (id.id() == TiltElevationId.id()) { return TILT_ELEVATATION; } else if (id.id() == SpeedId.id()) { return SPEED; } else if (id.id() == DrawingAngleId.id()) { return ANGLE; } else if (id.id() == RotationId.id()) { return ROTATION; } else if (id.id() == DistanceId.id()) { return DISTANCE; } else if (id.id() == TimeId.id()) { return TIME; } - else if (id.id() == FuzzyId.id()) { - return FUZZY; + else if (id.id() == FuzzyPerDabId.id()) { + return FUZZY_PER_DAB; + } + else if (id.id() == FuzzyPerStrokeId.id()) { + return FUZZY_PER_STROKE; } else if (id.id() == FadeId.id()) { return FADE; } else if (id.id() == PerspectiveId.id()) { return PERSPECTIVE; } else if (id.id() == TangentialPressureId.id()) { return TANGENTIAL_PRESSURE; } return UNKNOWN; } KisDynamicSensorSP KisDynamicSensor::type2Sensor(DynamicSensorType sensorType) { switch (sensorType) { - case FUZZY: - return new KisDynamicSensorFuzzy(); + case FUZZY_PER_DAB: + return new KisDynamicSensorFuzzy(false); + case FUZZY_PER_STROKE: + return new KisDynamicSensorFuzzy(true); case SPEED: return new KisDynamicSensorSpeed(); case FADE: return new KisDynamicSensorFade(); case DISTANCE: return new KisDynamicSensorDistance(); case TIME: return new KisDynamicSensorTime(); case ANGLE: return new KisDynamicSensorDrawingAngle(); case ROTATION: return new KisDynamicSensorRotation(); case PRESSURE: return new KisDynamicSensorPressure(); case XTILT: return new KisDynamicSensorXTilt(); case YTILT: return new KisDynamicSensorYTilt(); case TILT_DIRECTION: return new KisDynamicSensorTiltDirection(); case TILT_ELEVATATION: return new KisDynamicSensorTiltElevation(); case PERSPECTIVE: return new KisDynamicSensorPerspective(); case TANGENTIAL_PRESSURE: return new KisDynamicSensorTangentialPressure(); case PRESSURE_IN: return new KisDynamicSensorPressureIn(); default: return 0; } } QString KisDynamicSensor::minimumLabel(DynamicSensorType sensorType) { switch (sensorType) { - case FUZZY: + case FUZZY_PER_DAB: + case FUZZY_PER_STROKE: return QString(); case FADE: return i18n("0"); case DISTANCE: return i18n("0 px"); case TIME: return i18n("0 s"); case ANGLE: return i18n("0°"); case SPEED: return i18n("Slow"); case ROTATION: return i18n("0°"); case PRESSURE: return i18n("Low"); case XTILT: return i18n("-30°"); case YTILT: return i18n("-30°"); case TILT_DIRECTION: return i18n("0°"); case TILT_ELEVATATION: return i18n("90°"); case PERSPECTIVE: return i18n("Far"); case TANGENTIAL_PRESSURE: case PRESSURE_IN: return i18n("Low"); default: return i18n("0.0"); } } QString KisDynamicSensor::maximumLabel(DynamicSensorType sensorType, int max) { switch (sensorType) { - case FUZZY: + case FUZZY_PER_DAB: + case FUZZY_PER_STROKE: return QString(); case FADE: if (max < 0) return i18n("1000"); else return i18n("%1", max); case DISTANCE: if (max < 0) return i18n("30 px"); else return i18n("%1 px", max); case TIME: if (max < 0) return i18n("3 s"); else return i18n("%1 s", max / 1000); case ANGLE: return i18n("360°"); case SPEED: return i18n("Fast"); case ROTATION: return i18n("360°"); case PRESSURE: return i18n("High"); case XTILT: return i18n("30°"); case YTILT: return i18n("30°"); case TILT_DIRECTION: return i18n("360°"); case TILT_ELEVATATION: return i18n("0°"); case PERSPECTIVE: return i18n("Near"); case TANGENTIAL_PRESSURE: case PRESSURE_IN: return i18n("High"); default: return i18n("1.0"); }; } KisDynamicSensorSP KisDynamicSensor::createFromXML(const QString& s) { QDomDocument doc; doc.setContent(s); QDomElement e = doc.documentElement(); return createFromXML(e); } KisDynamicSensorSP KisDynamicSensor::createFromXML(const QDomElement& e) { QString id = e.attribute("id", ""); KisDynamicSensorSP sensor = id2Sensor(id); if (sensor) { sensor->fromXML(e); } return sensor; } QList KisDynamicSensor::sensorsIds() { QList ids; ids << PressureId << PressureInId << XTiltId << YTiltId << TiltDirectionId << TiltElevationId << SpeedId << DrawingAngleId << RotationId << DistanceId << TimeId - << FuzzyId + << FuzzyPerDabId + << FuzzyPerStrokeId << FadeId << PerspectiveId << TangentialPressureId; return ids; } QList KisDynamicSensor::sensorsTypes() { QList sensorTypes; sensorTypes << PRESSURE << PRESSURE_IN << XTILT << YTILT << TILT_DIRECTION << TILT_ELEVATATION << SPEED << ANGLE << ROTATION << DISTANCE << TIME - << FUZZY + << FUZZY_PER_DAB + << FUZZY_PER_STROKE << FADE << PERSPECTIVE << TANGENTIAL_PRESSURE; return sensorTypes; } QString KisDynamicSensor::id(DynamicSensorType sensorType) { switch (sensorType) { - case FUZZY: + case FUZZY_PER_DAB: return "fuzzy"; + case FUZZY_PER_STROKE: + return "fuzzystroke"; case FADE: return "fade"; case DISTANCE: return "distance"; case TIME: return "time"; case ANGLE: return "drawingangle"; case SPEED: return "speed"; case ROTATION: return "rotation"; case PRESSURE: return "pressure"; case XTILT: return "xtilt"; case YTILT: return "ytilt"; case TILT_DIRECTION: return "ascension"; case TILT_ELEVATATION: return "declination"; case PERSPECTIVE: return "perspective"; case TANGENTIAL_PRESSURE: return "tangentialpressure"; case PRESSURE_IN: return "pressurein"; case SENSORS_LIST: return "sensorslist"; default: return QString(); }; } void KisDynamicSensor::toXML(QDomDocument& doc, QDomElement& elt) const { elt.setAttribute("id", id(sensorType())); if (m_customCurve) { QDomElement curve_elt = doc.createElement("curve"); QDomText text = doc.createTextNode(m_curve.toString()); curve_elt.appendChild(text); elt.appendChild(curve_elt); } } void KisDynamicSensor::fromXML(const QDomElement& e) { Q_UNUSED(e); Q_ASSERT(e.attribute("id", "") == id(sensorType())); m_customCurve = false; QDomElement curve_elt = e.firstChildElement("curve"); if (!curve_elt.isNull()) { m_customCurve = true; m_curve.fromString(curve_elt.text()); } } qreal KisDynamicSensor::parameter(const KisPaintInformation& info) { - qreal val = value(info); + const qreal val = value(info); if (m_customCurve) { - int offset = qRound(256.0 * qAbs(val)); + qreal scaledVal = isAdditive() ? additiveToScaling(val) : val; + + int offset = qRound(256.0 * qAbs(scaledVal)); qreal newValue = m_curve.floatTransfer(257)[qBound(0, offset, 256)]; - return KisAlgebra2D::copysign(newValue, val); + scaledVal = KisAlgebra2D::copysign(newValue, scaledVal); + + return isAdditive() ? scalingToAdditive(scaledVal) : scaledVal; } else { return val; } } void KisDynamicSensor::setCurve(const KisCubicCurve& curve) { m_customCurve = true; m_curve = curve; } const KisCubicCurve& KisDynamicSensor::curve() const { return m_curve; } void KisDynamicSensor::removeCurve() { m_customCurve = false; } bool KisDynamicSensor::hasCustomCurve() const { return m_customCurve; } bool KisDynamicSensor::dependsOnCanvasRotation() const { return true; } bool KisDynamicSensor::isAdditive() const { return false; } +bool KisDynamicSensor::isAbsoluteRotation() const +{ + return false; +} + void KisDynamicSensor::setActive(bool active) { m_active = active; } bool KisDynamicSensor::isActive() const { return m_active; } diff --git a/plugins/paintops/libpaintop/kis_dynamic_sensor.h b/plugins/paintops/libpaintop/kis_dynamic_sensor.h index 3a973d9cdf..586e9f5a6b 100644 --- a/plugins/paintops/libpaintop/kis_dynamic_sensor.h +++ b/plugins/paintops/libpaintop/kis_dynamic_sensor.h @@ -1,204 +1,217 @@ /* * Copyright (c) 2006 Cyrille Berger * Copyright (c) 2011 Lukáš Tvrdý * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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. */ #ifndef _KIS_DYNAMIC_SENSOR_H_ #define _KIS_DYNAMIC_SENSOR_H_ #include #include #include #include #include "kis_serializable_configuration.h" #include "kis_curve_label.h" #include #include #include class QWidget; class KisPaintInformation; -const KoID FuzzyId("fuzzy", ki18n("Fuzzy")); ///< generate a random number +const KoID FuzzyPerDabId("fuzzy", ki18n("Fuzzy Dab")); ///< generate a random number +const KoID FuzzyPerStrokeId("fuzzystroke", ki18n("Fuzzy Stroke")); ///< generate a random number const KoID SpeedId("speed", ki18n("Speed")); ///< generate a number depending on the speed of the cursor const KoID FadeId("fade", ki18n("Fade")); ///< generate a number that increase every time you call it (e.g. per dab) const KoID DistanceId("distance", ki18n("Distance")); ///< generate a number that increase with distance const KoID TimeId("time", ki18n("Time")); ///< generate a number that increase with time const KoID DrawingAngleId("drawingangle", ki18n("Drawing angle")); ///< number depending on the angle const KoID RotationId("rotation", ki18n("Rotation")); ///< rotation coming from the device const KoID PressureId("pressure", ki18n("Pressure")); ///< number depending on the pressure const KoID PressureInId("pressurein", ki18n("PressureIn")); ///< number depending on the pressure const KoID XTiltId("xtilt", ki18n("X-Tilt")); ///< number depending on X-tilt const KoID YTiltId("ytilt", ki18n("Y-Tilt")); ///< number depending on Y-tilt /** * "TiltDirection" and "TiltElevation" parameters are written to * preset files as "ascension" and "declination" to keep backward * compatibility with older presets from the days when they were called * differently. */ const KoID TiltDirectionId("ascension", ki18n("Tilt direction")); /// < number depending on the X and Y tilt, tilt direction is 0 when stylus nib points to you and changes clockwise from -180 to +180. const KoID TiltElevationId("declination", ki18n("Tilt elevation")); /// < tilt elevation is 90 when stylus is perpendicular to tablet and 0 when it's parallel to tablet const KoID PerspectiveId("perspective", ki18n("Perspective")); ///< number depending on the distance on the perspective grid const KoID TangentialPressureId("tangentialpressure", ki18n("Tangential pressure")); ///< the wheel on an airbrush device const KoID SensorsListId("sensorslist", "SHOULD NOT APPEAR IN THE UI !"); ///< this a non user-visible sensor that can store a list of other sensors, and multiply their output class KisDynamicSensor; typedef KisSharedPtr KisDynamicSensorSP; enum DynamicSensorType { - FUZZY, + FUZZY_PER_DAB, + FUZZY_PER_STROKE, SPEED, FADE, DISTANCE, TIME, ANGLE, ROTATION, PRESSURE, XTILT, YTILT, TILT_DIRECTION, TILT_ELEVATATION, PERSPECTIVE, TANGENTIAL_PRESSURE, SENSORS_LIST, PRESSURE_IN, UNKNOWN = 255 }; /** * Sensors are used to extract from KisPaintInformation a single * double value which can be used to control the parameters of * a brush. */ class PAINTOP_EXPORT KisDynamicSensor : public KisSerializableConfiguration, public KisShared { public: enum ParameterSign { NegativeParameter = -1, UnSignedParameter = 0, PositiveParameter = 1 }; protected: KisDynamicSensor(DynamicSensorType type); public: virtual ~KisDynamicSensor(); /** * @return the value of this sensor for the given KisPaintInformation */ qreal parameter(const KisPaintInformation& info); /** * This function is call before beginning a stroke to reset the sensor. * Default implementation does nothing. */ virtual void reset(); /** * @param selector is a \ref QWidget that countains a signal called "parametersChanged()" */ virtual QWidget* createConfigurationWidget(QWidget* parent, QWidget* selector); /** * Creates a sensor from its identifiant. */ static KisDynamicSensorSP id2Sensor(const KoID& id); static KisDynamicSensorSP id2Sensor(const QString& s) { return id2Sensor(KoID(s)); } static DynamicSensorType id2Type(const KoID& id); static DynamicSensorType id2Type(const QString& s) { return id2Type(KoID(s)); } /** * type2Sensor creates a new sensor for the give type */ static KisDynamicSensorSP type2Sensor(DynamicSensorType sensorType); static QString minimumLabel(DynamicSensorType sensorType); static QString maximumLabel(DynamicSensorType sensorType, int max = -1); static KisDynamicSensorSP createFromXML(const QString&); static KisDynamicSensorSP createFromXML(const QDomElement&); /** * @return the list of sensors */ static QList sensorsIds(); static QList sensorsTypes(); /** * @return the identifiant of this sensor */ static QString id(DynamicSensorType sensorType); using KisSerializableConfiguration::fromXML; using KisSerializableConfiguration::toXML; virtual void toXML(QDomDocument&, QDomElement&) const; virtual void fromXML(const QDomElement&); void setCurve(const KisCubicCurve& curve); const KisCubicCurve& curve() const; void removeCurve(); bool hasCustomCurve() const; void setActive(bool active); bool isActive() const; virtual bool dependsOnCanvasRotation() const; virtual bool isAdditive() const; + virtual bool isAbsoluteRotation() const; inline DynamicSensorType sensorType() const { return m_type; } /** * @return the currently set length or -1 if not relevant */ int length() { return m_length; } + +public: + static inline qreal scalingToAdditive(qreal x) { + return -1.0 + 2.0 * x; + } + + static inline qreal additiveToScaling(qreal x) { + return 0.5 * (1.0 + x); + } + protected: virtual qreal value(const KisPaintInformation& info) = 0; int m_length; private: Q_DISABLE_COPY(KisDynamicSensor) DynamicSensorType m_type; bool m_customCurve; KisCubicCurve m_curve; bool m_active; }; #endif diff --git a/plugins/paintops/libpaintop/kis_pressure_darken_option.cpp b/plugins/paintops/libpaintop/kis_pressure_darken_option.cpp index 6093070a43..894f491f2e 100644 --- a/plugins/paintops/libpaintop/kis_pressure_darken_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_darken_option.cpp @@ -1,64 +1,66 @@ /* This file is part of the KDE project * Copyright (C) Boudewijn Rempt , (C) 2008 * * 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_pressure_darken_option.h" #include #include #include #include #include "kis_color_source.h" #include KisPressureDarkenOption::KisPressureDarkenOption() : KisCurveOption("Darken", KisPaintOpOption::COLOR, false) { } KoColor KisPressureDarkenOption::apply(KisPainter * painter, const KisPaintInformation& info) const { if (!isChecked()) { return painter->paintColor(); } KoColor darkened = painter->paintColor(); KoColor origColor = darkened; // Darken docs aren't really clear about what exactly the amount param can have as value... - quint32 darkenAmount = (qint32)(255 - 255 * computeValue(info)); + quint32 darkenAmount = (qint32)(255 - 255 * computeSizeLikeValue(info)); KoColorTransformation* darkenTransformation = darkened.colorSpace()->createDarkenAdjustment(darkenAmount, false, 0.0); if (!darkenTransformation) return origColor; darkenTransformation ->transform(painter->paintColor().data(), darkened.data(), 1); painter->setPaintColor(darkened); delete darkenTransformation; return origColor; } void KisPressureDarkenOption::apply(KisColorSource* colorSource, const KisPaintInformation& info) const { if (!isChecked()) return; - quint32 darkenAmount = (qint32)(255 - 255 * computeValue(info)); + // Darken docs aren't really clear about what exactly the amount param can have as value... + quint32 darkenAmount = (qint32)(255 - 255 * computeSizeLikeValue(info)); + KoColorTransformation* darkenTransformation = colorSource->colorSpace()->createDarkenAdjustment(darkenAmount, false, 0.0); if (!darkenTransformation) return; colorSource->applyColorTransformation(darkenTransformation); delete darkenTransformation; } diff --git a/plugins/paintops/libpaintop/kis_pressure_flow_opacity_option.cpp b/plugins/paintops/libpaintop/kis_pressure_flow_opacity_option.cpp index 52de650035..660e050077 100644 --- a/plugins/paintops/libpaintop/kis_pressure_flow_opacity_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_flow_opacity_option.cpp @@ -1,91 +1,91 @@ /* * Copyright (c) 2011 Silvio Heinrich * * 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_pressure_flow_opacity_option.h" #include "kis_paint_action_type_option.h" #include #include #include #include #include #include KisFlowOpacityOption::KisFlowOpacityOption(KisNodeSP currentNode) : KisCurveOption("Opacity", KisPaintOpOption::GENERAL, true, 1.0, 0.0, 1.0) , m_flow(1.0) { setCurveUsed(true); setSeparateCurveValue(true); m_checkable = false; m_nodeHasIndirectPaintingSupport = currentNode && dynamic_cast(currentNode.data()); } void KisFlowOpacityOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { KisCurveOption::writeOptionSetting(setting); setting->setProperty("FlowValue", m_flow); } void KisFlowOpacityOption::readOptionSetting(const KisPropertiesConfiguration* setting) { KisCurveOption::readOptionSetting(setting); setFlow(setting->getDouble("FlowValue", 1.0)); m_paintActionType = setting->getInt("PaintOpAction", BUILDUP); } qreal KisFlowOpacityOption::getFlow() const { return m_flow; } qreal KisFlowOpacityOption::getStaticOpacity() const { return value(); } qreal KisFlowOpacityOption::getDynamicOpacity(const KisPaintInformation& info) const { - return computeValue(info); + return computeSizeLikeValue(info); } void KisFlowOpacityOption::setFlow(qreal flow) { m_flow = qBound(qreal(0), flow, qreal(1)); } void KisFlowOpacityOption::setOpacity(qreal opacity) { setValue(opacity); } void KisFlowOpacityOption::apply(KisPainter* painter, const KisPaintInformation& info) { if (m_paintActionType == WASH && m_nodeHasIndirectPaintingSupport) painter->setOpacityUpdateAverage(quint8(getDynamicOpacity(info) * 255.0)); else painter->setOpacityUpdateAverage(quint8(getStaticOpacity() * getDynamicOpacity(info) * 255.0)); painter->setFlow(quint8(getFlow() * 255.0)); } diff --git a/plugins/paintops/libpaintop/kis_pressure_flow_option.cpp b/plugins/paintops/libpaintop/kis_pressure_flow_option.cpp index 9867fd1aba..79978138ae 100644 --- a/plugins/paintops/libpaintop/kis_pressure_flow_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_flow_option.cpp @@ -1,37 +1,36 @@ /* This file is part of the KDE project * Copyright (C) Timothée Giet , (C) 2014 * * 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_pressure_flow_option.h" #include #include #include KisPressureFlowOption::KisPressureFlowOption() : KisCurveOption("Flow", KisPaintOpOption::GENERAL, true) { m_checkable = false; } double KisPressureFlowOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return 1.0; - return computeValue(info); + return computeSizeLikeValue(info); } - diff --git a/plugins/paintops/libpaintop/kis_pressure_gradient_option.cpp b/plugins/paintops/libpaintop/kis_pressure_gradient_option.cpp index 1f34c4f056..49d104bccc 100644 --- a/plugins/paintops/libpaintop/kis_pressure_gradient_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_gradient_option.cpp @@ -1,35 +1,36 @@ /* This file is part of the KDE project * Copyright (C) 2011 Silvio Heinrich * * 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_pressure_gradient_option.h" #include #include #include #include KisPressureGradientOption::KisPressureGradientOption() : KisCurveOption("Gradient", KisPaintOpOption::GENERAL, false) { } void KisPressureGradientOption::apply(KoColor& color, const KoAbstractGradient* gradient, const KisPaintInformation& info) const { - if (isChecked() && gradient) - gradient->colorAt(color, computeValue(info)); + if (isChecked() && gradient) { + gradient->colorAt(color, computeSizeLikeValue(info)); + } } diff --git a/plugins/paintops/libpaintop/kis_pressure_hsv_option.cpp b/plugins/paintops/libpaintop/kis_pressure_hsv_option.cpp index 25807008de..2d5895b1aa 100644 --- a/plugins/paintops/libpaintop/kis_pressure_hsv_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_hsv_option.cpp @@ -1,145 +1,140 @@ /* This file is part of the KDE project * Copyright (c) 2010 Cyrille Berger * * 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_pressure_hsv_option.h" #include #include KisPressureHSVOption* KisPressureHSVOption::createHueOption() { return new KisPressureHSVOption("h"); } QString KisPressureHSVOption::hueMinLabel() { // xgettext: no-c-format - QString activeColorMsg = i18n("(50% is active color)"); + QString activeColorMsg = i18n("(0° is active color)"); QString br("
"); - QString fullPercent = i18n("100%"); - QString zeroPercent = i18n("0%"); + QString fullPercent = i18n("+180°"); + QString zeroPercent = i18n("-180°"); return QString(zeroPercent + br + i18n("CCW hue") + br + activeColorMsg); } QString KisPressureHSVOption::huemaxLabel() { // xgettext: no-c-format - QString activeColorMsg = i18n("(50% is active color)"); + QString activeColorMsg = i18n("(0° is active color)"); QString br("
"); - QString fullPercent = i18n("100%"); - QString zeroPercent = i18n("0%"); + QString fullPercent = i18n("+180°"); + QString zeroPercent = i18n("-180°"); return QString(fullPercent + br + i18n("CW hue")); } KisPressureHSVOption* KisPressureHSVOption::createSaturationOption() { return new KisPressureHSVOption("s"); } QString KisPressureHSVOption::saturationMinLabel() { // xgettext: no-c-format QString activeColorMsg = i18n("(50% is active color)"); QString br("
"); - QString fullPercent = i18n("100%"); - QString zeroPercent = i18n("0%"); + QString fullPercent = i18n("+100%"); + QString zeroPercent = i18n("-100%"); return QString(zeroPercent + br + i18n("Less saturation ") + br + activeColorMsg); } QString KisPressureHSVOption::saturationmaxLabel() { // xgettext: no-c-format QString activeColorMsg = i18n("(50% is active color)"); QString br("
"); - QString fullPercent = i18n("100%"); - QString zeroPercent = i18n("0%"); + QString fullPercent = i18n("+100%"); + QString zeroPercent = i18n("-100%"); return QString(fullPercent + br + i18n("More saturation")); } KisPressureHSVOption* KisPressureHSVOption::createValueOption() { return new KisPressureHSVOption("v"); } QString KisPressureHSVOption::valueMinLabel() { // xgettext: no-c-format QString activeColorMsg = i18n("(50% is active color)"); QString br("
"); - QString fullPercent = i18n("100%"); - QString zeroPercent = i18n("0%"); + QString fullPercent = i18n("+100%"); + QString zeroPercent = i18n("-100%"); return QString(zeroPercent + br + i18n("Lower value ") + br + activeColorMsg); } QString KisPressureHSVOption::valuemaxLabel() { // xgettext: no-c-format QString activeColorMsg = i18n("(50% is active color)"); QString br("
"); - QString fullPercent = i18n("100%"); - QString zeroPercent = i18n("0%"); + QString fullPercent = i18n("+100%"); + QString zeroPercent = i18n("-100%"); return QString(fullPercent + br + i18n("Higher value")); } struct KisPressureHSVOption::Private { QString parameterName; int paramId; - double min, max; }; KisPressureHSVOption::KisPressureHSVOption(const QString& parameterName) : KisCurveOption(parameterName, KisPaintOpOption::COLOR, false) , d(new Private()) { d->parameterName = parameterName; d->paramId = -1; - d->min = -1; - d->max = 1; } KisPressureHSVOption::~KisPressureHSVOption() { delete d; } void KisPressureHSVOption::apply(KoColorTransformation* transfo, const KisPaintInformation& info) const { if (!isChecked()) { return; } if (d->paramId == -1) { d->paramId = transfo->parameterId(d->parameterName); } + qreal value = computeRotationLikeValue(info, 0); - - double v = computeValue(info) * (d->max - d->min) + d->min; - - transfo->setParameter(d->paramId, v); + transfo->setParameter(d->paramId, value); transfo->setParameter(3, 0); //sets the type to HSV. transfo->setParameter(4, false); //sets the colorize to false. } diff --git a/plugins/paintops/libpaintop/kis_pressure_mirror_option.cpp b/plugins/paintops/libpaintop/kis_pressure_mirror_option.cpp index b533b6a508..cdca9717ce 100644 --- a/plugins/paintops/libpaintop/kis_pressure_mirror_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_mirror_option.cpp @@ -1,99 +1,101 @@ /* * Copyright (c) 2010 Lukáš Tvrdý * * 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_pressure_mirror_option.h" #include #include #include #include KisPressureMirrorOption::KisPressureMirrorOption() : KisCurveOption("Mirror", KisPaintOpOption::GENERAL, false) { m_enableHorizontalMirror = false; m_enableVerticalMirror = false; } void KisPressureMirrorOption::enableHorizontalMirror(bool mirror) { m_enableHorizontalMirror = mirror; } void KisPressureMirrorOption::enableVerticalMirror(bool mirror) { m_enableVerticalMirror = mirror; } bool KisPressureMirrorOption::isHorizontalMirrorEnabled() { return m_enableHorizontalMirror; } bool KisPressureMirrorOption::isVerticalMirrorEnabled() { return m_enableVerticalMirror; } void KisPressureMirrorOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { KisCurveOption::writeOptionSetting(setting); setting->setProperty(MIRROR_HORIZONTAL_ENABLED, m_enableHorizontalMirror); setting->setProperty(MIRROR_VERTICAL_ENABLED, m_enableVerticalMirror); } void KisPressureMirrorOption::readOptionSetting(const KisPropertiesConfiguration* setting) { KisCurveOption::readOptionSetting(setting); m_enableHorizontalMirror = setting->getBool(MIRROR_HORIZONTAL_ENABLED, false); m_enableVerticalMirror = setting->getBool(MIRROR_VERTICAL_ENABLED, false); m_canvasAxisXMirrored = setting->getBool("runtimeCanvasMirroredX", false); m_canvasAxisYMirrored = setting->getBool("runtimeCanvasMirroredY", false); } MirrorProperties KisPressureMirrorOption::apply(const KisPaintInformation& info) const { int mirrorXIncrement = m_canvasAxisXMirrored; int mirrorYIncrement = m_canvasAxisYMirrored; bool coordinateSystemFlipped = false; if (isChecked() && (m_enableHorizontalMirror || m_enableVerticalMirror)) { - qreal sensorResult = computeValue(info); + + qreal sensorResult = computeSizeLikeValue(info); + bool result = (sensorResult >= 0.5); mirrorXIncrement += result && m_enableHorizontalMirror; mirrorYIncrement += result && m_enableVerticalMirror; coordinateSystemFlipped = result && (m_enableHorizontalMirror != m_enableVerticalMirror); } MirrorProperties mirrors; mirrors.verticalMirror = mirrorYIncrement % 2; mirrors.horizontalMirror = mirrorXIncrement % 2; mirrors.coordinateSystemFlipped = coordinateSystemFlipped; return mirrors; } diff --git a/plugins/paintops/libpaintop/kis_pressure_mix_option.cpp b/plugins/paintops/libpaintop/kis_pressure_mix_option.cpp index e30fb86488..d040b04faa 100644 --- a/plugins/paintops/libpaintop/kis_pressure_mix_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_mix_option.cpp @@ -1,34 +1,34 @@ /* This file is part of the KDE project * Copyright (c) 2009 Cyrille Berger * * 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_pressure_mix_option.h" #include #include #include KisPressureMixOption::KisPressureMixOption() : KisCurveOption("Mix", KisPaintOpOption::COLOR, false) { } double KisPressureMixOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return 1.0; - return computeValue(info); + return computeSizeLikeValue(info); } diff --git a/plugins/paintops/libpaintop/kis_pressure_opacity_option.cpp b/plugins/paintops/libpaintop/kis_pressure_opacity_option.cpp index 3daeb06bb8..b9b556461e 100644 --- a/plugins/paintops/libpaintop/kis_pressure_opacity_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_opacity_option.cpp @@ -1,73 +1,74 @@ /* This file is part of the KDE project * Copyright (C) Boudewijn Rempt , (C) 2008 * * 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_pressure_opacity_option.h" #include #include #include KisPressureOpacityOption::KisPressureOpacityOption() : KisCurveOption("Opacity", KisPaintOpOption::GENERAL, true) { m_checkable = false; } void KisPressureOpacityOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { KisCurveOption::writeOptionSetting(setting); setting->setProperty("OpacityVersion", "2"); } void KisPressureOpacityOption::readOptionSetting(const KisPropertiesConfiguration* setting) { KisCurveOption::readOptionSetting(setting); if (setting->getString("OpacityVersion", "1") == "1") { KisDynamicSensorSP pressureSensor = sensor(PRESSURE, true); if (pressureSensor) { QList points = pressureSensor->curve().points(); QList points_new; Q_FOREACH (const QPointF & p, points) { points_new.push_back(QPointF(p.x() * 0.5, p.y())); } pressureSensor->setCurve(KisCubicCurve(points_new)); } } } quint8 KisPressureOpacityOption::apply(KisPainter* painter, const KisPaintInformation& info) const { if (!isChecked()) { return painter->opacity(); } quint8 origOpacity = painter->opacity(); - qreal opacity = (qreal)(origOpacity * computeValue(info)); + qreal opacity = (qreal)(origOpacity * computeSizeLikeValue(info)); quint8 opacity2 = (quint8)qRound(qBound(OPACITY_TRANSPARENT_U8, opacity, OPACITY_OPAQUE_U8)); painter->setOpacityUpdateAverage(opacity2); return origOpacity; } qreal KisPressureOpacityOption::getOpacityf(const KisPaintInformation& info) { - return isChecked() ? computeValue(info) : 1.0; + if (!isChecked()) return 1.0; + return computeSizeLikeValue(info); } diff --git a/plugins/paintops/libpaintop/kis_pressure_opacity_option.h b/plugins/paintops/libpaintop/kis_pressure_opacity_option.h index 584cea2072..e2eff74cc7 100644 --- a/plugins/paintops/libpaintop/kis_pressure_opacity_option.h +++ b/plugins/paintops/libpaintop/kis_pressure_opacity_option.h @@ -1,55 +1,51 @@ /* This file is part of the KDE project * Copyright (C) Boudewijn Rempt , (C) 2008 * * 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_PRESSURE_OPACITY_OPTION #define KIS_PRESSURE_OPACITY_OPTION #include "kis_curve_option.h" #include class KisPainter; /** * The pressure opacity option defines a curve that is used to * calculate the effect of pressure on opacity */ class PAINTOP_EXPORT KisPressureOpacityOption : public KisCurveOption { public: KisPressureOpacityOption(); /** * Set the opacity of the painter based on the pressure * and the curve (if checked) and return the old opacity * of the painter. */ quint8 apply(KisPainter* painter, const KisPaintInformation& info) const; - \ - quint8 getOpacityU8(const KisPaintInformation& info) { - return quint8(qRound(getOpacityf(info) * 255.0)); - } qreal getOpacityf(const KisPaintInformation& info); virtual void writeOptionSetting(KisPropertiesConfiguration* setting) const; virtual void readOptionSetting(const KisPropertiesConfiguration* setting); }; #endif diff --git a/plugins/paintops/libpaintop/kis_pressure_ratio_option.cpp b/plugins/paintops/libpaintop/kis_pressure_ratio_option.cpp index f2ac852317..58a50da1ed 100644 --- a/plugins/paintops/libpaintop/kis_pressure_ratio_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_ratio_option.cpp @@ -1,32 +1,32 @@ /* This file is part of the KDE project * Copyright (C) Nishant Rodrigues , (C) 2016 * * 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_pressure_ratio_option.h" KisPressureRatioOption::KisPressureRatioOption() : KisCurveOption("Ratio", KisPaintOpOption::GENERAL, true) { } double KisPressureRatioOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return 1.0; - return computeValue(info); + return computeSizeLikeValue(); } diff --git a/plugins/paintops/libpaintop/kis_pressure_rotation_option.cpp b/plugins/paintops/libpaintop/kis_pressure_rotation_option.cpp index 20582b457f..e4829ae19b 100644 --- a/plugins/paintops/libpaintop/kis_pressure_rotation_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_rotation_option.cpp @@ -1,83 +1,69 @@ /* This file is part of the KDE project * Copyright (c) 2009 Cyrille Berger * * 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_pressure_rotation_option.h" #include "kis_pressure_opacity_option.h" #include "sensors/kis_dynamic_sensor_drawing_angle.h" #include "sensors/kis_dynamic_sensor_fuzzy.h" #include #include #include #include KisPressureRotationOption::KisPressureRotationOption() : KisCurveOption("Rotation", KisPaintOpOption::GENERAL, false), m_defaultAngle(0.0), m_canvasAxisXMirrored(false), m_canvasAxisYMirrored(false) { } double KisPressureRotationOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return m_defaultAngle; - bool dependsOnViewportTransformations = false; - Q_FOREACH (const KisDynamicSensorSP s, activeSensors()) { - if (s->dependsOnCanvasRotation()) { - dependsOnViewportTransformations = true; - break; - } - } + qreal value = computeRotationLikeValue(info, m_defaultAngle); - qreal baseAngle = dependsOnViewportTransformations ? m_defaultAngle : 0; - qreal rotationCoeff = - dependsOnViewportTransformations || - m_canvasAxisXMirrored == m_canvasAxisYMirrored ? - 1.0 - computeValue(info) : - 0.5 + computeValue(info); + if (m_canvasAxisXMirrored == m_canvasAxisYMirrored) { + value = 1.0 - value; + } - return fmod(rotationCoeff * 2.0 * M_PI + baseAngle, 2.0 * M_PI); + return normalizeAngle(value * M_PI); } void KisPressureRotationOption::readOptionSetting(const KisPropertiesConfiguration* setting) { m_defaultAngle = setting->getDouble("runtimeCanvasRotation", 0.0) * M_PI / 180.0; KisCurveOption::readOptionSetting(setting); m_canvasAxisXMirrored = setting->getBool("runtimeCanvasMirroredX", false); m_canvasAxisYMirrored = setting->getBool("runtimeCanvasMirroredY", false); - - KisDynamicSensorFuzzy *s = dynamic_cast(sensor(FUZZY, true).data()); - if (s) { - s->setRotationModeEnabled(true); - } } void KisPressureRotationOption::applyFanCornersInfo(KisPaintOp *op) { KisDynamicSensorDrawingAngle *sensor = dynamic_cast(this->sensor(ANGLE, true).data()); /** * A special case for the Drawing Angle sensor, because it * changes the behavior of KisPaintOp::paintLine() */ if (sensor) { op->setFanCornersInfo(sensor->fanCornersEnabled(), qreal(sensor->fanCornersStep()) * M_PI / 180.0); } } diff --git a/plugins/paintops/libpaintop/kis_pressure_scatter_option.cpp b/plugins/paintops/libpaintop/kis_pressure_scatter_option.cpp index 6234eb57e2..1a914d9451 100644 --- a/plugins/paintops/libpaintop/kis_pressure_scatter_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_scatter_option.cpp @@ -1,122 +1,122 @@ /* * Copyright (c) 2010 Lukáš Tvrdý * Copyright (c) 2011 Silvio Heinrich * * 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_pressure_scatter_option.h" #include #include #include #include #include KisPressureScatterOption::KisPressureScatterOption() : KisCurveOption("Scatter", KisPaintOpOption::GENERAL, false, 1.0, 0.0, 5.0) { m_axisX = true; m_axisY = true; } void KisPressureScatterOption::enableAxisX(bool enable) { m_axisX = enable; } void KisPressureScatterOption::enableAxisY(bool enable) { m_axisY = enable; } bool KisPressureScatterOption::isAxisXEnabled() { return m_axisX; } bool KisPressureScatterOption::isAxisYEnabled() { return m_axisY; } void KisPressureScatterOption::setScatterAmount(qreal amount) { KisCurveOption::setValue(amount); } qreal KisPressureScatterOption::scatterAmount() { return KisCurveOption::value(); } void KisPressureScatterOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { KisCurveOption::writeOptionSetting(setting); setting->setProperty(SCATTER_X, m_axisX); setting->setProperty(SCATTER_Y, m_axisY); } void KisPressureScatterOption::readOptionSetting(const KisPropertiesConfiguration* setting) { KisCurveOption::readOptionSetting(setting); m_axisX = setting->getBool(SCATTER_X, true); m_axisY = setting->getBool(SCATTER_Y, true); // backward compatibility: test for a "scatter amount" property // and use this value if it does exist if (setting->hasProperty(SCATTER_AMOUNT) && !setting->hasProperty("ScatterValue")) KisCurveOption::setValue(setting->getDouble(SCATTER_AMOUNT)); } QPointF KisPressureScatterOption::apply(const KisPaintInformation& info, qreal width, qreal height) const { if ((!m_axisX && !m_axisY) || (!isChecked())) { return info.pos(); } // just use the most significant dimension for calculations qreal diameter = qMax(width, height); - qreal sensorValue = computeValue(info); + qreal sensorValue = computeSizeLikeValue(info); qreal jitter = (2.0 * info.randomSource()->generateNormalized() - 1.0) * diameter * sensorValue; QPointF result(0.0, 0.0); if (m_axisX && m_axisY) { qreal jitterY = (2.0 * info.randomSource()->generateNormalized() - 1.0) * diameter * sensorValue; result = QPointF(jitter, jitterY); return info.pos() + result; } qreal drawingAngle = info.drawingAngle(); QVector2D movement(cos(drawingAngle), sin(drawingAngle)); if (m_axisX) { movement *= jitter; result = movement.toPointF(); } else if (m_axisY) { QVector2D movementNormal(-movement.y(), movement.x()); movementNormal *= jitter; result = movementNormal.toPointF(); } return info.pos() + result; } diff --git a/plugins/paintops/libpaintop/kis_pressure_sharpness_option.cpp b/plugins/paintops/libpaintop/kis_pressure_sharpness_option.cpp index abdc868947..42f06e3014 100644 --- a/plugins/paintops/libpaintop/kis_pressure_sharpness_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_sharpness_option.cpp @@ -1,110 +1,110 @@ /* * Copyright (c) 2010 Lukáš Tvrdý * * 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_pressure_sharpness_option.h" #include #include #include #include #include #include KisPressureSharpnessOption::KisPressureSharpnessOption() : KisCurveOption("Sharpness", KisPaintOpOption::GENERAL, false) { m_threshold = 40; } void KisPressureSharpnessOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { KisCurveOption::writeOptionSetting(setting); setting->setProperty(SHARPNESS_THRESHOLD, m_threshold); } void KisPressureSharpnessOption::readOptionSetting(const KisPropertiesConfiguration* setting) { KisCurveOption::readOptionSetting(setting); m_threshold = setting->getInt(SHARPNESS_THRESHOLD, 4); // backward compatibility: test for a "sharpness factor" property // and use this value if it does exist if (setting->hasProperty(SHARPNESS_FACTOR) && !setting->hasProperty("SharpnessValue")) KisCurveOption::setValue(setting->getDouble(SHARPNESS_FACTOR)); } void KisPressureSharpnessOption::apply(const KisPaintInformation &info, const QPointF &pt, qint32 &x, qint32 &y, qreal &xFraction, qreal &yFraction) const { if (!isChecked() || KisCurveOption::value() == 0.0) { // brush KisPaintOp::splitCoordinate(pt.x(), &x, &xFraction); KisPaintOp::splitCoordinate(pt.y(), &y, &yFraction); } else { - qreal processedSharpnes = computeValue(info); //qBound(0.0, (computeValue(info) * 2), 1.0); + qreal processedSharpnes = computeSizeLikeValue(info); if (processedSharpnes == 1.0) { // pen xFraction = 0.0; yFraction = 0.0; x = qRound(pt.x()); y = qRound(pt.y()); } else { // something in between qint32 xi = qRound(pt.x()); qint32 yi = qRound(pt.y()); qreal xf = processedSharpnes * xi + (1.0 - processedSharpnes) * pt.x(); qreal yf = processedSharpnes * yi + (1.0 - processedSharpnes) * pt.y(); KisPaintOp::splitCoordinate(xf, &x, &xFraction); KisPaintOp::splitCoordinate(yf, &y, &yFraction); } } } void KisPressureSharpnessOption::applyThreshold(KisFixedPaintDeviceSP dab) { if (!isChecked()) return; const KoColorSpace * cs = dab->colorSpace(); // Set all alpha > opaque/2 to opaque, the rest to transparent. // XXX: Using 4/10 as the 1x1 circle brush paints nothing with 0.5. quint8* dabPointer = dab->data(); QRect rc = dab->bounds(); int pixelSize = dab->pixelSize(); int pixelCount = rc.width() * rc.height(); for (int i = 0; i < pixelCount; i++) { quint8 alpha = cs->opacityU8(dabPointer); if (alpha < (m_threshold * OPACITY_OPAQUE_U8) / 100) { cs->setOpacity(dabPointer, OPACITY_TRANSPARENT_U8, 1); } else { cs->setOpacity(dabPointer, OPACITY_OPAQUE_U8, 1); } dabPointer += pixelSize; } } diff --git a/plugins/paintops/libpaintop/kis_pressure_size_option.cpp b/plugins/paintops/libpaintop/kis_pressure_size_option.cpp index d2e7ef1e02..3f8c4e7516 100644 --- a/plugins/paintops/libpaintop/kis_pressure_size_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_size_option.cpp @@ -1,50 +1,50 @@ /* This file is part of the KDE project * Copyright (C) Boudewijn Rempt , (C) 2008 * * 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_pressure_size_option.h" #include "kis_pressure_opacity_option.h" #include #include #include #include "kis_dynamic_sensor.h" #include KisPressureSizeOption::KisPressureSizeOption() : KisCurveOption("Size", KisPaintOpOption::GENERAL, true) { } double KisPressureSizeOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return 1.0; - return computeValue(info); + return computeSizeLikeValue(info); } void KisPressureSizeOption::lodLimitations(KisPaintopLodLimitations *l) const { - if (sensor(FUZZY, true)) { + if (sensor(FUZZY_PER_DAB, true) || sensor(FUZZY_PER_DAB, true)) { l->limitations << KoID("size-fade", i18nc("PaintOp instant preview limitation", "Size -> Fuzzy (sensor)")); } if (sensor(FADE, true)) { l->blockers << KoID("size-fuzzy", i18nc("PaintOp instant preview limitation", "Size -> Fade (sensor)")); } } diff --git a/plugins/paintops/libpaintop/kis_pressure_softness_option.cpp b/plugins/paintops/libpaintop/kis_pressure_softness_option.cpp index f311525a1f..4d671ccc83 100644 --- a/plugins/paintops/libpaintop/kis_pressure_softness_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_softness_option.cpp @@ -1,32 +1,32 @@ /* * Copyright (c) 2010 Lukáš Tvrdý * * 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_pressure_softness_option.h" #include KisPressureSoftnessOption::KisPressureSoftnessOption() : KisCurveOption("Softness", KisPaintOpOption::GENERAL, false, 1.0, 0.1, 1.0) { } double KisPressureSoftnessOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return 1.0; - return computeValue(info); + return computeSizeLikeValue(info); } diff --git a/plugins/paintops/libpaintop/kis_pressure_spacing_option.cpp b/plugins/paintops/libpaintop/kis_pressure_spacing_option.cpp index ae3b1985ed..47e753f197 100644 --- a/plugins/paintops/libpaintop/kis_pressure_spacing_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_spacing_option.cpp @@ -1,61 +1,59 @@ /* This file is part of the KDE project * Copyright (c) 2011 Cyrille Berger * * 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_pressure_spacing_option.h" #include const QString ISOTROPIC_SPACING = "Spacing/Isotropic"; KisPressureSpacingOption::KisPressureSpacingOption() : KisCurveOption("Spacing", KisPaintOpOption::GENERAL, false), m_isotropicSpacing(false) { } double KisPressureSpacingOption::apply(const KisPaintInformation & info) const { - if (!isChecked()) - return 1.0; - - return computeValue(info); + if (!isChecked()) return 1.0; + return computeSizeLikeValue(info); } void KisPressureSpacingOption::setIsotropicSpacing(bool isotropic) { m_isotropicSpacing = isotropic; } bool KisPressureSpacingOption::isotropicSpacing() const { return m_isotropicSpacing; } void KisPressureSpacingOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { KisCurveOption::writeOptionSetting(setting); setting->setProperty(ISOTROPIC_SPACING, m_isotropicSpacing); } void KisPressureSpacingOption::readOptionSetting(const KisPropertiesConfiguration* setting) { KisCurveOption::readOptionSetting(setting); m_isotropicSpacing = setting->getBool(ISOTROPIC_SPACING, false); } diff --git a/plugins/paintops/libpaintop/kis_pressure_texture_strength_option.cpp b/plugins/paintops/libpaintop/kis_pressure_texture_strength_option.cpp index 934234b185..18e3c9427c 100644 --- a/plugins/paintops/libpaintop/kis_pressure_texture_strength_option.cpp +++ b/plugins/paintops/libpaintop/kis_pressure_texture_strength_option.cpp @@ -1,66 +1,66 @@ /* * 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_pressure_texture_strength_option.h" #include KisPressureTextureStrengthOption::KisPressureTextureStrengthOption() : KisCurveOption("Texture/Strength/", KisPaintOpOption::TEXTURE, false) { } double KisPressureTextureStrengthOption::apply(const KisPaintInformation & info) const { if (!isChecked()) return 1.0; - return computeValue(info); + return computeSizeLikeValue(info); } void KisPressureTextureStrengthOption::readOptionSetting(const KisPropertiesConfiguration* setting) { KisCurveOption::readOptionSetting(setting); /** * Backward compatibility with Krita < 2.7. * * Process the presets created with the old UI, when the * strength was a part of Texture/Pattern option. */ int strengthVersion = setting->getInt("Texture/Strength/StrengthVersion", 1); if (strengthVersion == 1) { double legacyStrength = setting->getDouble("Texture/Pattern/Strength", 1.0); setChecked(true); setValue(legacyStrength); } } void KisPressureTextureStrengthOption::writeOptionSetting(KisPropertiesConfiguration* setting) const { KisCurveOption::writeOptionSetting(setting); /** * Forward compatibility with the Krita < 2.7 * * Duplicate the value of the maximum strength into the * property used by older versions of Krita. */ setting->setProperty("Texture/Strength/StrengthVersion", 2); if (isChecked()) { setting->setProperty("Texture/Pattern/Strength", value()); } } diff --git a/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_drawing_angle.cpp b/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_drawing_angle.cpp index a58f9d7935..b56857d4f8 100644 --- a/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_drawing_angle.cpp +++ b/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_drawing_angle.cpp @@ -1,183 +1,188 @@ /* * 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_dynamic_sensor_drawing_angle.h" #include #include #include #include #include #include KisDynamicSensorDrawingAngle::KisDynamicSensorDrawingAngle() : KisDynamicSensor(ANGLE), m_fanCornersEnabled(false), m_fanCornersStep(30), m_angleOffset(0), m_dabIndex(0), m_lockedAngle(0), m_lockedAngleMode(false) { } void KisDynamicSensorDrawingAngle::reset() { m_dabIndex = 0; } qreal KisDynamicSensorDrawingAngle::value(const KisPaintInformation& info) { /* so that we are in 0.0..1.0 */ qreal ret = 0.5 + info.drawingAngle() / (2.0 * M_PI) + m_angleOffset/360.0; // check if m_angleOffset pushed us out of bounds if (ret > 1.0) ret -= 1.0; if (!info.isHoveringMode() && m_lockedAngleMode) { if (!m_dabIndex) { info.lockCurrentDrawingAngle(1.0); } else { info.lockCurrentDrawingAngle(0.5); } m_dabIndex++; } return ret; } bool KisDynamicSensorDrawingAngle::dependsOnCanvasRotation() const { return false; } +bool KisDynamicSensorDrawingAngle::isAbsoluteRotation() const +{ + return true; +} + void KisDynamicSensorDrawingAngle::updateGUI() { const bool fanEnabled = !m_chkLockedMode->isChecked(); m_chkFanCorners->setEnabled(fanEnabled); m_intFanCornersStep->setEnabled(fanEnabled); } QWidget* KisDynamicSensorDrawingAngle::createConfigurationWidget(QWidget* parent, QWidget *ss) { QWidget *w = new QWidget(parent); m_chkLockedMode = new QCheckBox(i18n("Lock"), w); m_chkLockedMode->setChecked(m_lockedAngleMode); connect(m_chkLockedMode, SIGNAL(stateChanged(int)), SLOT(setLockedAngleMode(int))); connect(m_chkLockedMode, SIGNAL(stateChanged(int)), SLOT(updateGUI())); connect(m_chkLockedMode, SIGNAL(stateChanged(int)), ss, SIGNAL(parametersChanged())); m_chkFanCorners = new QCheckBox(i18n("Fan Corners"), w); connect(m_chkFanCorners, SIGNAL(stateChanged(int)), SLOT(setFanCornersEnabled(int))); connect(m_chkFanCorners, SIGNAL(stateChanged(int)), ss, SIGNAL(parametersChanged())); m_chkFanCorners->setChecked(m_fanCornersEnabled); m_intFanCornersStep = new KisSliderSpinBox(w); m_intFanCornersStep->setRange(5, 90); m_intFanCornersStep->setSingleStep(1); m_intFanCornersStep->setSuffix(i18n("°")); connect(m_intFanCornersStep, SIGNAL(valueChanged(int)), SLOT(setFanCornersStep(int))); connect(m_intFanCornersStep, SIGNAL(valueChanged(int)), ss, SIGNAL(parametersChanged())); m_intFanCornersStep->setValue(m_fanCornersStep); KisSliderSpinBox *angleOffset = new KisSliderSpinBox(w); angleOffset->setRange(0, 359); angleOffset->setSingleStep(1); angleOffset->setSuffix(i18n("°")); connect(angleOffset, SIGNAL(valueChanged(int)), SLOT(setAngleOffset(int))); connect(angleOffset, SIGNAL(valueChanged(int)), ss, SIGNAL(parametersChanged())); angleOffset->setValue(m_angleOffset); QVBoxLayout* l = new QVBoxLayout(w); l->addWidget(m_chkLockedMode); l->addWidget(m_chkFanCorners); l->addWidget(m_intFanCornersStep); l->addWidget(new QLabel(i18n("Angle Offset"))); l->addWidget(angleOffset); updateGUI(); w->setLayout(l); return w; } bool KisDynamicSensorDrawingAngle::fanCornersEnabled() const { return m_fanCornersEnabled && !m_lockedAngleMode; } int KisDynamicSensorDrawingAngle::fanCornersStep() const { return m_fanCornersStep; } int KisDynamicSensorDrawingAngle::angleOffset() const { return m_angleOffset; } void KisDynamicSensorDrawingAngle::setFanCornersEnabled(int state) { m_fanCornersEnabled = state; } void KisDynamicSensorDrawingAngle::setFanCornersStep(int angle) { m_fanCornersStep = angle; } void KisDynamicSensorDrawingAngle::setLockedAngleMode(int value) { m_lockedAngleMode = value; } void KisDynamicSensorDrawingAngle::setAngleOffset(int angle) { Q_ASSERT(angle >= 0 && angle < 360);//dont include 360 m_angleOffset = angle; } void KisDynamicSensorDrawingAngle::toXML(QDomDocument &doc, QDomElement &e) const { KisDynamicSensor::toXML(doc, e); e.setAttribute("fanCornersEnabled", m_fanCornersEnabled); e.setAttribute("fanCornersStep", m_fanCornersStep); e.setAttribute("angleOffset", m_angleOffset); e.setAttribute("lockedAngleMode", m_lockedAngleMode); } void KisDynamicSensorDrawingAngle::fromXML(const QDomElement &e) { KisDynamicSensor::fromXML(e); m_fanCornersEnabled = e.attribute("fanCornersEnabled", "0").toInt(); m_fanCornersStep = e.attribute("fanCornersStep", "30").toInt(); m_angleOffset = e.attribute("angleOffset", "0").toInt(); m_lockedAngleMode = e.attribute("lockedAngleMode", "0").toInt(); } diff --git a/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_drawing_angle.h b/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_drawing_angle.h index 60837b130b..c1767b46d0 100644 --- a/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_drawing_angle.h +++ b/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_drawing_angle.h @@ -1,70 +1,71 @@ /* * 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. */ #ifndef __KIS_DYNAMIC_SENSOR_DRAWING_ANGLE_H #define __KIS_DYNAMIC_SENSOR_DRAWING_ANGLE_H #include "kis_dynamic_sensor.h" class QCheckBox; class KisSliderSpinBox; class KisDynamicSensorDrawingAngle : public QObject, public KisDynamicSensor { Q_OBJECT public: KisDynamicSensorDrawingAngle(); qreal value(const KisPaintInformation& info); bool dependsOnCanvasRotation() const; + bool isAbsoluteRotation() const; QWidget* createConfigurationWidget(QWidget* parent, QWidget*); using KisSerializableConfiguration::fromXML; using KisSerializableConfiguration::toXML; void toXML(QDomDocument&, QDomElement&) const; void fromXML(const QDomElement&); bool fanCornersEnabled() const; int fanCornersStep() const; int angleOffset() const; void reset(); public Q_SLOTS: void setFanCornersEnabled(int state); void setFanCornersStep(int angle); void setAngleOffset(int angle); void setLockedAngleMode(int value); void updateGUI(); private: bool m_fanCornersEnabled; int m_fanCornersStep; int m_angleOffset; // in degrees int m_dabIndex; qreal m_lockedAngle; bool m_lockedAngleMode; QCheckBox *m_chkLockedMode; QCheckBox *m_chkFanCorners; KisSliderSpinBox *m_intFanCornersStep; }; #endif /* __KIS_DYNAMIC_SENSOR_DRAWING_ANGLE_H */ diff --git a/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_fuzzy.cpp b/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_fuzzy.cpp index f9e0997894..44b087aacb 100644 --- a/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_fuzzy.cpp +++ b/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_fuzzy.cpp @@ -1,77 +1,71 @@ /* * Copyright (c) 2013 Dmitry Kazakov * Copyright (c) 2014 Mohit Goyal * 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_dynamic_sensor_fuzzy.h" #include #include #include #include -KisDynamicSensorFuzzy::KisDynamicSensorFuzzy() - : KisDynamicSensor(FUZZY) +KisDynamicSensorFuzzy::KisDynamicSensorFuzzy(bool fuzzyPerStroke) + : KisDynamicSensor(fuzzyPerStroke ? FUZZY_PER_STROKE : FUZZY_PER_DAB), + m_fuzzyPerStroke(fuzzyPerStroke), + m_isInitialized(false), + m_savedValue(0.0) { } -bool KisDynamicSensorFuzzy::isAdditive() const +void KisDynamicSensorFuzzy::reset() { - return m_rotationModeEnabled; + m_isInitialized = false; } -void KisDynamicSensorFuzzy::setRotationModeEnabled(int state) +bool KisDynamicSensorFuzzy::isAdditive() const { - m_rotationModeEnabled = state; + return true; } -qreal KisDynamicSensorFuzzy::value(const KisPaintInformation &info) { +qreal KisDynamicSensorFuzzy::value(const KisPaintInformation &info) +{ + if (m_fuzzyPerStroke && m_isInitialized) { + return m_savedValue; + } - qreal result = !m_rotationModeEnabled ? 1.0 : 0.0; + qreal result = 0.0; if (!info.isHoveringMode()) { result = info.randomSource()->generateNormalized(); + result = 2.0 * result - 1.0; - if (m_rotationModeEnabled) { - result = 2.0 * result - 1.0; - } + m_isInitialized = true; + m_savedValue = result; } return result; } -void KisDynamicSensorFuzzy::toXML(QDomDocument &doc, QDomElement &e) const -{ - KisDynamicSensor::toXML(doc, e); - e.setAttribute("rotationModeEnabled", m_rotationModeEnabled); - -} - -void KisDynamicSensorFuzzy::fromXML(const QDomElement &e) -{ - KisDynamicSensor::fromXML(e); - m_rotationModeEnabled = e.attribute("rotationModeEnabled", "0").toInt(); - -} bool KisDynamicSensorFuzzy::dependsOnCanvasRotation() const { return false; } diff --git a/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_fuzzy.h b/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_fuzzy.h index e7d3e77acd..ab749cd44e 100644 --- a/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_fuzzy.h +++ b/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_fuzzy.h @@ -1,57 +1,53 @@ /* * Copyright (c) 2013 Dmitry Kazakov * Copyright (c) 2014 Mohit Goyal * 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. */ #ifndef KIS_DYNAMIC_SENSOR_FUZZY_H #define KIS_DYNAMIC_SENSOR_FUZZY_H #include "kis_dynamic_sensor.h" #include #include #include #include #include #include class KisDynamicSensorFuzzy : public QObject, public KisDynamicSensor { Q_OBJECT public: bool dependsOnCanvasRotation() const; - using KisSerializableConfiguration::fromXML; - using KisSerializableConfiguration::toXML; - void toXML(QDomDocument&, QDomElement&) const; - void fromXML(const QDomElement&); - bool isAdditive() const; - KisDynamicSensorFuzzy(); + KisDynamicSensorFuzzy(bool fuzzyPerStroke = false); virtual ~KisDynamicSensorFuzzy() {} qreal value(const KisPaintInformation &info); - void setRotationModeEnabled(int state); + void reset(); private: - bool m_rotationModeEnabled; - + const bool m_fuzzyPerStroke; + bool m_isInitialized; + qreal m_savedValue; }; #endif // KIS_DYNAMIC_SENSOR_FUZZY_H diff --git a/plugins/paintops/sketch/kis_density_option.cpp b/plugins/paintops/sketch/kis_density_option.cpp index 456bd9188b..849047b143 100644 --- a/plugins/paintops/sketch/kis_density_option.cpp +++ b/plugins/paintops/sketch/kis_density_option.cpp @@ -1,34 +1,32 @@ /* * Copyright (c) 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 "kis_density_option.h" #include KisDensityOption::KisDensityOption() : KisCurveOption("Density", KisPaintOpOption::GENERAL, false) { } double KisDensityOption::apply(const KisPaintInformation & info, double probability) const { - if (!isChecked()) { - return probability; - } - return computeValue(info) * probability; + if (!isChecked()) return probability; + return computeSizeLikeValue(info) * probability; } diff --git a/plugins/paintops/sketch/kis_linewidth_option.cpp b/plugins/paintops/sketch/kis_linewidth_option.cpp index dc35292e73..7d566a8d47 100644 --- a/plugins/paintops/sketch/kis_linewidth_option.cpp +++ b/plugins/paintops/sketch/kis_linewidth_option.cpp @@ -1,33 +1,31 @@ /* * Copyright (c) 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 "kis_linewidth_option.h" KisLineWidthOption::KisLineWidthOption() : KisCurveOption("Line width", KisPaintOpOption::GENERAL, false) { } double KisLineWidthOption::apply(const KisPaintInformation & info, double lineWidth) const { - if (!isChecked()) { - return lineWidth; - } - return computeValue(info) * lineWidth; + if (!isChecked()) return lineWidth; + return computeSizeLikeValue(info) * lineWidth; } diff --git a/plugins/paintops/sketch/kis_offset_scale_option.cpp b/plugins/paintops/sketch/kis_offset_scale_option.cpp index 586b226be0..b82b049f78 100644 --- a/plugins/paintops/sketch/kis_offset_scale_option.cpp +++ b/plugins/paintops/sketch/kis_offset_scale_option.cpp @@ -1,34 +1,32 @@ /* * Copyright (c) 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 "kis_offset_scale_option.h" #include KisOffsetScaleOption::KisOffsetScaleOption() : KisCurveOption("Offset scale", KisPaintOpOption::GENERAL, false) { } double KisOffsetScaleOption::apply(const KisPaintInformation & info, double offsetScale) const { - if (!isChecked()) { - return offsetScale; - } - return computeValue(info) * offsetScale; + if (!isChecked()) return offsetScale; + return computeSizeLikeValue(info) * offsetScale; } diff --git a/plugins/paintops/sketch/kis_sketch_paintop_settings_widget.cpp b/plugins/paintops/sketch/kis_sketch_paintop_settings_widget.cpp index 020454ce26..3cd3a40ee0 100644 --- a/plugins/paintops/sketch/kis_sketch_paintop_settings_widget.cpp +++ b/plugins/paintops/sketch/kis_sketch_paintop_settings_widget.cpp @@ -1,87 +1,87 @@ /* * Copyright (c) 2010 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 "kis_sketch_paintop_settings_widget.h" #include "kis_sketchop_option.h" #include "kis_sketch_paintop_settings.h" #include #include #include #include #include #include #include #include #include #include #include "kis_density_option.h" #include "kis_linewidth_option.h" #include "kis_offset_scale_option.h" KisSketchPaintOpSettingsWidget::KisSketchPaintOpSettingsWidget(QWidget* parent) : KisBrushBasedPaintopOptionWidget(parent) { m_sketchOption = new KisSketchOpOption(); addPaintOpOption(m_sketchOption, i18n("Brush size")); addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size")); - addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation")); + addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation")); addPaintOpOption(new KisCurveOptionWidget(new KisLineWidthOption() , i18n("0%"), i18n("100%")), i18n("Line width")); addPaintOpOption(new KisCurveOptionWidget(new KisOffsetScaleOption(), i18n("0%"), i18n("100%")), i18n("Offset scale")); addPaintOpOption(new KisCurveOptionWidget(new KisDensityOption(), i18n("0%"), i18n("100%")), i18n("Density")); addPaintOpOption(new KisAirbrushOption(false), i18n("Airbrush")); m_paintActionType = new KisPaintActionTypeOption(); KisPropertiesConfiguration defaultSetting; defaultSetting.setProperty("PaintOpAction", BUILDUP); m_paintActionType->readOptionSetting(&defaultSetting); addPaintOpOption(m_paintActionType, i18n("Painting Mode")); KisPropertiesConfiguration* reconfigurationCourier = configuration(); QDomDocument xMLAnalyzer(""); xMLAnalyzer.setContent(reconfigurationCourier->getString("brush_definition")); QDomElement firstTag = xMLAnalyzer.documentElement(); QDomElement firstTagsChild = firstTag.elementsByTagName("MaskGenerator").item(0).toElement(); firstTagsChild.attributeNode("diameter").setValue("128"); reconfigurationCourier->setProperty("brush_definition", xMLAnalyzer.toString()); setConfiguration(reconfigurationCourier); delete reconfigurationCourier; } KisSketchPaintOpSettingsWidget::~ KisSketchPaintOpSettingsWidget() { } KisPropertiesConfiguration* KisSketchPaintOpSettingsWidget::configuration() const { KisSketchPaintOpSettings* config = new KisSketchPaintOpSettings(); config->setOptionsWidget(const_cast(this)); config->setProperty("paintop", "sketchbrush"); // XXX: make this a const id string writeConfiguration(config); return config; } diff --git a/plugins/paintops/spray/kis_spray_paintop_settings_widget.cpp b/plugins/paintops/spray/kis_spray_paintop_settings_widget.cpp index a65bfa0f8a..54c5a8d831 100644 --- a/plugins/paintops/spray/kis_spray_paintop_settings_widget.cpp +++ b/plugins/paintops/spray/kis_spray_paintop_settings_widget.cpp @@ -1,80 +1,80 @@ /* * Copyright (c) 2008,2009,2010 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 "kis_spray_paintop_settings_widget.h" #include "kis_sprayop_option.h" #include "kis_spray_paintop_settings.h" #include "kis_spray_shape_option.h" #include #include #include #include #include #include #include #include #include "kis_spray_shape_dynamics.h" #include #include KisSprayPaintOpSettingsWidget:: KisSprayPaintOpSettingsWidget(QWidget* parent) : KisPaintOpSettingsWidget(parent) , m_sprayArea(new KisSprayOpOption()) { addPaintOpOption(m_sprayArea, i18n("Spray shape")); addPaintOpOption(new KisSprayShapeOption(), i18n("Spray shape")); addPaintOpOption(new KisBrushOptionWidget(), i18n("Brush Tip")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size")); addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); addPaintOpOption(new KisSprayShapeDynamicsOption(), i18n("Shape dynamics")); addPaintOpOption(new KisColorOption(), i18n("Color options")); - addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation")); + addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation")); addPaintOpOption(new KisAirbrushOption(), i18n("Airbrush")); addPaintOpOption(new KisPaintActionTypeOption(), i18n("Painting Mode")); } KisSprayPaintOpSettingsWidget::~ KisSprayPaintOpSettingsWidget() { } KisPropertiesConfiguration* KisSprayPaintOpSettingsWidget::configuration() const { KisSprayPaintOpSettings* config = new KisSprayPaintOpSettings(); config->setOptionsWidget(const_cast(this)); config->setProperty("paintop", "spraybrush"); // XXX: make this a const id string writeConfiguration(config); return config; } void KisSprayPaintOpSettingsWidget::changePaintOpSize(qreal x, qreal y) { Q_UNUSED(y); m_sprayArea->setDiameter(m_sprayArea->diameter() + qRound(x)); } QSizeF KisSprayPaintOpSettingsWidget::paintOpSize() const { qreal width = m_sprayArea->diameter(); qreal height = width * m_sprayArea->brushAspect(); return QSizeF(width, height); } diff --git a/plugins/paintops/tangentnormal/kis_tangent_normal_paintop_settings_widget.cpp b/plugins/paintops/tangentnormal/kis_tangent_normal_paintop_settings_widget.cpp index d8dc34f43b..25d84a6d25 100644 --- a/plugins/paintops/tangentnormal/kis_tangent_normal_paintop_settings_widget.cpp +++ b/plugins/paintops/tangentnormal/kis_tangent_normal_paintop_settings_widget.cpp @@ -1,86 +1,86 @@ /* * Copyright (C) 2015 Wolthera van Hövell tot Westerflier * * 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_tangent_normal_paintop_settings_widget.h" #include "kis_brush_based_paintop_settings.h" #include "kis_tangent_tilt_option.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_texture_option.h" #include "kis_curve_option_widget.h" #include #include "kis_pressure_texture_strength_option.h" KisTangentNormalPaintOpSettingsWidget::KisTangentNormalPaintOpSettingsWidget(QWidget* parent): KisBrushBasedPaintopOptionWidget(parent) { setObjectName("brush option widget"); setPrecisionEnabled(true); addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureFlowOption(), i18n("0%"), i18n("100%")), i18n("Flow")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size")); addPaintOpOption(new KisTangentTiltOption(), i18n("Tangent Tilt")); addPaintOpOption(new KisPressureSpacingOptionWidget(), i18n("Spacing")); addPaintOpOption(new KisPressureMirrorOptionWidget(), i18n("Mirror")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSoftnessOption(), i18n("Soft"), i18n("Hard")), i18n("Softness")); addPaintOpOption(new KisPressureSharpnessOptionWidget(), i18n("Sharpness")); addPaintOpOption(new KisPressureScatterOptionWidget(), i18n("Scatter")); - addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation")); + addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation")); addPaintOpOption(new KisAirbrushOption(false), i18n("Airbrush")); addPaintOpOption(new KisPaintActionTypeOption(), i18n("Painting Mode")); addPaintOpOption(new KisTextureOption(), i18n("Pattern")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureTextureStrengthOption(), i18n("Weak"), i18n("Strong")), i18n("Strength")); } KisTangentNormalPaintOpSettingsWidget::~KisTangentNormalPaintOpSettingsWidget() { } KisPropertiesConfiguration* KisTangentNormalPaintOpSettingsWidget::configuration() const { KisBrushBasedPaintOpSettings *config = new KisBrushBasedPaintOpSettings(); config->setOptionsWidget(const_cast(this)); config->setProperty("paintop", "tangentnormal"); writeConfiguration(config); return config; }