Skip to content

Commit

Permalink
[sextante] improved toolbox and modeler to better use classification …
Browse files Browse the repository at this point in the history
…by categories (easy mode)
  • Loading branch information
volaya committed Feb 17, 2013
1 parent 5fead9f commit 7c67101
Show file tree
Hide file tree
Showing 5 changed files with 333 additions and 141 deletions.
7 changes: 4 additions & 3 deletions python/plugins/sextante/core/Sextante.py
Expand Up @@ -30,7 +30,7 @@
from sextante.core.SextanteConfig import SextanteConfig
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.SextanteLog import SextanteLog
from sextante.core.AlgorithmClassification import AlgorithmDecorator
from sextante.gui.AlgorithmClassification import AlgorithmDecorator
from sextante.gui.AlgorithmExecutor import AlgorithmExecutor
from sextante.gui.RenderingStyles import RenderingStyles
from sextante.gui.SextantePostprocessing import SextantePostprocessing
Expand Down Expand Up @@ -127,11 +127,11 @@ def initialize():
Sextante.addProvider(AdminToolsAlgorithmProvider())
Sextante.modeler.initializeSettings();
#and initialize
AlgorithmDecorator.loadClassification()
SextanteLog.startLogging()
SextanteConfig.initialize()
SextanteConfig.loadSettings()
RenderingStyles.loadStyles()
AlgorithmDecorator.loadClassification()
RenderingStyles.loadStyles()
Sextante.loadFromProviders()

@staticmethod
Expand Down Expand Up @@ -378,6 +378,7 @@ def alghelp(name):
alg = Sextante.getAlgorithm(name)
if alg != None:
print(str(alg))
algoptions(name)
else:
print "Algorithm not found"

Expand Down
Expand Up @@ -2,9 +2,9 @@

"""
***************************************************************************
SextanteToolbox.py
AlgorithmClassification.py
---------------------
Date : August 2012
Date : November 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
Expand All @@ -16,8 +16,6 @@
* *
***************************************************************************
"""
from sextante.core.SextanteUtils import SextanteUtils

__author__ = 'Victor Olaya'
__date__ = 'November 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -31,30 +29,33 @@ class AlgorithmDecorator():
classification = {};

@staticmethod
def loadClassification():
def loadClassification():
if not os.path.isfile(AlgorithmDecorator.classificationFile()):
return
lines = open(AlgorithmDecorator.classificationFile())
line = lines.readline().strip("\n")
while line != "":
tokens = line.split("\t")
AlgorithmDecorator.classification[tokens[0]] = (tokens[1], tokens[2], tokens[3]);
tokens = line.split(",")
subtokens = tokens[2].split("/")
AlgorithmDecorator.classification[tokens[0]] = (subtokens[0], subtokens[1], tokens[1]);
line = lines.readline().strip("\n")
lines.close()

@staticmethod
def classificationFile():
return os.path.join(SextanteUtils.userFolder(), "sextante_qgis_algclass.txt")
def classificationFile():
folder = os.path.join(os.path.dirname(__file__), "help")
f = os.path.join(folder, "algclasssification.txt")
return f

@staticmethod
def getGroupsAndName(alg):
if alg.commandLineName() in AlgorithmDecorator.classification:
group, subgroup, name = AlgorithmDecorator.classification[alg.commandLineName]
if alg.commandLineName().lower() in AlgorithmDecorator.classification:
group, subgroup, name = AlgorithmDecorator.classification[alg.commandLineName()]
if name == "USE_ORIGINAL_NAME":
name = alg.name
return (group, subgroup, name)
else:
return ("Uncategorized", alg.group, alg.name)
return (None,None,alg.commandLineName())



Expand Down
9 changes: 3 additions & 6 deletions python/plugins/sextante/gui/SextanteToolbox.py
Expand Up @@ -22,22 +22,17 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
import sys
import subprocess

from PyQt4.QtCore import *
from PyQt4.QtGui import *

import webbrowser
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.modeler.Providers import Providers
from sextante.core.AlgorithmClassification import AlgorithmDecorator
from sextante.gui.AlgorithmClassification import AlgorithmDecorator
from sextante.core.Sextante import Sextante
from sextante.core.SextanteLog import SextanteLog
from sextante.core.SextanteConfig import SextanteConfig
from sextante.core.QGisLayers import QGisLayers

from sextante.gui.ParametersDialog import ParametersDialog
from sextante.gui.BatchProcessingDialog import BatchProcessingDialog
from sextante.gui.EditRenderingStylesDialog import EditRenderingStylesDialog
Expand Down Expand Up @@ -192,6 +187,8 @@ def fillTreeUsingCategories(self):
if not alg.showInToolbox:
continue
altgroup, altsubgroup, altname = AlgorithmDecorator.getGroupsAndName(alg)
if altgroup is None:
continue
if text =="" or text.lower() in altname.lower():
if altgroup not in groups:
groups[altgroup] = {}
Expand Down

0 comments on commit 7c67101

Please sign in to comment.