mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Printing: scale fonts when printing
This seem to work better, but it misses a couple of items at times (for example the highest label on some of the axis). Needs lots more testing. See #590 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2d77788cb2
commit
76a8e83a54
5 changed files with 30 additions and 4 deletions
|
@ -136,6 +136,7 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
|
||||||
const int profileFrameStyle = profile->frameStyle();
|
const int profileFrameStyle = profile->frameStyle();
|
||||||
profile->setFrameStyle(QFrame::NoFrame);
|
profile->setFrameStyle(QFrame::NoFrame);
|
||||||
profile->setPrintMode(true, !printOptions->color_selected);
|
profile->setPrintMode(true, !printOptions->color_selected);
|
||||||
|
profile->setFontPrintScale(0.4); // does a single scale work for all layouts???
|
||||||
QSize originalSize = profile->size();
|
QSize originalSize = profile->size();
|
||||||
// swap rows/col for landscape
|
// swap rows/col for landscape
|
||||||
if (printer->orientation() == QPrinter::Landscape) {
|
if (printer->orientation() == QPrinter::Landscape) {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "diveplotdatamodel.h"
|
#include "diveplotdatamodel.h"
|
||||||
#include "animationfunctions.h"
|
#include "animationfunctions.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -132,7 +133,7 @@ void emptyList(QList<T *> &list, double steps)
|
||||||
|
|
||||||
void DiveCartesianAxis::updateTicks(color_indice_t color)
|
void DiveCartesianAxis::updateTicks(color_indice_t color)
|
||||||
{
|
{
|
||||||
if (!scene() || !changed)
|
if (!scene() || (!changed && !MainWindow::instance()->graphics()->getPrintMode()))
|
||||||
return;
|
return;
|
||||||
QLineF m = line();
|
QLineF m = line();
|
||||||
// unused so far:
|
// unused so far:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "divetextitem.h"
|
#include "divetextitem.h"
|
||||||
#include "animationfunctions.h"
|
#include "animationfunctions.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -61,11 +62,11 @@ void DiveTextItem::updateText()
|
||||||
QFont fnt(qApp->font());
|
QFont fnt(qApp->font());
|
||||||
if ((size = fnt.pixelSize()) > 0) {
|
if ((size = fnt.pixelSize()) > 0) {
|
||||||
// set in pixels - so the scale factor may not make a difference if it's too close to 1
|
// set in pixels - so the scale factor may not make a difference if it's too close to 1
|
||||||
size *= scale;
|
size *= scale * MainWindow::instance()->graphics()->getFontPrintScale();
|
||||||
fnt.setPixelSize(size);
|
fnt.setPixelSize(size);
|
||||||
} else {
|
} else {
|
||||||
size = fnt.pointSizeF();
|
size = fnt.pointSizeF();
|
||||||
size *= scale;
|
size *= scale * MainWindow::instance()->graphics()->getFontPrintScale();;
|
||||||
fnt.setPointSizeF(size);
|
fnt.setPointSizeF(size);
|
||||||
}
|
}
|
||||||
QFontMetrics fm(fnt);
|
QFontMetrics fm(fnt);
|
||||||
|
|
|
@ -90,7 +90,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
|
||||||
isGrayscale(false),
|
isGrayscale(false),
|
||||||
printMode(false),
|
printMode(false),
|
||||||
shouldCalculateMaxTime(true),
|
shouldCalculateMaxTime(true),
|
||||||
shouldCalculateMaxDepth(true)
|
shouldCalculateMaxDepth(true),
|
||||||
|
fontPrintScale(1.0)
|
||||||
{
|
{
|
||||||
memset(&plotInfo, 0, sizeof(plotInfo));
|
memset(&plotInfo, 0, sizeof(plotInfo));
|
||||||
|
|
||||||
|
@ -1054,12 +1055,30 @@ void ProfileWidget2::changeGas()
|
||||||
replot();
|
replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProfileWidget2::getPrintMode()
|
||||||
|
{
|
||||||
|
return printMode;
|
||||||
|
}
|
||||||
|
|
||||||
void ProfileWidget2::setPrintMode(bool mode, bool grayscale)
|
void ProfileWidget2::setPrintMode(bool mode, bool grayscale)
|
||||||
{
|
{
|
||||||
printMode = mode;
|
printMode = mode;
|
||||||
isGrayscale = mode ? grayscale : false;
|
isGrayscale = mode ? grayscale : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProfileWidget2::setFontPrintScale(double scale)
|
||||||
|
{
|
||||||
|
fontPrintScale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
double ProfileWidget2::getFontPrintScale()
|
||||||
|
{
|
||||||
|
if (printMode)
|
||||||
|
return fontPrintScale;
|
||||||
|
else
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
void ProfileWidget2::editName()
|
void ProfileWidget2::editName()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
QAction *action = qobject_cast<QAction *>(sender());
|
||||||
|
|
|
@ -71,9 +71,12 @@ public:
|
||||||
virtual bool eventFilter(QObject *, QEvent *);
|
virtual bool eventFilter(QObject *, QEvent *);
|
||||||
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
|
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
|
||||||
void setPrintMode(bool mode, bool grayscale = false);
|
void setPrintMode(bool mode, bool grayscale = false);
|
||||||
|
bool getPrintMode();
|
||||||
bool isPointOutOfBoundaries(const QPointF &point) const;
|
bool isPointOutOfBoundaries(const QPointF &point) const;
|
||||||
bool isPlanner();
|
bool isPlanner();
|
||||||
bool isAddOrPlanner();
|
bool isAddOrPlanner();
|
||||||
|
double getFontPrintScale();
|
||||||
|
void setFontPrintScale(double scale);
|
||||||
State currentState;
|
State currentState;
|
||||||
|
|
||||||
public
|
public
|
||||||
|
@ -174,6 +177,7 @@ private:
|
||||||
bool shouldCalculateMaxDepth;
|
bool shouldCalculateMaxDepth;
|
||||||
int maxtime;
|
int maxtime;
|
||||||
int maxdepth;
|
int maxdepth;
|
||||||
|
double fontPrintScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROFILEWIDGET2_H
|
#endif // PROFILEWIDGET2_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue