Skip to content

Commit

Permalink
[sextante] file selector and iterator buttons can be hidden now in pa…
Browse files Browse the repository at this point in the history
…rameters dialog if algorithm does not support them
  • Loading branch information
volaya committed Jul 23, 2013
1 parent 4c39d27 commit 6bcf10f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions python/plugins/sextante/algs/ftools/RandomSelection.py
Expand Up @@ -56,6 +56,7 @@ class RandomSelection(GeoAlgorithm):
#===========================================================================

def defineCharacteristics(self):
self.allowOnlyOpenedLayers = True
self.name = "Random selection"
self.group = "Vector selection tools"

Expand Down
Expand Up @@ -55,6 +55,7 @@ class RandomSelectionWithinSubsets(GeoAlgorithm):
#===========================================================================

def defineCharacteristics(self):
self.allowOnlyOpenedLayers = True
self.name = "Random selection within subsets"
self.group = "Vector selection tools"

Expand Down
1 change: 1 addition & 0 deletions python/plugins/sextante/algs/ftools/SelectByLocation.py
Expand Up @@ -51,6 +51,7 @@ class SelectByLocation(GeoAlgorithm):
#===========================================================================

def defineCharacteristics(self):
self.allowOnlyOpenedLayers = True
self.name = "Select by location"
self.group = "Vector selection tools"
self.addParameter(ParameterVector(self.INPUT, "Layer to select from", ParameterVector.VECTOR_TYPE_ANY))
Expand Down
1 change: 1 addition & 0 deletions python/plugins/sextante/algs/mmqgisx/MMQGISXAlgorithms.py
Expand Up @@ -1030,6 +1030,7 @@ class mmqgisx_select_algorithm(GeoAlgorithm):
RESULT = "RESULT"

def defineCharacteristics(self):
self.allowOnlyOpenedLayers = True
self.name = "Select by attribute"
self.group = "Vector selection tools"

Expand Down
3 changes: 3 additions & 0 deletions python/plugins/sextante/core/GeoAlgorithm.py
Expand Up @@ -59,6 +59,9 @@ def __init__(self):
#change any of the following if your algorithm should not appear in the toolbox or modeler
self.showInToolbox = True
self.showInModeler = True
#if true, will show only loaded layers in parameters dialog
self.allowOnlyOpenedLayers = False
#False if it should not be run a a batch process
self.canRunInBatchMode = True
#to be set by the provider when it loads the algorithm
self.provider = None
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/gui/ParametersPanel.py
Expand Up @@ -119,7 +119,7 @@ def initGUI(self):
self.labels[param.name] = label
widget = self.getWidgetFromParameter(param)
self.valueItems[param.name] = widget
if isinstance(param, ParameterVector):
if isinstance(param, ParameterVector) and not self.alg.allowOnlyOpenedLayers:
layout = QtGui.QHBoxLayout()
layout.setSpacing(2)
layout.setMargin(0)
Expand Down Expand Up @@ -202,7 +202,7 @@ def getWidgetFromParameter(self, param):
items.append((self.getExtendedLayerName(layer), layer))
item = InputLayerSelectorPanel(items)
elif isinstance(param, ParameterVector):
if self.somethingDependsOnThisParameter(param):
if self.somethingDependsOnThisParameter(param) or self.alg.allowOnlyOpenedLayers:
item = QtGui.QComboBox()
layers = QGisLayers.getVectorLayers(param.shapetype)
if (param.optional):
Expand Down

0 comments on commit 6bcf10f

Please sign in to comment.