QuickGraphLib 0.1.0a2__tar.gz → 0.1.0a4__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.
Files changed (113) hide show
  1. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/CMakeLists.txt +6 -0
  2. {quickgraphlib-0.1.0a2/QuickGraphLib.egg-info → quickgraphlib-0.1.0a4}/PKG-INFO +1 -1
  3. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/Axis.qml +10 -6
  4. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/PreFabs/XYAxes.qml +1 -0
  5. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/ShapeRepeater.qml +1 -1
  6. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/helpers/AxisHelper.cpp +28 -11
  7. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/helpers/AxisHelper.hpp +6 -2
  8. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/helpers/Helpers.cpp +59 -30
  9. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/helpers/Helpers.hpp +2 -0
  10. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4/QuickGraphLib.egg-info}/PKG-INFO +1 -1
  11. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib.egg-info/SOURCES.txt +1 -0
  12. quickgraphlib-0.1.0a4/examples/SpansAndLines.png +0 -0
  13. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/SpansAndLines.qml +4 -0
  14. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/pyproject.toml +27 -0
  15. quickgraphlib-0.1.0a4/setup.cfg +7 -0
  16. quickgraphlib-0.1.0a2/examples/SpansAndLines.png +0 -0
  17. quickgraphlib-0.1.0a2/setup.cfg +0 -4
  18. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/LICENCE +0 -0
  19. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/MANIFEST.in +0 -0
  20. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/AntialiasingContainer.qml +0 -0
  21. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/CMakeLists.txt +0 -0
  22. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphArea.qml +0 -0
  23. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/AxHLine.qml +0 -0
  24. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/AxHSpan.qml +0 -0
  25. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/AxVLine.qml +0 -0
  26. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/AxVSpan.qml +0 -0
  27. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/BasicLegend.qml +0 -0
  28. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/BasicLegendItem.qml +0 -0
  29. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/CMakeLists.txt +0 -0
  30. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/Contour.qml +0 -0
  31. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/GraphItemDragHandler.qml +0 -0
  32. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/Grid.qml +0 -0
  33. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/Histogram.qml +0 -0
  34. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/Line.qml +0 -0
  35. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/Marker.qml +0 -0
  36. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/helpers/GridHelper.cpp +0 -0
  37. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/helpers/GridHelper.hpp +0 -0
  38. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/helpers/HistogramHelper.cpp +0 -0
  39. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/GraphItems/helpers/HistogramHelper.hpp +0 -0
  40. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/PreFabs/CMakeLists.txt +0 -0
  41. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/ScalingContainer.qml +0 -0
  42. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/TickLabel.qml +0 -0
  43. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/ZoomPanHandler.qml +0 -0
  44. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/doc/AxesGridLayout.svg +0 -0
  45. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/doc/export.qdoc +0 -0
  46. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/doc/graphitems.qdoc +0 -0
  47. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/doc/graphstructure.qdoc +0 -0
  48. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/doc/index.qdoc +0 -0
  49. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/doc/interaction.qdoc +0 -0
  50. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/doc/module.qdoc +0 -0
  51. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/doc/prefabs.qdoc +0 -0
  52. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/doc/python_helpers.qdoc +0 -0
  53. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib/helpers/Foreign.hpp +0 -0
  54. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib.egg-info/dependency_links.txt +0 -0
  55. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib.egg-info/requires.txt +0 -0
  56. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/QuickGraphLib.egg-info/top_level.txt +0 -0
  57. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/README.md +0 -0
  58. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/AllTheAxes.png +0 -0
  59. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/AllTheAxes.qdoc +0 -0
  60. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/AllTheAxes.qml +0 -0
  61. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/BasicHistogram.png +0 -0
  62. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/BasicHistogram.qdoc +0 -0
  63. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/BasicHistogram.qml +0 -0
  64. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/BasicSinGraph.png +0 -0
  65. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/BasicSinGraph.qdoc +0 -0
  66. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/BasicSinGraph.qml +0 -0
  67. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/BasicSinGraphNoPrefabs.png +0 -0
  68. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/BasicSinGraphNoPrefabs.qdoc +0 -0
  69. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/BasicSinGraphNoPrefabs.qml +0 -0
  70. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Complex.png +0 -0
  71. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Complex.qdoc +0 -0
  72. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Complex.qml +0 -0
  73. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Contours.png +0 -0
  74. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Contours.qdoc +0 -0
  75. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Contours.qml +0 -0
  76. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/DarkSinGraph.png +0 -0
  77. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/DarkSinGraph.qdoc +0 -0
  78. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/DarkSinGraph.qml +0 -0
  79. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/DraggableRegion.png +0 -0
  80. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/DraggableRegion.qdoc +0 -0
  81. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/DraggableRegion.qml +0 -0
  82. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ExampleGallery.png +0 -0
  83. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ExampleGallery.qml +0 -0
  84. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/InvertedAxes.png +0 -0
  85. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/InvertedAxes.qdoc +0 -0
  86. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/InvertedAxes.qml +0 -0
  87. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ReadoutLine.png +0 -0
  88. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ReadoutLine.qdoc +0 -0
  89. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ReadoutLine.qml +0 -0
  90. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ScalingGraph.png +0 -0
  91. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ScalingGraph.qdoc +0 -0
  92. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ScalingGraph.qml +0 -0
  93. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Scatter.png +0 -0
  94. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Scatter.qdoc +0 -0
  95. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Scatter.qml +0 -0
  96. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/SpansAndLines.qdoc +0 -0
  97. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Subgraphs.png +0 -0
  98. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Subgraphs.qdoc +0 -0
  99. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/Subgraphs.qml +0 -0
  100. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/TwinX.png +0 -0
  101. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/TwinX.qdoc +0 -0
  102. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/TwinX.qml +0 -0
  103. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ZoomableAsImage.png +0 -0
  104. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ZoomableAsImage.qdoc +0 -0
  105. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ZoomableAsImage.qml +0 -0
  106. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ZoomableAxes.png +0 -0
  107. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ZoomableAxes.qdoc +0 -0
  108. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/examples/ZoomableAxes.qml +0 -0
  109. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/quickgraphlib_helpers/__init__.py +0 -0
  110. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/quickgraphlib_helpers/consts.py +0 -0
  111. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/quickgraphlib_helpers/contours.py +0 -0
  112. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/quickgraphlib_helpers/py.typed +0 -0
  113. {quickgraphlib-0.1.0a2 → quickgraphlib-0.1.0a4}/setup.py +0 -0
