mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
[composer] Fix world file filename for multipage compositions
also fix #11676
This commit is contained in:
parent
d897624704
commit
c84b2dfe61
@ -1972,6 +1972,12 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
|
|||||||
|
|
||||||
mView->setPaintingEnabled( false );
|
mView->setPaintingEnabled( false );
|
||||||
|
|
||||||
|
int worldFilePageNo = -1;
|
||||||
|
if ( mComposition->generateWorldFile() && mComposition->worldFileMap() )
|
||||||
|
{
|
||||||
|
worldFilePageNo = mComposition->worldFileMap()->page() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
for ( int i = 0; i < mComposition->numPages(); ++i )
|
for ( int i = 0; i < mComposition->numPages(); ++i )
|
||||||
{
|
{
|
||||||
if ( !mComposition->shouldExportPage( i + 1 ) )
|
if ( !mComposition->shouldExportPage( i + 1 ) )
|
||||||
@ -1991,16 +1997,19 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool saveOk;
|
bool saveOk;
|
||||||
|
QString outputFilePath;
|
||||||
if ( i == 0 )
|
if ( i == 0 )
|
||||||
{
|
{
|
||||||
saveOk = image.save( fileNExt.first, fileNExt.second.toLocal8Bit().constData() );
|
outputFilePath = fileNExt.first;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QFileInfo fi( fileNExt.first );
|
QFileInfo fi( fileNExt.first );
|
||||||
QString outputFilePath = fi.absolutePath() + "/" + fi.baseName() + "_" + QString::number( i + 1 ) + "." + fi.suffix();
|
outputFilePath = fi.absolutePath() + "/" + fi.baseName() + "_" + QString::number( i + 1 ) + "." + fi.suffix();
|
||||||
saveOk = image.save( outputFilePath, fileNExt.second.toLocal8Bit().constData() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveOk = image.save( outputFilePath, fileNExt.second.toLocal8Bit().constData() );
|
||||||
|
|
||||||
if ( !saveOk )
|
if ( !saveOk )
|
||||||
{
|
{
|
||||||
QMessageBox::warning( this, tr( "Image export error" ),
|
QMessageBox::warning( this, tr( "Image export error" ),
|
||||||
@ -2010,21 +2019,20 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
|
|||||||
mView->setPaintingEnabled( true );
|
mView->setPaintingEnabled( true );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
if ( i == worldFilePageNo )
|
||||||
// Write the world file if asked to
|
{
|
||||||
if ( mComposition->generateWorldFile() )
|
// should generate world file for this page
|
||||||
{
|
double a, b, c, d, e, f;
|
||||||
double a, b, c, d, e, f;
|
mComposition->computeWorldFileParameters( a, b, c, d, e, f );
|
||||||
mComposition->computeWorldFileParameters( a, b, c, d, e, f );
|
|
||||||
|
|
||||||
QFileInfo fi( fileNExt.first );
|
QFileInfo fi( outputFilePath );
|
||||||
// build the world file name
|
// build the world file name
|
||||||
QString worldFileName = fi.absolutePath() + "/" + fi.baseName() + "."
|
QString worldFileName = fi.absolutePath() + "/" + fi.baseName() + "."
|
||||||
+ fi.suffix()[0] + fi.suffix()[fi.suffix().size()-1] + "w";
|
+ fi.suffix()[0] + fi.suffix()[fi.suffix().size()-1] + "w";
|
||||||
|
|
||||||
writeWorldFile( worldFileName, a, b, c, d, e, f );
|
writeWorldFile( worldFileName, a, b, c, d, e, f );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mView->setPaintingEnabled( true );
|
mView->setPaintingEnabled( true );
|
||||||
@ -2150,6 +2158,12 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
|
|||||||
|
|
||||||
QString filename = QDir( dir ).filePath( atlasMap->currentFilename() ) + fileExt;
|
QString filename = QDir( dir ).filePath( atlasMap->currentFilename() ) + fileExt;
|
||||||
|
|
||||||
|
int worldFilePageNo = -1;
|
||||||
|
if ( mComposition->generateWorldFile() && mComposition->worldFileMap() )
|
||||||
|
{
|
||||||
|
worldFilePageNo = mComposition->worldFileMap()->page() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
for ( int i = 0; i < mComposition->numPages(); ++i )
|
for ( int i = 0; i < mComposition->numPages(); ++i )
|
||||||
{
|
{
|
||||||
if ( !mComposition->shouldExportPage( i + 1 ) )
|
if ( !mComposition->shouldExportPage( i + 1 ) )
|
||||||
@ -2177,21 +2191,20 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
|
|||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
if ( i == worldFilePageNo )
|
||||||
// Write the world file if asked to
|
{
|
||||||
if ( mComposition->generateWorldFile() )
|
// should generate world file for this page
|
||||||
{
|
double a, b, c, d, e, f;
|
||||||
double a, b, c, d, e, f;
|
mComposition->computeWorldFileParameters( a, b, c, d, e, f );
|
||||||
mComposition->computeWorldFileParameters( a, b, c, d, e, f );
|
|
||||||
|
|
||||||
QFileInfo fi( filename );
|
QFileInfo fi( imageFilename );
|
||||||
// build the world file name
|
// build the world file name
|
||||||
QString worldFileName = fi.absolutePath() + "/" + fi.baseName() + "."
|
QString worldFileName = fi.absolutePath() + "/" + fi.baseName() + "."
|
||||||
+ fi.suffix()[0] + fi.suffix()[fi.suffix().size()-1] + "w";
|
+ fi.suffix()[0] + fi.suffix()[fi.suffix().size()-1] + "w";
|
||||||
|
|
||||||
writeWorldFile( worldFileName, a, b, c, d, e, f );
|
writeWorldFile( worldFileName, a, b, c, d, e, f );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
atlasMap->endRender();
|
atlasMap->endRender();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user