Skip to content
Permalink
Browse files

added icons

added scripting stuff

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@16 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com
volayaf@gmail.com committed Jan 18, 2012
1 parent 71f731c commit 7a356f58bc790837ae0f9f806003c41170ea46ca
@@ -0,0 +1,54 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *


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 SextantePlugin:

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

def initGui(self):
self.toolbox = SextanteToolbox(self.iface)
self.toolbox.setVisible(False)

self.menu = QMenu()
self.menu.setTitle("SEXTANTE")

icon = QIcon(os.path.dirname(__file__) + "/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")
self.modelerAction = QAction(icon, \
"&SEXTANTE Modeler", self.iface.mainWindow())
QObject.connect(self.modelerAction, SIGNAL("triggered()"), self.openModeler)
self.menu.addAction(self.modelerAction)

menuBar = self.iface.mainWindow().menuBar()
menuBar.insertMenu(menuBar.actions()[-1], self.menu)

def unload(self):
self.toolbox.setVisible(False)
menuBar = self.iface.mainWindow().menuBar()
self.menu.deleteLater()

def openToolbox(self):
self.toolbox.setVisible(True)

def openModeler(self):
pass
@@ -1,4 +1,4 @@
from sextante.SextanteToolboxPlugin import SextanteToolboxPlugin
from sextante.SextantePlugin import SextantePlugin

def name():
return "SEXTANTE"
@@ -12,4 +12,4 @@ def qgisMinimumVersion():
return "1.0"
def classFactory(iface):
# load SextantePlugin class from file SextantePlugin
return SextanteToolboxPlugin(iface)
return SextantePlugin(iface)

This file was deleted.

@@ -1,9 +1,12 @@
from sextante.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
from sextante.script.ScriptAlgorithmProvider import ScriptAlgorithmProvider

class Sextante:

providers = [SagaAlgorithmProvider()]
providers = [SagaAlgorithmProvider(), ScriptAlgorithmProvider()]
algs = {}
actions = {}
contextMenuActions = []


def __init__(self):
@@ -12,16 +15,36 @@ def __init__(self):
@staticmethod
def initialize():
Sextante.loadAlgorithms()
Sextante.loadActions()
Sextante.loadContextMenuActions()

@staticmethod
def loadAlgorithms():
for provider in Sextante.providers:
providerAlgs = provider.algs
algs = {}
for alg in providerAlgs:
alg.icon = provider.icon
algs[alg.commandLineName()] = alg
Sextante.algs[provider.getName()] = algs

@staticmethod
def loadActions():
for provider in Sextante.providers:
providerActions = provider.actions
actions = list()
for action in providerActions:
action.icon = provider.icon
actions.append(action)
Sextante.actions[provider.getName()] = actions

@staticmethod
def loadContextMenuActions():
for provider in Sextante.providers:
providerActions = provider.contextMenuActions
for action in providerActions:
Sextante.contextMenuActions.append(action)

@staticmethod
def getAlgorithm(name):
for provider in Sextante.algs.values():
@@ -8,17 +8,24 @@ def userFolder():

return userfolder

@staticmethod
def softwareFolder():
path = os.path.join(os.path.dirname(__file__),"..","soft")
return path

@staticmethod
def isWindows():
return True
return os.path =="nt"


@staticmethod
def setTempOutput(out):
pass


@staticmethod
def addToLog(msg):
pass



@@ -13,14 +13,7 @@ def __init__(self, param, table):
QtGui.QDialog.__init__(self)
self.setModal(True)
self.param = param
if table != None:
self.table = table
else:
self.table = []
for i in range(param.numRows):
self.table.append(list())
for j in range(len(param.cols)):
self.table[i].append("0")
self.table = table
self.ui = Ui_FixedTableDialog()
self.ui.setupUi(self)
self.table = None
@@ -29,48 +22,53 @@ class Ui_FixedTableDialog(object):
def setupUi(self, dialog):
self.dialog = dialog
dialog.setObjectName(_fromUtf8("Dialog"))
dialog.resize(400, 350)
dialog.resize(600, 350)
dialog.setWindowTitle("Fixed Table")
self.buttonBox = QtGui.QDialogButtonBox(dialog)
self.buttonBox.setGeometry(QtCore.QRect(290, 10, 81, 61))
self.buttonBox.setGeometry(QtCore.QRect(490, 10, 81, 61))
self.buttonBox.setOrientation(QtCore.Qt.Vertical)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.table = QtGui.QTableWidget(dialog)
self.table.setGeometry(QtCore.QRect(10, 10, 270, 300))
self.table.setGeometry(QtCore.QRect(10, 10, 470, 300))
self.table.setObjectName(_fromUtf8("table"))
self.table.setColumnCount(len(self.dialog.param.cols))
for i in range(len(self.dialog.param.cols)):
self.table.setColumnWidth(i,380 / len(self.dialog.param.cols))
self.table.setHorizontalHeaderItem(i, QtGui.QTableWidgetItem(self.dialog.param.cols[i]))
self.table.setRowCount(self.dialog.param.numRows)
self.table.setRowCount(len(self.dialog.table))
for i in range(len(self.dialog.table)):
self.table.setRowHeight(i,22)
self.table.verticalHeader().setVisible(False)
self.addRow = QtGui.QPushButton(dialog)
self.addRow.setGeometry(QtCore.QRect(290, 290, 81, 23))
self.addRow.setObjectName(_fromUtf8("addRow"))
self.addRow.setText("Add row")
self.addRowButton = QtGui.QPushButton(dialog)
self.addRowButton.setGeometry(QtCore.QRect(490, 290, 81, 23))
self.addRowButton.setObjectName(_fromUtf8("addRowButton"))
self.addRowButton.setText("Add row")
self.setTableContent()
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), self.reject)
QtCore.QObject.connect(self.addRow, QtCore.SIGNAL(_fromUtf8("clicked()")), self.addRow)
QObject.connect(self.addRowButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.addRow)
QtCore.QMetaObject.connectSlotsByName(dialog)

