File indexing completed on 2024-06-23 04:27:52
0001 /* 0002 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KISSENSORDATA_H 0008 #define KISSENSORDATA_H 0009 0010 #include <boost/operators.hpp> 0011 #include "kritapaintop_export.h" 0012 #include "kis_assert.h" 0013 #include "kis_paintop_option.h" 0014 0015 struct PAINTOP_EXPORT KisSensorData : public boost::equality_comparable<KisSensorData> 0016 { 0017 KisSensorData(const KoID &sensorId); 0018 virtual ~KisSensorData(); 0019 0020 inline friend bool operator==(const KisSensorData &lhs, const KisSensorData &rhs) { 0021 return lhs.id == rhs.id && 0022 lhs.curve == rhs.curve && 0023 lhs.isActive == rhs.isActive; 0024 } 0025 0026 virtual QRectF baseCurveRange() const; 0027 virtual void setBaseCurveRange(const QRectF &rect); 0028 virtual void write(QDomDocument& doc, QDomElement &e) const; 0029 virtual void read(const QDomElement &e); 0030 virtual void reset(); 0031 0032 KoID id; 0033 QString curve; 0034 0035 // not a part of XML data, managed by the curve option 0036 bool isActive = false; 0037 }; 0038 0039 struct PAINTOP_EXPORT KisSensorWithLengthData : public KisSensorData, public boost::equality_comparable<KisSensorWithLengthData> 0040 { 0041 KisSensorWithLengthData(const KoID &sensorId, const QLatin1String &lengthTag = {}); 0042 0043 inline friend bool operator==(const KisSensorWithLengthData &lhs, const KisSensorWithLengthData &rhs) { 0044 return *static_cast<const KisSensorData*>(&lhs) == *static_cast<const KisSensorData*>(&rhs) && 0045 lhs.length == rhs.length && 0046 lhs.isPeriodic == rhs.isPeriodic && 0047 lhs.m_lengthTag == rhs.m_lengthTag; 0048 } 0049 0050 void write(QDomDocument& doc, QDomElement &e) const override; 0051 void read(const QDomElement &e) override; 0052 void reset() override; 0053 0054 int length = 30; 0055 bool isPeriodic = false; 0056 private: 0057 QLatin1String m_lengthTag; 0058 }; 0059 0060 struct PAINTOP_EXPORT KisDrawingAngleSensorData : public KisSensorData, public boost::equality_comparable<KisDrawingAngleSensorData> 0061 { 0062 KisDrawingAngleSensorData(); 0063 0064 inline friend bool operator==(const KisDrawingAngleSensorData &lhs, const KisDrawingAngleSensorData &rhs) { 0065 return *static_cast<const KisSensorData*>(&lhs) == *static_cast<const KisSensorData*>(&rhs) && 0066 lhs.fanCornersEnabled == rhs.fanCornersEnabled && 0067 lhs.fanCornersStep == rhs.fanCornersStep && 0068 lhs.angleOffset == rhs.angleOffset && 0069 lhs.lockedAngleMode == rhs.lockedAngleMode; 0070 } 0071 0072 void write(QDomDocument& doc, QDomElement &e) const override; 0073 void read(const QDomElement &e) override; 0074 void reset() override; 0075 0076 bool fanCornersEnabled = false; 0077 int fanCornersStep = 30; 0078 int angleOffset = 0; // in degrees 0079 bool lockedAngleMode = false; 0080 }; 0081 0082 #endif // KISSENSORDATA_H