mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Added support for hi-resolution printing
This commit is contained in:
parent
8b7422b70a
commit
ebf39f11bd
24
src/gui.cpp
24
src/gui.cpp
@ -854,15 +854,6 @@ void GUI::closePOIFiles()
|
||||
_poi->clear();
|
||||
}
|
||||
|
||||
void GUI::printFile()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
QPrintDialog dialog(&printer, this);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
plot(&printer);
|
||||
}
|
||||
|
||||
void GUI::openOptions()
|
||||
{
|
||||
Options options(_options);
|
||||
@ -948,6 +939,15 @@ void GUI::openOptions()
|
||||
_options = options;
|
||||
}
|
||||
|
||||
void GUI::printFile()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
QPrintDialog dialog(&printer, this);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
plot(&printer);
|
||||
}
|
||||
|
||||
void GUI::exportFile()
|
||||
{
|
||||
ExportDialog dialog(&_export, this);
|
||||
@ -1028,7 +1028,7 @@ void GUI::plot(QPrinter *printer)
|
||||
} else
|
||||
gh = 0;
|
||||
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||
- (ih + 2*mh + gh)));
|
||||
- (ih + 2*mh + gh)), _options.hiresPrint);
|
||||
|
||||
if (_graphTabWidget->isVisible() && _options.separateGraphPage) {
|
||||
printer->newPage();
|
||||
@ -1638,6 +1638,8 @@ void GUI::writeSettings()
|
||||
settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL);
|
||||
if (_options.pixmapCache != PIXMAP_CACHE_DEFAULT)
|
||||
settings.setValue(PIXMAP_CACHE_SETTING, _options.pixmapCache);
|
||||
if (_options.hiresPrint != HIRES_PRINT_DEFAULT)
|
||||
settings.setValue(HIRES_PRINT_SETTING, _options.hiresPrint);
|
||||
if (_options.printName != PRINT_NAME_DEFAULT)
|
||||
settings.setValue(PRINT_NAME_SETTING, _options.printName);
|
||||
if (_options.printDate != PRINT_DATE_DEFAULT)
|
||||
@ -1835,6 +1837,8 @@ void GUI::readSettings()
|
||||
.toBool();
|
||||
_options.pixmapCache = settings.value(PIXMAP_CACHE_SETTING,
|
||||
PIXMAP_CACHE_DEFAULT).toInt();
|
||||
_options.hiresPrint = settings.value(HIRES_PRINT_SETTING,
|
||||
HIRES_PRINT_DEFAULT).toBool();
|
||||
_options.printName = settings.value(PRINT_NAME_SETTING, PRINT_NAME_DEFAULT)
|
||||
.toBool();
|
||||
_options.printDate = settings.value(PRINT_DATE_SETTING, PRINT_DATE_DEFAULT)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QGroupBox>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QRadioButton>
|
||||
#include <QLabel>
|
||||
#include <QSysInfo>
|
||||
#include "config.h"
|
||||
@ -265,6 +266,36 @@ QWidget *OptionsDialog::createPOIPage()
|
||||
|
||||
QWidget *OptionsDialog::createExportPage()
|
||||
{
|
||||
_wysiwyg = new QRadioButton(tr("WYSIWYG"));
|
||||
_hires = new QRadioButton(tr("Hi-Resolution"));
|
||||
if (_options->hiresPrint)
|
||||
_hires->setChecked(true);
|
||||
else
|
||||
_wysiwyg->setChecked(true);
|
||||
QLabel *lw = new QLabel(tr("The printed area is approximately the display"
|
||||
" area. The map zoom level does not change."));
|
||||
QLabel *lh = new QLabel(tr("The zoom level will be changed so that"
|
||||
" the content still fits to the printed area and the map resolution is as"
|
||||
" close as possible to the printer resolution."));
|
||||
QFont f = lw->font();
|
||||
f.setPointSize(f.pointSize() - 1);
|
||||
lw->setWordWrap(true);
|
||||
lh->setWordWrap(true);
|
||||
lw->setFont(f);
|
||||
lh->setFont(f);
|
||||
|
||||
QVBoxLayout *modeTabLayout = new QVBoxLayout();
|
||||
modeTabLayout->addWidget(_wysiwyg);
|
||||
modeTabLayout->addWidget(lw);
|
||||
modeTabLayout->addSpacing(10);
|
||||
modeTabLayout->addWidget(_hires);
|
||||
modeTabLayout->addWidget(lh);
|
||||
modeTabLayout->addStretch();
|
||||
|
||||
QWidget *modeTab = new QWidget();
|
||||
modeTab->setLayout(modeTabLayout);
|
||||
|
||||
|
||||
_name = new QCheckBox(tr("Name"));
|
||||
_name->setChecked(_options->printName);
|
||||
_date = new QCheckBox(tr("Date"));
|
||||
@ -300,6 +331,7 @@ QWidget *OptionsDialog::createExportPage()
|
||||
|
||||
|
||||
QTabWidget *exportPage = new QTabWidget();
|
||||
exportPage->addTab(modeTab, tr("Print mode"));
|
||||
exportPage->addTab(headerTab, tr("Header"));
|
||||
exportPage->addTab(graphTab, tr("Graphs"));
|
||||
|
||||
@ -422,6 +454,7 @@ void OptionsDialog::accept()
|
||||
_options->useOpenGL = _useOpenGL->isChecked();
|
||||
_options->pixmapCache = _pixmapCache->value();
|
||||
|
||||
_options->hiresPrint = _hires->isChecked();
|
||||
_options->printName = _name->isChecked();
|
||||
_options->printDate = _date->isChecked();
|
||||
_options->printDistance = _distance->isChecked();
|
||||
|
@ -12,6 +12,7 @@ class QSpinBox;
|
||||
class QDoubleSpinBox;
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
class QRadioButton;
|
||||
class PercentSlider;
|
||||
|
||||
struct Options {
|
||||
@ -40,6 +41,7 @@ struct Options {
|
||||
bool useOpenGL;
|
||||
int pixmapCache;
|
||||
// Print/Export
|
||||
bool hiresPrint;
|
||||
bool printName;
|
||||
bool printDate;
|
||||
bool printDistance;
|
||||
@ -96,6 +98,8 @@ private:
|
||||
QSpinBox *_pixmapCache;
|
||||
QCheckBox *_useOpenGL;
|
||||
// Print/Export
|
||||
QRadioButton *_wysiwyg;
|
||||
QRadioButton *_hires;
|
||||
QCheckBox *_name;
|
||||
QCheckBox *_date;
|
||||
QCheckBox *_distance;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <QWheelEvent>
|
||||
#include <QApplication>
|
||||
#include <QPixmapCache>
|
||||
#include "config.h"
|
||||
#include "opengl.h"
|
||||
#include "misc.h"
|
||||
#include "poi.h"
|
||||
@ -471,12 +472,16 @@ void PathView::keyPressEvent(QKeyEvent *event)
|
||||
zoom(z, pos, c);
|
||||
}
|
||||
|
||||
void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
void PathView::plot(QPainter *painter, const QRectF &target, bool hires)
|
||||
{
|
||||
QRect orig, adj;
|
||||
qreal ratio, diff;
|
||||
qreal ratio, diff, origRes;
|
||||
QPointF origScene;
|
||||
Coordinates origLL;
|
||||
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
|
||||
orig = viewport()->rect();
|
||||
|
||||
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
|
||||
@ -489,7 +494,20 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
|
||||
}
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
if (hires) {
|
||||
origScene = mapToScene(orig.center());
|
||||
origLL = _map->xy2ll(origScene);
|
||||
origRes = _map->resolution(origScene);
|
||||
|
||||
qreal r = painter->device()->logicalDpiX() / SCREEN_DPI;
|
||||
adj.setSize(QSize(adj.width() * r, adj.height() * r));
|
||||
_map->zoomFit(adj.size(), _tr | _rr | _wr);
|
||||
rescale();
|
||||
QPointF center = contentCenter();
|
||||
centerOn(center);
|
||||
adj.moveCenter(mapFromScene(center));
|
||||
}
|
||||
|
||||
_plot = true;
|
||||
_map->setBlockingMode(true);
|
||||
|
||||
@ -504,6 +522,13 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
|
||||
_map->setBlockingMode(false);
|
||||
_plot = false;
|
||||
|
||||
if (hires) {
|
||||
_map->zoomFit(origRes, origLL);
|
||||
rescale();
|
||||
centerOn(origScene);
|
||||
}
|
||||
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
void setMap(Map *map);
|
||||
void setUnits(enum Units units);
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
void plot(QPainter *painter, const QRectF &target, bool hires);
|
||||
|
||||
int trackCount() const {return _tracks.count();}
|
||||
int routeCount() const {return _routes.count();}
|
||||
|
@ -114,6 +114,8 @@
|
||||
#define USE_OPENGL_DEFAULT false
|
||||
#define PIXMAP_CACHE_SETTING "pixmapCache"
|
||||
#define PIXMAP_CACHE_DEFAULT 64 /* MB */
|
||||
#define HIRES_PRINT_SETTING "hiresPrint"
|
||||
#define HIRES_PRINT_DEFAULT false
|
||||
#define PRINT_NAME_SETTING "printName"
|
||||
#define PRINT_NAME_DEFAULT true
|
||||
#define PRINT_DATE_SETTING "printDate"
|
||||
|
Loading…
Reference in New Issue
Block a user