Corrected bugs in the print feature.

* Bug: In Hurricane, in CellWidget, do *not* rescale iteratively the _initialSide
    attribute under high DPI (do it once).
* Bug: In Hurricane, in CellPrinter, suppress the divide by 4 scaling of the
    printer widget. Don't remember why I did so, and it generate too small
    pictures.
This commit is contained in:
Jean-Paul Chaput 2016-02-25 14:31:29 +01:00
parent cdacecd32b
commit 0f1775a77c
2 changed files with 23 additions and 19 deletions

View File

@ -1,8 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2012-2012, All Rights Reserved // Copyright (c) UPMC 2012-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | H U R R I C A N E | // | H U R R I C A N E |
@ -294,13 +293,15 @@ namespace Hurricane {
_paperWidth = _printer->width (); _paperWidth = _printer->width ();
_paperHeight = _printer->height (); _paperHeight = _printer->height ();
_drawingWidth = _paperWidth /4 - (frameMargin()<<1); //_drawingWidth = _paperWidth /4 - (frameMargin()<<1);
_drawingHeight = _paperHeight/4 - (frameMargin()<<1); //_drawingHeight = _paperHeight/4 - (frameMargin()<<1);
_drawingWidth = _paperWidth - (frameMargin()<<1);
_drawingHeight = _paperHeight - (frameMargin()<<1);
_xpaper = (imageOnly) ? 0 : frameMargin(); _xpaper = (imageOnly) ? 0 : frameMargin();
_ypaper = (imageOnly) ? 0 : frameMargin(); _ypaper = (imageOnly) ? 0 : frameMargin();
// Substract the cartouche size only for A4 format. // Substract the cartouche size only for A4 format.
cerr << _printer->paperSize() << endl; //cerr << _printer->paperSize() << endl;
if ( _printer->orientation() == QPrinter::Landscape ) { if ( _printer->orientation() == QPrinter::Landscape ) {
_drawingWidth -= cartoucheHeight(); _drawingWidth -= cartoucheHeight();
} else { } else {
@ -308,12 +309,13 @@ namespace Hurricane {
} }
// Compute the delta size between CellPrinter and CellWidget. // Compute the delta size between CellPrinter and CellWidget.
cerr << "(paperw,paperh) = (" << _paperWidth << "," << _paperHeight << ")" << endl; // cerr << "(paperw,paperh) = (" << _paperWidth << "," << _paperHeight << ")" << endl;
cerr << "CellPrinter:" << geometry().width() << "x" << geometry().height() << endl; // cerr << "CellPrinter: " << geometry().width() << "x" << geometry().height() << endl;
cerr << "CellWidget: " << _cellWidget->geometry().width() << "x" << _cellWidget->geometry().height() << endl; // cerr << "CellWidget: " << _cellWidget->geometry().width() << "x" << _cellWidget->geometry().height() << endl;
cerr << "resize: " << _drawingWidth << "x" << _drawingHeight << endl; // cerr << "ScreenCellWidget: " << _screenCellWidget->geometry().width() << "x" << _screenCellWidget->geometry().height() << endl;
cerr << "AbutmentBox:" << _cellWidget->getCell()->getAbutmentBox() << endl; // cerr << "resize: " << _drawingWidth << "x" << _drawingHeight << endl;
cerr << "visibleArea:" << _cellWidget->getVisibleArea() << endl; // cerr << "AbutmentBox: " << _cellWidget->getCell()->getAbutmentBox() << endl;
// cerr << "visibleArea: " << _cellWidget->getVisibleArea() << endl;
// Resize the pixel window to the size of the paper usable area. // Resize the pixel window to the size of the paper usable area.
// Then redraw the same visible area (in Hurricane coordinates). // Then redraw the same visible area (in Hurricane coordinates).
@ -326,15 +328,17 @@ namespace Hurricane {
Box visibleArea = _screenCellWidget->getVisibleArea(); Box visibleArea = _screenCellWidget->getVisibleArea();
if ( visibleArea.contains(_screenCellWidget->getCell()->getAbutmentBox()) ) { if ( visibleArea.contains(_screenCellWidget->getCell()->getAbutmentBox()) ) {
//cerr << "fit to AB" << endl;
setFitOnAbutmentBox( true ); setFitOnAbutmentBox( true );
_cellWidget->fitToContents(); _cellWidget->fitToContents();
} else { } else {
//cerr << "reframe" << endl;
_cellWidget->reframe( _screenCellWidget->getVisibleArea() ); _cellWidget->reframe( _screenCellWidget->getVisibleArea() );
} }
cerr << "After resize CellWidget: " << _cellWidget->geometry().width() << "x" << _cellWidget->geometry().height() << endl; // cerr << "After resize CellWidget: " << _cellWidget->geometry().width() << "x" << _cellWidget->geometry().height() << endl;
cerr << "visibleArea(printer):" << _cellWidget->getVisibleArea() << endl; // cerr << "visibleArea(printer): " << _cellWidget->getVisibleArea() << endl;
cerr << "visibleArea(screen): " << _screenCellWidget->getVisibleArea() << endl; // cerr << "visibleArea(screen): " << _screenCellWidget->getVisibleArea() << endl;
//cerr << "(xpaper,ypaper) = (" << xpaper << "," << ypaper << ")" << endl; //cerr << "(xpaper,ypaper) = (" << xpaper << "," << ypaper << ")" << endl;
//cerr << "(w,h) = (" << w << "," << h << ")" << endl; //cerr << "(w,h) = (" << w << "," << h << ")" << endl;

View File

@ -1084,8 +1084,8 @@ namespace Hurricane {
QFont font = Graphics::getNormalFont(); QFont font = Graphics::getNormalFont();
_textFontHeight = QFontMetrics(font).ascent(); _textFontHeight = QFontMetrics(font).ascent();
_initialSide = Graphics::toHighDpi( _initialSide ); if (Graphics::isHighDpi()) resize( Graphics::toHighDpi(_initialSide)
if (Graphics::isHighDpi()) resize( _initialSide, _initialSide ); , Graphics::toHighDpi(_initialSide) );
} }
@ -1196,7 +1196,7 @@ namespace Hurricane {
QSize CellWidget::minimumSizeHint () const QSize CellWidget::minimumSizeHint () const
{ {
return QSize(_initialSide,_initialSide); return QSize(Graphics::toHighDpi(_initialSide),Graphics::toHighDpi(_initialSide));
} }
@ -1615,7 +1615,7 @@ namespace Hurricane {
{ {
QFont font = Graphics::getNormalFont(flags&Bold); QFont font = Graphics::getNormalFont(flags&Bold);
if ( flags & BigFont ) font.setPointSize ( 18 ); if ( flags & BigFont ) font.setPointSize ( Graphics::isHighDpi() ? 7 : 18 );
QFontMetrics metrics = QFontMetrics(font); QFontMetrics metrics = QFontMetrics(font);
int width = metrics.width ( text ); int width = metrics.width ( text );
@ -1639,7 +1639,7 @@ namespace Hurricane {
painter.save(); painter.save();
if ( flags & Reverse ) painter.setPen ( Graphics::getPen("background") ); if ( flags & Reverse ) painter.setPen ( Graphics::getPen("background") );
if ( flags & Reverse ) painter.setBackgroundMode ( Qt::OpaqueMode ); if ( flags & Reverse ) painter.setBackgroundMode ( Qt::OpaqueMode );
if ( flags & BigFont ) font.setPointSize ( 18 ); if ( flags & BigFont ) font.setPointSize ( Graphics::isHighDpi() ? 7 : 18 );
QFontMetrics metrics = QFontMetrics(font); QFontMetrics metrics = QFontMetrics(font);
int width = metrics.width ( text ); int width = metrics.width ( text );