Skip to content

Commit

Permalink
moving to qgis-plugin
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@10 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com committed Jan 10, 2012
1 parent 593ef32 commit 75b77d0
Show file tree
Hide file tree
Showing 48 changed files with 1,411 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>sextante</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
10 changes: 10 additions & 0 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse-pydev version="1.0"?>

<pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/sextante/src</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>
5 changes: 5 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Mon Jan 09 20:28:29 CET 2012
eclipse.preferences.version=1
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
15 changes: 15 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<project name="SEXTANTE_LIB" default="copy" basedir=".">
<description>
SEXTANTE
</description>
<property name="version.number" value="0.1"/>

<target name="copy"
description="copy files">

<copy todir="C:/Users/volaya/.qgis/python/plugins/sextante">
<fileset dir="src/sextante" includes="**"/>
</copy>

</target>
</project>
49 changes: 49 additions & 0 deletions src/sextante/SextanteToolboxPlugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
# Initialize Qt resources from file resources.py
import resources
# Import the code for the dialog


import os, sys
import inspect
from sextante.core.Sextante import Sextante
from sextante.gui.SextanteToolbox import SextanteToolbox
from sextante.core.QGisLayers import QGisLayers

cmd_folder = os.path.split(inspect.getfile( inspect.currentframe() ))[0]
if cmd_folder not in sys.path:
sys.path.insert(0, cmd_folder)

class SextanteToolboxPlugin:

def __init__(self, iface):
self.iface = iface
QGisLayers.setInterface(iface)
Sextante.initialize()

def initGui(self):

self.toolboxAction = QAction(QIcon(":/plugins/sextante/toolbox.png"), \
"SEXTANTE Toolbox", self.iface.mainWindow())
QObject.connect(self.toolboxAction, SIGNAL("triggered()"), self.openToolbox)
self.iface.addPluginToMenu("&SEXTANTE", self.toolboxAction)

self.modelerAction = QAction(QIcon(":/plugins/sextante/modeler.png"), \
"SEXTANTE Modeler", self.iface.mainWindow())
QObject.connect(self.modelerAction, SIGNAL("triggered()"), self.openModeler)
self.iface.addPluginToMenu("&SEXTANTE", self.modelerAction)

def unload(self):
# Remove the plugin menu items
self.iface.removePluginMenu("&SEXTANTE",self.toolboxAction)
self.iface.removePluginMenu("&SEXTANTE",self.modelerAction)

def openToolbox(self):

dlg = SextanteToolbox()
dlg.exec_()

def openModeler(self):
pass
15 changes: 15 additions & 0 deletions src/sextante/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from sextante.SextanteToolboxPlugin import SextanteToolboxPlugin

def name():
return "SEXTANTE"
def description():
return "SEXTANTE Geoprocessing platform for QGIS"
def version():
return "Version 0.1"
def icon():
return "icon.png"
def qgisMinimumVersion():
return "1.0"
def classFactory(iface):
# load SextantePlugin class from file SextantePlugin
return SextanteToolboxPlugin(iface)
5 changes: 5 additions & 0 deletions src/sextante/core/AlgorithmProvider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AlgorithmProvider():

@property
def algs(self):
return self._algs
85 changes: 85 additions & 0 deletions src/sextante/core/GeoAlgorithm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from sextante.outputs.Output import Output
from sextante.parameters.Parameter import Parameter

class GeoAlgorithm:

def __init__(self):
self.parameters = {}
self.outputs = {}
self.name = ""
self.group = ""
self.defineCharacteristics()
self.providerName = ""

def execute(self):
if self.checkParameters():
self.proccessAlgorithm()


def checkParameters(self):
#TODO!!!!!!
return True

def defineCharacteristics(self):
pass

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


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

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

def canBeExecuted(self, layersCount):
return True

def __str__(self):
s = "ALGORITHM: " + self.name + "\n"
s+=self._descriptionfile + "\n"
for param in self.parameters.values():
s+=(str(param) + "\n")
for out in self.outputs.values():
s+=(str(out) + "\n")
s+=("\n")
return s

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


37 changes: 37 additions & 0 deletions src/sextante/core/QGisLayers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from qgis.core import *

class QGisLayers:

iface = None;

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


@staticmethod
def setInterface(iface):
QGisLayers.iface = iface


@staticmethod
def getLayersCount():
count = LayersCount()
return count



class LayersCount:

def __init__(self):
self.raster = 0
self.vector_point=0
self.vector_line=0
self.vector_polygon=0



41 changes: 41 additions & 0 deletions src/sextante/core/Sextante.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from sextante.saga.SagaAlgorithmProvider import SagaAlgorithmProvider

class Sextante:

providers = [SagaAlgorithmProvider()]
algs = {}


def __init__(self):
pass

@staticmethod
def initialize():
Sextante.loadAlgorithms()

@staticmethod
def loadAlgorithms():
for provider in Sextante.providers:
algs = provider.algs
for alg in algs:
Sextante.algs[alg.commandLineName()] = alg

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


@staticmethod
def asStr():
s=""
for alg in Sextante.algs.values():
s+=(str(alg) + "\n")
s+=str(len(Sextante.algs)) + " algorithms"
return s







11 changes: 11 additions & 0 deletions src/sextante/core/SextanteTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from sextante.core.Sextante import Sextante


def main():
Sextante.initialize()
print(Sextante.asStr())



if __name__ == '__main__':
main()
36 changes: 36 additions & 0 deletions src/sextante/core/SextanteUtils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
class SextanteUtils:

@staticmethod
def userFolder():
userfolder = os.getenv('HOME') + os.sep + "sextante"
mkdir(userfolder)

return userfolder


@staticmethod
def isWindows():
return True


@staticmethod
def setTempOutput(out):
pass







def mkdir(newdir):
if os.path.isdir(newdir):
pass
else:
head, tail = os.path.split(newdir)
if head and not os.path.isdir(head):
mkdir(head)
if tail:
os.mkdir(newdir)

Empty file added src/sextante/core/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions src/sextante/gui/ParametersDialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

from PyQt4 import QtGui

from sextante.gui.ui_ParametersDialog import Ui_ParametersDialog

class ParametersDialog(QtGui.QDialog):
def __init__(self, alg):
QtGui.QDialog.__init__(self)
self.setModal(True)
self.alg = alg
self.ui = Ui_ParametersDialog()
self.ui.setupUi(self)

Loading

0 comments on commit 75b77d0

Please sign in to comment.