Skip to content

Commit

Permalink
Started adding an auto configuration mechanism
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@75 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com committed Apr 13, 2012
1 parent 8dd4574 commit 365ccd3
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/sextante/SextantePlugin.py
Expand Up @@ -13,6 +13,7 @@
from sextante.gui.ResultsDialog import ResultsDialog
from sextante.about.AboutDialog import AboutDialog
import subprocess
from sextante.core.SextanteExternalAppsConfigurer import SextanteExternalAppsConfigurer

cmd_folder = os.path.split(inspect.getfile( inspect.currentframe() ))[0]
if cmd_folder not in sys.path:
Expand All @@ -25,6 +26,8 @@ def __init__(self, iface):
QGisLayers.setInterface(iface)
Sextante.initialize()
Sextante.setInterface(iface)
SextanteExternalAppsConfigurer.autoConfigure()


def initGui(self):
self.toolbox = SextanteToolbox(self.iface)
Expand Down
2 changes: 1 addition & 1 deletion src/sextante/core/Sextante.py
Expand Up @@ -80,12 +80,12 @@ def initialize():
Sextante.addProvider(MMQGISAlgorithmProvider())
Sextante.addProvider(FToolsAlgorithmProvider())
Sextante.addProvider(ModelerOnlyAlgorithmProvider())
Sextante.addProvider(ScriptAlgorithmProvider())
Sextante.addProvider(RAlgorithmProvider())
Sextante.addProvider(SagaAlgorithmProvider())
Sextante.addProvider(GrassAlgorithmProvider())
Sextante.addProvider(GdalAlgorithmProvider())
Sextante.addProvider(OTBAlgorithmProvider())
Sextante.addProvider(ScriptAlgorithmProvider())
Sextante.modeler.initializeSettings();
#and initialize
SextanteLog.startLogging()
Expand Down
6 changes: 6 additions & 0 deletions src/sextante/core/SextanteConfig.py
Expand Up @@ -82,6 +82,12 @@ def getSetting(name):
else:
return None

@staticmethod
def setSettingValue(name, value):
if name in SextanteConfig.settings.keys():
SextanteConfig.settings[name].value = value
SextanteConfig.saveSettings()


class Setting():
'''A simple config parameter that will appear on the SEXTANTE config dialog'''
Expand Down
14 changes: 14 additions & 0 deletions src/sextante/core/SextanteExternalAppsConfigurer.py
@@ -0,0 +1,14 @@
from sextante.core.SextanteConfig import SextanteConfig
from PyQt4 import QtCore
class SextanteExternalAppsConfigurer():

@staticmethod
def autoConfigure():
IS_FIRST_USAGE = "IS_FIRST_USAGE"
settings = QtCore.QSettings()
if not settings.contains(IS_FIRST_USAGE):
settings.setValue(IS_FIRST_USAGE, True)




2 changes: 1 addition & 1 deletion src/sextante/gdal/polygonize.py
Expand Up @@ -24,7 +24,7 @@ def defineCharacteristics(self):
self.addOutput(OutputVector(polygonize.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):
commands = ["polygonize"]
commands = ["gdal_polygonize"]
commands.append(self.getParameterValue(polygonize.INPUT))
commands.append("-f")
commands.append("ESRI Shapefile")
Expand Down
13 changes: 13 additions & 0 deletions src/sextante/gui/ExtentSelectionPanel.py
Expand Up @@ -31,6 +31,19 @@ def __init__(self, default):
self.connect(self.tool, SIGNAL("rectangleCreated()"), self.fillCoords)

def buttonPushed(self):
popupmenu = QMenu()
useLayerExtentAction = QtGui.QAction("Use layer/canvas extent", self.pushButton)
useLayerExtentAction.triggered.connect(self.useLayerExtent)
popupmenu.addAction(useLayerExtentAction)
selectOnCanvasAction = QtGui.QAction("Select extent on canvas", self.pushButton)
selectOnCanvasAction.triggered.connect(self.selectOnCanvas)
popupmenu.addAction(selectOnCanvasAction)
popupmenu.exec_(QtGui.QCursor.pos())

def useLayerExtent(self):
pass

def selectOnCanvas(self):
canvas = QGisLayers.iface.mapCanvas()
canvas.setMapTool(self.tool)

Expand Down
2 changes: 1 addition & 1 deletion src/sextante/gui/ParametersDialog.py
Expand Up @@ -35,7 +35,7 @@ class ParametersDialog(QtGui.QDialog):
'''the default parameters dialog, to be used when an algorithm is called from the toolbox'''
def __init__(self, alg):
QtGui.QDialog.__init__(self)
self.setModal(True)
self.setModal(False)
self.ui = Ui_ParametersDialog()
self.ui.setupUi(self, alg)
self.executed = False
Expand Down
3 changes: 2 additions & 1 deletion src/sextante/gui/SextanteToolbox.py
Expand Up @@ -97,7 +97,8 @@ def executeAlgorithm(self):
item = self.algorithmTree.currentItem()
if isinstance(item, TreeAlgorithmItem):
alg = Sextante.getAlgorithm(item.alg.commandLineName())
if alg.checkBeforeOpeningParametersDialog():
message = alg.checkBeforeOpeningParametersDialog()
if message:
QtGui.QMessageBox.warning(self, "Warning", message)
return
alg = copy.deepcopy(alg)
Expand Down
1 change: 1 addition & 0 deletions src/sextante/modeler/ModelerAlgorithm.py
Expand Up @@ -263,6 +263,7 @@ def getOutputType(self, i, outname):


def getAsPythonCode(self):
return
s = []
for param in self.parameters:
s.append(str(param.getAsScriptCode().lower()))
Expand Down
5 changes: 4 additions & 1 deletion src/sextante/script/ScriptAlgorithm.py
Expand Up @@ -43,7 +43,10 @@ def defineCharacteristicsFromFile(self):
line = lines.readline()
while line != "":
if line.startswith("##"):
self.processParameterLine(line.strip("\n"))
try:
self.processParameterLine(line.strip("\n"))
except:
raise WrongScriptException("Could not load script: " + self.descriptionFile +"\n" + "Problem with line: " + line)
self.script += line
line = lines.readline()
lines.close()
Expand Down

0 comments on commit 365ccd3

Please sign in to comment.