Skip to content

Commit

Permalink
indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Mar 1, 2016
1 parent a4a658a commit 0571395
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 86 deletions.
1 change: 0 additions & 1 deletion python/plugins/processing/algs/qgis/DefineProjection.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def defineCharacteristics(self):
self.addOutput(OutputVector(self.OUTPUT,
self.tr('Layer with projection'), True))


def processAlgorithm(self, progress):
fileName = self.getParameterValue(self.INPUT)
layer = dataobjects.getObjectFromUri(fileName)
Expand Down
1 change: 0 additions & 1 deletion python/plugins/processing/algs/qgis/SpatialIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def defineCharacteristics(self):
self.addOutput(OutputVector(self.OUTPUT,
self.tr('Indexed layer'), True))


def processAlgorithm(self, progress):
fileName = self.getParameterValue(self.INPUT)
layer = dataobjects.getObjectFromUri(fileName)
Expand Down
1 change: 0 additions & 1 deletion python/plugins/processing/core/Processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
progress.close()
return alg


@staticmethod
def tr(string, context=''):
if context == '':
Expand Down
174 changes: 91 additions & 83 deletions python/plugins/processing/gui/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,94 +10,95 @@
defaultMenuEntries = {}
vectorMenu = Processing.tr('Vect&or')
analysisToolsMenu = vectorMenu + "/" + Processing.tr('&Analysis Tools')
defaultMenuEntries.update({'qgis:distancematrix':analysisToolsMenu,
'qgis:sumlinelengths':analysisToolsMenu,
'qgis:pointsinpolygon':analysisToolsMenu,
'qgis:listuniquevalues':analysisToolsMenu,
'qgis:basicstatisticsfornumericfields':analysisToolsMenu,
'qgis:basicstatisticsfortextfields':analysisToolsMenu,
'qgis:nearestneighbouranalysis':analysisToolsMenu,
'qgis:meancoordinates':analysisToolsMenu,
'qgis:lineintersecions':analysisToolsMenu})
defaultMenuEntries.update({'qgis:distancematrix': analysisToolsMenu,
'qgis:sumlinelengths': analysisToolsMenu,
'qgis:pointsinpolygon': analysisToolsMenu,
'qgis:listuniquevalues': analysisToolsMenu,
'qgis:basicstatisticsfornumericfields': analysisToolsMenu,
'qgis:basicstatisticsfortextfields': analysisToolsMenu,
'qgis:nearestneighbouranalysis': analysisToolsMenu,
'qgis:meancoordinates': analysisToolsMenu,
'qgis:lineintersecions': analysisToolsMenu})
researchToolsMenu = vectorMenu + "/" + Processing.tr('&Research Tools')
defaultMenuEntries.update({'qgis:randomselection':researchToolsMenu,
'qgis:randomselectionwithinsubsets':researchToolsMenu,
'qgis:randompointsinextent':researchToolsMenu,
'qgis:randompointsinlayerbounds':researchToolsMenu,
'qgis:randompointsinsidepolygonsfixed':researchToolsMenu,
'qgis:randompointsinsidepolygonsvariable':researchToolsMenu,
'qgis:regularpoints':researchToolsMenu,
'qgis:vectorgrid':researchToolsMenu,
'qgis:selectbylocation':researchToolsMenu,
'qgis:polygonfromlayerextent':researchToolsMenu})
defaultMenuEntries.update({'qgis:randomselection': researchToolsMenu,
'qgis:randomselectionwithinsubsets': researchToolsMenu,
'qgis:randompointsinextent': researchToolsMenu,
'qgis:randompointsinlayerbounds': researchToolsMenu,
'qgis:randompointsinsidepolygonsfixed': researchToolsMenu,
'qgis:randompointsinsidepolygonsvariable': researchToolsMenu,
'qgis:regularpoints': researchToolsMenu,
'qgis:vectorgrid': researchToolsMenu,
'qgis:selectbylocation': researchToolsMenu,
'qgis:polygonfromlayerextent': researchToolsMenu})

