File indexing completed on 2024-12-22 04:16:10
0001 /* 0002 * SPDX-FileCopyrightText: 2008 Lukas Tvrdy <lukast.dev@gmail.com> 0003 * SPDX-FileCopyrightText: 2010 José Luis Vergara <pentalis@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 #include "KisHatchingOptionsData.h" 0008 0009 #include "kis_properties_configuration.h" 0010 #include <kis_paintop_lod_limitations.h> 0011 0012 0013 const QString HATCHING_ANGLE = "Hatching/angle"; 0014 const QString HATCHING_SEPARATION = "Hatching/separation"; 0015 const QString HATCHING_THICKNESS = "Hatching/thickness"; 0016 const QString HATCHING_ORIGIN_X = "Hatching/origin_x"; 0017 const QString HATCHING_ORIGIN_Y = "Hatching/origin_y"; 0018 0019 const QString HATCHING_BOOL_NOCROSSHATCHING = "Hatching/bool_nocrosshatching"; 0020 const QString HATCHING_BOOL_PERPENDICULAR = "Hatching/bool_perpendicular"; 0021 const QString HATCHING_BOOL_MINUSTHENPLUS = "Hatching/bool_minusthenplus"; 0022 const QString HATCHING_BOOL_PLUSTHENMINUS = "Hatching/bool_plusthenminus"; 0023 const QString HATCHING_BOOL_MOIREPATTERN = "Hatching/bool_moirepattern"; 0024 0025 const QString HATCHING_SEPARATIONINTERVALS = "Hatching/separationintervals"; 0026 0027 0028 bool KisHatchingOptionsData::read(const KisPropertiesConfiguration *setting) 0029 { 0030 angle = setting->getDouble(HATCHING_ANGLE, -60.0); 0031 separation = setting->getDouble(HATCHING_SEPARATION, 6.0); 0032 thickness = setting->getDouble(HATCHING_THICKNESS, 1.0); 0033 originX = setting->getDouble(HATCHING_ORIGIN_X, 50.0); 0034 originY = setting->getDouble(HATCHING_ORIGIN_Y, 50.0); 0035 0036 if (setting->getBool(HATCHING_BOOL_NOCROSSHATCHING, true)) { 0037 crosshatchingStyle = CrosshatchingType::NoCrosshatching; 0038 } 0039 else if (setting->getBool(HATCHING_BOOL_PERPENDICULAR, false)) { 0040 crosshatchingStyle = CrosshatchingType::Perpendicular; 0041 } 0042 else if (setting->getBool(HATCHING_BOOL_MINUSTHENPLUS, false)) { 0043 crosshatchingStyle = CrosshatchingType::MinusThenPlus; 0044 } 0045 else if (setting->getBool(HATCHING_BOOL_PLUSTHENMINUS, false)) { 0046 crosshatchingStyle = CrosshatchingType::PlusThenMinus; 0047 } 0048 else if (setting->getBool(HATCHING_BOOL_MOIREPATTERN, false)) { 0049 crosshatchingStyle = CrosshatchingType::MoirePattern; 0050 } 0051 0052 separationIntervals = setting->getInt(HATCHING_SEPARATIONINTERVALS, 2); 0053 return true; 0054 } 0055 0056 void KisHatchingOptionsData::write(KisPropertiesConfiguration *setting) const 0057 { 0058 setting->setProperty(HATCHING_ANGLE, angle); 0059 setting->setProperty(HATCHING_SEPARATION, separation); 0060 setting->setProperty(HATCHING_THICKNESS, thickness); 0061 setting->setProperty(HATCHING_ORIGIN_X, originX); 0062 setting->setProperty(HATCHING_ORIGIN_Y, originY); 0063 0064 setting->setProperty(HATCHING_BOOL_NOCROSSHATCHING, crosshatchingStyle == CrosshatchingType::NoCrosshatching); 0065 setting->setProperty(HATCHING_BOOL_PERPENDICULAR, crosshatchingStyle == CrosshatchingType::Perpendicular); 0066 setting->setProperty(HATCHING_BOOL_MINUSTHENPLUS, crosshatchingStyle == CrosshatchingType::MinusThenPlus); 0067 setting->setProperty(HATCHING_BOOL_PLUSTHENMINUS, crosshatchingStyle == CrosshatchingType::PlusThenMinus); 0068 setting->setProperty(HATCHING_BOOL_MOIREPATTERN, crosshatchingStyle == CrosshatchingType::MoirePattern); 0069 0070 setting->setProperty(HATCHING_SEPARATIONINTERVALS, separationIntervals); 0071 } 0072 0073 KisPaintopLodLimitations KisHatchingOptionsData::lodLimitations() const 0074 { 0075 KisPaintopLodLimitations l; 0076 l.limitations << KoID("hatching-brush", i18nc("PaintOp instant preview limitation", "Hatching Brush (heavy aliasing in preview mode)")); 0077 return l; 0078 }