Skip to content

Commit 074e85e

Browse files
author
mhugent
committed
Show checkbox for worldfile. Save output rasters in the same dir as the original raster if no path is given
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13764 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent caa18f7 commit 074e85e

File tree

3 files changed

+66
-14
lines changed

3 files changed

+66
-14
lines changed

src/plugins/georeferencer/qgstransformsettingsdialog.cpp

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ void QgsTransformSettingsDialog::getTransformSettings( QgsGeorefTransform::Trans
8787

8888
rm = ( QgsImageWarper::ResamplingMethod )cmbResampling->currentIndex();
8989
comprMethod = cmbCompressionComboBox->currentText();
90-
raster = leOutputRaster->text();
90+
if ( mWorldFileCheckBox->isChecked() )
91+
{
92+
raster = "";
93+
}
94+
else
95+
{
96+
raster = leOutputRaster->text();
97+
}
9198
proj = leTargetSRS->text();
9299
pdfReportFile = mReportFileLineEdit->text();
93100
zt = cbxZeroAsTrans->isChecked();
@@ -134,12 +141,11 @@ void QgsTransformSettingsDialog::accept()
134141
int minGCPpoints;
135142
if ( checkGCPpoints( cmbTransformType->currentIndex(), minGCPpoints ) )
136143
{
137-
if ( leOutputRaster->text().isEmpty() && cmbTransformType->currentIndex() > 1 )
144+
if ( leOutputRaster->text().isEmpty() )
138145
{
139146
QMessageBox::information( this, tr( "Info" ), tr( "Please set output name" ) );
140147
return;
141148
}
142-
QDialog::accept();
143149
}
144150
else
145151
{
@@ -150,6 +156,18 @@ void QgsTransformSettingsDialog::accept()
150156
return;
151157
}
152158

159+
//if the file path is relative, make it relative to the raster file directory
160+
QString outputRasterName = leOutputRaster->text();
161+
QFileInfo rasterFileInfo( mModifiedRaster );
162+
QFileInfo outputFileInfo( rasterFileInfo.absoluteDir(), outputRasterName );
163+
164+
if ( outputFileInfo.fileName().isEmpty() || !outputFileInfo.dir().exists() )
165+
{
166+
QMessageBox::information( this, tr( "Info" ), tr( "Invalid output file name" ) );
167+
return;
168+
}
169+
leOutputRaster->setText( outputFileInfo.absoluteFilePath() );
170+
153171
QSettings s;
154172
s.setValue( "/Plugin-GeoReferencer/lasttransformation", cmbTransformType->currentIndex() );
155173
s.setValue( "/Plugin-GeoReferencer/lastresampling", cmbResampling->currentIndex() );
@@ -166,6 +184,7 @@ void QgsTransformSettingsDialog::accept()
166184
QFileInfo fi( pdfReportFileName );
167185
s.setValue( "/Plugin-GeoReferencer/lastPDFReportDir", fi.absolutePath() );
168186
}
187+
QDialog::accept();
169188
}
170189

171190
void QgsTransformSettingsDialog::on_tbnOutputRaster_clicked()
@@ -240,6 +259,30 @@ void QgsTransformSettingsDialog::on_leTargetSRS_textChanged( const QString &text
240259
}
241260
}
242261

262+
void QgsTransformSettingsDialog::on_cmbTransformType_currentIndexChanged( const QString& text )
263+
{
264+
if ( text == tr( "Linear" ) )
265+
{
266+
mWorldFileCheckBox->setEnabled( true );
267+
}
268+
else
269+
{
270+
mWorldFileCheckBox->setEnabled( false );
271+
}
272+
}
273+
274+
void QgsTransformSettingsDialog::on_mWorldFileCheckBox_stateChanged( int state )
275+
{
276+
bool enableOutputRaster = true;
277+
if ( state == Qt::Checked )
278+
{
279+
enableOutputRaster = false;
280+
}
281+
label_2->setEnabled( enableOutputRaster );
282+
leOutputRaster->setEnabled( enableOutputRaster );
283+
tbnOutputRaster->setEnabled( enableOutputRaster );
284+
}
285+
243286
bool QgsTransformSettingsDialog::checkGCPpoints( int count, int &minGCPpoints )
244287
{
245288
QgsGeorefTransform georefTransform;

src/plugins/georeferencer/qgstransformsettingsdialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class QgsTransformSettingsDialog : public QDialog, private Ui::QgsTransformSetti
4545
void on_tbnTargetSRS_clicked();
4646
void on_tbnReportFile_clicked();
4747
void on_leTargetSRS_textChanged( const QString &text );
48+
void on_cmbTransformType_currentIndexChanged( const QString& text );
49+
void on_mWorldFileCheckBox_stateChanged( int state );
4850
QIcon getThemeIcon( const QString &theName );
4951

5052
private:

src/plugins/georeferencer/qgstransformsettingsdialogbase.ui

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@
115115
</item>
116116
</widget>
117117
</item>
118-
<item row="3" column="0">
118+
<item row="4" column="0">
119119
<widget class="QLabel" name="label_2">
120120
<property name="text">
121121
<string>Output raster:</string>
122122
</property>
123123
</widget>
124124
</item>
125-
<item row="3" column="1">
125+
<item row="4" column="1">
126126
<layout class="QHBoxLayout" name="horizontalLayout">
127127
<item>
128128
<widget class="QLineEdit" name="leOutputRaster"/>
@@ -136,14 +136,14 @@
136136
</item>
137137
</layout>
138138
</item>
139-
<item row="4" column="0">
139+
<item row="5" column="0">
140140
<widget class="QLabel" name="label_3">
141141
<property name="text">
142142
<string>Target SRS:</string>
143143
</property>
144144
</widget>
145145
</item>
146-
<item row="4" column="1">
146+
<item row="5" column="1">
147147
<layout class="QHBoxLayout" name="horizontalLayout_2">
148148
<item>
149149
<widget class="QLineEdit" name="leTargetSRS"/>
@@ -157,14 +157,14 @@
157157
</item>
158158
</layout>
159159
</item>
160-
<item row="5" column="0">
160+
<item row="6" column="0">
161161
<widget class="QLabel" name="label_6">
162162
<property name="text">
163163
<string>Generate pdf report:</string>
164164
</property>
165165
</widget>
166166
</item>
167-
<item row="5" column="1">
167+
<item row="6" column="1">
168168
<layout class="QHBoxLayout" name="horizontalLayout_3">
169169
<item>
170170
<widget class="QLineEdit" name="mReportFileLineEdit"/>
@@ -178,21 +178,21 @@
178178
</item>
179179
</layout>
180180
</item>
181-
<item row="6" column="0">
181+
<item row="7" column="0">
182182
<widget class="QCheckBox" name="cbxUserResolution">
183183
<property name="text">
184184
<string>Set Target Resolution</string>
185185
</property>
186186
</widget>
187187
</item>
188-
<item row="7" column="0">
188+
<item row="8" column="0">
189189
<widget class="QLabel" name="label_4">
190190
<property name="text">
191191
<string>Horizontal</string>
192192
</property>
193193
</widget>
194194
</item>
195-
<item row="7" column="1">
195+
<item row="8" column="1">
196196
<widget class="QgsValidatedDoubleSpinBox" name="dsbHorizRes">
197197
<property name="decimals">
198198
<number>5</number>
@@ -205,14 +205,14 @@
205205
</property>
206206
</widget>
207207
</item>
208-
<item row="8" column="0">
208+
<item row="9" column="0">
209209
<widget class="QLabel" name="label_5">
210210
<property name="text">
211211
<string>Vertical</string>
212212
</property>
213213
</widget>
214214
</item>
215-
<item row="8" column="1">
215+
<item row="9" column="1">
216216
<widget class="QgsValidatedDoubleSpinBox" name="dsbVerticalRes">
217217
<property name="sizePolicy">
218218
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -234,6 +234,13 @@
234234
</property>
235235
</widget>
236236
</item>
237+
<item row="3" column="0">
238+
<widget class="QCheckBox" name="mWorldFileCheckBox">
239+
<property name="text">
240+
<string>Create world file</string>
241+
</property>
242+
</widget>
243+
</item>
237244
</layout>
238245
</item>
239246
<item row="1" column="0">

0 commit comments

Comments
 (0)