Skip to content
Permalink
Browse files

cleanup in fTools menu creation code

  • Loading branch information
alexbruy committed Aug 14, 2012
1 parent 6649738 commit 880354f36770f17c56e15238e0aecd881c7ec0a9
Showing with 98 additions and 116 deletions.
  1. +98 −116 python/plugins/fTools/fTools.py
@@ -185,70 +185,55 @@ def initGui(self):
self.dataManageMenu.addActions([self.define, self.spatJoin, self.splitVect, self.mergeShapes, self.spatialIndex])
self.updateThemeIcons("theme")

self.menu = None
if hasattr(self.iface, "addPluginToVectorMenu"):
menuName = QCoreApplication.translate("fTools", "&Analysis Tools")
self.iface.addPluginToVectorMenu(menuName, self.distMatrix)
self.iface.addPluginToVectorMenu(menuName, self.sumLines)
self.iface.addPluginToVectorMenu(menuName, self.pointsPoly)
self.iface.addPluginToVectorMenu(menuName, self.listUnique)
self.iface.addPluginToVectorMenu(menuName, self.compStats)
self.iface.addPluginToVectorMenu(menuName, self.nearestNeigh)
self.iface.addPluginToVectorMenu(menuName, self.meanCoords)
self.iface.addPluginToVectorMenu(menuName, self.intLines)

menuName = QCoreApplication.translate("fTools", "&Research Tools")
self.iface.addPluginToVectorMenu(menuName, self.randSel)
self.iface.addPluginToVectorMenu(menuName, self.randSub)
self.iface.addPluginToVectorMenu(menuName, self.randPoints)
self.iface.addPluginToVectorMenu(menuName, self.regPoints)
self.iface.addPluginToVectorMenu(menuName, self.vectGrid)
self.iface.addPluginToVectorMenu(menuName, self.selectLocation)
self.iface.addPluginToVectorMenu(menuName, self.layerExtent)

menuName = QCoreApplication.translate("fTools", "&Geoprocessing Tools")
self.iface.addPluginToVectorMenu(menuName, self.minConvex)
self.iface.addPluginToVectorMenu(menuName, self.dynaBuffer)
self.iface.addPluginToVectorMenu(menuName, self.intersect)
self.iface.addPluginToVectorMenu(menuName, self.union)
self.iface.addPluginToVectorMenu(menuName, self.symDifference)
self.iface.addPluginToVectorMenu(menuName, self.clip)
self.iface.addPluginToVectorMenu(menuName, self.erase)
self.iface.addPluginToVectorMenu(menuName, self.dissolve)

menuName = QCoreApplication.translate("fTools", "G&eometry Tools")
self.iface.addPluginToVectorMenu(menuName, self.checkGeom)
self.iface.addPluginToVectorMenu(menuName, self.compGeo)
self.iface.addPluginToVectorMenu(menuName, self.centroids)
self.iface.addPluginToVectorMenu(menuName, self.delaunay)
self.iface.addPluginToVectorMenu(menuName, self.voronoi)
self.iface.addPluginToVectorMenu(menuName, self.simplify)
self.iface.addPluginToVectorMenu(menuName, self.densify)
self.iface.addPluginToVectorMenu(menuName, self.multiToSingle)
self.iface.addPluginToVectorMenu(menuName, self.singleToMulti)
self.iface.addPluginToVectorMenu(menuName, self.polysToLines)
self.iface.addPluginToVectorMenu(menuName, self.linesToPolys)
self.iface.addPluginToVectorMenu(menuName, self.extNodes)

menuName = QCoreApplication.translate("fTools", "&Data Management Tools")
self.iface.addPluginToVectorMenu(menuName, self.define)
self.iface.addPluginToVectorMenu(menuName, self.spatJoin)
self.iface.addPluginToVectorMenu(menuName, self.splitVect)
self.iface.addPluginToVectorMenu(menuName, self.mergeShapes)
self.iface.addPluginToVectorMenu(menuName, self.spatialIndex)
else:
self.menu = QMenu()
self.menu.setTitle(QCoreApplication.translate("fTools", "Vect&or"))
self.menu.addMenu(self.analysisMenu)
self.menu.addMenu(self.researchMenu)
self.menu.addMenu(self.geoMenu)
self.menu.addMenu(self.conversionMenu)
self.menu.addMenu(self.dataManageMenu)

menu_bar = self.iface.mainWindow().menuBar()
actions = menu_bar.actions()
lastAction = actions[len(actions) - 1]
menu_bar.insertMenu(lastAction, self.menu)
menuName = QCoreApplication.translate("fTools", "&Analysis Tools")
self.iface.addPluginToVectorMenu(menuName, self.distMatrix)
self.iface.addPluginToVectorMenu(menuName, self.sumLines)
self.iface.addPluginToVectorMenu(menuName, self.pointsPoly)
self.iface.addPluginToVectorMenu(menuName, self.listUnique)
self.iface.addPluginToVectorMenu(menuName, self.compStats)
self.iface.addPluginToVectorMenu(menuName, self.nearestNeigh)
self.iface.addPluginToVectorMenu(menuName, self.meanCoords)
self.iface.addPluginToVectorMenu(menuName, self.intLines)

