summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-07-11 10:22:24 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-07-17 13:31:16 +0000
commit358344c7249e04e26e011a3da27b87a4564b8dc4 (patch)
tree74e51cd080689ce353b15904bb148ecdd0e6c655
parent2ab93acd9751b3ffe2c36a4a0e37dc792686a08f (diff)
downloadqtlocation-358344c7249e04e26e011a3da27b87a4564b8dc4.tar.gz
Remove dead code in QDeclarativePolygon/Polyline MapItems
Change-Id: I95c1d361bd6ba43a3eed5465fc2f74b7a622af72 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/3rdparty/earcut/qt_attribution.json4
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp36
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem.cpp113
3 files changed, 3 insertions, 150 deletions
diff --git a/src/3rdparty/earcut/qt_attribution.json b/src/3rdparty/earcut/qt_attribution.json
index 0e52989c..94702971 100644
--- a/src/3rdparty/earcut/qt_attribution.json
+++ b/src/3rdparty/earcut/qt_attribution.json
@@ -9,5 +9,7 @@
"LicenseId": "ISC",
"License": "ISC License",
"LicenseFile": "LICENSE",
- "Copyright": "Copyright (c) 2015 Mapbox"
+ "Copyright": "Copyright (c) 2015 Mapbox",
+ "Version": "v0.12.3",
+ "DownloadLocation": "https://github.com/mapbox/earcut.hpp/releases/tag/v0.12.3"
}
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
index 3218f9f1..48f66423 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
@@ -256,16 +256,6 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
return;
}
- QDoubleVector2D origin = map.geoProjection().coordinateToItemPosition(srcOrigin_, false);
-
- // Create the viewport rect in the same coordinate system
- // as the actual points
- QRectF viewport(0, 0, map.viewportWidth(), map.viewportHeight());
- viewport.translate(-1 * origin.toPointF());
-
- QPainterPath vpPath;
- vpPath.addRect(viewport);
-
// The geometry has already been clipped against the visible region projection in wrapped mercator space.
QPainterPath ppi = srcPath_;
clear();
@@ -274,38 +264,12 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
if (ppi.elementCount() < 3)
return;
- // Intersection between the viewport and a concave polygon can create multiple polygons
- // joined by a line at the viewport border, and poly2tri does not triangulate this very well
- // so use the full src path if the resulting polygon is concave.
- if (clipToViewport_) {
- int changeInX = 0;
- int changeInY = 0;
- QPainterPath::Element e1 = ppi.elementAt(1);
- QPainterPath::Element e = ppi.elementAt(0);
- QVector2D edgeA(e1.x - e.x ,e1.y - e.y);
- for (int i = 2; i <= ppi.elementCount(); ++i) {
- e = ppi.elementAt(i % ppi.elementCount());
- if (e.x == e1.x && e.y == e1.y)
- continue;
- QVector2D edgeB(e.x - e1.x, e.y - e1.y);
- if ((edgeA.x() < 0) == (edgeB.x() >= 0))
- changeInX++;
- if ((edgeA.y() < 0) == (edgeB.y() >= 0))
- changeInY++;
- edgeA = edgeB;
- e1 = e;
- }
- if (changeInX > 2 || changeInY > 2) // polygon is concave
- ppi = srcPath_;
- }
-
// translate the path into top-left-centric coordinates
QRectF bb = ppi.boundingRect();
ppi.translate(-bb.left(), -bb.top());
firstPointOffset_ = -1 * bb.topLeft();
ppi.closeSubpath();
-
screenOutline_ = ppi;
using Coord = double;
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
index 26f030b0..2c6d3ba4 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
@@ -337,120 +337,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
}
////////////////////////////////////////////////////////////////////////////
-#if 0 // Old polyline to viewport clipping code. Retaining it for now.
-/* Polyline clip */
-
-enum ClipPointType {
- InsidePoint = 0x00,
- LeftPoint = 0x01,
- RightPoint = 0x02,
- BottomPoint = 0x04,
- TopPoint = 0x08
-};
-
-static inline int clipPointType(qreal x, qreal y, const QRectF &rect)
-{
- int type = InsidePoint;
- if (x < rect.left())
- type |= LeftPoint;
- else if (x > rect.right())
- type |= RightPoint;
- if (y < rect.top())
- type |= TopPoint;
- else if (y > rect.bottom())
- type |= BottomPoint;
- return type;
-}
-
-static void clipSegmentToRect(qreal x0, qreal y0, qreal x1, qreal y1,
- const QRectF &clipRect,
- QVector<qreal> &outPoints,
- QVector<QPainterPath::ElementType> &outTypes)
-{
- int type0 = clipPointType(x0, y0, clipRect);
- int type1 = clipPointType(x1, y1, clipRect);
- bool accept = false;
-
- while (true) {
- if (!(type0 | type1)) {
- accept = true;
- break;
- } else if (type0 & type1) {
- break;
- } else {
- qreal x = 0.0;
- qreal y = 0.0;
- int outsideType = type0 ? type0 : type1;
-
- if (outsideType & BottomPoint) {
- x = x0 + (x1 - x0) * (clipRect.bottom() - y0) / (y1 - y0);
- y = clipRect.bottom() - 0.1;
- } else if (outsideType & TopPoint) {
- x = x0 + (x1 - x0) * (clipRect.top() - y0) / (y1 - y0);
- y = clipRect.top() + 0.1;
- } else if (outsideType & RightPoint) {
- y = y0 + (y1 - y0) * (clipRect.right() - x0) / (x1 - x0);
- x = clipRect.right() - 0.1;
- } else if (outsideType & LeftPoint) {
- y = y0 + (y1 - y0) * (clipRect.left() - x0) / (x1 - x0);
- x = clipRect.left() + 0.1;
- }
-
- if (outsideType == type0) {
- x0 = x;
- y0 = y;
- type0 = clipPointType(x0, y0, clipRect);
- } else {
- x1 = x;
- y1 = y;
- type1 = clipPointType(x1, y1, clipRect);
- }
- }
- }
-
- if (accept) {
- if (outPoints.size() >= 2) {
- qreal lastX, lastY;
- lastY = outPoints.at(outPoints.size() - 1);
- lastX = outPoints.at(outPoints.size() - 2);
-
- if (!qFuzzyCompare(lastY, y0) || !qFuzzyCompare(lastX, x0)) {
- outTypes << QPainterPath::MoveToElement;
- outPoints << x0 << y0;
- }
- } else {
- outTypes << QPainterPath::MoveToElement;
- outPoints << x0 << y0;
- }
-
- outTypes << QPainterPath::LineToElement;
- outPoints << x1 << y1;
- }
-}
-
-static void clipPathToRect(const QVector<qreal> &points,
- const QVector<QPainterPath::ElementType> &types,
- const QRectF &clipRect,
- QVector<qreal> &outPoints,
- QVector<QPainterPath::ElementType> &outTypes)
-{
- outPoints.clear();
- outPoints.reserve(points.size());
- outTypes.clear();
- outTypes.reserve(types.size());
- qreal lastX, lastY;
- for (int i = 0; i < types.size(); ++i) {
- if (i > 0 && types[i] != QPainterPath::MoveToElement) {
- qreal x = points[i * 2], y = points[i * 2 + 1];
- clipSegmentToRect(lastX, lastY, x, y, clipRect, outPoints, outTypes);
- }
-
- lastX = points[i * 2];
- lastY = points[i * 2 + 1];
- }
-}
-#endif
/*!
\internal
*/