@@ -9,6 +9,12 @@ project(qmlmodule VERSION 1.0.0 LANGUAGES CXX)
9
9
  set(CMAKE_CXX_STANDARD 17)
10
10
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
11
11
 
12
+ if(MSVC)
13
+ add_compile_options(/W4)
14
+ else()
15
+ add_compile_options(-Wextra -Wpedantic -Werror -fno-visibility-inlines-hidden)
16
+ endif()
17
+
12
18
  if(NOT INSTALL_SUBPATH)
13
19
  set(INSTALL_SUBPATH ${CMAKE_INSTALL_LIBDIR}/qml CACHE STRING "Install subpath (defaults to lib/qml)")
14
20
  endif()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: QuickGraphLib
3
- Version: 0.1.0a2
3
+ Version: 0.1.0a4
4
4
  Summary: A scientific graphing library for QtQuick
5
5
  Author-email: Matthew Joyce <matthew.joyce@refeyn.com>
6
6
  License: MIT License
@@ -78,7 +78,8 @@ Item {
78
78
  case Axis.Direction.Bottom:
79
79
  let height = 0;
80
80
  if (ticks.length > 0) {
81
- height += root.tickLength + Math.max(0, ...[...Array(tickLabels.count).keys()].map(i => tickLabels.itemAt(i)?.height));
81
+ // Can't use childrenRect due to the binding loop it causes
82
+ height += root.tickLength + Math.max(0, ...tickLabelsContainer.children.map(x => x.height));
82
83
  }
83
84
  if (label !== "") {
84
85
  height += labelText.height + root.spacing;
@@ -92,7 +93,8 @@ Item {
92
93
  case Axis.Direction.Right:
93
94
  let width = 0;
94
95
  if (ticks.length > 0) {
95
- width += root.tickLength + Math.max(0, ...[...Array(tickLabels.count).keys()].map(i => tickLabels.itemAt(i)?.width));
96
+ // Can't use childrenRect due to the binding loop it causes
97
+ width += root.tickLength + Math.max(0, ...tickLabelsContainer.children.map(x => x.width));
96
98
  }
97
99
  if (label !== "") {
98
100
  width += labelText.height + root.spacing;
@@ -128,11 +130,13 @@ Item {
128
130
  }
129
131
  }
130
132
  }
131
- Repeater {
132
- id: tickLabels
133
+ Item {
134
+ id: tickLabelsContainer
133
135
 
134
- delegate: root.tickDelegate
135
- model: root.showTickLabels ? helper.tickModel : null
136
+ Repeater {
137
+ delegate: root.tickDelegate
138
+ model: root.showTickLabels ? helper.tickModel : null
139
+ }
136
140
  }
137
141
  Text {
138
142
  id: labelText
@@ -49,6 +49,7 @@ QuickGraphLib.AntialiasingContainer {
49
49
  id: background
50
50
 
51
51
  anchors.fill: parent
52
+ border.width: 0
52
53
  }
53
54
  QQL.GridLayout {
54
55
  id: axes
@@ -17,6 +17,6 @@ QQM.Instantiator {
17
17
  onObjectAdded: (i, obj) => graphArea.data.push(obj)
18
18
  onObjectRemoved: (i, obj) => {
19
19
  // Remove everything into a JS array and then add back in all items except for `obj`
20
- graphArea.data.splice(0, graphArea.data.length).filter(o => o !== obj).map(graphArea.data.push);
20
+ graphArea.data.splice(0, graphArea.data.length).filter(o => o !== obj).map(x => graphArea.data.push(x));
21
21
  }
22
22
  }
@@ -7,6 +7,7 @@ enum Direction { Left, Right, Top, Bottom };
7
7
 
8
8
  AxisHelper::AxisHelper(QObject *parent) : QObject{parent} {
9
9
  _tickModel = new AxisTickModel(this);
10
+ connect(this, &AxisHelper::pathChanged, _tickModel, &AxisTickModel::_updateToNewTicks);
10
11
 
11
12
  pathProp.setBinding([&]() -> QPolygonF {
12
13
  auto direction = directionProp.value();
@@ -16,7 +17,8 @@ AxisHelper::AxisHelper(QObject *parent) : QObject{parent} {
16
17
  auto dataTransform = dataTransformProp.value();
17
18
  auto tickLength = tickLengthProp.value();
18
19
 
19
- auto longAxis = direction == Top || direction == Bottom ? width : height;
20
+ auto isVertical = direction == Top || direction == Bottom;
21
+ auto longAxis = isVertical ? width : height;
20
22
 
21
23
  // Calculate everything as if we were a bottom axis
22
24
  auto points = QList{QPointF{0, 0}};
@@ -24,8 +26,7 @@ AxisHelper::AxisHelper(QObject *parent) : QObject{parent} {
24
26
  QList<int> tickPositions;
25
27
  tickPositions.reserve(ticks.size());
26
28
  for (auto tick : ticks) {
27
- auto t = direction == Top || direction == Bottom ? dataTransform.map(QPointF{tick, 0}).x()
28
- : dataTransform.map(QPointF{0, tick}).y();
29
+ auto t = isVertical ? dataTransform.map(QPointF{tick, 0}).x() : dataTransform.map(QPointF{0, tick}).y();
29
30
  if (t >= -0.5 && t <= longAxis + 0.5) {
30
31
  points.emplaceBack(t, 0);
31
32
  points.emplaceBack(t, tickLength);
@@ -76,7 +77,7 @@ AxisHelper::AxisHelper(QObject *parent) : QObject{parent} {
76
77
  }
77
78
  ++tickIndex;
78
79
  }
79
- _tickModel->_setTicks(std::move(tickDatas));
80
+ _tickModel->_setNewTicks(tickDatas);
80
81
 
81
82
  return points;
82
83
  });
@@ -109,14 +110,30 @@ QVariant AxisTickModel::data(const QModelIndex &index, int role) const {
109
110
 
110
111
  QHash<int, QByteArray> AxisTickModel::roleNames() const {
111
112
  return {
112
- {Qt::DisplayRole, {"display"}},
113
- {AxisTickModel::PositionRole, {"position"}},
114
- {AxisTickModel::ValueRole, {"value"}}
113
+ {Qt::DisplayRole, "display"},
114
+ {AxisTickModel::PositionRole, "position"},
115
+ {AxisTickModel::ValueRole, "value"},
115
116
  };
116
117
  }
117
118
 
118
- void AxisTickModel::_setTicks(QList<AxisTickModel::TickData> &&ticks) {
119
- beginResetModel();
120
- _ticks = std::move(ticks);
121
- endResetModel();
119
+ void AxisTickModel::_setNewTicks(const QList<AxisTickModel::TickData> &ticks) { _newTicks = ticks; }
120
+
121
+ void AxisTickModel::_updateToNewTicks() {
122
+ auto oldCount = _ticks.count();
123
+ if (oldCount < _newTicks.count()) {
124
+ beginInsertRows({}, oldCount, _newTicks.count() - 1);
125
+ }
126
+ else if (oldCount > _newTicks.count()) {
127
+ beginRemoveRows({}, _newTicks.count(), oldCount - 1);
128
+ }
129
+ _ticks = _newTicks;
130
+ if (oldCount < _newTicks.count()) {
131
+ endInsertRows();
132
+ }
133
+ else if (oldCount > _newTicks.count()) {
134
+ endRemoveRows();
135
+ }
136
+ if (_newTicks.count()) {
137
+ emit dataChanged(index(0), index(_newTicks.count() - 1));
138
+ }
122
139
  }
@@ -19,9 +19,13 @@ class AxisTickModel : public QAbstractListModel {
19
19
  qreal value;
20
20
  };
21
21
  QList<TickData> _ticks;
22
- void _setTicks(QList<TickData> &&ticks);
22
+ QList<TickData> _newTicks;
23
+ void _setNewTicks(const QList<TickData> &ticks);
23
24
  friend class AxisHelper;
24
25
 
26
+ private slots:
27
+ void _updateToNewTicks();
28
+
25
29
  public:
26
30
  enum Roles { PositionRole = Qt::UserRole, ValueRole };
27
31
 
@@ -49,7 +53,7 @@ class AxisHelper : public QObject {
49
53
  Q_PROPERTY(AxisTickModel *tickModel READ tickModel CONSTANT)
50
54
 
51
55
  QList<int> _cachedTickPositions;
52
- AxisTickModel *_tickModel;
56
+ AxisTickModel *_tickModel = nullptr;
53
57
 
54
58
  public:
55
59
  explicit AxisHelper(QObject *parent = nullptr);
@@ -23,6 +23,9 @@ QList<qreal> Helpers::linspace(qreal min, qreal max, int num) const {
23
23
  Returns a list of \a num values equally spaced from \a min and \a max (inclusive).
24
24
  */
25
25
  auto result = QList<qreal>();
26
+ if (num <= 0) {
27
+ return result;
28
+ }
26
29
  result.reserve(num);
27
30
  for (auto i = 0; i < num; ++i) {
28
31
  result.append(static_cast<qreal>(i) / (num - 1) * (max - min) + min);
@@ -37,7 +40,14 @@ QList<int> Helpers::range(int min, int max, int step /* = 1 */) const {
37
40
  Returns a list of values from \a min to \a max (exclusive) with a gap of \a step between each one.
38
41
  */
39
42
  auto result = QList<int>();
40
- result.reserve((max - min) / step);
43
+ if (step == 0) {
44
+ return result;
45
+ }
46
+ auto num = (max - min) / step;
47
+ if (num <= 0) {
48
+ return result;
49
+ }
50
+ result.reserve(num);
41
51
  for (auto i = min; i < max; i += step) {
42
52
  result.append(i);
43
53
  }
@@ -50,7 +60,7 @@ QList<qreal> Helpers::tickLocator(qreal min, qreal max, int maxNum) const {
50
60
 
51
61
  Returns a list of at most \a maxNum nice tick locations values equally spaced between \a min and \a max.
52
62
  */
53
- if (min == max || !std::isfinite(min) || !std::isfinite(max) || maxNum == 0) {
63
+ if (min == max || !std::isfinite(min) || !std::isfinite(max) || maxNum <= 0) {
54
64
  return {};
55
65
  }
56
66
  if (max < min) {
@@ -104,37 +114,22 @@ QPolygonF Helpers::mapPoints(QVariant points, QMatrix4x4 dataTransform) const {
104
114
  }
105
115
  }
106
116
 
107
- void exportPathElementToPainter(QObject* element, QPainter* painter) {
117
+ void exportPathElementToPainterPath(QObject* element, QPainterPath& path) {
108
118
  if (element->inherits("QQuickPathPolyline")) {
109
- auto brush = painter->brush();
110
- auto pen = painter->pen();
111
- auto path = element->property("path").value<QList<QPointF>>();
112
- painter->setPen(Qt::PenStyle::NoPen);
113
- painter->drawPolygon(path);
114
- painter->setPen(pen);
115
- painter->setBrush(Qt::BrushStyle::NoBrush);
116
- painter->drawPolyline(path);
117
- painter->setBrush(brush);
119
+ path.addPolygon(element->property("path").value<QList<QPointF>>());
118
120
  }
119
121
  else if (element->inherits("QQuickPathMultiline")) {
120
- auto brush = painter->brush();
121
- auto pen = painter->pen();
122
122
  auto paths = element->property("paths").value<QList<QList<QPointF>>>();
123
123
 
124
- QPainterPath fill_path;
125
- for (auto& path : paths) {
126
- fill_path.addPolygon(QPolygonF(path));
127
- fill_path.closeSubpath();
124
+ for (auto& p : paths) {
125
+ path.addPolygon(p);
128
126
  }
129
-
130
- painter->setPen(Qt::PenStyle::NoPen);
131
- painter->drawPath(fill_path);
132
- painter->setPen(pen);
133
- painter->setBrush(Qt::BrushStyle::NoBrush);
134
- for (auto& path : paths) {
135
- painter->drawPolyline(path);
136
- }
137
- painter->setBrush(brush);
127
+ }
128
+ else if (element->inherits("QQuickPathLine")) {
129
+ path.lineTo(element->property("x").toDouble(), element->property("y").toDouble());
130
+ }
131
+ else if (element->inherits("QQuickPathMove")) {
132
+ path.moveTo(element->property("x").toDouble(), element->property("y").toDouble());
138
133
  }
139
134
  }
140
135
 
@@ -172,15 +167,29 @@ void exportShapePathToPainter(QObject* shapePath, QPainter* painter) {
172
167
  painter->save();
173
168
  auto pen = QPen(shapePath->property("strokeColor").value<QColor>());
174
169
  pen.setWidth(shapePath->property("strokeWidth").toDouble());
170
+ auto strokeStyle = static_cast<Qt::PenStyle>(shapePath->property("strokeStyle").toInt());
171
+ pen.setStyle(strokeStyle);
172
+ if (strokeStyle == Qt::PenStyle::DashLine) {
173
+ pen.setDashOffset(shapePath->property("dashOffset").toDouble());
174
+ pen.setDashPattern(shapePath->property("dashPattern").value<QList<qreal>>());
175
+ }
176
+ pen.setCapStyle(static_cast<Qt::PenCapStyle>(shapePath->property("capStyle").toInt()));
177
+ pen.setJoinStyle(static_cast<Qt::PenJoinStyle>(shapePath->property("joinStyle").toInt()));
178
+ pen.setMiterLimit(shapePath->property("miterLimit").toDouble());
175
179
  painter->setPen(pen);
180
+
176
181
  auto brush = brushFromColorAndGradient(shapePath->property("fillGradient"), shapePath->property("fillColor"), {});
177
182
  painter->setBrush(brush);
178
183
 
184
+ QPainterPath path({shapePath->property("startX").toDouble(), shapePath->property("startY").toDouble()});
185
+ path.setFillRule(static_cast<Qt::FillRule>(shapePath->property("fillRule").toInt()));
186
+
179
187
  auto elements = QQmlListReference(shapePath, "pathElements");
180
188
  for (auto elIndex = 0; elIndex < elements.count(); ++elIndex) {
181
189
  auto element = elements.at(elIndex);
182
- exportPathElementToPainter(element, painter);
190
+ exportPathElementToPainterPath(element, path);
183
191
  }
192
+ painter->drawPath(path);
184
193
  painter->restore();
185
194
  }
186
195
 
@@ -301,11 +310,13 @@ bool Helpers::exportToSvg(QQuickItem* item, QUrl path) const {
301
310
  PathPolyline). Other elements will be rendered incorrectly or not at all. If an element is not rendered
302
311
  correctly, create a new issue and we'll see if it can be added.
303
312
 
304
- \sa Helpers::exportToPng
313
+ \sa Helpers::exportToPng, Helpers::exportToPicture
305
314
  */
306
315
 
307
316
  QSvgGenerator device;
308
317
  device.setFileName(path.toLocalFile());
318
+ device.setViewBox(QRectF(0, 0, item->width(), item->height()));
319
+ device.setResolution(96);
309
320
  exportToPaintDevice(item, &device);
310
321
  return true; // TODO How do we detect IO errors?
311
322
  }
@@ -321,7 +332,7 @@ bool Helpers::exportToPng(QQuickItem* item, QUrl path, int dpi /* = 96 * 2 */) c
321
332
  PathPolyline). Other elements will be rendered incorrectly or not at all. If an element is not rendered
322
333
  correctly, create a new issue and we'll see if it can be added.
323
334
 
324
- \sa Helpers::exportToSvg
335
+ \sa Helpers::exportToSvg, Helpers::exportToPicture
325
336
  */
326
337
 
327
338
  auto device = QPixmap(std::ceil(item->width() * dpi / 96), std::ceil(item->height() * dpi / 96));
@@ -330,3 +341,21 @@ bool Helpers::exportToPng(QQuickItem* item, QUrl path, int dpi /* = 96 * 2 */) c
330
341
  exportToPaintDevice(item, &device);
331
342
  return device.save(path.toLocalFile());
332
343
  }
344
+
345
+ QPicture Helpers::exportToPicture(QQuickItem* item) const {
346
+ /*!
347
+ \qmlmethod QPicture Helpers::exportToPicture(Item obj)
348
+
349
+ Exports the graph in \a obj to a QPicture.
350
+
351
+ \note Only some QML elements are supported by this export method (e.g. \l {QtQuick::Rectangle} {Rectangle},
352
+ PathPolyline). Other elements will be rendered incorrectly or not at all. If an element is not rendered
353
+ correctly, create a new issue and we'll see if it can be added.
354
+
355
+ \sa Helpers::exportToPng, Helpers::exportToSvg
356
+ */
357
+
358
+ QPicture device;
359
+ exportToPaintDevice(item, &device);
360
+ return device;
361
+ }
@@ -4,6 +4,7 @@
4
4
  #pragma once
5
5
 
6
6
  #include <QObject>
7
+ #include <QPicture>
7
8
  #include <QQmlEngine>
8
9
  #include <QQuickItem>
9
10
 
@@ -18,4 +19,5 @@ class Helpers : public QObject {
18
19
  Q_INVOKABLE QPolygonF mapPoints(QVariant points, QMatrix4x4 dataTransform) const;
19
20
  Q_INVOKABLE bool exportToSvg(QQuickItem* item, QUrl path) const;
20
21
  Q_INVOKABLE bool exportToPng(QQuickItem* item, QUrl path, int dpi = 96 * 2) const;
22
+ Q_INVOKABLE QPicture exportToPicture(QQuickItem* item) const;
21
23
  };
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: QuickGraphLib
3
- Version: 0.1.0a2
3
+ Version: 0.1.0a4
4
4
  Summary: A scientific graphing library for QtQuick
5
5
  Author-email: Matthew Joyce <matthew.joyce@refeyn.com>
6
6
  License: MIT License
@@ -3,6 +3,7 @@ LICENCE
3
3
  MANIFEST.in
4
4
  README.md
5
5
  pyproject.toml
6
+ setup.cfg
6
7
  setup.py
7
8
  ./CMakeLists.txt
8
9
  ./QuickGraphLib/CMakeLists.txt
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import QtQuick
5
+ import QtQuick.Shapes as QQS
5
6
  import QuickGraphLib.GraphItems as QGLGraphItems
6
7
  import QuickGraphLib.PreFabs as QGLPreFabs
7
8
 
@@ -27,9 +28,12 @@ QGLPreFabs.XYAxes {
27
28
  xMin: 1
28
29
  }
29
30
  QGLGraphItems.AxVLine {
31
+ dashOffset: 10
32
+ dashPattern: [10, 5]
30
33
  dataTransform: axes.dataTransform
31
34
  position: 0.5
32
35
  strokeColor: "blue"
36
+ strokeStyle: QQS.ShapePath.DashLine
33
37
  strokeWidth: 5
34
38
  viewRect: axes.viewRect
35
39
  }
@@ -48,6 +48,33 @@ enabled = true
48
48
  [tool.setuptools.packages.find]
49
49
  include = ["quickgraphlib_helpers*"]
50
50
 
51
+ [tool.cibuildwheel]
52
+ build = [
53
+ "cp37-macosx_x86_64",
54
+ "cp37-win_amd64",
55
+ "cp37-manylinux_x86_64",
56
+ # "cp37-manylinux_aarch64",
57
+ ]
58
+ before-all = "python ci/setup_qt.py"
59
+ repair-wheel-command = ""
60
+ build-frontend = "build"
61
+ # test-command = "pytest {project}/tests"
62
+ # test-extras = ["tests"]
63
+
64
+ [tool.cibuildwheel.environment]
65
+ CMAKE_BUILD_FLAGS = "-DCMAKE_PREFIX_PATH=\"$(python ci/find_qt.py)/lib/cmake\""
66
+
67
+ [tool.cibuildwheel.macos]
68
+ archs = ["universal2"]
69
+
70
+ [tool.cibuildwheel.linux]
71
+ archs = ["x86_64"] # , "aarch64"]
72
+ manylinux-x86_64-image = "manylinux_2_28"
73
+ manylinux-aarch64-image = "manylinux_2_28"
74
+
75
+ [tool.cibuildwheel.windows]
76
+ archs = ["AMD64"]
77
+
51
78
  [tool.isort]
52
79
  profile = "black"
53
80
  force_alphabetical_sort_within_sections = true
@@ -0,0 +1,7 @@
1
+ [bdist_wheel]
2
+ py_limited_api = cp37
3
+
4
+ [egg_info]
5
+ tag_build =
6
+ tag_date = 0
7
+
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
File without changes