Skip to content
Permalink
Browse files

working on qgis plugin, creating parameters window

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@11 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com
volayaf@gmail.com committed Jan 10, 2012
1 parent 75b77d0 commit eb91e9a3fb95c5897c1aa2d1e37fae7f2ca91093
@@ -4,8 +4,8 @@
class GeoAlgorithm:

def __init__(self):
self.parameters = {}
self.outputs = {}
self.parameters = list()
self.outputs = list()
self.name = ""
self.group = ""
self.defineCharacteristics()
@@ -25,46 +25,24 @@ def defineCharacteristics(self):

def processAlgorithm(self):
pass
#===============================================================================
#
# @property
# def outputs(self):
# return self._outputs
#
# @property
# def parameters(self):
# return self._parameters
#
# @property
# def group(self):
# return self._group
#
# @group.setter
# def group(self, g):
# self._group = g
#
# @property
# def name(self):
# return self._name
#
# @name.setter
# def name(self, name):
# self._name = name
#===============================================================================

def putOutput(self, output):
if isinstance(output, Output):
self.outputs[output.name] = output

self.outputs.append(output)

def putParameter(self, param):
if isinstance(param, Parameter):
self.parameters[param.name] = param
self.parameters.append(param)

def setParameterValue(self, paramName, value):
param = self.parameters[paramName]
if param != None:
param.value = value
for param in self.parameters:
if param.name == paramName:
param.value = value

def setOutputValue(self, outputName, value):
for out in self.outputs:
if out.name == outputName:
out.value = value

def canBeExecuted(self, layersCount):
return True
@@ -5,11 +5,22 @@ class QGisLayers:
iface = None;

@staticmethod
def getLayers():
def getRasterLayers():
layers = QGisLayers.iface.legendInterface().layers()
layerNames = list()
for l in layers:
layerNames.append(l.name())

for layer in layers:
if layer.type() == layer.RasterLayer :
layerNames.append(layer)
return layerNames

@staticmethod
def getVectorLayers():
layers = QGisLayers.iface.legendInterface().layers()
layerNames = list()
for layer in layers:
if layer.type() == layer.VectorLayer :
layerNames.append(layer)
return layerNames


@@ -16,14 +16,18 @@ def initialize():
@staticmethod
def loadAlgorithms():
for provider in Sextante.providers:
algs = provider.algs
for alg in algs:
Sextante.algs[alg.commandLineName()] = alg
providerAlgs = provider.algs
algs = {}
for alg in providerAlgs:
algs[alg.commandLineName()] = alg
Sextante.algs[provider.getName()] = algs

@staticmethod
def getAlgorithm(name):
return Sextante.algs[name]

for provider in Sextante.algs.values():
if name in provider:
return provider[name]
return None

@staticmethod
def asStr():
@@ -1,5 +1,9 @@
from PyQt4 import QtCore, QtGui
from sextante.core.QGisLayers import QGisLayers
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.parameters.ParameterVector import ParameterVector
from sextante.parameters.ParameterBoolean import ParameterBoolean
from sextante.parameters.ParameterSelection import ParameterSelection

try:
_fromUtf8 = QtCore.QString.fromUtf8
@@ -43,18 +47,34 @@ def setupUi(self, Dialog):

def getItemFromParameter(self, param):

item = QtGui.QComboBox()
item.addItems(QGisLayers.getLayers())
#item = QtGui.QLineEdit()
#item.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsEditable)
if isinstance(param, ParameterRaster):
item = QtGui.QComboBox()
layers = QGisLayers.getRasterLayers()
for layer in layers:
item.addItem(layer.name())
elif isinstance(param, ParameterVector):
item = QtGui.QComboBox()
layers = QGisLayers.getVectorLayers()
for layer in layers:
item.addItem(layer.name())
elif isinstance(param, ParameterBoolean):
item = QtGui.QComboBox()
item.addItem("Yes")
item.addItem("No")
elif isinstance(param, ParameterSelection):
item = QtGui.QComboBox()
item.addItems(param.options)
else:
item = QtGui.QLineEdit()

return item


def setTableContent(self):
params = self.alg.parameters.values()
outputs = self.alg.outputs.values()
numParams = len(self.alg.parameters.values())
numOutputs = len(self.alg.outputs.values())
params = self.alg.parameters
outputs = self.alg.outputs
numParams = len(self.alg.parameters)
numOutputs = len(self.alg.outputs)
self.tableWidget.setRowCount(numParams + numOutputs)

i=0
@@ -50,20 +50,25 @@ def executeAlgorithm(self):


def fillTree(self):
groups = {}
layersCount = QGisLayers.getLayersCount()
algs = Sextante.algs.values()
for alg in algs:
if alg.group in groups:
groupItem = groups[alg.group]
else:
groupItem = QtGui.QTreeWidgetItem()
groupItem.setText(0,alg.group)
groups[alg.group] = groupItem
algItem = TreeAlgorithmItem(alg, layersCount)
groupItem.addChild(algItem)
for groupItem in groups.values():
self.algorithmTree.addTopLevelItem(groupItem)
for providerName in Sextante.algs.keys():
groups = {}
provider = Sextante.algs[providerName]
algs = provider.values()
for alg in algs:
if alg.group in groups:
groupItem = groups[alg.group]
else:
groupItem = QtGui.QTreeWidgetItem()
groupItem.setText(0,alg.group)
groups[alg.group] = groupItem
algItem = TreeAlgorithmItem(alg, layersCount)
groupItem.addChild(algItem)
providerItem = QtGui.QTreeWidgetItem()
providerItem.setText(0,providerName)
for groupItem in groups.values():
providerItem.addChild(groupItem)
self.algorithmTree.addTopLevelItem(providerItem)



@@ -21,7 +21,8 @@ def loadAlgorithms(self):
except Exception:
pass


def getName(self):
return "SAGA"



@@ -3,7 +3,7 @@ class SagaBlackList:
@staticmethod
def isBlackListed(name, group):

if "Lectures" == group:
if "lectures_introduction" == group:
return True

if "pointcloud_viewer" == group:

0 comments on commit eb91e9a

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