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-03-29 19:44:40 +00:00
|
|
|
def initializeSettings(self):
|
|
|
|
'''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.
|
|
|
|
By default it just adds a setting to activate or deactivate algorithms from the provider'''
|
|
|
|
name = "ACTIVATE_" + self.getName().upper().replace(" ", "_")
|
|
|
|
SextanteConfig.addSetting(Setting(self.getName(), name, "Activate", True))
|
|
|
|
|
|
|
|
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-02-26 12:47:07 +00:00
|
|
|
def getName(self):
|
|
|
|
return "Generic algorithm provider"
|
|
|
|
|
|
|
|
def loadAlgorithms(self):
|
|
|
|
self.algs = []
|
|
|
|
name = "ACTIVATE_" + self.getName().upper().replace(" ", "_")
|
|
|
|
if not SextanteConfig.getSetting(name):
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self._loadAlgorithms()
|
|
|
|
|
2012-03-18 17:37:59 +00:00
|
|
|
#methods to be overridden.
|
2012-03-04 18:14:41 +00:00
|
|
|
#==============================
|
|
|
|
|
2012-03-29 19:44:40 +00:00
|
|
|
#Algorithm loading should take place here, filling self.algs, which is a list of
|
|
|
|
#elements of class GeoAlgorithm. Use that class to create your own algorithms
|
2012-03-27 14:30:32 +00:00
|
|
|
#Since algorithms should have a reference to the provider they come
|
|
|
|
#from, this is also the place to set the 'provider' variable of each algorithm
|
2012-02-26 12:47:07 +00:00
|
|
|
def _loadAlgorithms(self):
|
|
|
|
pass
|
|
|
|
|
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"]
|