menuName = QCoreApplication.translate("fTools", "&Research Tools")
self.iface.addPluginToVectorMenu(menuName, self.randSel)
self.iface.addPluginToVectorMenu(menuName, self.randSub)
self.iface.addPluginToVectorMenu(menuName, self.randPoints)
self.iface.addPluginToVectorMenu(menuName, self.regPoints)
self.iface.addPluginToVectorMenu(menuName, self.vectGrid)
self.iface.addPluginToVectorMenu(menuName, self.selectLocation)
self.iface.addPluginToVectorMenu(menuName, self.layerExtent)

menuName = QCoreApplication.translate("fTools", "&Geoprocessing Tools")
self.iface.addPluginToVectorMenu(menuName, self.minConvex)
self.iface.addPluginToVectorMenu(menuName, self.dynaBuffer)
self.iface.addPluginToVectorMenu(menuName, self.intersect)
self.iface.addPluginToVectorMenu(menuName, self.union)
self.iface.addPluginToVectorMenu(menuName, self.symDifference)
self.iface.addPluginToVectorMenu(menuName, self.clip)
self.iface.addPluginToVectorMenu(menuName, self.erase)
self.iface.addPluginToVectorMenu(menuName, self.dissolve)

menuName = QCoreApplication.translate("fTools", "G&eometry Tools")
self.iface.addPluginToVectorMenu(menuName, self.checkGeom)
self.iface.addPluginToVectorMenu(menuName, self.compGeo)
self.iface.addPluginToVectorMenu(menuName, self.centroids)
self.iface.addPluginToVectorMenu(menuName, self.delaunay)
self.iface.addPluginToVectorMenu(menuName, self.voronoi)
self.iface.addPluginToVectorMenu(menuName, self.simplify)
self.iface.addPluginToVectorMenu(menuName, self.densify)
self.iface.addPluginToVectorMenu(menuName, self.multiToSingle)
self.iface.addPluginToVectorMenu(menuName, self.singleToMulti)
self.iface.addPluginToVectorMenu(menuName, self.polysToLines)
self.iface.addPluginToVectorMenu(menuName, self.linesToPolys)
self.iface.addPluginToVectorMenu(menuName, self.extNodes)

menuName = QCoreApplication.translate("fTools", "&Data Management Tools")
self.iface.addPluginToVectorMenu(menuName, self.define)
self.iface.addPluginToVectorMenu(menuName, self.spatJoin)
self.iface.addPluginToVectorMenu(menuName, self.splitVect)
self.iface.addPluginToVectorMenu(menuName, self.mergeShapes)
self.iface.addPluginToVectorMenu(menuName, self.spatialIndex)

QObject.connect(self.distMatrix, SIGNAL("triggered()"), self.dodistMatrix)
QObject.connect(self.sumLines, SIGNAL("triggered()"), self.dosumLines)
@@ -296,58 +281,55 @@ def initGui(self):
QObject.connect(self.spatialIndex, SIGNAL("triggered()"), self.doSpatIndex)

def unload(self):
if self.menu == None:
menuName = QCoreApplication.translate("fTools", "&Analysis Tools")
self.iface.removePluginVectorMenu(menuName, self.distMatrix)
self.iface.removePluginVectorMenu(menuName, self.sumLines)
self.iface.removePluginVectorMenu(menuName, self.pointsPoly)
self.iface.removePluginVectorMenu(menuName, self.listUnique)
self.iface.removePluginVectorMenu(menuName, self.compStats)
self.iface.removePluginVectorMenu(menuName, self.nearestNeigh)
self.iface.removePluginVectorMenu(menuName, self.meanCoords)
self.iface.removePluginVectorMenu(menuName, self.intLines)

menuName = QCoreApplication.translate("fTools", "&Research Tools")
self.iface.removePluginVectorMenu(menuName, self.randSel)
self.iface.removePluginVectorMenu(menuName, self.randSub)
self.iface.removePluginVectorMenu(menuName, self.randPoints)
self.iface.removePluginVectorMenu(menuName, self.regPoints)
self.iface.removePluginVectorMenu(menuName, self.vectGrid)
self.iface.removePluginVectorMenu(menuName, self.selectLocation)
self.iface.removePluginVectorMenu(menuName, self.layerExtent)

menuName = QCoreApplication.translate("fTools", "&Geoprocessing Tools")
self.iface.removePluginVectorMenu(menuName, self.minConvex)
self.iface.removePluginVectorMenu(menuName, self.dynaBuffer)
self.iface.removePluginVectorMenu(menuName, self.intersect)
self.iface.removePluginVectorMenu(menuName, self.union)
self.iface.removePluginVectorMenu(menuName, self.symDifference)
self.iface.removePluginVectorMenu(menuName, self.clip)
self.iface.removePluginVectorMenu(menuName, self.erase)
self.iface.removePluginVectorMenu(menuName, self.dissolve)

