Skip to content
Permalink
Browse files
big QGIS update
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@24 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com committed Feb 26, 2012
1 parent 6ab1f52 commit 906d67a6946d6256f59f9e8f29415a4ff3e040d7
Showing 1,009 changed files with 25,660 additions and 18,232 deletions.
@@ -1,5 +1,6 @@
#Mon Jan 09 20:28:29 CET 2012
#Tue Feb 21 15:41:17 CET 2012
eclipse.preferences.version=1
encoding//src/sextante/ftools/ftools_utils.py=utf-8
encoding//src/sextante/gui/ui_ParametersDialog.py=utf-8
encoding//src/sextante/gui/ui_SextanteToolbox.py=utf-8
encoding//src/sextante/resources.py=utf-8
BIN -406 Bytes images/documenter.png
Binary file not shown.
BIN -750 Bytes images/grass.png
Binary file not shown.
BIN -829 Bytes images/r.png
Binary file not shown.
BIN -1.03 KB images/sextante.gif
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

@@ -11,7 +11,8 @@
from sextante.gui.HistoryDialog import HistoryDialog
from sextante.core.SextanteUtils import SextanteUtils
from sextante.gui.ConfigDialog import ConfigDialog
from sextante.gui.ModelerDialog import ModelerDialog
from sextante.modeler.ModelerDialog import ModelerDialog
from sextante.gui.ResultsDialog import ResultsDialog

cmd_folder = os.path.split(inspect.getfile( inspect.currentframe() ))[0]
if cmd_folder not in sys.path:
@@ -23,6 +24,7 @@ def __init__(self, iface):
self.iface = iface
QGisLayers.setInterface(iface)
Sextante.initialize()
Sextante .setInterface(iface)

def initGui(self):
self.toolbox = SextanteToolbox(self.iface)
@@ -31,30 +33,36 @@ def initGui(self):
self.menu = QMenu()
self.menu.setTitle("SEXTANTE")

icon = QIcon(os.path.dirname(__file__) + "/toolbox.png")
icon = QIcon(os.path.dirname(__file__) + "/images/toolbox.png")
self.toolboxAction = QAction(icon, \
"&SEXTANTE Toolbox", self.iface.mainWindow())
QObject.connect(self.toolboxAction, SIGNAL("triggered()"), self.openToolbox)
self.menu.addAction(self.toolboxAction)

icon = QIcon(os.path.dirname(__file__) + "/model.png")
icon = QIcon(os.path.dirname(__file__) + "/images/model.png")
self.modelerAction = QAction(icon, \
"&SEXTANTE Modeler", self.iface.mainWindow())
QObject.connect(self.modelerAction, SIGNAL("triggered()"), self.openModeler)
self.menu.addAction(self.modelerAction)

icon = QIcon(os.path.dirname(__file__) + "/history.gif")
icon = QIcon(os.path.dirname(__file__) + "/images/history.gif")
self.historyAction = QAction(icon, \
"&SEXTANTE History and log", self.iface.mainWindow())
QObject.connect(self.historyAction, SIGNAL("triggered()"), self.openHistory)
self.menu.addAction(self.historyAction)

icon = QIcon(os.path.dirname(__file__) + "/config.png")
icon = QIcon(os.path.dirname(__file__) + "/images/config.png")
self.configAction = QAction(icon, \
"&SEXTANTE options and configuration", self.iface.mainWindow())
QObject.connect(self.configAction, SIGNAL("triggered()"), self.openConfig)
self.menu.addAction(self.configAction)

icon = QIcon(os.path.dirname(__file__) + "/images/results.png")
self.resultsAction = QAction(icon, \
"&SEXTANTE results viewer", self.iface.mainWindow())
QObject.connect(self.resultsAction, SIGNAL("triggered()"), self.openResults)
self.menu.addAction(self.resultsAction)


menuBar = self.iface.mainWindow().menuBar()
menuBar.insertMenu(menuBar.actions()[-1], self.menu)
@@ -79,7 +87,12 @@ def openToolbox(self):
def openModeler(self):
dlg = ModelerDialog()
dlg.exec_()
if dlg.update:
self.toolbox.updateTree()

def openResults(self):
dlg = ResultsDialog()
dlg.exec_()

def openHistory(self):
dlg = HistoryDialog()

This file was deleted.

BIN -611 Bytes src/sextante/config.png
Binary file not shown.
@@ -0,0 +1,32 @@
from sextante.core.SextanteConfig import Setting, SextanteConfig
class AlgorithmProvider():

def __init__(self):
name = "ACTIVATE_" + self.getName().upper().replace(" ", "_")
SextanteConfig.addSetting(Setting(self.getName(), name, "Activate", True))
self.actions = []
self.contextMenuActions = []

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()

#method to be overriden. Algorithm loading should take place here
def _loadAlgorithms(self):
pass

def getSupportedOutputRasterLayerExtensions(self):
return ["tif"]

def getSupportedOutputVectorLayerExtensions(self):
return ["shp"]

