Skip to content

Commit

Permalink
[processing] refresh all layer selectors when layer added/removed (fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 3, 2017
1 parent b5f3832 commit 1306125
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/gdalcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')))
Expand All @@ -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:
Expand All @@ -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):
Expand Down
15 changes: 11 additions & 4 deletions python/plugins/processing/gui/ParametersPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 1306125

Please sign in to comment.