mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Added support for maps in PDF export
This commit is contained in:
parent
969d87ec51
commit
36937d8f2d
@ -357,10 +357,7 @@ void TrackView::plot(QPainter *painter, const QRectF &target)
|
|||||||
QRectF orig, adj;
|
QRectF orig, adj;
|
||||||
qreal ratio, diff;
|
qreal ratio, diff;
|
||||||
|
|
||||||
_scene->removeItem(_mapScale);
|
orig = viewport()->rect();
|
||||||
orig = _scene->itemsBoundingRect().adjusted(0, 0, 0,
|
|
||||||
_mapScale->boundingRect().height());
|
|
||||||
_scene->addItem(_mapScale);
|
|
||||||
|
|
||||||
if (target.width()/target.height() > orig.width()/orig.height()) {
|
if (target.width()/target.height() > orig.width()/orig.height()) {
|
||||||
ratio = target.width()/target.height();
|
ratio = target.width()/target.height();
|
||||||
@ -368,17 +365,15 @@ void TrackView::plot(QPainter *painter, const QRectF &target)
|
|||||||
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
|
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
|
||||||
} else {
|
} else {
|
||||||
ratio = target.height()/target.width();
|
ratio = target.height()/target.width();
|
||||||
diff = fabs((orig.width() * ratio) - orig.height());
|
diff = qAbs((orig.width() * ratio) - orig.height());
|
||||||
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
_mapScale->setPos(adj.bottomRight()
|
_mapScale->setPos(mapToScene(QPointF(adj.bottomRight()
|
||||||
+ QPoint(-_mapScale->boundingRect().width(),
|
+ QPoint(-_mapScale->boundingRect().width(),
|
||||||
-_mapScale->boundingRect().height()));
|
-_mapScale->boundingRect().height())).toPoint()));
|
||||||
|
|
||||||
setTrackLineWidth(0);
|
render(painter, target, adj.toRect());
|
||||||
_scene->render(painter, target, adj);
|
|
||||||
setTrackLineWidth(TRACK_WIDTH * _scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum QPrinter::Orientation TrackView::orientation() const
|
enum QPrinter::Orientation TrackView::orientation() const
|
||||||
@ -445,13 +440,12 @@ void TrackView::drawBackground(QPainter *painter, const QRectF &rect)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setWorldMatrixEnabled(false);
|
|
||||||
|
|
||||||
QRectF rr(rect.topLeft() * _scale, rect.size());
|
QRectF rr(rect.topLeft() * _scale, rect.size());
|
||||||
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
||||||
_zoom);
|
_zoom);
|
||||||
QPointF tm = tile2mercator(tile, _zoom);
|
QPointF tm = tile2mercator(tile, _zoom);
|
||||||
QPoint tl = mapFromScene(QPointF(tm.x() / _scale, -tm.y() / _scale));
|
QPoint tl = mapToScene(mapFromScene(QPointF(tm.x() / _scale,
|
||||||
|
-tm.y() / _scale))).toPoint();
|
||||||
|
|
||||||
QList<Tile> tiles;
|
QList<Tile> tiles;
|
||||||
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
|
for (int i = 0; i <= rr.size().width() / TILE_SIZE + 1; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user