summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Beschow <bbeschow@cs.tu-berlin.de>2016-11-02 19:50:18 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-11-05 16:49:32 (GMT)
commit461dc1122bebbf5d7e5a84b4d03764e1eb1e6b75 (patch)
tree75100537b78df5d929fb4e70783aebda64abd2dd
parent9350556f36a600ca3f5a6feec90cf96d5cfda307 (diff)
have polygon and linear ring icons rendered by PlacemarkLayer
* makes the icons clickable, i.e. a placemark dialg can be shown Partly re-applies b1a507ba5d9e2386bc2dd4b2432569910a5e030e (leaves out the building label changes unrelated to the comment above) Still needs a bit of tweaking to avoid too much label clutter. However with rings and polygons setting their zoomLevel to 17 this was reduced to the highest levels in the meantime. Fixes icon render order.
-rw-r--r--src/lib/marble/geodata/data/GeoDataPlacemark.cpp10
-rw-r--r--src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp12
2 files changed, 10 insertions, 12 deletions
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
index 5ccca5e..ad7cbe4 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
@@ -275,16 +275,20 @@ GeoDataCoordinates GeoDataPlacemark::coordinate( const QDateTime &dateTime, bool
if (d->m_geometry) {
// Beware: comparison between pointers, not strings.
- if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataPointType) {
+ if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataPointType
+ || d->m_geometry->nodeType() == GeoDataTypes::GeoDataPolygonType
+ || d->m_geometry->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
hasIcon = true;
- coord = static_cast<const GeoDataPoint *>(d->m_geometry)->coordinates();
+ coord = d->m_geometry->latLonAltBox().center();
} else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataMultiGeometryType) {
const GeoDataMultiGeometry *multiGeometry = static_cast<const GeoDataMultiGeometry *>(d->m_geometry);
QVector<GeoDataGeometry*>::ConstIterator it = multiGeometry->constBegin();
QVector<GeoDataGeometry*>::ConstIterator end = multiGeometry->constEnd();
for ( ; it != end; ++it ) {
- if ( (*it)->nodeType() == GeoDataTypes::GeoDataPointType ) {
+ if ((*it)->nodeType() == GeoDataTypes::GeoDataPointType
+ || (*it)->nodeType() == GeoDataTypes::GeoDataPolygonType
+ || (*it)->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
hasIcon = true;
break;
}
diff --git a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp
index cf86ea7..1a4bbdc 100644
--- a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp
+++ b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp
@@ -16,7 +16,6 @@
#include "GeoDataPlacemark.h"
#include "GeoDataLinearRing.h"
#include "GeoDataPolygon.h"
-#include "GeoDataIconStyle.h"
#include "GeoDataPolyStyle.h"
#include "OsmPlacemarkData.h"
#include "GeoPainter.h"
@@ -224,7 +223,6 @@ void BuildingGeoPolygonGraphicsItem::paintRoof(GeoPainter* painter, const Viewpo
painter->save();
QPen const currentPen = configurePainter(painter, viewport);
- bool const hasIcon = !style()->iconStyle().iconPath().isEmpty();
qreal maxSize(0.0);
QPointF roofCenter;
@@ -232,13 +230,13 @@ void BuildingGeoPolygonGraphicsItem::paintRoof(GeoPainter* painter, const Viewpo
painter->setPen(Qt::NoPen);
}
- // first paint the area and icon (and the outline if there are no inner boundaries)
+ // first paint the area (and the outline if there are no inner boundaries)
double maxArea = 0.0;
foreach(QPolygonF* outlinePolygon, outlinePolygons) {
QRectF const boundingRect = outlinePolygon->boundingRect();
QPolygonF buildingRoof;
- if (hasIcon || !m_buildingLabel.isEmpty() || !m_entries.isEmpty()) {
+ if (!m_buildingLabel.isEmpty() || !m_entries.isEmpty()) {
QSizeF const polygonSize = boundingRect.size();
qreal size = polygonSize.width() * polygonSize.height();
if (size > maxSize) {
@@ -283,11 +281,7 @@ void BuildingGeoPolygonGraphicsItem::paintRoof(GeoPainter* painter, const Viewpo
painter->translate(-offset);
}
- if (hasIcon && !roofCenter.isNull()) {
- QImage const icon = style()->iconStyle().scaledIcon();
- QPointF const iconCenter(icon.size().width()/2.0, icon.size().height()/2.0);
- painter->drawImage(roofCenter-iconCenter, icon);
- } else if (drawAccurate3D && !m_buildingLabel.isEmpty() && !roofCenter.isNull()) {
+ if (drawAccurate3D && !m_buildingLabel.isEmpty() && !roofCenter.isNull()) {
double const w2 = 0.5 * painter->fontMetrics().width(m_buildingLabel);
double const ascent = painter->fontMetrics().ascent();
double const descent = painter->fontMetrics().descent();