File indexing completed on 2024-09-22 04:08:30
0001 /* 0002 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef KISDYNAMICSENSOR_H 0007 #define KISDYNAMICSENSOR_H 0008 0009 #include <optional> 0010 #include <kis_cubic_curve.h> 0011 #include <KoID.h> 0012 0013 class KisPaintInformation; 0014 struct KisSensorData; 0015 0016 class KisDynamicSensor 0017 { 0018 public: 0019 KisDynamicSensor(const KoID &id, 0020 const KisSensorData &data, 0021 std::optional<KisCubicCurve> curveOverride); 0022 virtual ~KisDynamicSensor(); 0023 0024 KoID id() const; 0025 qreal parameter(const KisPaintInformation &info) const; 0026 0027 virtual bool isAdditive() const; 0028 virtual bool isAbsoluteRotation() const; 0029 0030 protected: 0031 0032 virtual qreal value(const KisPaintInformation &info) const = 0; 0033 0034 public: 0035 0036 static inline qreal scalingToAdditive(qreal x) { 0037 return -1.0 + 2.0 * x; 0038 } 0039 0040 static inline qreal additiveToScaling(qreal x) { 0041 return 0.5 * (1.0 + x); 0042 } 0043 0044 private: 0045 KoID m_id; 0046 std::optional<KisCubicCurve> m_curve; 0047 }; 0048 0049 #endif // KISDYNAMICSENSOR_H