summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Beschow <[email protected]>2016-06-12 18:24:13 +0200
committerBernhard Beschow <[email protected]>2016-06-12 18:27:23 +0200
commit499967fd5b8fdcf1f0bd9526d4175299d5056788 (patch)
tree2330fbf7751e8b5e8f8686479c5ed50521fa9c61
parentd99a1841312b75c2adfb06ea8d66796a268d3a0e (diff)
merge method into c'tor
-rw-r--r--src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp93
-rw-r--r--src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h1
2 files changed, 52 insertions, 42 deletions
diff --git a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
index 07ba238..0890404 100644
--- a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
+++ b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
@@ -27,22 +27,56 @@
namespace Marble
{
-GeoPolygonGraphicsItem::GeoPolygonGraphicsItem( const GeoDataFeature *feature, const GeoDataPolygon* polygon )
- : GeoGraphicsItem( feature ),
- m_polygon( polygon ),
- m_ring( 0 ),
- m_buildingHeight(0.0)
+GeoPolygonGraphicsItem::GeoPolygonGraphicsItem(const GeoDataFeature *feature, const GeoDataPolygon *polygon) :
+ GeoGraphicsItem(feature),
+ m_polygon(polygon),
+ m_ring(0),
+ m_buildingHeight(extractBuildingHeight(feature)),
+ m_buildingLabel(extractBuildingLabel(feature)),
+ m_entries(extractNamedEntries(feature))
{
- determineBuildingHeight();
+ const GeoDataFeature::GeoDataVisualCategory visualCategory = feature->visualCategory();
+ if (isBuilding(visualCategory))
+ {
+ setZValue(this->zValue() + m_buildingHeight);
+ Q_ASSERT(m_buildingHeight > 0.0);
+
+ QStringList paintLayers;
+ paintLayers << QString("Polygon/Building/frame");
+ paintLayers << QString("Polygon/Building/roof");
+ setPaintLayers(paintLayers);
+ }
+ else
+ {
+ const QString paintLayer = QString("Polygon/%1").arg(GeoDataFeature::visualCategoryName(visualCategory));
+ setPaintLayers(QStringList() << paintLayer);
+ }
}
-GeoPolygonGraphicsItem::GeoPolygonGraphicsItem( const GeoDataFeature *feature, const GeoDataLinearRing* ring )
- : GeoGraphicsItem( feature ),
- m_polygon( 0 ),
- m_ring( ring ),
- m_buildingHeight(0.0)
+GeoPolygonGraphicsItem::GeoPolygonGraphicsItem(const GeoDataFeature *feature, const GeoDataLinearRing *ring) :
+ GeoGraphicsItem(feature),
+ m_polygon(0),
+ m_ring(ring),
+ m_buildingHeight(extractBuildingHeight(feature)),
+ m_buildingLabel(extractBuildingLabel(feature)),
+ m_entries(extractNamedEntries(feature))
{
- determineBuildingHeight();
+ const GeoDataFeature::GeoDataVisualCategory visualCategory = feature->visualCategory();
+ if (isBuilding(visualCategory))
+ {
+ setZValue(this->zValue() + m_buildingHeight);
+ Q_ASSERT(m_buildingHeight > 0.0);
+
+ QStringList paintLayers;
+ paintLayers << QString("Polygon/Building/frame");
+ paintLayers << QString("Polygon/Building/roof");
+ setPaintLayers(paintLayers);
+ }
+ else
+ {
+ const QString paintLayer = QString("Polygon/%1").arg(GeoDataFeature::visualCategoryName(visualCategory));
+ setPaintLayers(QStringList() << paintLayer);
+ }
}
bool GeoPolygonGraphicsItem::isBuilding(GeoDataFeature::GeoDataVisualCategory visualCategory)
@@ -100,33 +134,6 @@ bool GeoPolygonGraphicsItem::isBuilding(GeoDataFeature::GeoDataVisualCategory vi
return false;
}
-void GeoPolygonGraphicsItem::determineBuildingHeight()
-{
- if (!m_polygon && !m_ring ) {
- return;
- }
-
- GeoDataFeature::GeoDataVisualCategory const visualCategory = feature()->visualCategory();
- if (isBuilding(visualCategory))
- {
- m_buildingHeight = extractBuildingHeight(feature());
- m_buildingLabel = extractBuildingLabel(feature());
- m_entries = extractNamedEntries(feature());
- setZValue(this->zValue() + m_buildingHeight);
- Q_ASSERT(m_buildingHeight > 0.0);
-
- QStringList paintLayers;
- paintLayers << QString("Polygon/Building/frame");
- paintLayers << QString("Polygon/Building/roof");
- setPaintLayers(paintLayers);
- }
- else
- {
- QString const paintLayer = QString("Polygon/%1").arg(GeoDataFeature::visualCategoryName(visualCategory));
- setPaintLayers(QStringList() << paintLayer);
- }
-}
-
void GeoPolygonGraphicsItem::initializeBuildingPainting(const GeoPainter* painter, const ViewportParams *viewport,
bool &drawAccurate3D, bool &isCameraAboveBuilding, bool &hasInnerBoundaries,
QVector<QPolygonF*>& outlinePolygons,
@@ -207,6 +214,10 @@ QPointF GeoPolygonGraphicsItem::buildingOffset(const QPointF &point, const Viewp
double GeoPolygonGraphicsItem::extractBuildingHeight(const GeoDataFeature *feature)
{
+ if (!isBuilding(feature->visualCategory())) {
+ return 0;
+ }
+
double height = 8.0;
if (feature->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
@@ -233,7 +244,7 @@ double GeoPolygonGraphicsItem::extractBuildingHeight(const GeoDataFeature *featu
QString GeoPolygonGraphicsItem::extractBuildingLabel(const GeoDataFeature *feature)
{
- if (feature->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
+ if (isBuilding(feature->visualCategory()) && feature->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
const GeoDataPlacemark *placemark = static_cast<const GeoDataPlacemark *>(feature);
if (!placemark->name().isEmpty()) {
@@ -252,7 +263,7 @@ QList<GeoPolygonGraphicsItem::NamedEntry> GeoPolygonGraphicsItem::extractNamedEn
{
QList<NamedEntry> entries;
- if (feature->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
+ if (isBuilding(feature->visualCategory()) && feature->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
const GeoDataPlacemark *placemark = static_cast<const GeoDataPlacemark *>(feature);
const auto end = placemark->osmData().nodeReferencesEnd();
diff --git a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h
index f9514c6..798c2a9 100644
--- a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h
+++ b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h
@@ -54,7 +54,6 @@ private:
void screenPolygons(const ViewportParams *viewport, const GeoDataPolygon* polygon, QVector<QPolygonF*> &polygons, QVector<QPolygonF*> &outlines) const;
QPen configurePainter(GeoPainter* painter, const ViewportParams *viewport, bool isBuildingFrame);
static bool isBuilding(GeoDataFeature::GeoDataVisualCategory visualCategory);
- void determineBuildingHeight();
void initializeBuildingPainting(const GeoPainter* painter, const ViewportParams *viewport,
bool &drawAccurate3D, bool &isCameraAboveBuilding, bool &hasInnerBoundaries,
QVector<QPolygonF*>& outlinePolygons,