From e69f17aad55db2aa2e11d33af61c80d457294a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Wed, 30 Aug 2017 13:09:54 +0200 Subject: [PATCH] Print font size id now appropriate to the page size --- src/config.h | 3 +-- src/graphview.cpp | 4 +--- src/graphview.h | 2 +- src/gui.cpp | 12 +++++++----- src/pathview.cpp | 8 +++++--- src/trackinfo.cpp | 4 +--- src/trackinfo.h | 2 +- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/config.h b/src/config.h index 619a8462..cb2296b4 100644 --- a/src/config.h +++ b/src/config.h @@ -10,8 +10,7 @@ #define APP_HOMEPAGE "http://www.gpxsee.org" #define FONT_FAMILY "Arial" -#define FONT_SIZE 12 -#define SCREEN_DPI 96.0 +#define FONT_SIZE 12 // px #define ELLIPSOID_FILE QString("ellipsoids.csv") #define DATUM_FILE QString("datums.csv") diff --git a/src/graphview.cpp b/src/graphview.cpp index d27e2ba5..84f90ff2 100644 --- a/src/graphview.cpp +++ b/src/graphview.cpp @@ -326,10 +326,8 @@ void GraphView::mousePressEvent(QMouseEvent *e) QGraphicsView::mousePressEvent(e); } -void GraphView::plot(QPainter *painter, const QRectF &target) +void GraphView::plot(QPainter *painter, const QRectF &target, qreal ratio) { - qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX() - / SCREEN_DPI; QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio); setUpdatesEnabled(false); diff --git a/src/graphview.h b/src/graphview.h index 5c199cb8..2e496b7d 100644 --- a/src/graphview.h +++ b/src/graphview.h @@ -53,7 +53,7 @@ public: qreal sliderPosition() const {return _sliderPos;} void setSliderPosition(qreal pos); - void plot(QPainter *painter, const QRectF &target); + void plot(QPainter *painter, const QRectF &target, qreal ratio); void useOpenGL(bool use); diff --git a/src/gui.cpp b/src/gui.cpp index bb06e83e..d0de370b 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -1008,15 +1008,15 @@ void GUI::plot(QPrinter *printer) if (tm > 0 && _options.printMovingTime) info.insert(tr("Moving time"), Format::timeSpan(tm)); - - ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI; + qreal fsr = 96.0 / (qMax(printer->width(), printer->height()) / 3392.0); + ratio = p.paintEngine()->paintDevice()->logicalDpiX() / fsr; if (info.isEmpty()) { ih = 0; mh = 0; } else { ih = info.contentSize().height() * ratio; mh = ih / 2; - info.plot(&p, QRectF(0, 0, printer->width(), ih)); + info.plot(&p, QRectF(0, 0, printer->width(), ih), ratio); } if (_graphTabWidget->isVisible() && !_options.separateGraphPage) { qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height())); @@ -1025,7 +1025,8 @@ void GUI::plot(QPrinter *printer) : 0.15 * (printer->height() - ih - 2*mh); gh = qMax(gh, ratio * 150); GraphTab *gt = static_cast(_graphTabWidget->currentWidget()); - gt->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh)); + gt->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh), + ratio); } else gh = 0; _pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height() @@ -1046,7 +1047,8 @@ void GUI::plot(QPrinter *printer) qreal y = 0; for (int i = 0; i < _tabs.size(); i++) { if (_tabs.at(i)->count()) { - _tabs.at(i)->plot(&p, QRectF(0, y, printer->width(), gh)); + _tabs.at(i)->plot(&p, QRectF(0, y, printer->width(), gh), + ratio); y += gh + sp; } } diff --git a/src/pathview.cpp b/src/pathview.cpp index d367c951..3c1da6dd 100644 --- a/src/pathview.cpp +++ b/src/pathview.cpp @@ -498,9 +498,11 @@ void PathView::plot(QPainter *painter, const QRectF &target, bool hires) origLL = _map->xy2ll(origScene); origRes = _map->resolution(origScene); - qreal r = painter->device()->logicalDpiX() - / (qreal)metric(QPaintDevice::PdmDpiX); - adj.setSize(QSize(adj.width() * r, adj.height() * r)); + QPointF scale(painter->device()->logicalDpiX() + / (qreal)metric(QPaintDevice::PdmDpiX), + painter->device()->logicalDpiY() + / (qreal)metric(QPaintDevice::PdmDpiY)); + adj.setSize(QSize(adj.width() * scale.x(), adj.height() * scale.y())); _map->zoomFit(adj.size(), _tr | _rr | _wr); rescale(); QPointF center = contentCenter(); diff --git a/src/trackinfo.cpp b/src/trackinfo.cpp index 8dcf1dcf..14a65b6e 100644 --- a/src/trackinfo.cpp +++ b/src/trackinfo.cpp @@ -16,10 +16,8 @@ void TrackInfo::insert(const QString &key, const QString &value) _info->insert(key, value); } -void TrackInfo::plot(QPainter *painter, const QRectF &target) +void TrackInfo::plot(QPainter *painter, const QRectF &target, qreal ratio) { - qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX() - / SCREEN_DPI; QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio); QSizeF diff = QSizeF(qAbs(canvas.width() - sceneRect().width()), qAbs(canvas.height() - sceneRect().height())); diff --git a/src/trackinfo.h b/src/trackinfo.h index b27a6913..e7bd37a3 100644 --- a/src/trackinfo.h +++ b/src/trackinfo.h @@ -13,7 +13,7 @@ public: TrackInfo(QObject *parent = 0); void insert(const QString &key, const QString &value); - void plot(QPainter *painter, const QRectF &target); + void plot(QPainter *painter, const QRectF &target, qreal ratio); bool isEmpty() const; QSizeF contentSize() const;