equal
deleted
inserted
replaced
302 return b; |
302 return b; |
303 } |
303 } |
304 |
304 |
305 void DrawMapScene::decode(QByteArray data) |
305 void DrawMapScene::decode(QByteArray data) |
306 { |
306 { |
|
307 hideCursor(); |
|
308 |
307 bool erasing = m_isErasing; |
309 bool erasing = m_isErasing; |
308 |
310 |
309 oldItems.clear(); |
311 oldItems.clear(); |
310 oldPaths.clear(); |
312 oldPaths.clear(); |
311 clear(); |
313 clear(); |
322 data.remove(0, 2); |
324 data.remove(0, 2); |
323 qint16 py = qFromBigEndian(*(qint16 *)data.data()); |
325 qint16 py = qFromBigEndian(*(qint16 *)data.data()); |
324 data.remove(0, 2); |
326 data.remove(0, 2); |
325 quint8 flags = *(quint8 *)data.data(); |
327 quint8 flags = *(quint8 *)data.data(); |
326 data.remove(0, 1); |
328 data.remove(0, 1); |
327 qDebug() << px << py; |
329 //qDebug() << px << py; |
328 if(flags & 0x80) |
330 if(flags & 0x80) |
329 { |
331 { |
330 isSpecial = false; |
332 isSpecial = false; |
331 |
333 |
332 if(params.points.size()) |
334 if(params.points.size()) |
483 if(qAbs(rotated.y() / rotated.x()) < 0.05) return initialPoint + transform.inverted().map(QPointF(rotated.x(), 0)); |
485 if(qAbs(rotated.y() / rotated.x()) < 0.05) return initialPoint + transform.inverted().map(QPointF(rotated.x(), 0)); |
484 } |
486 } |
485 |
487 |
486 return point; |
488 return point; |
487 } |
489 } |
|
490 |
|
491 void DrawMapScene::optimize() |
|
492 { |
|
493 if(!paths.size()) return; |
|
494 |
|
495 // break paths into segments |
|
496 Paths pth; |
|
497 |
|
498 foreach(const PathParams & pp, paths) |
|
499 { |
|
500 int l = pp.points.size(); |
|
501 |
|
502 if(l == 1) |
|
503 { |
|
504 pth.prepend(pp); |
|
505 } else |
|
506 { |
|
507 for(int i = l - 2; i >= 0; --i) |
|
508 { |
|
509 PathParams p = pp; |
|
510 p.points = QList<QPoint>() << p.points[i] << p.points[i + 1]; |
|
511 pth.prepend(pp); |
|
512 } |
|
513 } |
|
514 } |
|
515 |
|
516 // clear the scene |
|
517 oldItems.clear(); |
|
518 oldPaths.clear(); |
|
519 clear(); |
|
520 paths.clear(); |
|
521 m_specialPoints.clear(); |
|
522 |
|
523 // render the result |
|
524 foreach(const PathParams & p, pth) |
|
525 { |
|
526 if(p.erasing) |
|
527 m_pen.setBrush(m_eraser); |
|
528 else |
|
529 m_pen.setBrush(m_brush); |
|
530 |
|
531 m_pen.setWidth(deserializePenWidth(p.width)); |
|
532 |
|
533 addPath(pointsToPath(p.points), m_pen); |
|
534 } |
|
535 |
|
536 emit pathChanged(); |
|
537 } |