diff --git a/python/plugins/GdalTools/__init__.py b/python/plugins/GdalTools/__init__.py index 66a5588a72ad..bc965e77d152 100644 --- a/python/plugins/GdalTools/__init__.py +++ b/python/plugins/GdalTools/__init__.py @@ -22,7 +22,7 @@ def name(): def description(): return "Integrate gdal tools into qgis" def version(): - return "Version 1.2.22" + return "Version 1.2.23" def qgisMinimumVersion(): return "1.0" def icon(): diff --git a/python/plugins/GdalTools/tools/doWarp.py b/python/plugins/GdalTools/tools/doWarp.py index 0b6521f67bff..54d7c86d1e0b 100644 --- a/python/plugins/GdalTools/tools/doWarp.py +++ b/python/plugins/GdalTools/tools/doWarp.py @@ -40,7 +40,9 @@ def __init__(self, iface): (self.cacheSpin, SIGNAL("valueChanged(int)"), self.cacheCheck), ( [self.widthSpin, self.heightSpin], SIGNAL( "valueChanged(int)" ), self.resizeGroupBox ), (self.multithreadCheck, SIGNAL("stateChanged(int)")), - (self.noDataEdit, SIGNAL( "textChanged( const QString & )" ), self.noDataCheck) + (self.noDataEdit, SIGNAL( "textChanged( const QString & )" ), self.noDataCheck), + (self.cutlineLayerCombo, [SIGNAL("currentIndexChanged(int)"), SIGNAL("editTextChanged(const QString &)")], self.cutlineCheck, "1.6.0"), + (self.selectCutlineFileButton, None, self.cutlineCheck, "1.6.0") ] ) @@ -49,6 +51,7 @@ def __init__(self, iface): self.connect(self.selectOutputFileButton, SIGNAL("clicked()"), self.fillOutputFileEdit) self.connect(self.selectSourceSRSButton, SIGNAL("clicked()"), self.fillSourceSRSEdit) self.connect(self.selectTargetSRSButton, SIGNAL("clicked()"), self.fillTargetSRSEdit) + self.connect(self.selectCutlineFileButton, SIGNAL("clicked()"), self.fillCutlineFile) self.connect( self.batchCheck, SIGNAL( "stateChanged( int )" ), self.switchToolMode ) @@ -90,12 +93,19 @@ def switchToolMode( self ): def onLayersChanged(self): self.fillInputLayerCombo() + self.fillCutlineLayerCombo() def fillInputLayerCombo(self): self.inputLayerCombo.clear() - ( self.layers, names ) = Utils.LayerRegistry.instance().getRasterLayers() + ( self.inputLayers, names ) = Utils.LayerRegistry.instance().getRasterLayers() self.inputLayerCombo.addItems( names ) + def fillCutlineLayerCombo(self): + self.cutlineLayerCombo.clear() + ( self.cutlineLayers, names ) = Utils.LayerRegistry.instance().getVectorLayers() + self.cutlineLayerCombo.addItems( names ) + + def fillInputFile(self): lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter() inputFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the input file for Warp" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter ) @@ -119,6 +129,17 @@ def fillOutputFileEdit(self): self.outputFormat = Utils.fillRasterOutputFormat( lastUsedFilter, outputFile ) self.outputFileEdit.setText(outputFile) + def fillCutlineFile(self): + lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() + cutlineFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the cutline file" ), Utils.FileFilter.allVectorsFilter(), lastUsedFilter ) + if cutlineFile.isEmpty(): + return + Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) + + self.cutlineLayerCombo.setCurrentIndex(-1) + self.cutlineLayerCombo.setEditText(cutlineFile) + + def fillInputDir( self ): inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files to Warp" )) if inputDir.isEmpty(): @@ -187,6 +208,13 @@ def getArguments(self): if not nodata.isEmpty(): arguments << "-dstnodata" arguments << nodata + if self.cutlineCheck.isChecked(): + cutline = self.getCutlineFileName() + if not cutline.isEmpty(): + arguments << "-q" + arguments << "-cutline" + arguments << cutline + arguments << "-dstalpha" if self.isBatchEnabled(): return arguments @@ -199,12 +227,17 @@ def getArguments(self): def getInputFileName(self): if self.inputLayerCombo.currentIndex() >= 0: - return self.layers[self.inputLayerCombo.currentIndex()].source() + return self.inputLayers[self.inputLayerCombo.currentIndex()].source() return self.inputLayerCombo.currentText() def getOutputFileName(self): return self.outputFileEdit.text() + def getCutlineFileName(self): + if self.cutlineLayerCombo.currentIndex() >= 0: + return self.cutlineLayers[self.cutlineLayerCombo.currentIndex()].source() + return self.cutlineLayerCombo.currentText() + def addLayerIntoCanvas(self, fileInfo): self.iface.addRasterLayer(fileInfo.filePath()) diff --git a/python/plugins/GdalTools/tools/widgetWarp.ui b/python/plugins/GdalTools/tools/widgetWarp.ui index fefa13379496..f9c388ad9fe0 100644 --- a/python/plugins/GdalTools/tools/widgetWarp.ui +++ b/python/plugins/GdalTools/tools/widgetWarp.ui @@ -7,7 +7,7 @@ 0 0 415 - 417 + 453 @@ -19,15 +19,15 @@ Warp - - + + Batch mode (for processing whole directory) - + @@ -203,14 +203,14 @@ - + &Memory used for caching - + MB @@ -223,9 +223,43 @@ + + + + Cutline + + + + + + + + + + 0 + 0 + + + + true + + + QComboBox::NoInsert + + + + + + + Select... + + + + + - + Resize @@ -283,10 +317,10 @@ - + - + Use m&ultithreaded warping implementation