Skip to content

Commit

Permalink
fixed #3449 making sure the clipping result has the layers order as i…
Browse files Browse the repository at this point in the history
…n TOC

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15125 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler committed Feb 3, 2011
1 parent 3f01957 commit fc6fb01
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions python/plugins/GdalTools/tools/doClipper.py
Expand Up @@ -53,8 +53,10 @@ def onClosing(self):
def fillInputFiles(self):
self.inputFiles = QStringList()

# for each active layer
for i in range(self.canvas.layerCount()):
# Reversed list to have the topmost layer as the last one in the list
# because "In areas of overlap, the last image will be copied over
# earlier ones" (see http://www.gdal.org/gdal_merge.html).
for i in range(self.canvas.layerCount()-1, -1, -1):
layer = self.canvas.layer(i)
# only raster layers, but not WMS ones
if layer.type() == layer.RasterLayer and ( not layer.usesProvider() ):
Expand All @@ -70,6 +72,9 @@ def fillInputFiles(self):
if self.isVisible() and self.warningDialog.isHidden():
msg = QString( self.tr("No active raster layers. You must add almost one raster layer to continue.") )
self.warningDialog.showMessage(msg)

# refresh command when there are no active layers
self.someValueChanged()
else:
self.warningDialog.hide()
self.extentSelector.start()
Expand Down Expand Up @@ -114,6 +119,15 @@ def getArguments(self):
if not self.outputFileEdit.text().isEmpty():
arguments << "-o"
arguments << self.outputFileEdit.text()

if self.pctCheck.isChecked() and len(self.inputFiles) > 1:
# The topmost layer in the TOC is the last one in the list (see above),
# but I want to grab the pseudocolor table from the first image (the
# topmost layer in the TOC).
# Workaround: duplicate the last layer inserting it also as the first
# one to grab the pseudocolor table from it.
arguments << self.inputFiles[ len(self.inputFiles)-1 ]

arguments << self.inputFiles
return arguments

Expand Down

0 comments on commit fc6fb01

Please sign in to comment.