Commit aa5585a6 authored by Torsten Rahn's avatar Torsten Rahn
Browse files

- Introduce clipScreenCoordinates property for GeoPolyline. This allows for restoring the

  previous slow behavior that creates all possible screen coordinates.
- Fix memory leak.
parent b7e526e6
Pipeline #257137 passed with stage
in 31 minutes and 54 seconds
......@@ -28,7 +28,8 @@ namespace Marble
m_observable(false),
m_lineColor(Qt::black),
m_lineWidth(1),
m_tessellate(true)
m_tessellate(true),
m_clipScreenCoordinates(true)
{
setFlag(ItemHasContents, true);
}
......@@ -59,10 +60,19 @@ namespace Marble
m_screenPolygons.clear();
QVector<QPolygonF*> fullScreenPolygons;
bool success = m_map->screenCoordinatesFromGeoDataLineString(lineString, fullScreenPolygons);
for (auto reducedPolygon : qAsConst(fullScreenPolygons)) {
m_screenPolygons << reducedPolygon->intersected(displayPolygon);
if (m_clipScreenCoordinates) {
for (auto reducedPolygon : qAsConst(fullScreenPolygons)) {
m_screenPolygons << reducedPolygon->intersected(displayPolygon);
}
}
else {
for (auto eachPolygon : qAsConst(fullScreenPolygons)) {
m_screenPolygons << *eachPolygon;
}
}
qDeleteAll(fullScreenPolygons);
QVariantList previousScreenCoordinates;
previousScreenCoordinates = m_screenCoordinates;
m_screenCoordinates.clear();
......@@ -178,6 +188,11 @@ namespace Marble
return m_tessellate;
}
bool GeoPolyline::clipScreenCoordinates() const
{
return m_clipScreenCoordinates;
}
void GeoPolyline::setTessellate(bool tessellate)
{
if (m_tessellate == tessellate)
......@@ -187,6 +202,15 @@ namespace Marble
emit tessellateChanged(m_tessellate);
}
void GeoPolyline::setClipScreenCoordinates(bool clipped)
{
if (m_clipScreenCoordinates == clipped)
return;
m_clipScreenCoordinates = clipped;
emit clipScreenCoordinatesChanged(m_clipScreenCoordinates);
}
qreal GeoPolyline::readonlyX() const
{
return x();
......
......@@ -38,6 +38,10 @@ namespace Marble
Q_PROPERTY( QColor lineColor READ lineColor WRITE setLineColor NOTIFY lineColorChanged )
Q_PROPERTY( qreal lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged )
// When enabled only those screenCoordinates are calculated and rendered that are visible on the screen.
// Setting this to false can severely reduce performance. Therefore this defaults to true.
Q_PROPERTY( bool clipScreenCoordinates READ clipScreenCoordinates WRITE setClipScreenCoordinates NOTIFY clipScreenCoordinatesChanged )
public:
/** Constructor */
explicit GeoPolyline( QQuickItem *parent = nullptr );
......@@ -57,10 +61,12 @@ namespace Marble
QColor lineColor() const;
qreal lineWidth() const;
bool tessellate() const;
bool clipScreenCoordinates() const;
void setLineColor(const QColor& lineColor);
void setLineWidth(const qreal lineWidth);
void setTessellate(bool tessellate);
void setClipScreenCoordinates(bool clipped);
qreal readonlyX() const;
......@@ -79,6 +85,7 @@ namespace Marble
void lineWidthChanged(qreal lineWidth);
void tessellateChanged(bool tessellate);
void clipScreenCoordinatesChanged(bool enabled);
void readonlyXChanged();
void readonlyYChanged();
......@@ -98,6 +105,7 @@ namespace Marble
QColor m_lineColor;
qreal m_lineWidth;
bool m_tessellate;
bool m_clipScreenCoordinates;
void updateScreenPositions();
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment