@@ -1300,34 +1300,39 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
1300
1300
QFont tableContentFont;
1301
1301
tableContentFont.setPointSize ( 9 );
1302
1302
1303
+ QSettings s;
1304
+ double leftMargin = s.value ( " /Plugin-GeoReferencer/Config/LeftMarginPDF" , " 2.0" ).toDouble ();
1305
+ double rightMargin = s.value ( " /Plugin-GeoReferencer/Config/RightMarginPDF" , " 2.0" ).toDouble ();
1306
+ double contentWidth = 210 - ( leftMargin + rightMargin );
1307
+
1303
1308
// title
1304
1309
QFileInfo rasterFi ( mRasterFileName );
1305
1310
QgsComposerLabel* titleLabel = new QgsComposerLabel ( composition );
1306
1311
titleLabel->setFont ( titleFont );
1307
1312
titleLabel->setText ( rasterFi.fileName () );
1308
1313
composition->addItem ( titleLabel );
1309
- titleLabel->setSceneRect ( QRectF ( 2 , 5 , composition-> paperWidth () , 8 ) );
1314
+ titleLabel->setSceneRect ( QRectF ( leftMargin , 5 , contentWidth , 8 ) );
1310
1315
titleLabel->setFrame ( false );
1311
1316
1312
1317
// composer map
1313
1318
QgsRectangle canvasExtent = mCanvas ->extent ();
1314
1319
// calculate width and height considering extent aspect ratio and max Width 206, maxHeight 70
1315
- double widthExtentRatio = 206 / canvasExtent.width ();
1320
+ double widthExtentRatio = contentWidth / canvasExtent.width ();
1316
1321
double heightExtentRatio = 70 / canvasExtent.height ();
1317
1322
double mapWidthMM = 0 ;
1318
1323
double mapHeightMM = 0 ;
1319
1324
if ( widthExtentRatio < heightExtentRatio )
1320
1325
{
1321
- mapWidthMM = 206 ;
1322
- mapHeightMM = 206 / canvasExtent.width () * canvasExtent.height ();
1326
+ mapWidthMM = contentWidth ;
1327
+ mapHeightMM = contentWidth / canvasExtent.width () * canvasExtent.height ();
1323
1328
}
1324
1329
else
1325
1330
{
1326
1331
mapHeightMM = 70 ;
1327
1332
mapWidthMM = 70 / canvasExtent.height () * canvasExtent.width ();
1328
1333
}
1329
1334
1330
- QgsComposerMap* composerMap = new QgsComposerMap ( composition, 2 , titleLabel->rect ().bottom () + titleLabel->transform ().dy (), mapWidthMM, mapHeightMM );
1335
+ QgsComposerMap* composerMap = new QgsComposerMap ( composition, leftMargin , titleLabel->rect ().bottom () + titleLabel->transform ().dy (), mapWidthMM, mapHeightMM );
1331
1336
composerMap->setLayerSet ( canvasRenderer->layerSet () );
1332
1337
composerMap->setNewExtent ( mCanvas ->extent () );
1333
1338
composerMap->setMapCanvas ( mCanvas );
@@ -1344,7 +1349,6 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
1344
1349
bool wldTransform = transform.getOriginScaleRotation ( origin, scaleX, scaleY, rotation );
1345
1350
1346
1351
QString residualUnits;
1347
- QSettings s;
1348
1352
if ( s.value ( " /Plugin-GeoReferencer/Config/ResidualUnits" ) == " mapUnits" && mGeorefTransform .providesAccurateInverseTransformation () )
1349
1353
{
1350
1354
residualUnits = tr ( " map units" );
@@ -1362,7 +1366,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
1362
1366
parameterLabel->setText ( parameterTitle );
1363
1367
parameterLabel->adjustSizeToText ();
1364
1368
composition->addItem ( parameterLabel );
1365
- parameterLabel->setSceneRect ( QRectF ( 2 , composerMap->rect ().bottom () + composerMap->transform ().dy () + 5 , composition-> paperWidth () , 8 ) );
1369
+ parameterLabel->setSceneRect ( QRectF ( leftMargin , composerMap->rect ().bottom () + composerMap->transform ().dy () + 5 , contentWidth , 8 ) );
1366
1370
parameterLabel->setFrame ( false );
1367
1371
1368
1372
// calculate mean error
@@ -1379,7 +1383,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
1379
1383
row << QString::number ( origin.x (), ' f' , 3 ) << QString::number ( origin.y (), ' f' , 3 ) << QString::number ( scaleX ) << QString::number ( scaleY ) << QString::number ( rotation * 180 / M_PI ) << QString::number ( meanError );
1380
1384
parameterTable->addRow ( row );
1381
1385
composition->addItem ( parameterTable );
1382
- parameterTable->setSceneRect ( QRectF ( 2 , parameterLabel->rect ().bottom () + parameterLabel->transform ().dy () + 5 , 50 , 20 ) );
1386
+ parameterTable->setSceneRect ( QRectF ( leftMargin , parameterLabel->rect ().bottom () + parameterLabel->transform ().dy () + 5 , contentWidth , 20 ) );
1383
1387
parameterTable->setGridStrokeWidth ( 0.1 );
1384
1388
parameterTable->adjustFrameToSize ();
1385
1389
}
@@ -1394,13 +1398,13 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
1394
1398
residualLabel->setFont ( titleFont );
1395
1399
residualLabel->setText ( tr ( " Residuals" ) );
1396
1400
composition->addItem ( residualLabel );
1397
- residualLabel->setSceneRect ( QRectF ( 2 , previousItem->rect ().bottom () + previousItem->transform ().dy () + 5 , composition-> paperWidth () , 6 ) );
1401
+ residualLabel->setSceneRect ( QRectF ( leftMargin , previousItem->rect ().bottom () + previousItem->transform ().dy () + 5 , contentWidth , 6 ) );
1398
1402
residualLabel->setFrame ( false );
1399
1403
1400
1404
// residual plot
1401
1405
QgsResidualPlotItem* resPlotItem = new QgsResidualPlotItem ( composition );
1402
1406
composition->addItem ( resPlotItem );
1403
- resPlotItem->setSceneRect ( QRectF ( 2 , residualLabel->rect ().bottom () + residualLabel->transform ().dy () + 5 , composerMap-> rect (). width () , composerMap->rect ().height () ) );
1407
+ resPlotItem->setSceneRect ( QRectF ( leftMargin , residualLabel->rect ().bottom () + residualLabel->transform ().dy () + 5 , contentWidth , composerMap->rect ().height () ) );
1404
1408
resPlotItem->setExtent ( composerMap->extent () );
1405
1409
resPlotItem->setGCPList ( mPoints );
1406
1410
@@ -1437,7 +1441,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
1437
1441
1438
1442
composition->addItem ( gcpTable );
1439
1443
1440
- gcpTable->setSceneRect ( QRectF ( 2 , resPlotItem->rect ().bottom () + resPlotItem->transform ().dy () + 5 , 170 , 100 ) );
1444
+ gcpTable->setSceneRect ( QRectF ( leftMargin , resPlotItem->rect ().bottom () + resPlotItem->transform ().dy () + 5 , contentWidth , 100 ) );
1441
1445
gcpTable->setGridStrokeWidth ( 0.1 );
1442
1446
1443
1447
printer.setResolution ( composition->printResolution () );
0 commit comments