menuName = QCoreApplication.translate("fTools", "G&eometry Tools")
self.iface.removePluginVectorMenu(menuName, self.checkGeom)
self.iface.removePluginVectorMenu(menuName, self.compGeo)
self.iface.removePluginVectorMenu(menuName, self.centroids)
self.iface.removePluginVectorMenu(menuName, self.delaunay)
self.iface.removePluginVectorMenu(menuName, self.voronoi)
self.iface.removePluginVectorMenu(menuName, self.simplify)
self.iface.removePluginVectorMenu(menuName, self.densify)
self.iface.removePluginVectorMenu(menuName, self.multiToSingle)
self.iface.removePluginVectorMenu(menuName, self.singleToMulti)
self.iface.removePluginVectorMenu(menuName, self.polysToLines)
self.iface.removePluginVectorMenu(menuName, self.linesToPolys)
self.iface.removePluginVectorMenu(menuName, self.extNodes)

menuName = QCoreApplication.translate("fTools", "&Data Management Tools")
self.iface.removePluginVectorMenu(menuName, self.define)
self.iface.removePluginVectorMenu(menuName, self.spatJoin)
self.iface.removePluginVectorMenu(menuName, self.splitVect)
self.iface.removePluginVectorMenu(menuName, self.mergeShapes)
self.iface.removePluginVectorMenu(menuName, self.spatialIndex)
else:
pass
menuName = QCoreApplication.translate("fTools", "&Analysis Tools")
self.iface.removePluginVectorMenu(menuName, self.distMatrix)
self.iface.removePluginVectorMenu(menuName, self.sumLines)
self.iface.removePluginVectorMenu(menuName, self.pointsPoly)
self.iface.removePluginVectorMenu(menuName, self.listUnique)
self.iface.removePluginVectorMenu(menuName, self.compStats)
self.iface.removePluginVectorMenu(menuName, self.nearestNeigh)
self.iface.removePluginVectorMenu(menuName, self.meanCoords)
self.iface.removePluginVectorMenu(menuName, self.intLines)

menuName = QCoreApplication.translate("fTools", "&Research Tools")
self.iface.removePluginVectorMenu(menuName, self.randSel)
self.iface.removePluginVectorMenu(menuName, self.randSub)
self.iface.removePluginVectorMenu(menuName, self.randPoints)
self.iface.removePluginVectorMenu(menuName, self.regPoints)
self.iface.removePluginVectorMenu(menuName, self.vectGrid)
self.iface.removePluginVectorMenu(menuName, self.selectLocation)
self.iface.removePluginVectorMenu(menuName, self.layerExtent)

menuName = QCoreApplication.translate("fTools", "&Geoprocessing Tools")
self.iface.removePluginVectorMenu(menuName, self.minConvex)
self.iface.removePluginVectorMenu(menuName, self.dynaBuffer)
self.iface.removePluginVectorMenu(menuName, self.intersect)
self.iface.removePluginVectorMenu(menuName, self.union)
self.iface.removePluginVectorMenu(menuName, self.symDifference)
self.iface.removePluginVectorMenu(menuName, self.clip)
self.iface.removePluginVectorMenu(menuName, self.erase)
self.iface.removePluginVectorMenu(menuName, self.dissolve)

menuName = QCoreApplication.translate("fTools", "G&eometry Tools")
self.iface.removePluginVectorMenu(menuName, self.checkGeom)
self.iface.removePluginVectorMenu(menuName, self.compGeo)
self.iface.removePluginVectorMenu(menuName, self.centroids)
self.iface.removePluginVectorMenu(menuName, self.delaunay)
self.iface.removePluginVectorMenu(menuName, self.voronoi)
self.iface.removePluginVectorMenu(menuName, self.simplify)
self.iface.removePluginVectorMenu(menuName, self.densify)
self.iface.removePluginVectorMenu(menuName, self.multiToSingle)
self.iface.removePluginVectorMenu(menuName, self.singleToMulti)
self.iface.removePluginVectorMenu(menuName, self.polysToLines)
self.iface.removePluginVectorMenu(menuName, self.linesToPolys)
self.iface.removePluginVectorMenu(menuName, self.extNodes)

menuName = QCoreApplication.translate("fTools", "&Data Management Tools")
self.iface.removePluginVectorMenu(menuName, self.define)
self.iface.removePluginVectorMenu(menuName, self.spatJoin)
self.iface.removePluginVectorMenu(menuName, self.splitVect)
self.iface.removePluginVectorMenu(menuName, self.mergeShapes)
self.iface.removePluginVectorMenu(menuName, self.spatialIndex)

def doSimplify(self):
d = doSimplify.Dialog(self.iface, 1)

0 comments on commit 880354f

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