[QGIS-Developer] [Qgis-developer] OTB and LiDAR tools as separate plugins

Martin Isenburg martin.isenburg at gmail.com
Mon Sep 3 09:47:33 PDT 2018


Hello,

my question was answered at the QGIS hackfest by Matteo Ghetta with a
DataPlotly code snippet. (-: You can add your own entries into the
"Processing Settings" menu under the "Providers" section by following the
example below in your own Provider class.

from processing.core.ProcessingConfig import Setting, ProcessingConfig

class LAStoolsProvider(QgsProcessingProvider):

    def __init__(self):
        QgsProcessingProvider.__init__(self)

    def load(self):
        ProcessingConfig.settingIcons[self.name()] = self.icon()
        ProcessingConfig.addSetting(Setting(self.name(),
'LASTOOLS_ACTIVATED', 'Activate', True))
        ProcessingConfig.addSetting(Setting(self.name(), 'LASTOOLS_FOLDER',
'LAStools folder', "C:\LAStools", valuetype=Setting.FOLDER))
        ProcessingConfig.addSetting(Setting(self.name(), 'WINE_FOLDER',
'Wine folder', "", valuetype=Setting.FOLDER))
        ProcessingConfig.readSettings()
        self.refreshAlgorithms()
        return True

    def unload(self):
        ProcessingConfig.removeSetting('LASTOOLS_ACTIVATED')
        ProcessingConfig.removeSetting('LASTOOLS_FOLDER')
        ProcessingConfig.removeSetting('WINE_FOLDER')
        pass

    def isActive(self):
        return ProcessingConfig.getSetting('LASTOOLS_ACTIVATED')

    def setActive(self, active):
        ProcessingConfig.setSettingValue('LASTOOLS_ACTIVATED', active)


    def loadAlgorithms(self):
       [...]

and you can always query those settings with code snippets such as

from processing.core.ProcessingConfig import ProcessingConfig
from processing.tools.system import isWindows

    @staticmethod
    def hasWine():
        wine_folder = ProcessingConfig.getSetting("WINE_FOLDER")
        return (wine_folder is not None) and (wine_folder != "")

    @staticmethod
    def LAStoolsPath():
        lastools_folder = ProcessingConfig.getSetting("LASTOOLS_FOLDER")
        if isWindows():
            wine_folder = ""
        else:
            wine_folder = ProcessingConfig.getSetting("WINE_FOLDER")
        if (wine_folder is None) or (wine_folder == ""):
            folder = lastools_folder
        else:
            folder = wine_folder + "/wine " + lastools_folder
        return folder

Regards,

Martin


On Fri, Aug 24, 2018 at 7:11 PM Martin Isenburg <martin.isenburg at gmail.com>
wrote:

> Hello,
>
> when the LAStools toolboxes were part of the "built-in" scripts of
> Processing I had was able to have two entries (i.e. the folder path to the
> "Wine" and the "LAStools" installation) in the "Processing Settings" menu
> under the "Providers" section. You can see as an example how GRASS still
> has such options in the attached screen shot. How can I place these two
> options back there now that I load the LAStools toolboxes as Processing
> plugins?
>
> Off for beers at the Zanzi-bar ... (-;
>
> Martin
>
> On Thu, Aug 23, 2018 at 8:26 PM, Alexander Bruy <alexander.bruy at gmail.com>
>> wrote:
>>
>>> Hi Martin,
>>>
>>> It is up to you how to distribute your plugin. You can publish it in
>>> QGIS Official
>>> plugins repository, or setup your own repository as many other
>>> developers do.
>>> It is even possible to share just a ZIP with the plugin via web-site,
>>> pretty much
>>> similar to how LAStools distributed.
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180903/b028d98f/attachment.html>


More information about the QGIS-Developer mailing list