[Qgis-developer] Replacing Raster and Vector menus with Processing algorithms (update)
kimaidou
kimaidou at gmail.com
Wed Sep 23 09:59:17 PDT 2015
Hi Victor,
Thanks a lot for this work !
I think this kind of script must ben called by Processing which can check
if all the needed providers are well configured ( grass, otb, etc.). Menu
item could then be removed (or just set inactive) if Processing finds any
issue with each one.
Regards
Michaël
2015-09-23 12:21 GMT+02:00 Victor Olaya <volayaf at gmail.com>:
> Hi all
>
> As a first step to replace Raster and Vector menus with new menu
> entries that call Processing algorithms to avoid redundancy (as we
> have been discussing since sometime ago...), I have added a new method
> to Processing named addAlgorithmEntry. It adds a menu entry in the
> specified menu, which calls a Processign algorithm. Basically, it's an
> easy way of placing an entry point to a Processing algorithm outside
> of the Processing toolbox
>
> Usage is rather straight forward
>
> addAlgorithmEntry([name_of_algorithm], [menu_name], [submenu_name],
> [menuentry_text], [icon])
>
> The last two parameters can be ommited, and the original title and
> icon of the algorithm will be used.
>
> Here is an example, on how the Raster/Conversion menu could be
> replaced with this:
>
> import os
> from GdalTools import GdalTools
> from processing.gui.utils import addAlgorithmEntry
> from PyQt4.QtGui import *
>
> def addRasterAlgorithm(name, group, iconName):
> icon = QIcon(os.path.join(os.path.dirname(GdalTools.__file__),
> "icons", iconName + ".png"))
> addAlgorithmEntry(name, "Raster", group, icon = icon)
>
> addRasterAlgorithm("gdalogr:rasterize", "Conversion", "rasterize")
> addRasterAlgorithm("gdalogr:translate", "Conversion", "translate")
> addRasterAlgorithm("gdalogr:pcttorgb", "Conversion", "24-to-8-bits")
> addRasterAlgorithm("gdalogr:rgbtopct", "Conversion", "8-to-24-bits")
> addRasterAlgorithm("gdalogr:polygonize", "Conversion", "polygonize")
>
>
> Now it's a matter of making sure that all algorithms are replaceable
> with a Processing equivalent, and add more lines to the above a script
> for creating the full alternative menu structure.
>
> Then, that script can be called by Processing itself, or put it in a
> separate plugin that adds GDAL/OGR functionality based on Processing
> algorithms. (Paths to icons should be modified from the above example,
> of course)
>
> Let me know if you have questions or you want to help on this,
>
> Regards
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150923/a5e27f10/attachment.html>
More information about the Qgis-developer
mailing list