Differential D6303 Diff 16183 src/lib/marble/geodata/graphicsitem/AbstractGeoPolygonGraphicsItem.cpp
Changeset View
Changeset View
Standalone View
Standalone View
src/lib/marble/geodata/graphicsitem/AbstractGeoPolygonGraphicsItem.cpp
1 | // | 1 | // | ||
---|---|---|---|---|---|
2 | // This file is part of the Marble Virtual Globe. | 2 | // This file is part of the Marble Virtual Globe. | ||
3 | // | 3 | // | ||
4 | // This program is free software licensed under the GNU LGPL. You can | 4 | // This program is free software licensed under the GNU LGPL. You can | ||
5 | // find a copy of this license in LICENSE.txt in the top directory of | 5 | // find a copy of this license in LICENSE.txt in the top directory of | ||
6 | // the source code. | 6 | // the source code. | ||
7 | // | 7 | // | ||
8 | // Copyright 2011 Konstantin Oblaukhov <oblaukhov.konstantin@gmail.com> | 8 | // Copyright 2011 Konstantin Oblaukhov <oblaukhov.konstantin@gmail.com> | ||
9 | // | 9 | // | ||
10 | 10 | | |||
11 | #include "AbstractGeoPolygonGraphicsItem.h" | 11 | #include "AbstractGeoPolygonGraphicsItem.h" | ||
12 | 12 | | |||
13 | #include "GeoDataLinearRing.h" | 13 | #include "GeoDataLinearRing.h" | ||
14 | #include "GeoDataPolygon.h" | 14 | #include "GeoDataPolygon.h" | ||
15 | #include "GeoDataBuilding.h" | ||||
15 | #include "GeoPainter.h" | 16 | #include "GeoPainter.h" | ||
16 | #include "GeoDataLatLonAltBox.h" | 17 | #include "GeoDataLatLonAltBox.h" | ||
17 | #include "GeoDataStyle.h" | 18 | #include "GeoDataStyle.h" | ||
18 | #include "GeoDataIconStyle.h" | 19 | #include "GeoDataIconStyle.h" | ||
19 | #include "GeoDataLineStyle.h" | 20 | #include "GeoDataLineStyle.h" | ||
20 | #include "GeoDataPlacemark.h" | 21 | #include "GeoDataPlacemark.h" | ||
21 | #include "GeoDataPolyStyle.h" | 22 | #include "GeoDataPolyStyle.h" | ||
22 | #include "GeoDataTypes.h" | 23 | #include "GeoDataTypes.h" | ||
23 | #include "OsmPlacemarkData.h" | 24 | #include "OsmPlacemarkData.h" | ||
24 | #include "MarbleDebug.h" | 25 | #include "MarbleDebug.h" | ||
25 | #include "ViewportParams.h" | 26 | #include "ViewportParams.h" | ||
26 | 27 | | |||
27 | #include <QtMath> | 28 | #include <QtMath> | ||
28 | #include <QImageReader> | 29 | #include <QImageReader> | ||
29 | #include <QPixmapCache> | 30 | #include <QPixmapCache> | ||
30 | 31 | | |||
31 | namespace Marble | 32 | namespace Marble | ||
32 | { | 33 | { | ||
33 | 34 | | |||
34 | const void *AbstractGeoPolygonGraphicsItem::s_previousStyle = 0; | 35 | const void *AbstractGeoPolygonGraphicsItem::s_previousStyle = 0; | ||
35 | 36 | | |||
36 | AbstractGeoPolygonGraphicsItem::AbstractGeoPolygonGraphicsItem(const GeoDataPlacemark *placemark, const GeoDataPolygon *polygon) : | 37 | AbstractGeoPolygonGraphicsItem::AbstractGeoPolygonGraphicsItem(const GeoDataPlacemark *placemark, const GeoDataPolygon *polygon) : | ||
37 | GeoGraphicsItem(placemark), | 38 | GeoGraphicsItem(placemark), | ||
38 | m_polygon(polygon), | 39 | m_polygon(polygon), | ||
39 | m_ring(0) | 40 | m_ring(0), | ||
41 | m_building(0) | ||||
40 | { | 42 | { | ||
41 | } | 43 | } | ||
42 | 44 | | |||
43 | AbstractGeoPolygonGraphicsItem::AbstractGeoPolygonGraphicsItem(const GeoDataPlacemark *placemark, const GeoDataLinearRing *ring) : | 45 | AbstractGeoPolygonGraphicsItem::AbstractGeoPolygonGraphicsItem(const GeoDataPlacemark *placemark, const GeoDataLinearRing *ring) : | ||
44 | GeoGraphicsItem(placemark), | 46 | GeoGraphicsItem(placemark), | ||
45 | m_polygon(0), | 47 | m_polygon(0), | ||
46 | m_ring(ring) | 48 | m_ring(ring), | ||
49 | m_building(0) | ||||
50 | { | ||||
51 | } | ||||
52 | | ||||
53 | AbstractGeoPolygonGraphicsItem::AbstractGeoPolygonGraphicsItem(const GeoDataPlacemark *placemark, const GeoDataBuilding *building) : | ||||
54 | GeoGraphicsItem(placemark), | ||||
55 | m_polygon(0), | ||||
56 | m_ring(0), | ||||
57 | m_building(building) | ||||
47 | { | 58 | { | ||
48 | } | 59 | } | ||
49 | 60 | | |||
50 | AbstractGeoPolygonGraphicsItem::~AbstractGeoPolygonGraphicsItem() | 61 | AbstractGeoPolygonGraphicsItem::~AbstractGeoPolygonGraphicsItem() | ||
51 | { | 62 | { | ||
52 | } | 63 | } | ||
53 | 64 | | |||
54 | const GeoDataLatLonAltBox& AbstractGeoPolygonGraphicsItem::latLonAltBox() const | 65 | const GeoDataLatLonAltBox& AbstractGeoPolygonGraphicsItem::latLonAltBox() const | ||
55 | { | 66 | { | ||
56 | if( m_polygon ) { | 67 | if(m_polygon) { | ||
57 | return m_polygon->latLonAltBox(); | 68 | return m_polygon->latLonAltBox(); | ||
69 | } else if (m_ring) { | ||||
70 | return m_ring->latLonAltBox(); | ||||
58 | } | 71 | } | ||
59 | 72 | | |||
60 | return m_ring->latLonAltBox(); | 73 | return m_building->latLonAltBox(); | ||
61 | } | 74 | } | ||
62 | 75 | | |||
63 | void AbstractGeoPolygonGraphicsItem::paint( GeoPainter* painter, const ViewportParams* viewport, const QString &layer, int tileZoomLevel) | 76 | void AbstractGeoPolygonGraphicsItem::paint( GeoPainter* painter, const ViewportParams* viewport, const QString &layer, int tileZoomLevel) | ||
64 | { | 77 | { | ||
65 | Q_UNUSED(layer); | 78 | Q_UNUSED(layer); | ||
66 | Q_UNUSED(tileZoomLevel); | 79 | Q_UNUSED(tileZoomLevel); | ||
67 | 80 | | |||
68 | bool isValid = true; | 81 | bool isValid = true; | ||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | 213 | if (texture.hasAlphaChannel()) { | |||
205 | imagePainter.end(); | 218 | imagePainter.end(); | ||
206 | texture = pixmap; | 219 | texture = pixmap; | ||
207 | } | 220 | } | ||
208 | QPixmapCache::insert(key, texture); | 221 | QPixmapCache::insert(key, texture); | ||
209 | } | 222 | } | ||
210 | return texture; | 223 | return texture; | ||
211 | } | 224 | } | ||
212 | 225 | | |||
226 | void AbstractGeoPolygonGraphicsItem::setLinearRing(GeoDataLinearRing *ring) | ||||
227 | { | ||||
228 | Q_ASSERT(m_building); | ||||
nienhueser: Do we need to care (e.g. Q_ASSERT on) the value of m_polygon, m_building here? Same in… | |||||
229 | Q_ASSERT(!m_polygon); | ||||
230 | m_ring = ring; | ||||
231 | } | ||||
232 | | ||||
233 | void AbstractGeoPolygonGraphicsItem::setPolygon(GeoDataPolygon *polygon) | ||||
234 | { | ||||
235 | Q_ASSERT(m_building); | ||||
236 | Q_ASSERT(!m_ring); | ||||
237 | m_polygon = polygon; | ||||
238 | } | ||||
239 | | ||||
213 | } | 240 | } |
Do we need to care (e.g. Q_ASSERT on) the value of m_polygon, m_building here? Same in setPolygon.