def getSupportedOutputTableExtensions(self):
return ["dbf"]
@@ -3,6 +3,11 @@
from sextante.core.QGisLayers import QGisLayers
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.parameters.ParameterVector import ParameterVector
from PyQt4 import QtGui
import os.path
from sextante.core.SextanteUtils import SextanteUtils
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterBoolean import ParameterBoolean


class GeoAlgorithm:
@@ -18,17 +23,27 @@ def __init__(self):

#methods to overwrite when creating a custom geoalgorithm
#=========================================================
def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")

def processAlgorithm(self):
pass

def defineCharacteristics(self):
pass

#=========================================================

def execute(self, progress):
self.setOutputCRSFromInputLayers()
self.resolveTemporaryOutputs()
self.processAlgorithm(progress)

def resolveTemporaryOutputs(self):
for out in self.outputs:
if out.value == None:
SextanteUtils.setTempOutput(out, self)

def setOutputCRSFromInputLayers(self):
for param in self.parameters:
if isinstance(param, ParameterRaster):
@@ -38,17 +53,17 @@ def setOutputCRSFromInputLayers(self):
else:
continue
for layer in layers:
if layer.dataProvider().dataSourceUri() == param.value:
if layer.source() == param.value:
self.crs = layer.crs()
return


def putOutput(self, output):
def addOutput(self, output):
#TODO: check that name does not exist
if isinstance(output, Output):
self.outputs.append(output)

def putParameter(self, param):
def addParameter(self, param):
#TODO: check that name does not exist
if isinstance(param, Parameter):
self.parameters.append(param)
@@ -68,7 +83,6 @@ def canBeExecuted(self, layersCount):

def __str__(self):
s = "ALGORITHM: " + self.name + "\n"
#s+=self._descriptionFile + "\n"
for param in self.parameters:
s+=(str(param) + "\n")
for out in self.outputs:
@@ -78,20 +92,42 @@ def __str__(self):


def commandLineName(self):
return self.providerName + self.name.lower().replace(" ", "")
return self.provider.getName().lower() + ":" + self.name.lower().replace(" ", "")


def getOutputFromName(self, name):
for out in self.outputs:
if out.name == name:
return out

def getParameterFromName(self, name):
for param in self.parameters:
if param.name == name:
return param

def getOuputsChannelsAsMap(self):
retmap = {}
def getParameterValue(self, name):
for param in self.parameters:
if param.name == name:
if isinstance(param, ParameterNumber):
return float(param.value)
elif isinstance(param, ParameterBoolean):
return param.value == True
else:
return param.value
return None

def getOutputValue(self, name):
for out in self.outputs:
retmap[out.name] = out.channel
return retmap
if out.name == name:
return out.value
return None


def getAsCommand(self):
s="Sextante.runalg(\"" + self.commandLineName() + "\","
for param in self.parameters:
s+=param.getValueAsCommandLineParameter() + ","
for out in self.outputs:
s+=out.getChannelAsCommandLineParameter() + ","
s+=out.getValueAsCommandLineParameter() + ","
s= s[:-1] + ")"
return s

This file was deleted.

@@ -6,26 +6,28 @@

class QGisLayers:

ALL_TYPES = -1
iface = None;

@staticmethod
def getRasterLayers():
layers = QGisLayers.iface.legendInterface().layers()
layerNames = list()
raster = list()

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

@staticmethod
def getVectorLayers():
def getVectorLayers(shapetype=-1):
layers = QGisLayers.iface.legendInterface().layers()
layerNames = list()
vector = list()
for layer in layers:
if layer.type() == layer.VectorLayer :
layerNames.append(layer)
return layerNames
if shapetype == QGisLayers.ALL_TYPES or layer.geometryType() == shapetype:
vector.append(layer)
return vector

@staticmethod
def getTables():
@@ -50,6 +52,8 @@ def loadList(layers):

@staticmethod
def load(layer, name = None, crs = None):
if layer == None:
return
prjSetting = None
settings = QSettings()
try:
@@ -68,6 +72,8 @@ def load(layer, name = None, crs = None):
if crs != None:
qgslayer.setCrs(crs,False)
QgsMapLayerRegistry.instance().addMapLayer(qgslayer)
except Exception:
QtGui.QMessageBox(None, "Error", "Could not load layer: " + str(layer))
finally:
if prjSetting:
settings.setValue("/Projections/defaultBehaviour", prjSetting)
@@ -79,21 +85,23 @@ def loadMap(layersmap, crs):
QGisLayers.load(layersmap[name], name, crs)


@staticmethod
def loadFromAlg(alg):
QGisLayers.loadMap(alg.getOuputsChannelsAsMap(), alg.crs)


@staticmethod
def getObjectFromUri(uri):
layers = QGisLayers.getRasterLayers()
for layer in layers:
if layer.dataProvider().dataSourceUri() == uri:
if layer.source() == uri:
return layer
layers = QGisLayers.getVectorLayers()
for layer in layers:
if layer.dataProvider().dataSourceUri() == uri:
if layer.source() == uri:
return layer
#if is not opened, we open it
layer = QgsVectorLayer(uri, uri , 'ogr')
if layer.isValid():
return layer
layer = QgsRasterLayer(uri, uri)
if layer.isValid():
return layer



0 comments on commit 906d67a

Please sign in to comment.