[2014-07-25 02:10:18 +0300] Lubomir I. Ivanov:
> i need 10 more minutes and will supply a patch.

Me too!

Here is a (very) quick and dirty patch. It's definitely not the fix we
want in a pure Subsurface, but it gets the job done so printing on Linux
gives pretty plots (no think lines and no pixelization).

-- 
Gaetan
>From fb52a5d4d22d7e90f51a7138650c176bfaa173f0 Mon Sep 17 00:00:00 2001
From: Gaetan Bisson <bis...@archlinux.org>
Date: Thu, 24 Jul 2014 13:24:31 -1000
Subject: [PATCH] Increase printing resolution

This quick and dirty fix increases the printing resolution three-fold to
make the rasterized profile legible. There might be issues left. Oh,
yes: the font size should be restored to their original values
otherwise, going back to any dive profile view after printing, the
labels appear much too big.

Signed-off-by: Gaetan Bisson <bis...@archlinux.org>
---
 qt-ui/printlayout.cpp | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index 4b368db..d470e0f 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -89,8 +89,8 @@ void PrintLayout::setup()
 	printerDpi = printer->resolution();
 	pageRect = printer->pageRect();
 
-	scaleX = (qreal)printerDpi / (qreal)screenDpiX;
-	scaleY = (qreal)printerDpi / (qreal)screenDpiY;
+	scaleX = (qreal)printerDpi / (qreal)screenDpiX / 3;
+	scaleY = (qreal)printerDpi / (qreal)screenDpiY / 3;
 
 	// a printer page scalled to screen DPI
 	scaledPageW = pageRect.width() / scaleX;
@@ -149,7 +149,8 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
 	const int profileFrameStyle = profile->frameStyle();
 	profile->setFrameStyle(QFrame::NoFrame);
 	profile->setPrintMode(true, !printOptions->color_selected);
-	profile->setFontPrintScale(0.4); // does a single scale work for all layouts???
+	// for more than 3 dives per page we use a smaller font
+	profile->setFontPrintScale(((divesPerColumn * divesPerRow > 3) ? 0.4 : 0.6) * 3);
 	QSize originalSize = profile->size();
 	// swap rows/col for landscape
 	if (printer->orientation() == QPrinter::Landscape) {
@@ -169,7 +170,7 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
 	const int padPT = 5;
 	// create a model and table
 	ProfilePrintModel model;
-	model.setFontsize(divesPerColumn == 1 ? 6.5 : 4.5);
+	model.setFontsize((divesPerColumn == 1 ? 6.5 : 4.5) * 3);
 	// if there is only one dive per page row we pass fitNotesToHeight to be almost half the page height
 	QPointer<QTableView> table(createProfileTable(&model, scaledW, (divesPerRow == 1) ? scaledH * 0.45 : 0.0));
 	// profilePrintTableMaxH updates after the table is created
@@ -277,7 +278,7 @@ QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int
 	for (i = 0; i < rows; i++) {
 		int h = (i == rows - 1 && fitNotesToHeight != 0.0) ? fitNotesToHeight : profilePrintRowHeights.at(i);
 		profilePrintTableMaxH += h;
-		vHeader->resizeSection(i, h);
+		vHeader->resizeSection(i, 3 * h);
 	}
 
 	// resize columns. columns widths are percentages from the table width.
@@ -293,7 +294,7 @@ QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int
 	table->resize(tableW, profilePrintTableMaxH);
 	// hide the grid and set a stylesheet
 	table->setItemDelegate(new ProfilePrintDelegate(table));
-	table->setItemDelegateForRow(7, new HTMLDelegate(table));
+	table->setItemDelegateForRow(3 * 7, new HTMLDelegate(table));
 
 	table->setShowGrid(false);
 	table->setStyleSheet(
-- 
2.0.2

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to