1 | // Copyright (C) 2023 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #include "axisgrid_p.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | AxisGrid::AxisGrid(QQuickItem *parent) : |
9 | QQuickShaderEffect(parent) |
10 | { |
11 | } |
12 | |
13 | AxisGrid::~AxisGrid() {} |
14 | |
15 | void AxisGrid::componentComplete() |
16 | { |
17 | QQuickShaderEffect::componentComplete(); |
18 | setupShaders(); |
19 | } |
20 | |
21 | void AxisGrid::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) |
22 | { |
23 | m_iResolution = QVector3D(newGeometry.width(), newGeometry.height(), 1.0); |
24 | emit iResolutionChanged(); |
25 | |
26 | QQuickShaderEffect::geometryChange(newGeometry, oldGeometry); |
27 | } |
28 | |
29 | void AxisGrid::setupShaders() |
30 | { |
31 | setFragmentShader(QUrl(QStringLiteral("qrc:/shaders/gridshader.frag.qsb"))); |
32 | setVertexShader(QUrl(QStringLiteral("qrc:/shaders/gridshader.vert.qsb"))); |
33 | } |
34 | |
35 | QVector3D AxisGrid::iResolution() const |
36 | { |
37 | return m_iResolution; |
38 | } |
39 | |
40 | qreal AxisGrid::smoothing() const |
41 | { |
42 | return m_smoothing; |
43 | } |
44 | |
45 | void AxisGrid::setSmoothing(qreal newSmoothing) |
46 | { |
47 | if (qFuzzyCompare(p1: m_smoothing, p2: newSmoothing)) |
48 | return; |
49 | m_smoothing = newSmoothing; |
50 | emit smoothingChanged(); |
51 | } |
52 | |
53 | int AxisGrid::origo() const |
54 | { |
55 | return m_origo; |
56 | } |
57 | |
58 | void AxisGrid::setOrigo(int newOrigo) |
59 | { |
60 | if (m_origo == newOrigo) |
61 | return; |
62 | m_origo = newOrigo; |
63 | emit origoChanged(); |
64 | } |
65 | |
66 | QVector4D AxisGrid::gridVisibility() const |
67 | { |
68 | return m_gridVisibility; |
69 | } |
70 | |
71 | void AxisGrid::setGridVisibility(const QVector4D &newGridVisibility) |
72 | { |
73 | if (m_gridVisibility == newGridVisibility) |
74 | return; |
75 | m_gridVisibility = newGridVisibility; |
76 | emit gridVisibilityChanged(); |
77 | } |
78 | |
79 | qreal AxisGrid::gridWidth() const |
80 | { |
81 | return m_gridWidth; |
82 | } |
83 | |
84 | void AxisGrid::setGridWidth(qreal newGridWidth) |
85 | { |
86 | if (qFuzzyCompare(p1: m_gridWidth, p2: newGridWidth)) |
87 | return; |
88 | m_gridWidth = newGridWidth; |
89 | emit gridWidthChanged(); |
90 | } |
91 | |
92 | qreal AxisGrid::gridHeight() const |
93 | { |
94 | return m_gridHeight; |
95 | } |
96 | |
97 | void AxisGrid::setGridHeight(qreal newGridHeight) |
98 | { |
99 | if (qFuzzyCompare(p1: m_gridHeight, p2: newGridHeight)) |
100 | return; |
101 | m_gridHeight = newGridHeight; |
102 | emit gridHeightChanged(); |
103 | } |
104 | |
105 | QPointF AxisGrid::gridMovement() const |
106 | { |
107 | return m_gridMovement; |
108 | } |
109 | |
110 | void AxisGrid::setGridMovement(QPointF newGridMovement) |
111 | { |
112 | if (m_gridMovement == newGridMovement) |
113 | return; |
114 | m_gridMovement = newGridMovement; |
115 | emit gridMovementChanged(); |
116 | } |
117 | |
118 | QColor AxisGrid::subGridColor() const |
119 | { |
120 | return m_subGridColor; |
121 | } |
122 | |
123 | void AxisGrid::setSubGridColor(QColor newSubGridColor) |
124 | { |
125 | if (m_subGridColor == newSubGridColor) |
126 | return; |
127 | m_subGridColor = newSubGridColor; |
128 | emit subGridColorChanged(); |
129 | } |
130 | |
131 | QColor AxisGrid::gridColor() const |
132 | { |
133 | return m_gridColor; |
134 | } |
135 | |
136 | void AxisGrid::setGridColor(QColor newGridColor) |
137 | { |
138 | if (m_gridColor == newGridColor) |
139 | return; |
140 | m_gridColor = newGridColor; |
141 | emit gridColorChanged(); |
142 | } |
143 | |
144 | QColor AxisGrid::plotAreaBackgroundColor() const |
145 | { |
146 | return m_plotAreaBackgroundColor; |
147 | } |
148 | |
149 | void AxisGrid::setPlotAreaBackgroundColor(QColor color) |
150 | { |
151 | if (m_plotAreaBackgroundColor == color) |
152 | return; |
153 | m_plotAreaBackgroundColor = color; |
154 | emit plotAreaBackgroundColorChanged(); |
155 | } |
156 | |
157 | qreal AxisGrid::subGridLineWidth() const |
158 | { |
159 | return m_subGridLineWidth; |
160 | } |
161 | |
162 | void AxisGrid::setSubGridLineWidth(qreal newSubGridLineWidth) |
163 | { |
164 | if (qFuzzyCompare(p1: m_subGridLineWidth, p2: newSubGridLineWidth)) |
165 | return; |
166 | m_subGridLineWidth = newSubGridLineWidth; |
167 | emit subGridLineWidthChanged(); |
168 | } |
169 | |
170 | qreal AxisGrid::gridLineWidth() const |
171 | { |
172 | return m_gridLineWidth; |
173 | } |
174 | |
175 | void AxisGrid::setGridLineWidth(qreal newGridLineWidth) |
176 | { |
177 | if (qFuzzyCompare(p1: m_gridLineWidth, p2: newGridLineWidth)) |
178 | return; |
179 | m_gridLineWidth = newGridLineWidth; |
180 | emit gridLineWidthChanged(); |
181 | } |
182 | |
183 | qreal AxisGrid::verticalSubGridScale() const |
184 | { |
185 | return m_verticalSubGridScale; |
186 | } |
187 | |
188 | void AxisGrid::setVerticalSubGridScale(qreal newVerticalSubGridScale) |
189 | { |
190 | if (qFuzzyCompare(p1: m_verticalSubGridScale, p2: newVerticalSubGridScale)) |
191 | return; |
192 | m_verticalSubGridScale = newVerticalSubGridScale; |
193 | emit verticalSubGridScaleChanged(); |
194 | } |
195 | |
196 | qreal AxisGrid::horizontalSubGridScale() const |
197 | { |
198 | return m_horizontalSubGridScale; |
199 | } |
200 | |
201 | void AxisGrid::setHorizontalSubGridScale(qreal newHorizontalSubGridScale) |
202 | { |
203 | if (qFuzzyCompare(p1: m_horizontalSubGridScale, p2: newHorizontalSubGridScale)) |
204 | return; |
205 | m_horizontalSubGridScale = newHorizontalSubGridScale; |
206 | emit horizontalSubGridScaleChanged(); |
207 | } |
208 | |
209 | QT_END_NAMESPACE |
210 |
Definitions
- AxisGrid
- ~AxisGrid
- componentComplete
- geometryChange
- setupShaders
- iResolution
- smoothing
- setSmoothing
- origo
- setOrigo
- gridVisibility
- setGridVisibility
- gridWidth
- setGridWidth
- gridHeight
- setGridHeight
- gridMovement
- setGridMovement
- subGridColor
- setSubGridColor
- gridColor
- setGridColor
- plotAreaBackgroundColor
- setPlotAreaBackgroundColor
- subGridLineWidth
- setSubGridLineWidth
- gridLineWidth
- setGridLineWidth
- verticalSubGridScale
- setVerticalSubGridScale
- horizontalSubGridScale
Start learning QML with our Intro Training
Find out more