geoprocessingToolsMenu = vectorMenu + "/" + Processing.tr('&Geoprocessing Tools')
defaultMenuEntries.update({'qgis:convexhull':geoprocessingToolsMenu,
'qgis:fixeddistancebuffer':geoprocessingToolsMenu,
'qgis:variabledistancebuffer':geoprocessingToolsMenu,
'qgis:intersection':geoprocessingToolsMenu,
'qgis:union':geoprocessingToolsMenu,
'qgis:symmetricaldifference':geoprocessingToolsMenu,
'qgis:clip':geoprocessingToolsMenu,
'qgis:difference':geoprocessingToolsMenu,
'qgis:dissolve':geoprocessingToolsMenu,
'qgis:eliminatesliverpolygons':geoprocessingToolsMenu})
defaultMenuEntries.update({'qgis:convexhull': geoprocessingToolsMenu,
'qgis:fixeddistancebuffer': geoprocessingToolsMenu,
'qgis:variabledistancebuffer': geoprocessingToolsMenu,
'qgis:intersection': geoprocessingToolsMenu,
'qgis:union': geoprocessingToolsMenu,
'qgis:symmetricaldifference': geoprocessingToolsMenu,
'qgis:clip': geoprocessingToolsMenu,
'qgis:difference': geoprocessingToolsMenu,
'qgis:dissolve': geoprocessingToolsMenu,
'qgis:eliminatesliverpolygons': geoprocessingToolsMenu})
geometryToolsMenu = vectorMenu + "/" + Processing.tr('G&eometry Tools')
defaultMenuEntries.update({'qgis:checkvalidity':geometryToolsMenu,
'qgis:exportaddgeometrycolumns':geometryToolsMenu,
'qgis:polygoncentroids':geometryToolsMenu,
'qgis:delaunaytriangulation':geometryToolsMenu,
'qgis:voronoipolygons':geometryToolsMenu,
'qgis:simplifygeometries':geometryToolsMenu,
'qgis:densifygeometries':geometryToolsMenu,
'qgis:multiparttosingleparts':geometryToolsMenu,
'qgis:singlepartstomultipart':geometryToolsMenu,
'qgis:polygonstolines':geometryToolsMenu,
'qgis:linestopolygons':geometryToolsMenu,
'qgis:extractnodes':geometryToolsMenu})
defaultMenuEntries.update({'qgis:checkvalidity': geometryToolsMenu,
'qgis:exportaddgeometrycolumns': geometryToolsMenu,
'qgis:polygoncentroids': geometryToolsMenu,
'qgis:delaunaytriangulation': geometryToolsMenu,
'qgis:voronoipolygons': geometryToolsMenu,
'qgis:simplifygeometries': geometryToolsMenu,
'qgis:densifygeometries': geometryToolsMenu,
'qgis:multiparttosingleparts': geometryToolsMenu,
'qgis:singlepartstomultipart': geometryToolsMenu,
'qgis:polygonstolines': geometryToolsMenu,
'qgis:linestopolygons': geometryToolsMenu,
'qgis:extractnodes': geometryToolsMenu})
managementToolsMenu = vectorMenu + "/" + Processing.tr('&Data Management Tools')
defaultMenuEntries.update({'qgis:definecurrentprojection':managementToolsMenu,
'qgis:joinattributesbylocation':managementToolsMenu,
'qgis:splitvectorlayer':managementToolsMenu,
'qgis:mergevectorlayers':managementToolsMenu,
'qgis:createspatialindex':managementToolsMenu})

