Skip to content

Commit 75b77d0

Browse files
author
volayaf@gmail.com
committed
moving to qgis-plugin
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@10 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 593ef32 commit 75b77d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1411
-0
lines changed

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>sextante</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.python.pydev.PyDevBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.python.pydev.pythonNature</nature>
16+
</natures>
17+
</projectDescription>

.pydevproject

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?eclipse-pydev version="1.0"?>
3+
4+
<pydev_project>
5+
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
6+
<path>/sextante/src</path>
7+
</pydev_pathproperty>
8+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
9+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
10+
</pydev_project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#Mon Jan 09 20:28:29 CET 2012
2+
eclipse.preferences.version=1
3+
encoding//src/sextante/gui/ui_ParametersDialog.py=utf-8
4+
encoding//src/sextante/gui/ui_SextanteToolbox.py=utf-8
5+
encoding//src/sextante/resources.py=utf-8

build.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<project name="SEXTANTE_LIB" default="copy" basedir=".">
2+
<description>
3+
SEXTANTE
4+
</description>
5+
<property name="version.number" value="0.1"/>
6+
7+
<target name="copy"
8+
description="copy files">
9+
10+
<copy todir="C:/Users/volaya/.qgis/python/plugins/sextante">
11+
<fileset dir="src/sextante" includes="**"/>
12+
</copy>
13+
14+
</target>
15+
</project>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from PyQt4.QtCore import *
2+
from PyQt4.QtGui import *
3+
from qgis.core import *
4+
# Initialize Qt resources from file resources.py
5+
import resources
6+
# Import the code for the dialog
7+
8+
9+
import os, sys
10+
import inspect
11+
from sextante.core.Sextante import Sextante
12+
from sextante.gui.SextanteToolbox import SextanteToolbox
13+
from sextante.core.QGisLayers import QGisLayers
14+
15+
cmd_folder = os.path.split(inspect.getfile( inspect.currentframe() ))[0]
16+
if cmd_folder not in sys.path:
17+
sys.path.insert(0, cmd_folder)
18+
19+
class SextanteToolboxPlugin:
20+
21+
def __init__(self, iface):
22+
self.iface = iface
23+
QGisLayers.setInterface(iface)
24+
Sextante.initialize()
25+
26+
def initGui(self):
27+
28+
self.toolboxAction = QAction(QIcon(":/plugins/sextante/toolbox.png"), \
29+
"SEXTANTE Toolbox", self.iface.mainWindow())
30+
QObject.connect(self.toolboxAction, SIGNAL("triggered()"), self.openToolbox)
31+
self.iface.addPluginToMenu("&SEXTANTE", self.toolboxAction)
32+
33+
self.modelerAction = QAction(QIcon(":/plugins/sextante/modeler.png"), \
34+
"SEXTANTE Modeler", self.iface.mainWindow())
35+
QObject.connect(self.modelerAction, SIGNAL("triggered()"), self.openModeler)
36+
self.iface.addPluginToMenu("&SEXTANTE", self.modelerAction)
37+
38+
def unload(self):
39+
# Remove the plugin menu items
40+
self.iface.removePluginMenu("&SEXTANTE",self.toolboxAction)
41+
self.iface.removePluginMenu("&SEXTANTE",self.modelerAction)
42+
43+
def openToolbox(self):
44+
45+
dlg = SextanteToolbox()
46+
dlg.exec_()
47+
48+
def openModeler(self):
49+
pass

src/sextante/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from sextante.SextanteToolboxPlugin import SextanteToolboxPlugin
2+
3+
def name():
4+
return "SEXTANTE"
5+
def description():
6+
return "SEXTANTE Geoprocessing platform for QGIS"
7+
def version():
8+
return "Version 0.1"
9+
def icon():
10+
return "icon.png"
11+
def qgisMinimumVersion():
12+
return "1.0"
13+
def classFactory(iface):
14+
# load SextantePlugin class from file SextantePlugin
15+
return SextanteToolboxPlugin(iface)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AlgorithmProvider():
2+
3+
@property
4+
def algs(self):
5+
return self._algs

