1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +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_SIZE 12
#define SCREEN_DPI 96.0
#define MAP_FILE QString("maps.txt")
#define POI_DIR QString("POI")

View File

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

View File

@ -1,6 +1,10 @@
#include <QPaintEngine>
#include <QPaintDevice>
#include "config.h"
#include "infoitem.h"
#include "trackinfo.h"
TrackInfo::TrackInfo(QObject *parent) : QGraphicsScene(parent)
{
_info = new InfoItem();
@ -14,7 +18,15 @@ void TrackInfo::insert(const QString &key, const QString &value)
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()