Krita Source Code Documentation
Loading...
Searching...
No Matches
KisCurveRangeModel.cpp
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
8
10
11using LabelsState = std::tuple<QString, int>;
12
13namespace {
14QString calcMinLabelWithFactory(const QString &sensorId)
15{
18
20
21 return factory->minimumLabel();
22}
23
24QString calcMaxLabelWithFactory(const QString &activeSensorId, const int length)
25{
28
30
31 return factory->maximumLabel(length);
32}
33
34QString calcValueSuffixWithFactory(const QString &activeSensorId)
35{
38
40
41 return factory->valueSuffix();
42}
43
44
45}
46
47KisCurveRangeModel::KisCurveRangeModel(lager::cursor<QString> curve,
48 lager::reader<QString> activeSensorId,
49 lager::reader<int> activeSensorLength,
50 const QString &yMinLabel,
51 const QString &yMaxLabel,
52 int yMinValue,
53 int yMaxValue,
54 const QString &yValueSuffix)
55 : m_curve(std::move(curve))
56 , m_activeSensorId(std::move(activeSensorId))
57 , m_activeSensorLength(std::move(activeSensorLength))
58 , m_yMinLabel(yMinLabel)
59 , m_yMaxLabel(yMaxLabel)
60 , m_yMinValue(yMinValue)
61 , m_yMaxValue(yMaxValue)
62 , m_yValueSuffix(yValueSuffix)
63{
64}
65
67 const QString &yMaxLabel,
68 int curveMinValue,
69 int curveMaxValue,
70 const QString &curveValueSuffix)
71{
72 return [yMinLabel, yMaxLabel,
73 curveMinValue, curveMaxValue,
74 curveValueSuffix](lager::cursor<QString> curve,
75 lager::cursor<QRectF> curveRange,
76 lager::reader<QString> activeSensorId,
77 lager::reader<int> activeSensorLength) {
78
79 Q_UNUSED(curveRange);
80 return new KisCurveRangeModel(curve, activeSensorId, activeSensorLength, yMinLabel, yMaxLabel, curveMinValue, curveMaxValue, curveValueSuffix);
81 };
82}
83
85{
88
90
91 return qreal(factory->minimumValue());
92}
93
94qreal KisCurveRangeModel::calcXMaxValueWithFactory(const QString &activeSensorId, const int length)
95{
98
100
101 return factory->maximumValue(length);
102}
103
107
108lager::cursor<QString> KisCurveRangeModel::curve()
109{
110 return m_curve;
111}
112
113lager::reader<QString> KisCurveRangeModel::xMinLabel()
114{
115 return m_activeSensorId.map(&calcMinLabelWithFactory);
116}
117
118lager::reader<QString> KisCurveRangeModel::xMaxLabel()
119{
120 return lager::with(m_activeSensorId, m_activeSensorLength).map(&calcMaxLabelWithFactory);
121}
122
123lager::reader<QString> KisCurveRangeModel::yMinLabel()
124{
125 return m_yMinLabel;
126}
127
128lager::reader<QString> KisCurveRangeModel::yMaxLabel()
129{
130 return m_yMaxLabel;
131}
132
133lager::reader<qreal> KisCurveRangeModel::yMinValue()
134{
135 return m_yMinValue;
136}
137
138lager::reader<qreal> KisCurveRangeModel::yMaxValue()
139{
140 return m_yMaxValue;
141}
142
143lager::reader<QString> KisCurveRangeModel::yValueSuffix()
144{
145 return m_yValueSuffix;
146}
147
148lager::reader<qreal> KisCurveRangeModel::xMinValue()
149{
151}
152
153lager::reader<qreal> KisCurveRangeModel::xMaxValue()
154{
156}
157
158lager::reader<QString> KisCurveRangeModel::xValueSuffix()
159{
160 return m_activeSensorId.map(&calcValueSuffixWithFactory);
161}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
std::tuple< QString, int > LabelsState
std::function< KisCurveRangeModelInterface *(lager::cursor< QString >, lager::cursor< QRectF >, lager::reader< QString >, lager::reader< int >)> KisCurveRangeModelFactory
lager::reader< QString > xValueSuffix() override
static KisCurveRangeModelFactory factory(const QString &yMinLabel, const QString &yMaxLabel, int curveMinValue, int curveMaxValue, const QString &curveValueSuffix)
lager::reader< QString > yMinLabel() override
lager::constant< QString > m_yMinLabel
lager::reader< qreal > yMaxValue() override
lager::reader< qreal > xMinValue() override
lager::cursor< QString > m_curve
KisCurveRangeModel(lager::cursor< QString > curve, lager::reader< QString > activeSensorId, lager::reader< int > activeSensorLength, const QString &yMinLabel, const QString &yMaxLabel, int yMinValue, int yMaxValue, const QString &yValueSuffix)
lager::constant< QString > m_yValueSuffix
lager::reader< QString > xMinLabel() override
lager::cursor< QString > curve() override
lager::reader< qreal > xMaxValue() override
lager::reader< QString > m_activeSensorId
static qreal calcXMaxValueWithFactory(const QString &activeSensorId, const int length)
lager::constant< QString > m_yMaxLabel
lager::reader< qreal > yMinValue() override
static qreal calcXMinValueWithFactory(const QString &sensorId)
lager::constant< qreal > m_yMaxValue
lager::constant< qreal > m_yMinValue
lager::reader< QString > yValueSuffix() override
lager::reader< QString > yMaxLabel() override
lager::reader< QString > xMaxLabel() override
lager::reader< int > m_activeSensorLength
static KisDynamicSensorFactoryRegistry * instance()
virtual QString valueSuffix()=0
virtual QString minimumLabel()=0
virtual QString maximumLabel(int length)=0
T get(const QString &id) const
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129