#~ rasterMenu = Processing.tr('&Raster')
#~ projectionsMenu = rasterMenu + "/" + Processing.tr('Projections')
#~ defaultMenuEntries.update({'gdalogr:warpreproject':projectionsMenu,
#~ 'gdalogr:assignprojection':projectionsMenu,
#~ 'gdalogr:extractprojection':projectionsMenu})
#~ conversionMenu = rasterMenu + "/" + Processing.tr('Conversion')
#~ defaultMenuEntries.update({'gdalogr:rasterize':conversionMenu,
#~ 'gdalogr:rasterize_over':conversionMenu,
#~ 'gdalogr:polygonize':conversionMenu,
#~ 'gdalogr:translate':conversionMenu,
#~ 'gdalogr:rgbtopct':conversionMenu,
#~ 'gdalogr:pcttorgb':conversionMenu})
#~ extractionMenu = rasterMenu + "/" + Processing.tr('Extraction')
#~ defaultMenuEntries.update({'gdalogr:contour':extractionMenu,
#~ 'gdalogr:cliprasterbyextent':extractionMenu,
#~ 'gdalogr:cliprasterbymasklayer':extractionMenu})
#~ analysisMenu = rasterMenu + "/" + Processing.tr('Analysis')
#~ defaultMenuEntries.update({'gdalogr:sieve':analysisMenu, 'gdalogr:nearblack':analysisMenu,
#~ 'gdalogr:fillnodata':analysisMenu,
#~ 'gdalogr:proximity':analysisMenu,
#~ 'gdalogr:griddatametrics':analysisMenu,
#~ 'gdalogr:gridaverage':analysisMenu,
#~ 'gdalogr:gridinvdist':analysisMenu,
#~ 'gdalogr:gridnearestneighbor':analysisMenu,
#~ 'gdalogr:aspect':analysisMenu,
#~ 'gdalogr:hillshade':analysisMenu,
#~ 'gdalogr:roughness':analysisMenu,
#~ 'gdalogr:slope':analysisMenu,
#~ 'gdalogr:tpi':analysisMenu,
#~ 'gdalogr:tri':analysisMenu})
#~ miscMenu = rasterMenu + "/" + Processing.tr('Miscellaneous')
#~ defaultMenuEntries.update({'gdalogr:buildvirtualraster':miscMenu,
#~ 'gdalogr:merge':miscMenu,
#~ 'gdalogr:rasterinfo':miscMenu,
#~ 'gdalogr:overviews':miscMenu,
#~ 'gdalogr:tileindex':miscMenu})
defaultMenuEntries.update({'qgis:definecurrentprojection': managementToolsMenu,
'qgis:joinattributesbylocation': managementToolsMenu,
'qgis:splitvectorlayer': managementToolsMenu,
'qgis:mergevectorlayers': managementToolsMenu,
'qgis:createspatialindex': managementToolsMenu})
"""
rasterMenu = Processing.tr('&Raster')
projectionsMenu = rasterMenu + "/" + Processing.tr('Projections')
defaultMenuEntries.update({'gdalogr:warpreproject':projectionsMenu,
'gdalogr:assignprojection':projectionsMenu,
'gdalogr:extractprojection':projectionsMenu})
conversionMenu = rasterMenu + "/" + Processing.tr('Conversion')
defaultMenuEntries.update({'gdalogr:rasterize':conversionMenu,
'gdalogr:rasterize_over':conversionMenu,
'gdalogr:polygonize':conversionMenu,
'gdalogr:translate':conversionMenu,
'gdalogr:rgbtopct':conversionMenu,
'gdalogr:pcttorgb':conversionMenu})
extractionMenu = rasterMenu + "/" + Processing.tr('Extraction')
defaultMenuEntries.update({'gdalogr:contour':extractionMenu,
'gdalogr:cliprasterbyextent':extractionMenu,
'gdalogr:cliprasterbymasklayer':extractionMenu})
analysisMenu = rasterMenu + "/" + Processing.tr('Analysis')
defaultMenuEntries.update({'gdalogr:sieve':analysisMenu, 'gdalogr:nearblack':analysisMenu,
'gdalogr:fillnodata':analysisMenu,
'gdalogr:proximity':analysisMenu,
'gdalogr:griddatametrics':analysisMenu,
'gdalogr:gridaverage':analysisMenu,
'gdalogr:gridinvdist':analysisMenu,
'gdalogr:gridnearestneighbor':analysisMenu,
'gdalogr:aspect':analysisMenu,
'gdalogr:hillshade':analysisMenu,
'gdalogr:roughness':analysisMenu,
'gdalogr:slope':analysisMenu,
'gdalogr:tpi':analysisMenu,
'gdalogr:tri':analysisMenu})
miscMenu = rasterMenu + "/" + Processing.tr('Miscellaneous')
defaultMenuEntries.update({'gdalogr:buildvirtualraster':miscMenu,
'gdalogr:merge':miscMenu,
'gdalogr:rasterinfo':miscMenu,
'gdalogr:overviews':miscMenu,
'gdalogr:tileindex':miscMenu})
"""


def initializeMenus():
Expand All @@ -109,10 +110,12 @@ def initializeMenus():

ProcessingConfig.readSettings()


def updateMenus():
removeMenus()
createMenus()


def createMenus():
for provider in Processing.algs.values():
for alg in provider.values():
Expand All @@ -130,6 +133,7 @@ def removeMenus():
paths = menuPath.split("/")
removeAlgorithmEntry(alg, paths[0], paths[-1])


def addAlgorithmEntry(alg, menuName, submenuName, actionText=None, icon=None, addButton=False):
action = QAction(icon or alg.getIcon(), actionText or alg.name, iface.mainWindow())
action.triggered.connect(lambda: _executeAlgorithm(alg))
Expand All @@ -145,6 +149,7 @@ def addAlgorithmEntry(alg, menuName, submenuName, actionText=None, icon=None, ad
algorithmsToolbar = iface.addToolBar('ProcessingAlgorithms')
algorithmsToolbar.addAction(action)


def removeAlgorithmEntry(alg, menuName, submenuName, actionText=None, delButton=True):
if menuName:
menu = getMenu(menuName, iface.mainWindow().menuBar())
Expand All @@ -163,6 +168,7 @@ def removeAlgorithmEntry(alg, menuName, submenuName, actionText=None, delButton=
if action is not None:
algorithmsToolbar.removeAction(action)


def _executeAlgorithm(alg):
message = alg.checkBeforeOpeningParametersDialog()
if message:
Expand All @@ -188,6 +194,7 @@ def _executeAlgorithm(alg):
pass
canvas.setMapTool(prevMapTool)


def getMenu(name, parent):
menus = [c for c in parent.children() if isinstance(c, QMenu)]
menusDict = {m.title(): m for m in menus}
Expand All @@ -198,6 +205,7 @@ def getMenu(name, parent):
parent.addMenu(menu)
return menu


def findAction(actions, alg, actionText=None):
for action in actions:
if action.text() in [actionText, alg.name]:
Expand Down

0 comments on commit 0571395

Please sign in to comment.