5 changes: 2 additions & 3 deletions python/plugins/sextante/algs/FieldsCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class FieldsCalculator(GeoAlgorithm):
FORMULA = "FORMULA"
OUTPUT_LAYER = "OUTPUT_LAYER"

TYPE_NAMES = ["Float", "Integer", "String", "Boolean"]
TYPES = [QVariant.Double, QVariant.Int, QVariant.String, QVariant.Bool]
TYPE_NAMES = ["Float", "Integer", "String"]
TYPES = [QVariant.Double, QVariant.Int, QVariant.String]


def defineCharacteristics(self):
Expand Down Expand Up @@ -96,7 +96,6 @@ def processAlgorithm(self, progress):
result = eval(expression)
except Exception:
result = None
#raise GeoAlgorithmExecutionException("Problem evaluation formula: Wrong field values or formula")
nElement += 1
inGeom = inFeat.geometry()
outFeat.setGeometry(inGeom)
Expand Down
1 change: 1 addition & 0 deletions python/plugins/sextante/algs/ftools/RandomSelection.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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