Commit 159a6126 authored by Dmitry Kazakov's avatar Dmitry Kazakov

FEATURE: Implement per-stroke Fuzzy sensor

This patch also does a significant refactoring in the sensors
computation framework. Now the Fuzzy sensors work correctly with
Rotation, Hues, Saturation and Value options.

The fuzzy sensor's curve is divided into tho halves: the leftmost part
controls the negative offsets, the rightmost --- positive ones. Therefore
you can control if your fuzzy sensor increases the output or decreases it.

Please take into account that this rule works only for "relative" options,
that is for Rotation, Hue, Saturation and Value.

Ref T166
CC:kimageshop@kde.org
parent ac2d5a06
......@@ -58,7 +58,7 @@ KisColorSmudgeOpSettingsWidget::KisColorSmudgeOpSettingsWidget(QWidget* parent):
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"));
......
......@@ -41,7 +41,9 @@ void KisRateOption::apply(KisPainter& painter, const KisPaintInformation& info,
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);
}
......@@ -41,7 +41,9 @@ void KisSmudgeOption::apply(KisPainter& painter, const KisPaintInformation& info
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);
......
......@@ -55,7 +55,10 @@ void KisSmudgeRadiusOption::apply(KisPainter& painter,
qreal posy,
KisPaintDeviceSP dev) const
{
double sliderValue = computeValue(info);
if (!isChecked()) return;
qreal sliderValue = computeSizeLikeValue(info);
int smudgeRadius = ((sliderValue * diameter) * 0.5) / 100.0;
......
......@@ -27,8 +27,6 @@ KisCurvesOpacityOption::KisCurvesOpacityOption()
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;
}
......@@ -27,8 +27,6 @@ KisLineWidthOption::KisLineWidthOption()
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;
}
......@@ -62,7 +62,7 @@ KisBrushOpSettingsWidget::KisBrushOpSettingsWidget(QWidget* parent)
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
......
......@@ -41,7 +41,7 @@ KisDeformPaintOpSettingsWidget::KisDeformPaintOpSettingsWidget(QWidget* parent)
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"));
}
......
......@@ -49,7 +49,7 @@ KisFilterOpSettingsWidget::KisFilterOpSettingsWidget(QWidget* parent)
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();
......
......@@ -41,7 +41,7 @@ KisHairyPaintOpSettingsWidget:: KisHairyPaintOpSettingsWidget(QWidget* parent)
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"));
}
......
......@@ -32,5 +32,5 @@ KisHatchingPressureCrosshatchingOption::KisHatchingPressureCrosshatchingOption()
double KisHatchingPressureCrosshatchingOption::apply(const KisPaintInformation & info) const
{
if (!isChecked()) return 0.5;
return computeValue(info);
return computeSizeLikeValue(info);
}
......@@ -33,5 +33,5 @@ KisHatchingPressureSeparationOption::KisHatchingPressureSeparationOption()
double KisHatchingPressureSeparationOption::apply(const KisPaintInformation & info) const
{
if (!isChecked()) return 0.5;
return computeValue(info);
return computeSizeLikeValue(info);
}
......@@ -33,5 +33,5 @@ KisHatchingPressureThicknessOption::KisHatchingPressureThicknessOption()
double KisHatchingPressureThicknessOption::apply(const KisPaintInformation & info) const
{
if (!isChecked()) return 0.5;
return computeValue(info);
return computeSizeLikeValue(info);
}
......@@ -222,7 +222,8 @@ KisDynamicSensorSP KisCurveOption::sensor(DynamicSensorType sensorType, bool act
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
......@@ -326,49 +327,49 @@ 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<KisDynamicSensorSP> 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<KisDynamicSensorSP> KisCurveOption::sensors()
......
......@@ -81,11 +81,83 @@ public:
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:
......
......@@ -85,8 +85,11 @@ KisDynamicSensorSP KisDynamicSensor::id2Sensor(const KoID& id)
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();
......@@ -136,8 +139,11 @@ DynamicSensorType KisDynamicSensor::id2Type(const KoID &id)
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;
......@@ -154,8 +160,10 @@ DynamicSensorType KisDynamicSensor::id2Type(const KoID &id)
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:
......@@ -192,7 +200,8 @@ KisDynamicSensorSP KisDynamicSensor::type2Sensor(DynamicSensorType sensorType)
QString KisDynamicSensor::minimumLabel(DynamicSensorType sensorType)
{
switch (sensorType) {
case FUZZY:
case FUZZY_PER_DAB:
case FUZZY_PER_STROKE:
return QString();
case FADE:
return i18n("0");
......@@ -229,7 +238,8 @@ QString KisDynamicSensor::minimumLabel(DynamicSensorType sensorType)
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)
......@@ -306,7 +316,8 @@ QList<KoID> KisDynamicSensor::sensorsIds()
<< RotationId
<< DistanceId
<< TimeId
<< FuzzyId
<< FuzzyPerDabId
<< FuzzyPerStrokeId
<< FadeId
<< PerspectiveId
<< TangentialPressureId;
......@@ -329,7 +340,8 @@ QList<DynamicSensorType> KisDynamicSensor::sensorsTypes()
<< ROTATION
<< DISTANCE
<< TIME
<< FUZZY
<< FUZZY_PER_DAB
<< FUZZY_PER_STROKE
<< FADE
<< PERSPECTIVE
<< TANGENTIAL_PRESSURE;
......@@ -339,8 +351,10 @@ QList<DynamicSensorType> KisDynamicSensor::sensorsTypes()
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:
......@@ -402,11 +416,15 @@ void KisDynamicSensor::fromXML(const QDomElement& e)
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;
......@@ -444,6 +462,11 @@ bool KisDynamicSensor::isAdditive() const
return false;
}
bool KisDynamicSensor::isAbsoluteRotation() const
{
return false;
}
void KisDynamicSensor::setActive(bool active)
{
m_active = active;
......
......@@ -37,7 +37,8 @@
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
......@@ -66,7 +67,8 @@ class KisDynamicSensor;
typedef KisSharedPtr<KisDynamicSensor> KisDynamicSensorSP;
enum DynamicSensorType {
FUZZY,
FUZZY_PER_DAB,
FUZZY_PER_STROKE,
SPEED,
FADE,
DISTANCE,
......@@ -175,6 +177,7 @@ public:
virtual bool dependsOnCanvasRotation() const;
virtual bool isAdditive() const;
virtual bool isAbsoluteRotation() const;
inline DynamicSensorType sensorType() const { return m_type; }
......@@ -184,6 +187,16 @@ public:
*/
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;
......
......@@ -40,7 +40,7 @@ KoColor KisPressureDarkenOption::apply(KisPainter * painter, const KisPaintInfor
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;
......@@ -55,7 +55,9 @@ void KisPressureDarkenOption::apply(KisColorSource* colorSource, const KisPaintI
{
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);
......
......@@ -67,7 +67,7 @@ qreal KisFlowOpacityOption::getStaticOpacity() const
qreal KisFlowOpacityOption::getDynamicOpacity(const KisPaintInformation& info) const
{
return computeValue(info);
return computeSizeLikeValue(info);
}
void KisFlowOpacityOption::setFlow(qreal flow)
......
......@@ -32,6 +32,5 @@ KisPressureFlowOption::KisPressureFlowOption()
double KisPressureFlowOption::apply(const KisPaintInformation & info) const
{
if (!isChecked()) return 1.0;
return computeValue(info);
return computeSizeLikeValue(info);
}
......@@ -30,6 +30,7 @@ KisPressureGradientOption::KisPressureGradientOption()
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));
}
}
......@@ -27,10 +27,10 @@ KisPressureHSVOption* KisPressureHSVOption::createHueOption() {
QString KisPressureHSVOption::hueMinLabel()
{
// xgettext: no-c-format
QString activeColorMsg = i18n("(50% is active color)");
QString activeColorMsg = i18n("( is active color)");
QString br("<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);
}
......@@ -38,10 +38,10 @@ QString KisPressureHSVOption::hueMinLabel()
QString KisPressureHSVOption::huemaxLabel()
{
// xgettext: no-c-format
QString activeColorMsg = i18n("(50% is active color)");
QString activeColorMsg = i18n("( is active color)");
QString br("<br />");
QString fullPercent = i18n("100%");
QString zeroPercent = i18n("0%");
QString fullPercent = i18n("+180°");
QString zeroPercent = i18n("-180°");
return QString(fullPercent + br + i18n("CW hue"));
}
......@@ -55,8 +55,8 @@ QString KisPressureHSVOption::saturationMinLabel()
// xgettext: no-c-format
QString activeColorMsg = i18n("(50% is active color)");
QString br("<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);
......@@ -67,8 +67,8 @@ QString KisPressureHSVOption::saturationmaxLabel()
// xgettext: no-c-format
QString activeColorMsg = i18n("(50% is active color)");
QString br("<br />");
QString fullPercent = i18n("100%");
QString zeroPercent = i18n("0%");
QString fullPercent = i18n("+100%");
QString zeroPercent = i18n("-100%");
return QString(fullPercent + br + i18n("More saturation"));
}
......@@ -82,8 +82,8 @@ QString KisPressureHSVOption::valueMinLabel()
// xgettext: no-c-format
QString activeColorMsg = i18n("(50% is active color)");
QString br("<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);
......@@ -94,8 +94,8 @@ QString KisPressureHSVOption::valuemaxLabel()
// xgettext: no-c-format
QString activeColorMsg = i18n("(50% is active color)");
QString br("<br />");
QString fullPercent = i18n("100%");
QString zeroPercent = i18n("0%");
QString fullPercent = i18n("+100%");
QString zeroPercent = i18n("-100%");
return QString(fullPercent + br + i18n("Higher value"));
......@@ -106,7 +106,6 @@ struct KisPressureHSVOption::Private
{
QString parameterName;
int paramId;
double min, max;
};
KisPressureHSVOption::KisPressureHSVOption(const QString& parameterName)
......@@ -115,8 +114,6 @@ KisPressureHSVOption::KisPressureHSVOption(const QString& parameterName)
{
d->parameterName = parameterName;
d->paramId = -1;
d->min = -1;
d->max = 1;
}
KisPressureHSVOption::~KisPressureHSVOption()
......@@ -135,11 +132,9 @@ void KisPressureHSVOption::apply(KoColorTransformation* transfo, const KisPaintI
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.
}
......@@ -77,7 +77,9 @@ MirrorProperties KisPressureMirrorOption::apply(const KisPaintInformation& info)
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;
......
......@@ -30,5 +30,5 @@ KisPressureMixOption::KisPressureMixOption()
double KisPressureMixOption::apply(const KisPaintInformation & info) const
{
if (!isChecked()) return 1.0;
return computeValue(info);
return computeSizeLikeValue(info);
}
......@@ -59,7 +59,7 @@ quint8 KisPressureOpacityOption::apply(KisPainter* painter, const KisPaintInform
}
quint8 origOpacity = painter->opacity();
qreal opacity = (qreal)(origOpacity * computeValue(info));
qreal opacity = (qreal)(origOpacity * computeSizeLikeValue(info));
quint8 opacity2 = (quint8)qRound(qBound<qreal>(OPACITY_TRANSPARENT_U8, opacity, OPACITY_OPAQUE_U8));
painter->setOpacityUpdateAverage(opacity2);
......@@ -68,6 +68,7 @@ quint8 KisPressureOpacityOption::apply(KisPainter* painter, const KisPaintInform
qreal KisPressureOpacityOption::getOpacityf(const KisPaintInformation& info)
{
return isChecked() ? computeValue(info) : 1.0;
if (!isChecked()) return 1.0;
return computeSizeLikeValue(info);
}
......@@ -40,10 +40,6 @@ public:
* 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);