Skip to content

Commit 05f1876

Browse files
author
mhugent
committed
Fix layout problems in georef pdf output by making size of left and right margins a user option
git-svn-id: http://svn.osgeo.org/qgis/trunk@13765 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 350fcc4 commit 05f1876

File tree

3 files changed

+87
-30
lines changed

3 files changed

+87
-30
lines changed

src/plugins/georeferencer/qgsgeorefconfigdialog.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ void QgsGeorefConfigDialog::readSettings()
8888
{
8989
mPixelsButton->setChecked( true );
9090
}
91+
92+
mLeftMarginSpinBox->setValue( s.value( "/Plugin-GeoReferencer/Config/LeftMarginPDF", "2.0" ).toDouble() );
93+
mRightMarginSpinBox->setValue( s.value( "/Plugin-GeoReferencer/Config/RightMarginPDF", "2.0" ).toDouble() );
9194
}
9295

9396
void QgsGeorefConfigDialog::writeSettings()
@@ -104,4 +107,6 @@ void QgsGeorefConfigDialog::writeSettings()
104107
{
105108
s.setValue( "/Plugin-GeoReferencer/Config/ResidualUnits", "mapUnits" );
106109
}
110+
s.setValue( "/Plugin-GeoReferencer/Config/LeftMarginPDF", mLeftMarginSpinBox->value() );
111+
s.setValue( "/Plugin-GeoReferencer/Config/RightMarginPDF", mRightMarginSpinBox->value() );
107112
}

src/plugins/georeferencer/qgsgeorefconfigdialogbase.ui

+67-19
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<x>0</x>
88
<y>0</y>
99
<width>249</width>
10-
<height>249</height>
10+
<height>344</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
1414
<string>Configure Georeferencer</string>
1515
</property>
16-
<layout class="QGridLayout" name="gridLayout_2">
16+
<layout class="QGridLayout" name="gridLayout_4">
1717
<item row="0" column="0">
1818
<widget class="QGroupBox" name="mPointTipGroupBox">
1919
<property name="title">
@@ -37,23 +37,6 @@
3737
</layout>
3838
</widget>
3939
</item>
40-
<item row="2" column="0">
41-
<widget class="QCheckBox" name="mShowDockedCheckBox">
42-
<property name="text">
43-
<string>Show Georeferencer window docked</string>
44-
</property>
45-
</widget>
46-
</item>
47-
<item row="3" column="0">
48-
<widget class="QDialogButtonBox" name="buttonBox">
49-
<property name="orientation">
50-
<enum>Qt::Horizontal</enum>
51-
</property>
52-
<property name="standardButtons">
53-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
54-
</property>
55-
</widget>
56-
</item>
5740
<item row="1" column="0">
5841
<widget class="QGroupBox" name="mResidualUnitsGroupBox">
5942
<property name="title">
@@ -77,6 +60,71 @@
7760
</layout>
7861
</widget>
7962
</item>
63+
<item row="2" column="0">
64+
<widget class="QGroupBox" name="mPdfReportGroupBox">
65+
<property name="title">
66+
<string>PDF report</string>
67+
</property>
68+
<layout class="QGridLayout" name="gridLayout_2">
69+
<item row="0" column="0">
70+
<layout class="QHBoxLayout" name="horizontalLayout">
71+
<item>
72+
<widget class="QLabel" name="label">
73+
<property name="text">
74+
<string>Left margin</string>
75+
</property>
76+
</widget>
77+
</item>
78+
<item>
79+
<widget class="QDoubleSpinBox" name="mLeftMarginSpinBox">
80+
<property name="prefix">
81+
<string/>
82+
</property>
83+
<property name="suffix">
84+
<string> mm</string>
85+
</property>
86+
</widget>
87+
</item>
88+
</layout>
89+
</item>
90+
<item row="1" column="0">
91+
<layout class="QHBoxLayout" name="horizontalLayout_2">
92+
<item>
93+
<widget class="QLabel" name="label_2">
94+
<property name="text">
95+
<string>Right margin</string>
96+
</property>
97+
</widget>
98+
</item>
99+
<item>
100+
<widget class="QDoubleSpinBox" name="mRightMarginSpinBox">
101+
<property name="suffix">
102+
<string> mm</string>
103+
</property>
104+
</widget>
105+
</item>
106+
</layout>
107+
</item>
108+
</layout>
109+
</widget>
110+
</item>
111+
<item row="3" column="0">
112+
<widget class="QCheckBox" name="mShowDockedCheckBox">
113+
<property name="text">
114+
<string>Show Georeferencer window docked</string>
115+
</property>
116+
</widget>
117+
</item>
118+
<item row="4" column="0">
119+
<widget class="QDialogButtonBox" name="buttonBox">
120+
<property name="orientation">
121+
<enum>Qt::Horizontal</enum>
122+
</property>
123+
<property name="standardButtons">
124+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
125+
</property>
126+
</widget>
127+
</item>
80128
</layout>
81129
</widget>
82130
<resources/>

