Commit 461dc112 authored by Bernhard Beschow's avatar Bernhard Beschow Committed by Friedrich W. H. Kossebau

have polygon and linear ring icons rendered by PlacemarkLayer

* makes the icons clickable, i.e. a placemark dialg can be shown

Partly re-applies b1a507ba
(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.
parent 9350556f
......@@ -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;
}
......
......@@ -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();
......
Markdown is supported
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