Index: src/plugins/georeferencer/qgsresidualplotitem.cpp =================================================================== --- src/plugins/georeferencer/qgsresidualplotitem.cpp (revision 14080) +++ src/plugins/georeferencer/qgsresidualplotitem.cpp (working copy) @@ -44,12 +44,10 @@ double widthMM = rect().width(); double heightMM = rect().height(); - QPen enabledPen( QColor( 0, 0, 255, 255 ) ); - enabledPen.setWidthF( 0.4 ); - QPen disabledPen( QColor( 0, 0, 255, 127 ) ); - disabledPen.setWidthF( 0.3 ); - QBrush enabledBrush( QColor( 255, 0, 0, 255 ) ); - QBrush disabledBrush( QColor( 255, 0, 0, 127 ) ); + QPen enabledPen( QColor( 255, 0, 0, 255 ), 0.3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin ); + QPen disabledPen( QColor( 255, 0, 0, 85 ), 0.2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin ); + QBrush enabledBrush( QColor( 255, 255, 255, 255 ) ); + QBrush disabledBrush( QColor( 255, 255, 255, 127 ) ); //draw all points and collect minimal mm/pixel ratio double minMMPixelRatio = DBL_MAX; @@ -74,7 +72,7 @@ painter->setPen( disabledPen ); painter->setBrush( disabledBrush ); } - painter->drawRect( QRectF( gcpItemMMX - 1, gcpItemMMY - 1, 2, 2 ) ); + painter->drawRect( QRectF( gcpItemMMX - 0.5, gcpItemMMY - 0.5, 1, 1 ) ); drawText( painter, gcpItemMMX + 2, gcpItemMMY + 2, QString::number(( *gcpIt )->id() ), QFont() ); mmPixelRatio = maxMMToPixelRatioForGCP( *gcpIt, gcpItemMMX, gcpItemMMY ); Index: src/plugins/georeferencer/qgsgeorefplugingui.h =================================================================== --- src/plugins/georeferencer/qgsgeorefplugingui.h (revision 14080) +++ src/plugins/georeferencer/qgsgeorefplugingui.h (working copy) @@ -142,6 +142,7 @@ bool georeference(); bool writeWorldFile( QgsPoint origin, double pixelXSize, double pixelYSize, double rotation ); bool writePDFReportFile( const QString& fileName, const QgsGeorefTransform& transform ); + bool writePDFMapFile( const QString& fileName, const QgsGeorefTransform& transform ); void updateTransformParamLabel(); // gdal script @@ -201,6 +202,7 @@ QString mGCPpointsFileName; QString mProjection; QString mPdfOutputFile; + QString mPdfOutputMapFile; double mUserResX, mUserResY; // User specified target scale QgsGeorefTransform::TransformParametrisation mTransformParam; Index: src/plugins/georeferencer/qgsgeorefconfigdialogbase.ui =================================================================== --- src/plugins/georeferencer/qgsgeorefconfigdialogbase.ui (revision 14080) +++ src/plugins/georeferencer/qgsgeorefconfigdialogbase.ui (working copy) @@ -6,8 +6,8 @@ 0 0 - 249 - 344 + 309 + 468 @@ -108,14 +108,14 @@ - + Show Georeferencer window docked - + Qt::Horizontal @@ -125,6 +125,29 @@ + + + + PDF map + + + + + + + + Paper size + + + + + + + + + + + Index: src/plugins/georeferencer/qgstransformsettingsdialog.cpp =================================================================== --- src/plugins/georeferencer/qgstransformsettingsdialog.cpp (revision 14080) +++ src/plugins/georeferencer/qgstransformsettingsdialog.cpp (working copy) @@ -86,12 +86,13 @@ tbnOutputRaster->setIcon( getThemeIcon( "/mPushButtonFileOpen.png" ) ); tbnTargetSRS->setIcon( getThemeIcon( "/mPushButtonTargetSRSDisabled.png" ) ); tbnReportFile->setIcon( getThemeIcon( "/mActionSaveAsPDF.png" ) ); + tbnMapFile->setIcon( getThemeIcon( "/mActionSaveAsPDF.png" ) ); } void QgsTransformSettingsDialog::getTransformSettings( QgsGeorefTransform::TransformParametrisation &tp, QgsImageWarper::ResamplingMethod &rm, QString &comprMethod, QString &raster, - QString &proj, QString& pdfReportFile, bool &zt, bool &loadInQgis, + QString &proj, QString& pdfMapFile, QString& pdfReportFile, bool &zt, bool &loadInQgis, double& resX, double& resY ) { if ( cmbTransformType->currentIndex() == -1 ) @@ -110,6 +111,7 @@ raster = leOutputRaster->text(); } proj = leTargetSRS->text(); + pdfMapFile = mMapFileLineEdit->text(); pdfReportFile = mReportFileLineEdit->text(); zt = cbxZeroAsTrans->isChecked(); loadInQgis = cbxLoadInQgisWhenDone->isChecked(); @@ -244,6 +246,21 @@ } } +void QgsTransformSettingsDialog::on_tbnMapFile_clicked() +{ + QSettings s; + QString myLastUsedDir = s.value( "/Plugin-GeoReferencer/lastPDFReportDir", "" ).toString(); + QString outputFileName = QFileDialog::getSaveFileName( 0, tr( "Select save PDF file" ), myLastUsedDir, tr( "PDF Format" ) + " (*.pdf *PDF)" ); + if ( !outputFileName.isNull() ) + { + if ( !outputFileName.endsWith( ".pdf", Qt::CaseInsensitive ) ) + { + outputFileName.append( ".pdf" ); + } + mMapFileLineEdit->setText( outputFileName ); + } +} + void QgsTransformSettingsDialog::on_tbnReportFile_clicked() { QSettings s; Index: src/plugins/georeferencer/qgsgeorefconfigdialog.cpp =================================================================== --- src/plugins/georeferencer/qgsgeorefconfigdialog.cpp (revision 14080) +++ src/plugins/georeferencer/qgsgeorefconfigdialog.cpp (working copy) @@ -15,6 +15,7 @@ /* $Id$ */ #include #include +#include #include "qgsgeorefconfigdialog.h" @@ -24,6 +25,35 @@ setupUi( this ); readSettings(); + + mPaperSizeComboBox->addItem( tr( "A5 (148x210 mm)" ), QSizeF (148, 210 ) ); + mPaperSizeComboBox->addItem( tr( "A4 (210x297 mm)" ), QSizeF (210, 297 ) ); + mPaperSizeComboBox->addItem( tr( "A3 (297x420 mm)" ), QSizeF (297, 420 ) ); + mPaperSizeComboBox->addItem( tr( "A2 (420x594 mm)" ), QSizeF (420, 594 ) ); + mPaperSizeComboBox->addItem( tr( "A1 (594x841 mm)" ), QSizeF (594, 841 ) ); + mPaperSizeComboBox->addItem( tr( "A0 (841x1189 mm)" ), QSizeF (841, 1189 ) ); + mPaperSizeComboBox->addItem( tr( "B5 (176 x 250 mm)" ), QSizeF (176, 250 ) ); + mPaperSizeComboBox->addItem( tr( "B4 (250 x 353 mm)" ), QSizeF (250, 353 ) ); + mPaperSizeComboBox->addItem( tr( "B3 (353 x 500 mm)" ), QSizeF (353, 500 ) ); + mPaperSizeComboBox->addItem( tr( "B2 (500 x 707 mm)" ), QSizeF (500, 707 ) ); + mPaperSizeComboBox->addItem( tr( "B1 (707 x 1000 mm)" ), QSizeF (707, 1000 ) ); + mPaperSizeComboBox->addItem( tr( "B0 (1000 x 1414 mm)" ), QSizeF (1000, 1414 ) ); + // North american formats + mPaperSizeComboBox->addItem( tr( "Legal (8.5x14 inches)" ), QSizeF (215.9, 355.6 ) ); + mPaperSizeComboBox->addItem( tr( "ANSI A (Letter; 8.5x11 inches)" ), QSizeF (215.9, 279.4 ) ); + mPaperSizeComboBox->addItem( tr( "ANSI B (Tabloid; 11x17 inches)" ), QSizeF (279.4, 431.8 ) ); + mPaperSizeComboBox->addItem( tr( "ANSI C (17x22 inches)" ), QSizeF (431.8, 558.8 ) ); + mPaperSizeComboBox->addItem( tr( "ANSI D (22x34 inches)" ), QSizeF (558.8, 863.6 ) ); + mPaperSizeComboBox->addItem( tr( "ANSI E (34x44 inches)" ), QSizeF (863.6, 1117.6 ) ); + mPaperSizeComboBox->addItem( tr( "Arch A (9x12 inches)" ), QSizeF (228.6, 304.8 ) ); + mPaperSizeComboBox->addItem( tr( "Arch B (12x18 inches)" ), QSizeF (304.8, 457.2 ) ); + mPaperSizeComboBox->addItem( tr( "Arch C (18x24 inches)" ), QSizeF (457.2, 609.6 ) ); + mPaperSizeComboBox->addItem( tr( "Arch D (24x36 inches)" ), QSizeF (609.6, 914.4 ) ); + mPaperSizeComboBox->addItem( tr( "Arch E (36x48 inches)" ), QSizeF (914.4, 1219.2 ) ); + mPaperSizeComboBox->addItem( tr( "Arch E1 (30x42 inches)" ) , QSizeF ( 762, 1066.8 ) ); + + mPaperSizeComboBox->setCurrentIndex( 2 ); //A3 + } void QgsGeorefConfigDialog::changeEvent( QEvent *e ) @@ -109,4 +139,9 @@ } s.setValue( "/Plugin-GeoReferencer/Config/LeftMarginPDF", mLeftMarginSpinBox->value() ); s.setValue( "/Plugin-GeoReferencer/Config/RightMarginPDF", mRightMarginSpinBox->value() ); + + s.setValue( "/Plugin-GeoReferencer/Config/WidthPDFMap", mPaperSizeComboBox->itemData( mPaperSizeComboBox->currentIndex() ).toSizeF().width() ); + s.setValue( "/Plugin-GeoReferencer/Config/HeightPDFMap", mPaperSizeComboBox->itemData( mPaperSizeComboBox->currentIndex() ).toSizeF().height() ); + } + Index: src/plugins/georeferencer/qgsgeorefplugingui.cpp =================================================================== --- src/plugins/georeferencer/qgsgeorefplugingui.cpp (revision 14080) +++ src/plugins/georeferencer/qgsgeorefplugingui.cpp (working copy) @@ -28,6 +28,9 @@ #include #include #include +#include +#include +#include #include "qgisinterface.h" #include "qgslegendinterface.h" @@ -62,7 +65,6 @@ #include "qgsgeorefplugingui.h" - QgsGeorefDockWidget::QgsGeorefDockWidget( const QString & title, QWidget * parent, Qt::WindowFlags flags ) : QDockWidget( title, parent, flags ) { @@ -310,7 +312,7 @@ } d.getTransformSettings( mTransformParam, mResamplingMethod, mCompressionMethod, - mModifiedRasterFileName, mProjection, mPdfOutputFile, mUseZeroForTrans, mLoadInQgis, mUserResX, mUserResY ); + mModifiedRasterFileName, mProjection, mPdfOutputMapFile, mPdfOutputFile, mUseZeroForTrans, mLoadInQgis, mUserResX, mUserResY ); mTransformParamLabel->setText( tr( "Transform: " ) + convertTransformEnumToString( mTransformParam ) ); mGeorefTransform.selectTransformParametrisation( mTransformParam ); mGCPListWidget->setGeorefTransform( &mGeorefTransform ); @@ -1219,6 +1221,12 @@ { writePDFReportFile( mPdfOutputFile, mGeorefTransform ); } + if ( success && !mPdfOutputMapFile.isEmpty() ) + { + writePDFMapFile( mPdfOutputMapFile, mGeorefTransform ); + } + + } else // Helmert, Polinom 1, Polinom 2, Polinom 3 { @@ -1243,6 +1251,10 @@ { writePDFReportFile( mPdfOutputFile, mGeorefTransform ); } + if ( !mPdfOutputMapFile.isEmpty() ) + { + writePDFMapFile( mPdfOutputMapFile, mGeorefTransform ); + } return true; } } @@ -1328,6 +1340,108 @@ return true; } +bool QgsGeorefPluginGui::writePDFMapFile( const QString& fileName, const QgsGeorefTransform& transform ) +{ + if ( !mCanvas ) + { + return false; + } + + QgsMapRenderer* canvasRenderer = mCanvas->mapRenderer(); + if ( !canvasRenderer ) + { + return false; + } + + QgsRasterLayer *rlayer = (QgsRasterLayer*) mCanvas->layer(0); + double mapRatio = rlayer->extent().width() / rlayer->extent().height(); + + QPrinter printer; + printer.setOutputFormat( QPrinter::PdfFormat ); + printer.setOutputFileName( fileName ); + + QSettings s; + double paperWidth = s.value( "/Plugin-GeoReferencer/Config/WidthPDFMap" ).toDouble(); + double paperHeight = s.value( "/Plugin-GeoReferencer/Config/HeightPDFMap" ).toDouble(); + + //create composition + QgsComposition* composition = new QgsComposition( mCanvas->mapRenderer() ); + if ( mapRatio >= 1 ) + { + composition->setPaperSize( paperHeight, paperWidth ); + } + else + { + composition->setPaperSize( paperWidth, paperHeight ); + } + composition->setPrintResolution( 300 ); + printer.setPaperSize( QSizeF( composition->paperWidth(), composition->paperHeight() ), QPrinter::Millimeter ); + + double leftMargin = 8; + double topMargin = 8; + double contentWidth = composition->paperWidth()-2*leftMargin; + double contentHeight = composition->paperHeight()-2*topMargin; + double contentRatio = contentWidth / contentHeight; + + //composer map + QgsComposerMap* composerMap = new QgsComposerMap( composition, leftMargin, topMargin, contentWidth, contentHeight ); + composerMap->setKeepLayerSet(true); + QStringList list; + list.append( canvasRenderer->layerSet()[0] ); + composerMap->setLayerSet( list ); + + double xcenter = rlayer->extent().center().x(); + double ycenter = rlayer->extent().center().y(); + + QgsRectangle rect; + if ( mapRatio > contentRatio ) + { + rect = QgsRectangle( 0, ycenter-(rlayer->extent().width() / contentRatio)/2, rlayer->extent().width(), ycenter+(rlayer->extent().width() / contentRatio)/2 ); + } + if (mapRatio <= contentRatio ) + { + rect = QgsRectangle( xcenter-(rlayer->extent().height()*contentRatio/2), -1*rlayer->extent().height(), xcenter+(rlayer->extent().height()*contentRatio/2), 0 ); + } + + composerMap->setNewExtent( rect ); + composition->addItem( composerMap ); + printer.setFullPage( true ); + printer.setColorMode( QPrinter::Color ); + + QString residualUnits; + if ( s.value( "/Plugin-GeoReferencer/Config/ResidualUnits" ) == "mapUnits" && mGeorefTransform.providesAccurateInverseTransformation() ) + { + residualUnits = tr( "map units" ); + } + else + { + residualUnits = tr( "pixels" ); + } + + //residual plot + QgsResidualPlotItem* resPlotItem = new QgsResidualPlotItem( composition ); + composition->addItem( resPlotItem ); + resPlotItem->setSceneRect( QRectF( leftMargin, topMargin, contentWidth, contentHeight ) ); + resPlotItem->setExtent( rect ); + resPlotItem->setGCPList( mPoints ); + resPlotItem->setConvertScaleToMapUnits( residualUnits == tr( "map units" ) ); + + printer.setResolution( composition->printResolution() ); + QPainter p( &printer ); + composition->setPlotStyle( QgsComposition::Print ); + QRectF paperRectMM = printer.pageRect( QPrinter::Millimeter ); + QRectF paperRectPixel = printer.pageRect( QPrinter::DevicePixel ); + composition->render( &p, paperRectPixel, paperRectMM ); + + delete resPlotItem; + delete composerMap; + delete composition; + + return true; +} + + + bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsGeorefTransform& transform ) { if ( !mCanvas ) @@ -1475,7 +1589,7 @@ gcpTable->setHeaderFont( tableHeaderFont ); gcpTable->setContentFont( tableContentFont ); QStringList gcpHeader; - gcpHeader << "id" << "enabled" << "pixelX" << "pixelY" << "mapX" << "mapY" << "resX[" + residualUnits + "]" << "resY[" + residualUnits + "]" << "resTot[" + residualUnits + "]"; + gcpHeader << "id" << "enabled" << "pixelX" << "pixelY" << "mapX" << "mapY" << "resX [" + residualUnits + "]" << "resY [" + residualUnits + "]" << "resTot [" + residualUnits + "]"; gcpTable->setHeaderLabels( gcpHeader ); QgsGCPList::const_iterator gcpIt = mPoints.constBegin(); @@ -1494,8 +1608,8 @@ { currentGCPStrings << tr( "no" ); } - currentGCPStrings << QString::number(( *gcpIt )->pixelCoords().x(), 'f', 2 ) << QString::number(( *gcpIt )->pixelCoords().y(), 'f', 2 ) << QString::number(( *gcpIt )->mapCoords().x(), 'f', 2 )\ - << QString::number(( *gcpIt )->mapCoords().y(), 'f', 2 ) << QString::number( residual.x() ) << QString::number( residual.y() ) << QString::number( residualTot ); + currentGCPStrings << QString::number(( *gcpIt )->pixelCoords().x(), 'f', 0 ) << QString::number(( *gcpIt )->pixelCoords().y(), 'f', 0 ) << QString::number(( *gcpIt )->mapCoords().x(), 'f', 3 )\ + << QString::number(( *gcpIt )->mapCoords().y(), 'f', 3 ) << QString::number( residual.x() ) << QString::number( residual.y() ) << QString::number( residualTot ); gcpTable->addRow( currentGCPStrings ); } Index: src/plugins/georeferencer/qgstransformsettingsdialogbase.ui =================================================================== --- src/plugins/georeferencer/qgstransformsettingsdialogbase.ui (revision 14080) +++ src/plugins/georeferencer/qgstransformsettingsdialogbase.ui (working copy) @@ -6,8 +6,8 @@ 0 0 - 356 - 429 + 438 + 478 @@ -137,14 +137,14 @@ - + Generate pdf report: - + @@ -158,21 +158,21 @@ - + Set Target Resolution - + Horizontal - + 5 @@ -185,14 +185,14 @@ - + Vertical - + @@ -221,6 +221,27 @@ + + + + Generate pdf map: + + + + + + + + + + + + ... + + + + + Index: src/plugins/georeferencer/qgstransformsettingsdialog.h =================================================================== --- src/plugins/georeferencer/qgstransformsettingsdialog.h (revision 14080) +++ src/plugins/georeferencer/qgstransformsettingsdialog.h (working copy) @@ -12,7 +12,7 @@ * (at your option) any later version. * * * ***************************************************************************/ -/* $Id: qgstransformsettingsdialog.h 13764 2010-06-21 12:11:11Z mhugent $ */ +/* $Id$ */ #ifndef QGSTRANSFORMSETTINGSDIALOG_H #define QGSTRANSFORMSETTINGSDIALOG_H @@ -32,7 +32,7 @@ int countGCPpoints, QWidget *parent = 0 ); void getTransformSettings( QgsGeorefTransform::TransformParametrisation &tp, QgsImageWarper::ResamplingMethod &rm, QString &comprMethod, - QString &raster, QString &proj, QString& pdfReportFile, bool &zt, bool &loadInQgis, + QString &raster, QString &proj, QString& pdfMapFile, QString& pdfReportFile, bool &zt, bool &loadInQgis, double& resX, double& resY ); static void resetSettings(); @@ -43,7 +43,8 @@ private slots: void on_tbnOutputRaster_clicked(); void on_tbnTargetSRS_clicked(); - void on_tbnReportFile_clicked(); + void on_tbnMapFile_clicked(); + void on_tbnReportFile_clicked(); void on_leTargetSRS_textChanged( const QString &text ); void on_cmbTransformType_currentIndexChanged( const QString& text ); void on_mWorldFileCheckBox_stateChanged( int state );