File indexing completed on 2024-06-16 04:17:31

0001 /*
0002  *  SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #include "KisSharpnessOptionData.h"
0007 
0008 const QString SHARPNESS_FACTOR = "Sharpness/factor";
0009 const QString SHARPNESS_ALIGN_OUTLINE_PIXELS = "Sharpness/alignoutline";
0010 const QString SHARPNESS_SOFTNESS  = "Sharpness/softness";
0011 
0012 
0013 bool KisSharpnessOptionMixInImpl::read(const KisPropertiesConfiguration *setting)
0014 {
0015     alignOutlinePixels = setting->getBool(SHARPNESS_ALIGN_OUTLINE_PIXELS);
0016     softness = setting->getInt(SHARPNESS_SOFTNESS);
0017 
0018     if (setting->hasProperty(SHARPNESS_FACTOR) && !setting->hasProperty("SharpnessValue")) {
0019         softness = quint32(setting->getDouble(SHARPNESS_FACTOR) * 100);
0020     }
0021 
0022     return true;
0023 }
0024 
0025 void KisSharpnessOptionMixInImpl::write(KisPropertiesConfiguration *setting) const
0026 {
0027     setting->setProperty(SHARPNESS_ALIGN_OUTLINE_PIXELS, alignOutlinePixels);
0028     setting->setProperty(SHARPNESS_SOFTNESS, softness);
0029 }
0030 
0031 KisSharpnessOptionData::KisSharpnessOptionData(const QString &prefix)
0032     : KisOptionTuple<KisCurveOptionData, KisSharpnessOptionMixIn>(prefix, KoID("Sharpness", i18n("Sharpness")))
0033 {
0034     valueFixUpReadCallback = [] (KisCurveOptionDataCommon *data, const KisPropertiesConfiguration *setting) {
0035 
0036         if (setting->hasProperty(SHARPNESS_FACTOR) && !setting->hasProperty("SharpnessValue")) {
0037             data->strengthValue = setting->getDouble(SHARPNESS_FACTOR);
0038         }
0039     };
0040 }