1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Make the file info and graph info having the same text size in plots.

This commit is contained in:
Martin Tůma 2016-05-22 11:54:27 +02:00
parent b713da0012
commit 2ad94947d7
3 changed files with 20 additions and 5 deletions

View File

@ -11,6 +11,7 @@
#define FONT_FAMILY "Arial" #define FONT_FAMILY "Arial"
#define FONT_SIZE 12 #define FONT_SIZE 12
#define SCREEN_DPI 96.0
#define MAP_FILE QString("maps.txt") #define MAP_FILE QString("maps.txt")
#define POI_DIR QString("POI") #define POI_DIR QString("POI")

View File

@ -1,6 +1,8 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QEvent> #include <QEvent>
#include <QPaintEngine>
#include <QPaintDevice>
#include "config.h" #include "config.h"
#include "axisitem.h" #include "axisitem.h"
#include "slideritem.h" #include "slideritem.h"
@ -237,15 +239,15 @@ void GraphView::resizeEvent(QResizeEvent *)
void GraphView::plot(QPainter *painter, const QRectF &target) void GraphView::plot(QPainter *painter, const QRectF &target)
{ {
qreal ratio = target.width() / target.height(); qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
QSizeF orig = _scene->sceneRect().size(); / SCREEN_DPI;
QSizeF canvas = QSizeF(orig.height() * ratio, orig.height()); QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
setUpdatesEnabled(false); setUpdatesEnabled(false);
redraw(canvas); redraw(canvas);
if (_slider->pos().x() == _slider->area().left()) if (_slider->pos().x() == _slider->area().left())
_slider->hide(); _slider->hide();
_scene->render(painter, target, _scene->itemsBoundingRect()); _scene->render(painter, target);
_slider->show(); _slider->show();
redraw(); redraw();
setUpdatesEnabled(true); setUpdatesEnabled(true);

View File

@ -1,6 +1,10 @@
#include <QPaintEngine>
#include <QPaintDevice>
#include "config.h"
#include "infoitem.h" #include "infoitem.h"
#include "trackinfo.h" #include "trackinfo.h"
TrackInfo::TrackInfo(QObject *parent) : QGraphicsScene(parent) TrackInfo::TrackInfo(QObject *parent) : QGraphicsScene(parent)
{ {
_info = new InfoItem(); _info = new InfoItem();
@ -14,7 +18,15 @@ void TrackInfo::insert(const QString &key, const QString &value)
void TrackInfo::plot(QPainter *painter, const QRectF &target) void TrackInfo::plot(QPainter *painter, const QRectF &target)
{ {
render(painter, target); 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()));
QRectF adj = sceneRect().adjusted(0, -diff.height()/2, diff.width(),
diff.height()/2);
render(painter, target, adj);
} }
bool TrackInfo::isEmpty() bool TrackInfo::isEmpty()