src/sextante/core/GeoAlgorithm.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
from sextante.outputs.Output import Output
2+
from sextante.parameters.Parameter import Parameter
3+
4+
class GeoAlgorithm:
5+
6+
def __init__(self):
7+
self.parameters = {}
8+
self.outputs = {}
9+
self.name = ""
10+
self.group = ""
11+
self.defineCharacteristics()
12+
self.providerName = ""
13+
14+
def execute(self):
15+
if self.checkParameters():
16+
self.proccessAlgorithm()
17+
18+
19+
def checkParameters(self):
20+
#TODO!!!!!!
21+
return True
22+
23+
def defineCharacteristics(self):
24+
pass
25+
26+
def processAlgorithm(self):
27+
pass
28+
#===============================================================================
29+
#
30+
# @property
31+
# def outputs(self):
32+
# return self._outputs
33+
#
34+
# @property
35+
# def parameters(self):
36+
# return self._parameters
37+
#
38+
# @property
39+
# def group(self):
40+
# return self._group
41+
#
42+
# @group.setter
43+
# def group(self, g):
44+
# self._group = g
45+
#
46+
# @property
47+
# def name(self):
48+
# return self._name
49+
#
50+
# @name.setter
51+
# def name(self, name):
52+
# self._name = name
53+
#===============================================================================
54+
55+
def putOutput(self, output):
56+
if isinstance(output, Output):
57+
self.outputs[output.name] = output
58+
59+
60+
def putParameter(self, param):
61+
if isinstance(param, Parameter):
62+
self.parameters[param.name] = param
63+
64+
def setParameterValue(self, paramName, value):
65+
param = self.parameters[paramName]
66+
if param != None:
67+
param.value = value
68+
69+
def canBeExecuted(self, layersCount):
70+
return True
71+
72+
def __str__(self):
73+
s = "ALGORITHM: " + self.name + "\n"
74+
s+=self._descriptionfile + "\n"
75+
for param in self.parameters.values():
76+
s+=(str(param) + "\n")
77+
for out in self.outputs.values():
78+
s+=(str(out) + "\n")
79+
s+=("\n")
80+
return s
81+
82+
def commandLineName(self):
83+
return self.providerName + self.name.lower().replace(" ", "")
84+
85+

src/sextante/core/QGisLayers.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from qgis.core import *
2+
3+
class QGisLayers:
4+
5+
iface = None;
6+
7+
@staticmethod
8+
def getLayers():
9+
layers = QGisLayers.iface.legendInterface().layers()
10+
layerNames = list()
11+
for l in layers:
12+
layerNames.append(l.name())
13+
return layerNames
14+
15+
16+
@staticmethod
17+
def setInterface(iface):
18+
QGisLayers.iface = iface
19+
20+
21+
@staticmethod
22+
def getLayersCount():
23+
count = LayersCount()
24+
return count
25+
26+
27+
28+
class LayersCount:
29+
30+
def __init__(self):
31+
self.raster = 0
32+
self.vector_point=0
33+
self.vector_line=0
34+
self.vector_polygon=0
35+
36+
37+

src/sextante/core/Sextante.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from sextante.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
2+
3+
class Sextante:
4+
5+
providers = [SagaAlgorithmProvider()]
6+
algs = {}
7+
8+
9+
def __init__(self):
10+
pass
11+
12+
@staticmethod
13+
def initialize():
14+
Sextante.loadAlgorithms()
15+
16+
@staticmethod
17+
def loadAlgorithms():
18+
for provider in Sextante.providers:
19+
algs = provider.algs
20+
for alg in algs:
21+
Sextante.algs[alg.commandLineName()] = alg
22+
23+
@staticmethod
24+
def getAlgorithm(name):
25+
return Sextante.algs[name]
26+
27+
28+
@staticmethod
29+
def asStr():
30+
s=""
31+
for alg in Sextante.algs.values():
32+
s+=(str(alg) + "\n")
33+
s+=str(len(Sextante.algs)) + " algorithms"
34+
return s
35+
36+
37+
38+
39+
40+
41+

0 commit comments

Comments
 (0)