Changeset View
Changeset View
Standalone View
Standalone View
src/lib/marble/geodata/data/GeoDataPolygon.cpp
Show All 34 Lines | |||||
35 | 35 | | |||
36 | GeoDataPolygon::~GeoDataPolygon() | 36 | GeoDataPolygon::~GeoDataPolygon() | ||
37 | { | 37 | { | ||
38 | #ifdef DEBUG_GEODATA | 38 | #ifdef DEBUG_GEODATA | ||
39 | mDebug() << "delete polygon"; | 39 | mDebug() << "delete polygon"; | ||
40 | #endif | 40 | #endif | ||
41 | } | 41 | } | ||
42 | 42 | | |||
43 | GeoDataPolygonPrivate* GeoDataPolygon::p() | | |||
44 | { | | |||
45 | return static_cast<GeoDataPolygonPrivate*>(d); | | |||
46 | } | | |||
47 | | ||||
48 | const GeoDataPolygonPrivate* GeoDataPolygon::p() const | | |||
49 | { | | |||
50 | return static_cast<GeoDataPolygonPrivate*>(d); | | |||
51 | } | | |||
52 | | ||||
53 | bool GeoDataPolygon::operator==( const GeoDataPolygon &other ) const | 43 | bool GeoDataPolygon::operator==( const GeoDataPolygon &other ) const | ||
54 | { | 44 | { | ||
55 | const GeoDataPolygonPrivate *d = p(); | 45 | Q_D(const GeoDataPolygon); | ||
56 | const GeoDataPolygonPrivate *other_d = other.p(); | 46 | const GeoDataPolygonPrivate *other_d = other.d_func(); | ||
57 | 47 | | |||
58 | if ( !GeoDataGeometry::equals(other) || | 48 | if ( !GeoDataGeometry::equals(other) || | ||
59 | tessellate() != other.tessellate() || | 49 | tessellate() != other.tessellate() || | ||
60 | isClosed() != other.isClosed() || | 50 | isClosed() != other.isClosed() || | ||
61 | d->inner.size() != other_d->inner.size() || | 51 | d->inner.size() != other_d->inner.size() || | ||
62 | d->outer != other_d->outer ) { | 52 | d->outer != other_d->outer ) { | ||
63 | return false; | 53 | return false; | ||
64 | } | 54 | } | ||
Show All 20 Lines | |||||
85 | 75 | | |||
86 | bool GeoDataPolygon::isClosed() const | 76 | bool GeoDataPolygon::isClosed() const | ||
87 | { | 77 | { | ||
88 | return true; | 78 | return true; | ||
89 | } | 79 | } | ||
90 | 80 | | |||
91 | bool GeoDataPolygon::tessellate() const | 81 | bool GeoDataPolygon::tessellate() const | ||
92 | { | 82 | { | ||
93 | return p()->m_tessellationFlags.testFlag(Tessellate); | 83 | Q_D(const GeoDataPolygon); | ||
84 | return d->m_tessellationFlags.testFlag(Tessellate); | ||||
94 | } | 85 | } | ||
95 | 86 | | |||
96 | void GeoDataPolygon::setTessellate( bool tessellate ) | 87 | void GeoDataPolygon::setTessellate( bool tessellate ) | ||
97 | { | 88 | { | ||
98 | // According to the KML reference the tesselation is done along great circles | 89 | // According to the KML reference the tesselation is done along great circles | ||
99 | // for polygons in Google Earth. Our "Tesselate" flag does this. | 90 | // for polygons in Google Earth. Our "Tesselate" flag does this. | ||
100 | // Only for pure line strings and linear rings the | 91 | // Only for pure line strings and linear rings the | ||
101 | // latitude circles are followed for subsequent points that share the same latitude. | 92 | // latitude circles are followed for subsequent points that share the same latitude. | ||
102 | detach(); | 93 | detach(); | ||
103 | 94 | | |||
95 | Q_D(GeoDataPolygon); | ||||
104 | if ( tessellate ) { | 96 | if ( tessellate ) { | ||
105 | p()->m_tessellationFlags |= Tessellate; | 97 | d->m_tessellationFlags |= Tessellate; | ||
106 | } else { | 98 | } else { | ||
107 | p()->m_tessellationFlags ^= Tessellate; | 99 | d->m_tessellationFlags ^= Tessellate; | ||
108 | } | 100 | } | ||
109 | } | 101 | } | ||
110 | 102 | | |||
111 | TessellationFlags GeoDataPolygon::tessellationFlags() const | 103 | TessellationFlags GeoDataPolygon::tessellationFlags() const | ||
112 | { | 104 | { | ||
113 | return p()->m_tessellationFlags; | 105 | Q_D(const GeoDataPolygon); | ||
106 | return d->m_tessellationFlags; | ||||
114 | } | 107 | } | ||
115 | 108 | | |||
116 | void GeoDataPolygon::setTessellationFlags( TessellationFlags f ) | 109 | void GeoDataPolygon::setTessellationFlags( TessellationFlags f ) | ||
117 | { | 110 | { | ||
118 | detach(); | 111 | detach(); | ||
119 | p()->m_tessellationFlags = f; | 112 | | ||
113 | Q_D(GeoDataPolygon); | ||||
114 | d->m_tessellationFlags = f; | ||||
120 | } | 115 | } | ||
121 | 116 | | |||
122 | const GeoDataLatLonAltBox& GeoDataPolygon::latLonAltBox() const | 117 | const GeoDataLatLonAltBox& GeoDataPolygon::latLonAltBox() const | ||
123 | { | 118 | { | ||
124 | return p()->outer.latLonAltBox(); | 119 | Q_D(const GeoDataPolygon); | ||
120 | return d->outer.latLonAltBox(); | ||||
125 | } | 121 | } | ||
126 | 122 | | |||
127 | GeoDataLinearRing &GeoDataPolygon::outerBoundary() | 123 | GeoDataLinearRing &GeoDataPolygon::outerBoundary() | ||
128 | { | 124 | { | ||
129 | detach(); | 125 | detach(); | ||
130 | return (p()->outer); | 126 | | ||
127 | Q_D(GeoDataPolygon); | ||||
128 | return (d->outer); | ||||
131 | } | 129 | } | ||
132 | 130 | | |||
133 | const GeoDataLinearRing &GeoDataPolygon::outerBoundary() const | 131 | const GeoDataLinearRing &GeoDataPolygon::outerBoundary() const | ||
134 | { | 132 | { | ||
135 | return (p()->outer); | 133 | Q_D(const GeoDataPolygon); | ||
134 | return d->outer; | ||||
136 | } | 135 | } | ||
137 | 136 | | |||
138 | void GeoDataPolygon::setOuterBoundary( const GeoDataLinearRing& boundary ) | 137 | void GeoDataPolygon::setOuterBoundary( const GeoDataLinearRing& boundary ) | ||
139 | { | 138 | { | ||
140 | detach(); | 139 | detach(); | ||
141 | p()->outer = boundary; | 140 | | ||
141 | Q_D(GeoDataPolygon); | ||||
142 | d->outer = boundary; | ||||
142 | } | 143 | } | ||
143 | 144 | | |||
144 | QVector<GeoDataLinearRing>& GeoDataPolygon::innerBoundaries() | 145 | QVector<GeoDataLinearRing>& GeoDataPolygon::innerBoundaries() | ||
145 | { | 146 | { | ||
146 | detach(); | 147 | detach(); | ||
147 | return p()->inner; | 148 | | ||
149 | Q_D(GeoDataPolygon); | ||||
150 | return d->inner; | ||||
148 | } | 151 | } | ||
149 | 152 | | |||
150 | const QVector<GeoDataLinearRing>& GeoDataPolygon::innerBoundaries() const | 153 | const QVector<GeoDataLinearRing>& GeoDataPolygon::innerBoundaries() const | ||
151 | { | 154 | { | ||
152 | return p()->inner; | 155 | Q_D(const GeoDataPolygon); | ||
156 | return d->inner; | ||||
153 | } | 157 | } | ||
154 | 158 | | |||
155 | void GeoDataPolygon::appendInnerBoundary( const GeoDataLinearRing& boundary ) | 159 | void GeoDataPolygon::appendInnerBoundary( const GeoDataLinearRing& boundary ) | ||
156 | { | 160 | { | ||
157 | detach(); | 161 | detach(); | ||
158 | p()->inner.append( boundary ); | 162 | | ||
163 | Q_D(GeoDataPolygon); | ||||
164 | d->inner.append(boundary); | ||||
159 | } | 165 | } | ||
160 | 166 | | |||
161 | void GeoDataPolygon::setRenderOrder(int renderOrder){ | 167 | void GeoDataPolygon::setRenderOrder(int renderOrder) | ||
168 | { | ||||
162 | detach(); | 169 | detach(); | ||
163 | p()->m_renderOrder = renderOrder; | 170 | | ||
171 | Q_D(GeoDataPolygon); | ||||
172 | d->m_renderOrder = renderOrder; | ||||
164 | } | 173 | } | ||
165 | 174 | | |||
166 | int GeoDataPolygon::renderOrder() const{ | 175 | int GeoDataPolygon::renderOrder() const | ||
167 | return p()->m_renderOrder; | 176 | { | ||
177 | Q_D(const GeoDataPolygon); | ||||
178 | return d->m_renderOrder; | ||||
168 | } | 179 | } | ||
169 | 180 | | |||
170 | void GeoDataPolygon::pack( QDataStream& stream ) const | 181 | void GeoDataPolygon::pack( QDataStream& stream ) const | ||
171 | { | 182 | { | ||
183 | Q_D(const GeoDataPolygon); | ||||
184 | | ||||
172 | GeoDataObject::pack( stream ); | 185 | GeoDataObject::pack( stream ); | ||
173 | 186 | | |||
174 | p()->outer.pack( stream ); | 187 | d->outer.pack( stream ); | ||
175 | 188 | | |||
176 | stream << p()->inner.size(); | 189 | stream << d->inner.size(); | ||
177 | stream << (qint32)(p()->m_tessellationFlags); | 190 | stream << (qint32)(d->m_tessellationFlags); | ||
178 | 191 | | |||
179 | for( QVector<GeoDataLinearRing>::const_iterator iterator | 192 | for( QVector<GeoDataLinearRing>::const_iterator iterator | ||
180 | = p()->inner.constBegin(); | 193 | = d->inner.constBegin(); | ||
181 | iterator != p()->inner.constEnd(); | 194 | iterator != d->inner.constEnd(); | ||
182 | ++iterator ) { | 195 | ++iterator ) { | ||
183 | mDebug() << "innerRing: size" << p()->inner.size(); | 196 | mDebug() << "innerRing: size" << d->inner.size(); | ||
184 | GeoDataLinearRing linearRing = ( *iterator ); | 197 | GeoDataLinearRing linearRing = ( *iterator ); | ||
185 | linearRing.pack( stream ); | 198 | linearRing.pack( stream ); | ||
186 | } | 199 | } | ||
187 | } | 200 | } | ||
188 | 201 | | |||
189 | void GeoDataPolygon::unpack( QDataStream& stream ) | 202 | void GeoDataPolygon::unpack( QDataStream& stream ) | ||
190 | { | 203 | { | ||
191 | detach(); | 204 | detach(); | ||
205 | | ||||
206 | Q_D(GeoDataPolygon); | ||||
207 | | ||||
192 | GeoDataObject::unpack( stream ); | 208 | GeoDataObject::unpack( stream ); | ||
193 | 209 | | |||
194 | p()->outer.unpack( stream ); | 210 | d->outer.unpack( stream ); | ||
195 | 211 | | |||
196 | qint32 size; | 212 | qint32 size; | ||
197 | qint32 tessellationFlags; | 213 | qint32 tessellationFlags; | ||
198 | 214 | | |||
199 | stream >> size; | 215 | stream >> size; | ||
200 | stream >> tessellationFlags; | 216 | stream >> tessellationFlags; | ||
201 | 217 | | |||
202 | p()->m_tessellationFlags = (TessellationFlags)(tessellationFlags); | 218 | d->m_tessellationFlags = (TessellationFlags)(tessellationFlags); | ||
203 | 219 | | |||
204 | QVector<GeoDataLinearRing> &inner = p()->inner; | 220 | QVector<GeoDataLinearRing> &inner = d->inner; | ||
205 | inner.reserve(inner.size() + size); | 221 | inner.reserve(inner.size() + size); | ||
206 | for(qint32 i = 0; i < size; i++ ) { | 222 | for(qint32 i = 0; i < size; i++ ) { | ||
207 | GeoDataLinearRing linearRing; | 223 | GeoDataLinearRing linearRing; | ||
208 | linearRing.unpack( stream ); | 224 | linearRing.unpack( stream ); | ||
209 | inner.append(linearRing); | 225 | inner.append(linearRing); | ||
210 | } | 226 | } | ||
211 | } | 227 | } | ||
212 | 228 | | |||
Show All 18 Lines |