2012-02-26 12:47:07 +00:00
|
|
|
from sextante.core.SextanteConfig import Setting, SextanteConfig
|
2012-03-04 18:14:41 +00:00
|
|
|
import os
|
|
|
|
from PyQt4 import QtGui
|
2012-03-29 19:44:40 +00:00
|
|
|
|
2012-02-26 12:47:07 +00:00
|
|
|
class AlgorithmProvider():
|
2012-03-29 19:44:40 +00:00
|
|
|
'''this is the base class for algorithms providers.
|
|
|
|
An algorithm provider is a set of related algorithms, typically from the same
|
|
|
|
external application or related to a common area of analysis.
|
|
|
|
'''
|
|
|
|
|
2012-02-26 12:47:07 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.actions = []
|
|
|
|
self.contextMenuActions = []
|
|
|
|
|
2012-04-01 09:15:16 +00:00
|
|
|
def loadAlgorithms(self):
|
|
|
|
self.algs = []
|
|
|
|
name = "ACTIVATE_" + self.getName().upper().replace(" ", "_")
|
|
|
|
if not SextanteConfig.getSetting(name):
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self._loadAlgorithms()
|
2012-04-06 09:01:08 +00:00
|
|
|
for alg in self.algs:
|
|
|
|
alg.provider = self
|
2012-04-01 09:15:16 +00:00
|
|
|
|
|
|
|
#methods to be overridden.
|
|
|
|
#==============================
|
|
|
|
|
|
|
|
def _loadAlgorithms(self):
|
|
|
|
'''Algorithm loading should take place here, filling self.algs, which is a list of
|
2012-04-06 09:01:08 +00:00
|
|
|
elements of class GeoAlgorithm. Use that class to create your own algorithms'''
|
2012-04-01 09:15:16 +00:00
|
|
|
pass
|
|
|
|
|
2012-03-29 19:44:40 +00:00
|
|
|
def initializeSettings(self):
|
2012-04-06 09:01:08 +00:00
|
|
|
'''this is the place where you should add config parameters to SEXTANTE using the SextanteConfig class.
|
|
|
|
this method is called when a provider is added to SEXTANTE.
|
2012-03-29 19:44:40 +00:00
|
|
|
By default it just adds a setting to activate or deactivate algorithms from the provider'''
|
2012-04-25 17:09:08 +00:00
|
|
|
SextanteConfig.settingIcons[self.getDescription()] = self.getIcon()
|
2012-03-29 19:44:40 +00:00
|
|
|
name = "ACTIVATE_" + self.getName().upper().replace(" ", "_")
|
2012-04-25 15:51:34 +00:00
|
|
|
SextanteConfig.addSetting(Setting(self.getDescription(), name, "Activate", True))
|
2012-03-29 19:44:40 +00:00
|
|
|
|
|
|
|
def unload(self):
|
|
|
|
'''Do here anything that you want to be done when the provider is removed from the list of available ones.
|
|
|
|
This method is called when you remove the provider from Sextante.
|
|
|
|
Removal of config setting should be done here'''
|
|
|
|
name = "ACTIVATE_" + self.getName().upper().replace(" ", "_")
|
|
|
|
SextanteConfig.removeSetting(name)
|
2012-04-01 09:15:16 +00:00
|
|
|
|
2012-02-26 12:47:07 +00:00
|
|
|
def getName(self):
|
2012-04-24 17:28:11 +00:00
|
|
|
'''Returns the name to use to create the command-line name. Should be a short descriptive name of the provider'''
|
|
|
|
return "sextante"
|
|
|
|
|
|
|
|
def getDescription(self):
|
|
|
|
'''Returns the full name of the provider'''
|
2012-02-26 12:47:07 +00:00
|
|
|
return "Generic algorithm provider"
|
|
|
|
|
|
|
|
|
2012-03-04 18:14:41 +00:00
|
|
|
def getIcon(self):
|
|
|
|
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
|
|
|
|
|
2012-02-26 12:47:07 +00:00
|
|
|
def getSupportedOutputRasterLayerExtensions(self):
|
|
|
|
return ["tif"]
|
|
|
|
|
|
|
|
def getSupportedOutputVectorLayerExtensions(self):
|
|
|
|
return ["shp"]
|
|
|
|
|
|
|
|
def getSupportedOutputTableExtensions(self):
|
|
|
|
return ["dbf"]
|