QuickGraphLib 0.1.0a0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- QuickGraphLib-0.1.0a0/LICENCE +21 -0
- QuickGraphLib-0.1.0a0/MANIFEST.in +1 -0
- QuickGraphLib-0.1.0a0/PKG-INFO +73 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/AntialiasingContainer.qml +18 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/Axis.qml +227 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphArea.qml +54 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/AxHLine.qml +25 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/AxHSpan.qml +28 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/AxVLine.qml +25 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/AxVSpan.qml +28 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/BasicLegend.qml +29 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/BasicLegendItem.qml +54 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/Contour.qml +33 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/GraphItemDragHandler.qml +39 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/Grid.qml +58 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/Histogram.qml +50 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/Line.qml +58 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/Marker.qml +28 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/GraphItems/qmldir +16 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/Helpers.js +167 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/PreFabs/XYAxes.qml +103 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/PreFabs/qmldir +5 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/ScalingContainer.qml +38 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/ZoomPanHandler.qml +78 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib/qmldir +10 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib.egg-info/PKG-INFO +73 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib.egg-info/SOURCES.txt +36 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib.egg-info/dependency_links.txt +1 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib.egg-info/requires.txt +11 -0
- QuickGraphLib-0.1.0a0/QuickGraphLib.egg-info/top_level.txt +2 -0
- QuickGraphLib-0.1.0a0/README.md +21 -0
- QuickGraphLib-0.1.0a0/pyproject.toml +60 -0
- QuickGraphLib-0.1.0a0/quickgraphlib_helpers/__init__.py +4 -0
- QuickGraphLib-0.1.0a0/quickgraphlib_helpers/consts.py +6 -0
- QuickGraphLib-0.1.0a0/quickgraphlib_helpers/contours.py +79 -0
- QuickGraphLib-0.1.0a0/quickgraphlib_helpers/export.py +167 -0
- QuickGraphLib-0.1.0a0/quickgraphlib_helpers/py.typed +0 -0
- QuickGraphLib-0.1.0a0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include QuickGraphLib *.qml *.js qmldir
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: QuickGraphLib
|
|
3
|
+
Version: 0.1.0a0
|
|
4
|
+
Summary: A scientific graphing library for QtQuick
|
|
5
|
+
Author-email: Matthew Joyce <matthew.joyce@refeyn.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Homepage, https://github.com/refeyn/QuickGraphLib
|
|
28
|
+
Project-URL: Issues, https://github.com/refeyn/QuickGraphLib/issues
|
|
29
|
+
Project-URL: Source, https://github.com/refeyn/QuickGraphLib
|
|
30
|
+
Classifier: Development Status :: 3 - Alpha
|
|
31
|
+
Classifier: Environment :: X11 Applications :: Qt
|
|
32
|
+
Classifier: Intended Audience :: Science/Research
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Operating System :: OS Independent
|
|
35
|
+
Classifier: Programming Language :: Python
|
|
36
|
+
Classifier: Topic :: Multimedia :: Graphics :: Presentation
|
|
37
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
38
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
39
|
+
Classifier: Typing :: Typed
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
License-File: LICENCE
|
|
42
|
+
Requires-Dist: PySide6
|
|
43
|
+
Requires-Dist: contourpy
|
|
44
|
+
Provides-Extra: analyse
|
|
45
|
+
Requires-Dist: black; extra == "analyse"
|
|
46
|
+
Requires-Dist: pylint; extra == "analyse"
|
|
47
|
+
Requires-Dist: mypy; extra == "analyse"
|
|
48
|
+
Requires-Dist: pre-commit; extra == "analyse"
|
|
49
|
+
Requires-Dist: lxml; extra == "analyse"
|
|
50
|
+
Requires-Dist: pytest; extra == "analyse"
|
|
51
|
+
Requires-Dist: pytest-cov; extra == "analyse"
|
|
52
|
+
|
|
53
|
+
# QuickGraphLib
|
|
54
|
+
|
|
55
|
+
A scientific graphing library for [QtQuick](https://doc.qt.io/qt-6/qtquick-index.html) using Qt6.
|
|
56
|
+
|
|
57
|
+
Key advantages:
|
|
58
|
+
|
|
59
|
+
- Written in pure QML (with some optional Python helpers), so it can be used in both C++ and Python projects
|
|
60
|
+
- QtQuick's hardware-based rendering makes this library render very fast
|
|
61
|
+
- Support for line graphs, histograms, contour plots and more
|
|
62
|
+
- Interactivity supported natively though declarative bindings and QtQuick
|
|
63
|
+
- Support for PNG and SVG export
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
The example gallery can be run using (provided the Python environment has [PySide6](https://pypi.org/project/PySide6/) and [contourpy](https://pypi.org/project/contourpy/) installed):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
python examples\gallery.py
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
<p align="center"><img src="./examples/ExampleGallery.png" width="80%"></p>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
|
|
6
|
+
/*!
|
|
7
|
+
\qmltype AntialiasingContainer
|
|
8
|
+
\inqmlmodule QuickGraphLib
|
|
9
|
+
\inherits QtQuick::Item
|
|
10
|
+
\brief Enables antialiasing for it's contents.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
Item {
|
|
14
|
+
implicitHeight: 100
|
|
15
|
+
implicitWidth: 100
|
|
16
|
+
layer.enabled: true // Improves rendering of fractional DPIs
|
|
17
|
+
layer.samples: 2
|
|
18
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
pragma ComponentBehavior: Bound
|
|
5
|
+
import QtQuick
|
|
6
|
+
import QtQuick.Shapes as QQS
|
|
7
|
+
|
|
8
|
+
/*!
|
|
9
|
+
\qmltype Axis
|
|
10
|
+
\inqmlmodule QuickGraphLib
|
|
11
|
+
\inherits QtQuick::Item
|
|
12
|
+
\brief Displays an Axis.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
Item {
|
|
16
|
+
id: root
|
|
17
|
+
|
|
18
|
+
enum Direction {
|
|
19
|
+
Left,
|
|
20
|
+
Right,
|
|
21
|
+
Top,
|
|
22
|
+
Bottom
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
property list<point> _path: _calculateTickPath(ticks, direction, width, height, dataTransform)
|
|
26
|
+
property list<int> _tickPositions
|
|
27
|
+
/*!
|
|
28
|
+
TODO
|
|
29
|
+
\sa {GraphArea::dataTransform}
|
|
30
|
+
*/
|
|
31
|
+
required property matrix4x4 dataTransform
|
|
32
|
+
/*! TODO */
|
|
33
|
+
property int decimalPoints: 2
|
|
34
|
+
/*! TODO
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
\value Axis.Direction.Left Axis to the left of the GraphArea
|
|
38
|
+
\value Axis.Direction.Right Axis to the right of the GraphArea
|
|
39
|
+
\value Axis.Direction.Top Axis above of the GraphArea
|
|
40
|
+
\value Axis.Direction.Bottom Axis below of the GraphArea
|
|
41
|
+
*/
|
|
42
|
+
required property int direction
|
|
43
|
+
/*! TODO */
|
|
44
|
+
property alias label: labelText.text
|
|
45
|
+
/*! TODO */
|
|
46
|
+
property bool showTickLabels: true
|
|
47
|
+
/*! TODO */
|
|
48
|
+
property double spacing: 4
|
|
49
|
+
/*! TODO */
|
|
50
|
+
property double tickLength: 10
|
|
51
|
+
/*! TODO */
|
|
52
|
+
required property list<double> ticks
|
|
53
|
+
|
|
54
|
+
function _calculateTickPath(ticks, direction: int, width: double, height: double, dataTransform) {
|
|
55
|
+
const longAxis = direction == Axis.Direction.Top || direction == Axis.Direction.Bottom ? width : height;
|
|
56
|
+
let transformedTicks = ticks.map(t => dataTransform.map(Qt.point(t, t))[direction == Axis.Direction.Top || direction == Axis.Direction.Bottom ? "x" : "y"]);
|
|
57
|
+
|
|
58
|
+
// Calculate everything as if we were a bottom axis
|
|
59
|
+
let points = [Qt.point(0, 0)], tickPositions = [];
|
|
60
|
+
transformedTicks.forEach(t => {
|
|
61
|
+
if (t >= -0.5 && t <= longAxis + 0.5) {
|
|
62
|
+
points.push(Qt.point(t, 0));
|
|
63
|
+
points.push(Qt.point(t, root.tickLength));
|
|
64
|
+
points.push(Qt.point(t, 0));
|
|
65
|
+
tickPositions.push(points.length - 2);
|
|
66
|
+
} else {
|
|
67
|
+
tickPositions.push(-1);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
points.push(Qt.point(longAxis, 0));
|
|
71
|
+
_tickPositions = tickPositions;
|
|
72
|
+
|
|
73
|
+
// Transform into the correct positions
|
|
74
|
+
switch (root.direction) {
|
|
75
|
+
case Axis.Direction.Left:
|
|
76
|
+
return points.map(p => Qt.point(width - p.y, p.x));
|
|
77
|
+
case Axis.Direction.Right:
|
|
78
|
+
return points.map(p => Qt.point(p.y, p.x));
|
|
79
|
+
case Axis.Direction.Top:
|
|
80
|
+
return points.map(p => Qt.point(p.x, height - p.y));
|
|
81
|
+
case Axis.Direction.Bottom:
|
|
82
|
+
return points;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
implicitHeight: {
|
|
87
|
+
switch (root.direction) {
|
|
88
|
+
case Axis.Direction.Left:
|
|
89
|
+
case Axis.Direction.Right:
|
|
90
|
+
return 100;
|
|
91
|
+
case Axis.Direction.Top:
|
|
92
|
+
case Axis.Direction.Bottom:
|
|
93
|
+
let height = 0;
|
|
94
|
+
if (ticks.length > 0) {
|
|
95
|
+
height += root.tickLength + Math.max(0, ...[...Array(tickLabels.count).keys()].map(i => tickLabels.itemAt(i)?.height));
|
|
96
|
+
}
|
|
97
|
+
if (label != "") {
|
|
98
|
+
height += labelText.height + root.spacing;
|
|
99
|
+
}
|
|
100
|
+
return height;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
implicitWidth: {
|
|
104
|
+
switch (root.direction) {
|
|
105
|
+
case Axis.Direction.Left:
|
|
106
|
+
case Axis.Direction.Right:
|
|
107
|
+
let width = 0;
|
|
108
|
+
if (ticks.length > 0) {
|
|
109
|
+
width += root.tickLength + Math.max(0, ...[...Array(tickLabels.count).keys()].map(i => tickLabels.itemAt(i)?.width));
|
|
110
|
+
}
|
|
111
|
+
if (label != "") {
|
|
112
|
+
width += labelText.height + root.spacing;
|
|
113
|
+
}
|
|
114
|
+
return width;
|
|
115
|
+
case Axis.Direction.Top:
|
|
116
|
+
case Axis.Direction.Bottom:
|
|
117
|
+
return 100;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
z: 1
|
|
121
|
+
|
|
122
|
+
QQS.Shape {
|
|
123
|
+
id: shape
|
|
124
|
+
|
|
125
|
+
anchors.fill: parent
|
|
126
|
+
|
|
127
|
+
QQS.ShapePath {
|
|
128
|
+
id: myPath
|
|
129
|
+
|
|
130
|
+
startX: root._path[0].x
|
|
131
|
+
startY: root._path[0].y
|
|
132
|
+
strokeColor: "black"
|
|
133
|
+
strokeWidth: 1
|
|
134
|
+
|
|
135
|
+
PathPolyline {
|
|
136
|
+
path: root._path
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
Repeater {
|
|
141
|
+
id: tickLabels
|
|
142
|
+
|
|
143
|
+
model: root.showTickLabels ? root.ticks : []
|
|
144
|
+
|
|
145
|
+
Text {
|
|
146
|
+
required property int index
|
|
147
|
+
required property double modelData
|
|
148
|
+
|
|
149
|
+
leftPadding: 2
|
|
150
|
+
rightPadding: 2
|
|
151
|
+
text: Number(modelData).toFixed(root.decimalPoints)
|
|
152
|
+
visible: root._tickPositions[index] >= 0
|
|
153
|
+
x: {
|
|
154
|
+
let baseX = root._path[root._tickPositions[index]]?.x ?? 0;
|
|
155
|
+
switch (root.direction) {
|
|
156
|
+
case Axis.Direction.Left:
|
|
157
|
+
return baseX - width;
|
|
158
|
+
case Axis.Direction.Right:
|
|
159
|
+
return baseX;
|
|
160
|
+
case Axis.Direction.Top:
|
|
161
|
+
return baseX - width / 2;
|
|
162
|
+
case Axis.Direction.Bottom:
|
|
163
|
+
return baseX - width / 2;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
y: {
|
|
167
|
+
let baseY = root._path[root._tickPositions[index]]?.y ?? 0;
|
|
168
|
+
switch (root.direction) {
|
|
169
|
+
case Axis.Direction.Left:
|
|
170
|
+
return baseY - height / 2;
|
|
171
|
+
case Axis.Direction.Right:
|
|
172
|
+
return baseY - height / 2;
|
|
173
|
+
case Axis.Direction.Top:
|
|
174
|
+
return baseY - height;
|
|
175
|
+
case Axis.Direction.Bottom:
|
|
176
|
+
return baseY;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
Text {
|
|
182
|
+
id: labelText
|
|
183
|
+
|
|
184
|
+
x: {
|
|
185
|
+
switch (root.direction) {
|
|
186
|
+
case Axis.Direction.Left:
|
|
187
|
+
return height / 2;
|
|
188
|
+
case Axis.Direction.Right:
|
|
189
|
+
return root.width - height / 2;
|
|
190
|
+
case Axis.Direction.Top:
|
|
191
|
+
case Axis.Direction.Bottom:
|
|
192
|
+
return root.width / 2;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
y: {
|
|
196
|
+
switch (root.direction) {
|
|
197
|
+
case Axis.Direction.Left:
|
|
198
|
+
case Axis.Direction.Right:
|
|
199
|
+
return root.height / 2;
|
|
200
|
+
case Axis.Direction.Top:
|
|
201
|
+
return height / 2;
|
|
202
|
+
case Axis.Direction.Bottom:
|
|
203
|
+
return root.height - height / 2;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
transform: [
|
|
208
|
+
Translate {
|
|
209
|
+
x: -labelText.width / 2
|
|
210
|
+
y: -labelText.height / 2
|
|
211
|
+
},
|
|
212
|
+
Rotation {
|
|
213
|
+
angle: {
|
|
214
|
+
switch (root.direction) {
|
|
215
|
+
case Axis.Direction.Left:
|
|
216
|
+
return -90;
|
|
217
|
+
case Axis.Direction.Right:
|
|
218
|
+
return 90;
|
|
219
|
+
case Axis.Direction.Top:
|
|
220
|
+
case Axis.Direction.Bottom:
|
|
221
|
+
return 0;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
import QtQuick.Shapes as QQS
|
|
6
|
+
|
|
7
|
+
/*!
|
|
8
|
+
\qmltype Histogram
|
|
9
|
+
\inqmlmodule QuickGraphLib
|
|
10
|
+
\inherits QtQuick::Shapes::Shape
|
|
11
|
+
\brief An area that graphs can be added to.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
QQS.Shape {
|
|
15
|
+
id: root
|
|
16
|
+
|
|
17
|
+
/*!
|
|
18
|
+
Transform from data coordinates to pixel coordinates inside the GraphArea with the viewTransform applied
|
|
19
|
+
*/
|
|
20
|
+
readonly property matrix4x4 dataTransform: viewTransform.times(rawDataTransform)
|
|
21
|
+
/*!
|
|
22
|
+
The view rect the view is actually showing based on viewTransform
|
|
23
|
+
*/
|
|
24
|
+
readonly property rect effectiveViewRect: {
|
|
25
|
+
let mat = rawDataTransform.inverted().times(viewTransform.inverted().times(rawDataTransform));
|
|
26
|
+
return mat.mapRect(viewRect);
|
|
27
|
+
}
|
|
28
|
+
/*!
|
|
29
|
+
Transform from data coordinates to pixel coordinates inside the GraphArea
|
|
30
|
+
*/
|
|
31
|
+
readonly property matrix4x4 rawDataTransform: {
|
|
32
|
+
let mat = Qt.matrix4x4();
|
|
33
|
+
// Flip coordinate system so that Y points upwards
|
|
34
|
+
mat.translate(Qt.vector3d(0, root.height, 0));
|
|
35
|
+
mat.scale(root.width / viewRect.width, -root.height / viewRect.height, 1);
|
|
36
|
+
mat.translate(Qt.vector3d(-viewRect.x, -viewRect.y, 0));
|
|
37
|
+
return mat;
|
|
38
|
+
}
|
|
39
|
+
/*! TODO */
|
|
40
|
+
required property rect viewRect
|
|
41
|
+
/*! TODO */
|
|
42
|
+
property matrix4x4 viewTransform
|
|
43
|
+
|
|
44
|
+
function baseTransformFromRect(r: rect): matrix4x4 {
|
|
45
|
+
let mat = Qt.matrix4x4();
|
|
46
|
+
mat.scale(viewRect.width / r.width, viewRect.height / r.height, 1);
|
|
47
|
+
mat.translate(Qt.vector3d((viewRect.x - r.x) / viewRect.width, (r.y + r.height - viewRect.y - viewRect.height) / viewRect.height, 0));
|
|
48
|
+
return mat;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
clip: true
|
|
52
|
+
implicitHeight: 100
|
|
53
|
+
implicitWidth: 100
|
|
54
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
|
|
6
|
+
/*!
|
|
7
|
+
\qmltype AxHLine
|
|
8
|
+
\inqmlmodule QuickGraphLib.GraphItems
|
|
9
|
+
\inherits QtQuick::Rectangle
|
|
10
|
+
\brief Displays a horizontal line.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
Rectangle {
|
|
14
|
+
id: root
|
|
15
|
+
|
|
16
|
+
/*! TODO */
|
|
17
|
+
required property matrix4x4 dataTransform
|
|
18
|
+
/*! TODO */
|
|
19
|
+
required property double position
|
|
20
|
+
|
|
21
|
+
height: 2
|
|
22
|
+
width: parent.width + border.width * 4
|
|
23
|
+
x: -border.width * 2
|
|
24
|
+
y: root.dataTransform.map(Qt.point(0, position)).y - height / 2
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
|
|
6
|
+
/*!
|
|
7
|
+
\qmltype AxHSpan
|
|
8
|
+
\inqmlmodule QuickGraphLib.GraphItems
|
|
9
|
+
\inherits QtQuick::Rectangle
|
|
10
|
+
\brief Displays a horizontal span.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
Rectangle {
|
|
14
|
+
id: root
|
|
15
|
+
|
|
16
|
+
/*! TODO */
|
|
17
|
+
required property matrix4x4 dataTransform
|
|
18
|
+
/*! TODO */
|
|
19
|
+
required property double yMax
|
|
20
|
+
/*! TODO */
|
|
21
|
+
required property double yMin
|
|
22
|
+
|
|
23
|
+
border.width: 0
|
|
24
|
+
height: root.dataTransform.map(Qt.point(0, yMin)).y - root.dataTransform.map(Qt.point(0, yMax)).y
|
|
25
|
+
width: parent.width + border.width * 4
|
|
26
|
+
x: -border.width * 2
|
|
27
|
+
y: root.dataTransform.map(Qt.point(0, yMax)).y
|
|
28
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
|
|
6
|
+
/*!
|
|
7
|
+
\qmltype AxVLine
|
|
8
|
+
\inqmlmodule QuickGraphLib.GraphItems
|
|
9
|
+
\inherits QtQuick::Rectangle
|
|
10
|
+
\brief Displays an vertical line.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
Rectangle {
|
|
14
|
+
id: root
|
|
15
|
+
|
|
16
|
+
/*! TODO */
|
|
17
|
+
required property matrix4x4 dataTransform
|
|
18
|
+
/*! TODO */
|
|
19
|
+
required property double position
|
|
20
|
+
|
|
21
|
+
height: parent.height + border.width * 4
|
|
22
|
+
width: 2
|
|
23
|
+
x: root.dataTransform.map(Qt.point(position, 0)).x - width / 2
|
|
24
|
+
y: -border.width * 2
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
|
|
6
|
+
/*!
|
|
7
|
+
\qmltype AxVSpan
|
|
8
|
+
\inqmlmodule QuickGraphLib.GraphItems
|
|
9
|
+
\inherits QtQuick::Rectangle
|
|
10
|
+
\brief Displays an vertical span.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
Rectangle {
|
|
14
|
+
id: root
|
|
15
|
+
|
|
16
|
+
/*! TODO */
|
|
17
|
+
required property matrix4x4 dataTransform
|
|
18
|
+
/*! TODO */
|
|
19
|
+
required property double xMax
|
|
20
|
+
/*! TODO */
|
|
21
|
+
required property double xMin
|
|
22
|
+
|
|
23
|
+
border.width: 0
|
|
24
|
+
height: parent.height + border.width * 4
|
|
25
|
+
width: root.dataTransform.map(Qt.point(xMax, 0)).x - root.dataTransform.map(Qt.point(xMin, 0)).x
|
|
26
|
+
x: root.dataTransform.map(Qt.point(xMin, 0)).x
|
|
27
|
+
y: -border.width * 2
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
|
|
6
|
+
/*!
|
|
7
|
+
\qmltype BasicLegend
|
|
8
|
+
\inqmlmodule QuickGraphLib.GraphItems
|
|
9
|
+
\inherits QtQuick::Rectangle
|
|
10
|
+
\brief Displays a simple legend.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
Rectangle {
|
|
14
|
+
/*! TODO */
|
|
15
|
+
default property alias contentChildren: legend.children
|
|
16
|
+
/*! TODO */
|
|
17
|
+
property alias verticalSpacing: legend.spacing
|
|
18
|
+
|
|
19
|
+
border.color: "black"
|
|
20
|
+
color: "#aaffffff"
|
|
21
|
+
height: legend.height + 10
|
|
22
|
+
width: legend.width + 10
|
|
23
|
+
|
|
24
|
+
Column {
|
|
25
|
+
id: legend
|
|
26
|
+
|
|
27
|
+
anchors.centerIn: parent
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
|
|
6
|
+
/*!
|
|
7
|
+
\qmltype BasicLegendItem
|
|
8
|
+
\inqmlmodule QuickGraphLib.GraphItems
|
|
9
|
+
\inherits QtQuick::Row
|
|
10
|
+
\brief An single entry in a simple legend.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
Row {
|
|
14
|
+
id: root
|
|
15
|
+
|
|
16
|
+
/*! TODO */
|
|
17
|
+
property color fillColor: "transparent"
|
|
18
|
+
/*! TODO */
|
|
19
|
+
property Gradient fillGradient: null
|
|
20
|
+
|
|
21
|
+
/*! TODO */
|
|
22
|
+
property color strokeColor: "black"
|
|
23
|
+
/*! TODO */
|
|
24
|
+
property real strokeWidth: 1
|
|
25
|
+
/*! TODO */
|
|
26
|
+
property alias text: label.text
|
|
27
|
+
|
|
28
|
+
spacing: 2
|
|
29
|
+
|
|
30
|
+
Item {
|
|
31
|
+
id: clipper
|
|
32
|
+
|
|
33
|
+
anchors.verticalCenter: parent.verticalCenter
|
|
34
|
+
clip: true
|
|
35
|
+
height: root.height - 2
|
|
36
|
+
width: root.height - 2
|
|
37
|
+
|
|
38
|
+
Rectangle {
|
|
39
|
+
border.color: root.strokeColor
|
|
40
|
+
border.width: root.strokeWidth
|
|
41
|
+
color: root.fillColor
|
|
42
|
+
gradient: root.fillGradient
|
|
43
|
+
height: clipper.height / 2 + root.strokeWidth * 2
|
|
44
|
+
width: clipper.width + root.strokeWidth * 4
|
|
45
|
+
x: -root.strokeWidth * 2
|
|
46
|
+
y: clipper.height / 2
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
Text {
|
|
50
|
+
id: label
|
|
51
|
+
|
|
52
|
+
anchors.verticalCenter: parent.verticalCenter
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
import QtQuick.Shapes as QQS
|
|
6
|
+
|
|
7
|
+
/*!
|
|
8
|
+
\qmltype Contours
|
|
9
|
+
\inqmlmodule QuickGraphLib.GraphItems
|
|
10
|
+
\inherits QtQuick::Shapes::ShapePath
|
|
11
|
+
\brief Draw a contour line or fill.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
QQS.ShapePath {
|
|
15
|
+
id: root
|
|
16
|
+
|
|
17
|
+
/*!
|
|
18
|
+
TODO
|
|
19
|
+
*/
|
|
20
|
+
required property matrix4x4 dataTransform
|
|
21
|
+
/*!
|
|
22
|
+
TODO
|
|
23
|
+
*/
|
|
24
|
+
required property var paths
|
|
25
|
+
|
|
26
|
+
capStyle: QQS.ShapePath.RoundCap
|
|
27
|
+
fillColor: "transparent"
|
|
28
|
+
joinStyle: QQS.ShapePath.RoundJoin
|
|
29
|
+
|
|
30
|
+
PathMultiline {
|
|
31
|
+
paths: root.paths.map(ps => ps.map(p => root.dataTransform.map(p)))
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2024 Matthew Joyce and other QuickGraphLib contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import QtQuick
|
|
5
|
+
|
|
6
|
+
/*!
|
|
7
|
+
\qmltype GraphItemDragHandler
|
|
8
|
+
\inqmlmodule QuickGraphLib.GraphItems
|
|
9
|
+
\inherits QtQuick::MouseArea
|
|
10
|
+
\brief Assists converting mouse drags into data positions.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
MouseArea {
|
|
14
|
+
id: root
|
|
15
|
+
|
|
16
|
+
property rect _startDragPos
|
|
17
|
+
|
|
18
|
+
/*! TODO */
|
|
19
|
+
required property matrix4x4 dataTransform
|
|
20
|
+
/*! TODO */
|
|
21
|
+
property bool dragging
|
|
22
|
+
|
|
23
|
+
signal moved(rect position)
|
|
24
|
+
|
|
25
|
+
hoverEnabled: true
|
|
26
|
+
|
|
27
|
+
onPositionChanged: event => {
|
|
28
|
+
if (dragging) {
|
|
29
|
+
moved(dataTransform.inverted().mapRect(Qt.rect(parent.x + event.x - _startDragPos.x, parent.y + event.y - _startDragPos.y, _startDragPos.width, _startDragPos.height)));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
onPressed: event => {
|
|
33
|
+
_startDragPos = Qt.rect(mouseX, mouseY, width, height);
|
|
34
|
+
dragging = true;
|
|
35
|
+
}
|
|
36
|
+
onReleased: event => {
|
|
37
|
+
dragging = false;
|
|
38
|
+
}
|
|
39
|
+
}
|