mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-03 12:10:57 -06:00
Render at resolution required to match widget size
This commit is contained in:
parent
81c092f2c4
commit
281fa24a2d
@ -84,7 +84,22 @@ void RicSnapshotViewToFileFeature::savePlotPDFReportAs( const QString& fileName,
|
||||
QFile pdfFile( fileName );
|
||||
if ( pdfFile.open( QIODevice::WriteOnly ) )
|
||||
{
|
||||
const int resolution = RiaGuiApplication::instance()->desktop()->logicalDpiX();
|
||||
int resolution = RiaGuiApplication::applicationResolution();
|
||||
int pageWidth = plot->pageLayout().fullRectPixels( resolution ).width();
|
||||
int widgetWidth = plot->viewWidget()->width();
|
||||
int deltaWidth = widgetWidth - pageWidth;
|
||||
|
||||
while ( std::abs( deltaWidth ) > 1 )
|
||||
{
|
||||
int newResolution = resolution + deltaWidth / std::abs( deltaWidth );
|
||||
pageWidth = plot->pageLayout().fullRectPixels( resolution ).width();
|
||||
int newDeltaWidth = widgetWidth - pageWidth;
|
||||
if ( std::abs( newDeltaWidth ) > std::abs( deltaWidth ) ) break;
|
||||
|
||||
resolution = newResolution;
|
||||
deltaWidth = newDeltaWidth;
|
||||
}
|
||||
|
||||
QPdfWriter pdfPrinter( fileName );
|
||||
pdfPrinter.setPageLayout( plot->pageLayout() );
|
||||
pdfPrinter.setCreator( QCoreApplication::applicationName() );
|
||||
|
Loading…
Reference in New Issue
Block a user