Skip to content
Permalink
Browse files

[processing] refresh all layer selectors when layer added/removed (fix

  • Loading branch information
alexbruy committed Oct 3, 2017
1 parent b5f3832 commit 13061251e104c38c066a85ad778420c91711f173
Showing with 13 additions and 10 deletions.
  1. +2 −6 python/plugins/processing/algs/gdal/gdalcalc.py
  2. +11 −4 python/plugins/processing/gui/ParametersPanel.py
@@ -56,7 +56,6 @@ class gdalcalc(GdalAlgorithm):
EXTRA = 'EXTRA'
RTYPE = 'RTYPE'
TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']
#DEBUG = 'DEBUG'

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Raster calculator')
@@ -85,14 +84,13 @@ def defineCharacteristics(self):
self.INPUT_F, self.tr('Input layer F'), True))
self.addParameter(ParameterString(self.BAND_F,
self.tr('Number of raster band for raster F'), '1', optional=True))

self.addParameter(ParameterString(self.FORMULA,
self.tr('Calculation in gdalnumeric syntax using +-/* or any numpy array functions (i.e. logical_and())'), 'A*2', optional=False))
self.addParameter(ParameterString(self.NO_DATA,
self.tr('Set output nodata value'), '', optional=True))
self.addParameter(ParameterSelection(self.RTYPE,
self.tr('Output raster type'), self.TYPE, 5))
#self.addParameter(ParameterBoolean(
# self.DEBUG, self.tr('Print debugging information'), False))
self.addParameter(ParameterString(self.EXTRA,
self.tr('Additional creation parameters'), '', optional=True))
self.addOutput(OutputRaster(self.OUTPUT, self.tr('Calculated')))
@@ -102,7 +100,6 @@ def getConsoleCommands(self):
extra = self.getParameterValue(self.EXTRA)
if extra is not None:
extra = unicode(extra)
#debug = self.getParameterValue(self.DEBUG)
formula = self.getParameterValue(self.FORMULA)
noData = self.getParameterValue(self.NO_DATA)
if noData is not None:
@@ -120,8 +117,7 @@ def getConsoleCommands(self):
arguments.append(noData)
if extra and len(extra) > 0:
arguments.append(extra)
#if debug:
# arguments.append('--debug')

arguments.append('-A')
arguments.append(self.getParameterValue(self.INPUT_A))
if self.getParameterValue(self.BAND_A):
@@ -145,17 +145,24 @@ def layerRemoved(self, layer):
if isinstance(widget, InputLayerSelectorPanel):
widget = widget.cmbText

if widget is not None:
idx = widget.findData(layer)
if idx != -1:
widget.removeItem(idx)
widget = None

elif layer.type() == QgsMapLayer.RasterLayer:
for param in self.alg.parameters:
if param.hidden:
continue
if isinstance(param, ParameterRaster):
widget = self.valueItems[param.name].cmbText

if widget is not None:
idx = widget.findData(layer)
if idx != -1:
widget.removeItem(idx)
if widget is not None:
idx = widget.findData(layer)
if idx != -1:
widget.removeItem(idx)
widget = None

self.updateMultipleInputs()

0 comments on commit 1306125

Please sign in to comment.
You can’t perform that action at this time.