src/plugins/georeferencer/qgsgeorefplugingui.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -1300,34 +1300,39 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
13001300
QFont tableContentFont;
13011301
tableContentFont.setPointSize( 9 );
13021302

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+
13031308
//title
13041309
QFileInfo rasterFi( mRasterFileName );
13051310
QgsComposerLabel* titleLabel = new QgsComposerLabel( composition );
13061311
titleLabel->setFont( titleFont );
13071312
titleLabel->setText( rasterFi.fileName() );
13081313
composition->addItem( titleLabel );
1309-
titleLabel->setSceneRect( QRectF( 2, 5, composition->paperWidth(), 8 ) );
1314+
titleLabel->setSceneRect( QRectF( leftMargin, 5, contentWidth, 8 ) );
13101315
titleLabel->setFrame( false );
13111316

13121317
//composer map
13131318
QgsRectangle canvasExtent = mCanvas->extent();
13141319
//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();
13161321
double heightExtentRatio = 70 / canvasExtent.height();
13171322
double mapWidthMM = 0;
13181323
double mapHeightMM = 0;
13191324
if ( widthExtentRatio < heightExtentRatio )
13201325
{
1321-
mapWidthMM = 206;
1322-
mapHeightMM = 206 / canvasExtent.width() * canvasExtent.height();
1326+
mapWidthMM = contentWidth;
1327+
mapHeightMM = contentWidth / canvasExtent.width() * canvasExtent.height();
13231328
}
13241329
else
13251330
{
13261331
mapHeightMM = 70;
13271332
mapWidthMM = 70 / canvasExtent.height() * canvasExtent.width();
13281333
}
13291334

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 );
13311336
composerMap->setLayerSet( canvasRenderer->layerSet() );
13321337
composerMap->setNewExtent( mCanvas->extent() );
13331338
composerMap->setMapCanvas( mCanvas );
@@ -1344,7 +1349,6 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
13441349
bool wldTransform = transform.getOriginScaleRotation( origin, scaleX, scaleY, rotation );
13451350

13461351
QString residualUnits;
1347-
QSettings s;
13481352
if ( s.value( "/Plugin-GeoReferencer/Config/ResidualUnits" ) == "mapUnits" && mGeorefTransform.providesAccurateInverseTransformation() )
13491353
{
13501354
residualUnits = tr( "map units" );
@@ -1362,7 +1366,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
13621366
parameterLabel->setText( parameterTitle );
13631367
parameterLabel->adjustSizeToText();
13641368
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 ) );
13661370
parameterLabel->setFrame( false );
13671371

13681372
//calculate mean error
@@ -1379,7 +1383,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
13791383
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 );
13801384
parameterTable->addRow( row );
13811385
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 ) );
13831387
parameterTable->setGridStrokeWidth( 0.1 );
13841388
parameterTable->adjustFrameToSize();
13851389
}
@@ -1394,13 +1398,13 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
13941398
residualLabel->setFont( titleFont );
13951399
residualLabel->setText( tr( "Residuals" ) );
13961400
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 ) );
13981402
residualLabel->setFrame( false );
13991403

14001404
//residual plot
14011405
QgsResidualPlotItem* resPlotItem = new QgsResidualPlotItem( composition );
14021406
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() ) );
14041408
resPlotItem->setExtent( composerMap->extent() );
14051409
resPlotItem->setGCPList( mPoints );
14061410

@@ -1437,7 +1441,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
14371441

14381442
composition->addItem( gcpTable );
14391443

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 ) );
14411445
gcpTable->setGridStrokeWidth( 0.1 );
14421446

14431447
printer.setResolution( composition->printResolution() );

0 commit comments

Comments
 (0)