Changeset View
Changeset View
Standalone View
Standalone View
plugins/paintops/libpaintop/kis_pressure_sharpness_option.h
Show All 19 Lines | |||||
20 | #ifndef KIS_PRESSURE_SHARPNESS_OPTION_H | 20 | #ifndef KIS_PRESSURE_SHARPNESS_OPTION_H | ||
21 | #define KIS_PRESSURE_SHARPNESS_OPTION_H | 21 | #define KIS_PRESSURE_SHARPNESS_OPTION_H | ||
22 | 22 | | |||
23 | #include "kis_curve_option.h" | 23 | #include "kis_curve_option.h" | ||
24 | #include <brushengine/kis_paint_information.h> | 24 | #include <brushengine/kis_paint_information.h> | ||
25 | #include <kritapaintop_export.h> | 25 | #include <kritapaintop_export.h> | ||
26 | #include <kis_types.h> | 26 | #include <kis_types.h> | ||
27 | 27 | | |||
28 | | ||||
29 | const QString SHARPNESS_FACTOR = "Sharpness/factor"; | 28 | const QString SHARPNESS_FACTOR = "Sharpness/factor"; | ||
30 | const QString SHARPNESS_THRESHOLD = "Sharpness/threshold"; | 29 | const QString SHARPNESS_SOFTNESS = "Sharpness/softness"; | ||
31 | 30 | | |||
32 | /** | 31 | /** | ||
33 | * This option is responsible to mimic pencil effect from former Pixel Pencil brush engine.auto | 32 | * This option is responsible to mimic pencil effect from former Pixel Pencil brush engine.auto | ||
34 | */ | 33 | */ | ||
35 | class PAINTOP_EXPORT KisPressureSharpnessOption : public KisCurveOption | 34 | class PAINTOP_EXPORT KisPressureSharpnessOption : public KisCurveOption | ||
36 | { | 35 | { | ||
37 | public: | 36 | public: | ||
38 | KisPressureSharpnessOption(); | 37 | KisPressureSharpnessOption(); | ||
39 | 38 | | |||
40 | /** | 39 | /** | ||
41 | * First part of the sharpness is the coordinates: in pen mode they are integers without fractions | 40 | * First part of the sharpness is the coordinates: in pen mode they are integers without fractions | ||
42 | */ | 41 | */ | ||
43 | void apply(const KisPaintInformation &info, const QPointF &pt, qint32 &x, qint32 &y, qreal &xFraction, qreal &yFraction) const; | 42 | void apply(const KisPaintInformation &info, const QPointF &pt, qint32 &x, qint32 &y, qreal &xFraction, qreal &yFraction) const; | ||
44 | 43 | | |||
45 | /** | 44 | /** | ||
46 | * Apply threshold specified by user | 45 | * Apply threshold specified by user | ||
47 | */ | 46 | */ | ||
48 | void applyThreshold(KisFixedPaintDeviceSP dab); | 47 | void applyThreshold(KisFixedPaintDeviceSP dab, const KisPaintInformation &info); | ||
49 | 48 | | |||
50 | void writeOptionSetting(KisPropertiesConfigurationSP setting) const override; | 49 | void writeOptionSetting(KisPropertiesConfigurationSP setting) const override; | ||
51 | void readOptionSetting(const KisPropertiesConfigurationSP setting) override; | 50 | void readOptionSetting(const KisPropertiesConfigurationSP setting) override; | ||
52 | 51 | | |||
53 | /// threshold has 100 levels (like opacity) | 52 | /// threshold has 100 levels (like opacity) | ||
54 | void setThreshold(qint32 threshold) { | 53 | void setThreshold(qint32 threshold) { | ||
55 | m_threshold = qBound<qint32>(0, threshold, 100); | 54 | m_softness = qBound<quint32>(0, quint32(threshold), 100); | ||
56 | } | 55 | } | ||
57 | qint32 threshold() { | 56 | qint32 threshold() { | ||
58 | return m_threshold; | 57 | return qint32(m_softness); | ||
59 | } | 58 | } | ||
60 | 59 | | |||
61 | void setSharpnessFactor(qreal factor) { | 60 | void setSharpnessFactor(qreal factor) { | ||
62 | KisCurveOption::setValue(factor); | 61 | KisCurveOption::setValue(factor); | ||
63 | } | 62 | } | ||
64 | qreal sharpnessFactor() { | 63 | qreal sharpnessFactor() { | ||
65 | return KisCurveOption::value(); | 64 | return KisCurveOption::value(); | ||
66 | } | 65 | } | ||
67 | 66 | | |||
68 | private: | 67 | private: | ||
69 | qint32 m_threshold {40}; | 68 | quint32 m_softness {0}; | ||
70 | }; | 69 | }; | ||
71 | 70 | | |||
72 | #endif | 71 | #endif |