1 | /* |
2 | * This file is part of KQuickCharts |
3 | * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> |
4 | * |
5 | * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
6 | */ |
7 | |
8 | #ifndef LINESEGMENTNODE_H |
9 | #define LINESEGMENTNODE_H |
10 | |
11 | #include <QColor> |
12 | #include <QSGGeometryNode> |
13 | #include <QVector2D> |
14 | |
15 | class QRectF; |
16 | class LineChartMaterial; |
17 | |
18 | /** |
19 | * @todo write docs |
20 | */ |
21 | class LineSegmentNode : public QSGGeometryNode |
22 | { |
23 | public: |
24 | LineSegmentNode(); |
25 | |
26 | /** |
27 | * Default constructor |
28 | */ |
29 | explicit LineSegmentNode(const QRectF &rect); |
30 | |
31 | /** |
32 | * Destructor |
33 | */ |
34 | ~LineSegmentNode(); |
35 | |
36 | void setRect(const QRectF &rect); |
37 | void setAspect(float xAspect, float yAspect); |
38 | void setSmoothing(float smoothing); |
39 | void setLineWidth(float width); |
40 | void setLineColor(const QColor &color); |
41 | void setFillColor(const QColor &color); |
42 | void setValues(const QList<QVector2D> &values); |
43 | void setFarLeft(const QVector2D &value); |
44 | void setFarRight(const QVector2D &value); |
45 | |
46 | void update(); |
47 | |
48 | private: |
49 | QRectF m_rect; |
50 | float m_lineWidth = 0.0; |
51 | float m_xAspect = 1.0; |
52 | float m_yAspect = 1.0; |
53 | float m_smoothing = 0.1; |
54 | QVector2D m_farLeft; |
55 | QVector2D m_farRight; |
56 | QList<QVector2D> m_values; |
57 | QSGGeometry *m_geometry = nullptr; |
58 | LineChartMaterial *m_material = nullptr; |
59 | QColor m_lineColor; |
60 | QColor m_fillColor; |
61 | }; |
62 | |
63 | #endif // LINESEGMENTNODE_H |
64 | |