Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSensorData.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KISSENSORDATA_H
8#define KISSENSORDATA_H
9
10#include <boost/operators.hpp>
11#include "kritapaintop_export.h"
12#include "kis_assert.h"
13#include "kis_paintop_option.h"
14
15struct PAINTOP_EXPORT KisSensorData : public boost::equality_comparable<KisSensorData>
16{
17 KisSensorData(const KoID &sensorId);
18 virtual ~KisSensorData();
19
20 inline friend bool operator==(const KisSensorData &lhs, const KisSensorData &rhs) {
21 return lhs.id == rhs.id &&
22 lhs.curve == rhs.curve &&
23 lhs.isActive == rhs.isActive;
24 }
25
26 virtual QRectF baseCurveRange() const;
27 virtual void setBaseCurveRange(const QRectF &rect);
28 virtual void write(QDomDocument& doc, QDomElement &e) const;
29 virtual void read(const QDomElement &e);
30 virtual void reset();
31
33 QString curve;
34
35 // not a part of XML data, managed by the curve option
36 bool isActive = false;
37};
38
39struct PAINTOP_EXPORT KisSensorWithLengthData : public KisSensorData, public boost::equality_comparable<KisSensorWithLengthData>
40{
41 KisSensorWithLengthData(const KoID &sensorId, const QLatin1String &lengthTag = {});
42
43 inline friend bool operator==(const KisSensorWithLengthData &lhs, const KisSensorWithLengthData &rhs) {
44 return *static_cast<const KisSensorData*>(&lhs) == *static_cast<const KisSensorData*>(&rhs) &&
45 lhs.length == rhs.length &&
46 lhs.isPeriodic == rhs.isPeriodic &&
47 lhs.m_lengthTag == rhs.m_lengthTag;
48 }
49
50 void write(QDomDocument& doc, QDomElement &e) const override;
51 void read(const QDomElement &e) override;
52 void reset() override;
53
54 int length = 30;
55 bool isPeriodic = false;
56private:
57 QLatin1String m_lengthTag;
58};
59
60struct PAINTOP_EXPORT KisDrawingAngleSensorData : public KisSensorData, public boost::equality_comparable<KisDrawingAngleSensorData>
61{
63
64 inline friend bool operator==(const KisDrawingAngleSensorData &lhs, const KisDrawingAngleSensorData &rhs) {
65 return *static_cast<const KisSensorData*>(&lhs) == *static_cast<const KisSensorData*>(&rhs) &&
67 lhs.fanCornersStep == rhs.fanCornersStep &&
70 }
71
72 void write(QDomDocument& doc, QDomElement &e) const override;
73 void read(const QDomElement &e) override;
74 void reset() override;
75
76 bool fanCornersEnabled = false;
77 int fanCornersStep = 30;
78 qreal angleOffset = 0.0; // in degrees
79 bool lockedAngleMode = false;
80};
81
82#endif // KISSENSORDATA_H
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
Definition KoID.h:30
static bool qFuzzyCompare(half p1, half p2)
friend bool operator==(const KisDrawingAngleSensorData &lhs, const KisDrawingAngleSensorData &rhs)
friend bool operator==(const KisSensorData &lhs, const KisSensorData &rhs)
friend bool operator==(const KisSensorWithLengthData &lhs, const KisSensorWithLengthData &rhs)
QLatin1String m_lengthTag