2 #include <Curve/Segment/CurveSegmentModel.hpp>
5 #include <score/serialization/VisitorInterface.hpp>
7 #include <ossia/detail/flat_map.hpp>
19 #include <score/model/Identifier.hpp>
23 class PointArraySegment;
26 CURVE_SEGMENT_METADATA(
27 SCORE_PLUGIN_CURVE_EXPORT, Curve::PointArraySegment,
28 "c598b840-db67-4c8f-937a-46cfac87cb59",
"PointArray",
"PointArray",
"hidden")
34 struct PointArraySegmentData
38 QVector<QPointF> m_points;
40 class SCORE_PLUGIN_CURVE_EXPORT PointArraySegment final :
public SegmentModel
42 W_OBJECT(PointArraySegment)
44 MODEL_METADATA_IMPL(PointArraySegment)
46 using data_type = PointArraySegmentData;
48 : SegmentModel{id, parent}
51 PointArraySegment(
const SegmentData& dat, QObject* parent);
53 PointArraySegment(
const PointArraySegment& other,
const id_type&
id, QObject* parent);
56 : SegmentModel{vis, parent}
62 : SegmentModel{vis, parent}
67 ~PointArraySegment()
override;
69 void on_startChanged()
override;
70 void on_endChanged()
override;
72 void updateData(
int numInterp)
const override;
73 double valueAt(
double x)
const override;
75 void addPoint(
double,
double);
76 void addPointUnscaled(
double,
double);
77 void simplify(
double ratio);
78 std::vector<SegmentData> toLinearSegments()
const;
79 std::vector<SegmentData> toPowerSegments()
const;
81 double min() {
return min_y; }
82 double max() {
return max_y; }
84 void setMinX(
double y) { min_x = y; }
85 void setMinY(
double y) { min_y = y; }
86 void setMaxX(
double y) { max_x = y; }
87 void setMaxY(
double y) { max_y = y; }
89 const auto& points()
const {
return m_points; }
90 void reserve(std::size_t p);
92 QVariant toSegmentSpecificData()
const override
94 PointArraySegmentData dat{min_x, max_x, min_y, max_y, {}};
96 dat.m_points.reserve(m_points.size());
97 for(
const auto& pt : m_points)
98 dat.m_points.push_back({pt.first, pt.second});
100 return QVariant::fromValue(std::move(dat));
104 ossia::curve_segment<double> makeDoubleFunction()
const override;
105 ossia::curve_segment<float> makeFloatFunction()
const override;
106 ossia::curve_segment<int> makeIntFunction()
const override;
110 void minChanged(
double arg_1) E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, minChanged, arg_1)
111 void maxChanged(
double arg_1) E_SIGNAL(SCORE_PLUGIN_CURVE_EXPORT, maxChanged, arg_1)
115 double min_x{}, max_x{};
116 double min_y{}, max_y{};
120 ossia::flat_map<double, double> m_points;
124 SCORE_SERIALIZE_DATASTREAM_DECLARE(
125 SCORE_PLUGIN_CURVE_EXPORT, Curve::PointArraySegmentData)
126 Q_DECLARE_METATYPE(Curve::PointArraySegmentData)
127 W_REGISTER_ARGTYPE(Curve::PointArraySegmentData)
Definition: DataStreamVisitor.hpp:202
Definition: JSONVisitor.hpp:423
The id_base_t class.
Definition: Identifier.hpp:57
Utilities and base classes for 1D curves.
Definition: FocusDispatcher.hpp:12