def setTableContent(self):
for i in range(len(self.dialog.table)):
for j in range(len(self.dialog.table)):
for j in range(len(self.dialog.table[0])):
self.table.setItem(i,j,QtGui.QTableWidgetItem(self.dialog.table[i][j]))

def accept(self):
self.dialog.selectedoptions = []
for i in range(len(self.dialog.options)):
widget = self.table.cellWidget(i, 0)
if widget.isChecked():
self.dialog.selectedoptions.append(i)
self.dialog.table = []
for i in range(self.table.rowCount()):
self.dialog.table.append(list())
for j in range(self.table.columnCount()):
self.dialog.table[i].append(str(self.table.item(i,j).text()))
self.dialog.close()

def reject(self):
self.dialog.selectedoptions = None
self.dialog.table = None
self.dialog.close()

def addRow(self):
self.table.addRow()
self.table.setRowCount(self.table.rowCount()+1)
self.table.setRowHeight(self.table.rowCount()-1, 22)
for i in range(self.table.columnCount()):
self.table.setItem(self.table.rowCount()-1,i,QtGui.QTableWidgetItem("0"))
@@ -12,6 +12,10 @@ def __init__(self, param, parent = None):
super(FixedTablePanel, self).__init__(parent)
self.param = param
self.table = []
for i in range(param.numRows):
self.table.append(list())
for j in range(len(param.cols)):
self.table[i].append("0")
self.setObjectName(_fromUtf8("MSPanel"))
self.contents = QtGui.QWidget(self)
self.contents.setObjectName(_fromUtf8("contents"))
@@ -10,6 +10,9 @@
from sextante.gui.MultipleInputPanel import MultipleInputPanel
from sextante.parameters.ParameterFixedTable import ParameterFixedTable
from sextante.gui.FixedTablePanel import FixedTablePanel
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterRange import ParameterRange
from sextante.parameters.ParameterTableField import ParameterTableField

try:
_fromUtf8 = QtCore.QString.fromUtf8
@@ -33,6 +36,7 @@ def setupUi(self, dialog, alg):
self.alg = alg
self.dialog = dialog
self.valueItems = {}
self.depentItems = {}
dialog.setObjectName(_fromUtf8("Parameters"))
dialog.resize(650, 450)
self.buttonBox = QtGui.QDialogButtonBox(dialog)
@@ -77,6 +81,9 @@ def getWidgetFromParameter(self, param):
item = QtGui.QComboBox()
item.addItem("Yes")
item.addItem("No")
elif isinstance(param, ParameterTableField):
item = QtGui.QComboBox()
item = self.getFields(QGisLayers.getVectorLayers()[0])
elif isinstance(param, ParameterSelection):
item = QtGui.QComboBox()
item.addItems(param.options)
@@ -93,9 +100,16 @@ def getWidgetFromParameter(self, param):
item = MultipleInputPanel(opts)
else:
item = QtGui.QLineEdit()
if isinstance(param, ParameterNumber):
item.setText("0")
elif isinstance(param, ParameterRange):
item.setText("0,1")


return item

def getFields(self, layer):


def setTableContent(self):
params = self.alg.parameters
@@ -153,6 +167,8 @@ def setParamValue(self, param, widget):
param.value = widget.currentIndex() == 0
elif isinstance(param, ParameterSelection):
param.value = widget.currentIndex()
elif isinstance(param, ParameterFixedTable):
param.value = widget.table
elif isinstance(param, ParameterMultipleInput):
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = QGisLayers.getVectorLayers()
@@ -164,6 +180,17 @@ def setParamValue(self, param, widget):
for index in widget.selectedoptions:
value.append(options[index])
param.value = value
elif isinstance(param, ParameterRange):
text = widget.text()
tokens = text.split(",")
if len(tokens)!= 2:
return False
try:
n1 = float(tokens[0])
n2 = float(tokens[1])
except:
return False

else:
param.value = widget.text()

0 comments on commit 7a356f5

Please sign in to comment.
You can’t perform that action at this time.