equal
deleted
inserted
replaced
154 { |
154 { |
155 // cursor is a part of items() |
155 // cursor is a part of items() |
156 if(m_isCursorShown) |
156 if(m_isCursorShown) |
157 return; |
157 return; |
158 |
158 |
159 if(items().size()) |
159 if(paths.size()) |
160 { |
160 { |
161 removeItem(items().first()); |
161 removeItem(items().first()); |
162 paths.removeFirst(); |
162 paths.removeFirst(); |
163 |
163 |
164 emit pathChanged(); |
164 emit pathChanged(); |
181 |
181 |
182 // don't clear if already cleared |
182 // don't clear if already cleared |
183 if(!items().size()) |
183 if(!items().size()) |
184 return; |
184 return; |
185 |
185 |
|
186 m_specialPoints.clear(); |
186 oldItems.clear(); |
187 oldItems.clear(); |
187 |
188 |
188 // do this since clear() would _destroy_ all items |
189 // do this since clear() would _destroy_ all items |
189 while(items().size()) |
190 for(int i = paths.size() - 1; i >= 0; --i) |
190 { |
191 { |
191 oldItems.push_front(items().first()); |
192 oldItems.push_front(items().first()); |
192 removeItem(items().first()); |
193 removeItem(items().first()); |
193 } |
194 } |
|
195 |
|
196 items().clear(); |
194 |
197 |
195 oldPaths = paths; |
198 oldPaths = paths; |
196 |
199 |
197 paths.clear(); |
200 paths.clear(); |
198 |
201 |
209 m_pen.setBrush(m_brush); |
212 m_pen.setBrush(m_brush); |
210 } |
213 } |
211 |
214 |
212 QByteArray DrawMapScene::encode() |
215 QByteArray DrawMapScene::encode() |
213 { |
216 { |
214 QByteArray b; |
217 QByteArray b(m_specialPoints); |
215 |
218 |
216 for(int i = paths.size() - 1; i >= 0; --i) |
219 for(int i = paths.size() - 1; i >= 0; --i) |
217 { |
220 { |
218 int cnt = 0; |
221 int cnt = 0; |
219 PathParams params = paths.at(i); |
222 PathParams params = paths.at(i); |
245 |
248 |
246 oldItems.clear(); |
249 oldItems.clear(); |
247 oldPaths.clear(); |
250 oldPaths.clear(); |
248 clear(); |
251 clear(); |
249 paths.clear(); |
252 paths.clear(); |
|
253 m_specialPoints.clear(); |
250 |
254 |
251 PathParams params; |
255 PathParams params; |
|
256 |
|
257 bool isSpecial = true; |
252 |
258 |
253 while(data.size() >= 5) |
259 while(data.size() >= 5) |
254 { |
260 { |
255 qint16 px = qFromBigEndian(*(qint16 *)data.data()); |
261 qint16 px = qFromBigEndian(*(qint16 *)data.data()); |
256 data.remove(0, 2); |
262 data.remove(0, 2); |
257 qint16 py = qFromBigEndian(*(qint16 *)data.data()); |
263 qint16 py = qFromBigEndian(*(qint16 *)data.data()); |
258 data.remove(0, 2); |
264 data.remove(0, 2); |
259 quint8 flags = *(quint8 *)data.data(); |
265 quint8 flags = *(quint8 *)data.data(); |
260 data.remove(0, 1); |
266 data.remove(0, 1); |
261 |
267 qDebug() << px << py; |
262 if(flags & 0x80) |
268 if(flags & 0x80) |
263 { |
269 { |
|
270 isSpecial = false; |
|
271 |
264 if(params.points.size()) |
272 if(params.points.size()) |
265 { |
273 { |
266 addPath(pointsToPath(params.points), m_pen); |
274 addPath(pointsToPath(params.points), m_pen); |
267 |
275 |
268 paths.prepend(params); |
276 paths.prepend(params); |
276 if(params.erasing) |
284 if(params.erasing) |
277 m_pen.setBrush(m_eraser); |
285 m_pen.setBrush(m_eraser); |
278 else |
286 else |
279 m_pen.setBrush(m_brush); |
287 m_pen.setBrush(m_brush); |
280 params.width = penWidth; |
288 params.width = penWidth; |
281 } |
289 } else |
282 |
290 if(isSpecial) |
283 params.points.append(QPoint(px, py)); |
291 { |
|
292 QPainterPath path; |
|
293 path.addEllipse(QPointF(px, py), 10, 10); |
|
294 |
|
295 addPath(path); |
|
296 |
|
297 qint16 x = qToBigEndian(px); |
|
298 qint16 y = qToBigEndian(py); |
|
299 m_specialPoints.append((const char *)&x, 2); |
|
300 m_specialPoints.append((const char *)&y, 2); |
|
301 m_specialPoints.append((const char *)&flags, 1); |
|
302 } |
|
303 |
|
304 if(!isSpecial) |
|
305 params.points.append(QPoint(px, py)); |
284 } |
306 } |
285 |
307 |
286 if(params.points.size()) |
308 if(params.points.size()) |
287 { |
309 { |
288 addPath(pointsToPath(params.points), m_pen); |
310 addPath(pointsToPath(params.points), m_pen); |