Esempio n. 1
0
    def initialize():
        # Add the basic providers
        Processing.addProvider(QGISAlgorithmProvider(), updateList=False)
        Processing.addProvider(ModelerOnlyAlgorithmProvider(), updateList=False)
        Processing.addProvider(GdalOgrAlgorithmProvider(), updateList=False)
        Processing.addProvider(LidarToolsAlgorithmProvider(), updateList=False)
        Processing.addProvider(OTBAlgorithmProvider(), updateList=False)
        Processing.addProvider(RAlgorithmProvider(), updateList=False)
        Processing.addProvider(SagaAlgorithmProvider(), updateList=False)
        Processing.addProvider(GrassAlgorithmProvider(), updateList=False)
        Processing.addProvider(Grass7AlgorithmProvider(), updateList=False)
        Processing.addProvider(ScriptAlgorithmProvider(), updateList=False)
        Processing.addProvider(TauDEMAlgorithmProvider(), updateList=False)
        Processing.addProvider(Processing.modeler, updateList=False)
        Processing.modeler.initializeSettings()

        # And initialize
        AlgorithmClassification.loadClassification()
        AlgorithmClassification.loadDisplayNames()
        ProcessingLog.startLogging()
        ProcessingConfig.initialize()
        ProcessingConfig.readSettings()
        RenderingStyles.loadStyles()
        Processing.loadFromProviders()

        # Inform registered listeners that all providers' algorithms have been loaded
        Processing.fireAlgsListHasChanged()
Esempio n. 2
0
    def initialize():
        # Add the basic providers
        Processing.addProvider(QGISAlgorithmProvider(), updateList=False)
        Processing.addProvider(ModelerOnlyAlgorithmProvider(),
                               updateList=False)
        Processing.addProvider(GdalOgrAlgorithmProvider(), updateList=False)
        Processing.addProvider(LidarToolsAlgorithmProvider(), updateList=False)
        Processing.addProvider(OTBAlgorithmProvider(), updateList=False)
        Processing.addProvider(RAlgorithmProvider(), updateList=False)
        Processing.addProvider(SagaAlgorithmProvider(), updateList=False)
        Processing.addProvider(GrassAlgorithmProvider(), updateList=False)
        Processing.addProvider(Grass7AlgorithmProvider(), updateList=False)
        Processing.addProvider(ScriptAlgorithmProvider(), updateList=False)
        Processing.addProvider(TauDEMAlgorithmProvider(), updateList=False)
        Processing.addProvider(Processing.modeler, updateList=False)
        Processing.modeler.initializeSettings()

        # And initialize
        AlgorithmClassification.loadClassification()
        AlgorithmClassification.loadDisplayNames()
        ProcessingLog.startLogging()
        ProcessingConfig.initialize()
        ProcessingConfig.readSettings()
        RenderingStyles.loadStyles()
        Processing.loadFromProviders()

        # Inform registered listeners that all providers' algorithms have been loaded
        Processing.fireAlgsListHasChanged()
Esempio n. 3
0
    def __init__(self, alg):
        super(AlgorithmDialogBase, self).__init__(iface.mainWindow())
        self.setupUi(self)

        self.settings = QSettings()
        self.restoreGeometry(self.settings.value("/Processing/dialogBase", QByteArray()))

        self.executed = False
        self.mainWidget = None
        self.alg = alg

        # Rename OK button to Run
        self.btnRun = self.buttonBox.button(QDialogButtonBox.Ok)
        self.btnRun.setText(self.tr('Run'))

        self.btnClose = self.buttonBox.button(QDialogButtonBox.Close)

        self.setWindowTitle(AlgorithmClassification.getDisplayName(self.alg))

        desktop = QDesktopWidget()
        if desktop.physicalDpiX() > 96:
            self.textHelp.setZoomFactor(desktop.physicalDpiX() / 96)

        algHelp = self.alg.shortHelp()
        if algHelp is None:
            self.textShortHelp.setVisible(False)
        else:
            self.textShortHelp.document().setDefaultStyleSheet('''.summary { margin-left: 10px; margin-right: 10px; }
                                                    h2 { color: #555555; padding-bottom: 15px; }
                                                    a { text-decoration: none; color: #3498db; font-weight: bold; }
                                                    p { color: #666666; }
                                                    b { color: #333333; }
                                                    dl dd { margin-bottom: 5px; }''')
            self.textShortHelp.setHtml(algHelp)

        self.textShortHelp.setOpenLinks(False)

        def linkClicked(url):
            webbrowser.open(url.toString())
        self.textShortHelp.anchorClicked.connect(linkClicked)

        self.textHelp.page().setNetworkAccessManager(QgsNetworkAccessManager.instance())

        isText, algHelp = self.alg.help()
        if algHelp is not None:
            algHelp = algHelp if isText else QUrl(algHelp)
            try:
                if isText:
                    self.textHelp.setHtml(algHelp)
                else:
                    self.textHelp.settings().clearMemoryCaches()
                    self.textHelp.load(algHelp)
            except:
                self.tabWidget.removeTab(2)
        else:
            self.tabWidget.removeTab(2)

        self.showDebug = ProcessingConfig.getSetting(
            ProcessingConfig.SHOW_DEBUG_IN_DIALOG)
Esempio n. 4
0
    def __init__(self, alg):
        super(AlgorithmDialogBase, self).__init__(iface.mainWindow())
        self.setupUi(self)

        self.settings = QSettings()
        self.restoreGeometry(self.settings.value("/Processing/dialogBase", QByteArray()))

        self.executed = False
        self.mainWidget = None
        self.alg = alg

        # Rename OK button to Run
        self.btnRun = self.buttonBox.button(QDialogButtonBox.Ok)
        self.btnRun.setText(self.tr('Run'))

        self.btnClose = self.buttonBox.button(QDialogButtonBox.Close)

        self.setWindowTitle(AlgorithmClassification.getDisplayName(self.alg))

        desktop = QDesktopWidget()
        if desktop.physicalDpiX() > 96:
            self.textHelp.setZoomFactor(desktop.physicalDpiX() / 96)

        algHelp = self.alg.shortHelp()
        if algHelp is None:
            self.textShortHelp.setVisible(False)
        else:
            self.textShortHelp.document().setDefaultStyleSheet('''.summary { margin-left: 10px; margin-right: 10px; }
                                                    h2 { color: #555555; padding-bottom: 15px; }
                                                    a { text-decoration: none; color: #3498db; font-weight: bold; }
                                                    p { color: #666666; }
                                                    b { color: #333333; }
                                                    dl dd { margin-bottom: 5px; }''')
            self.textShortHelp.setHtml(algHelp)

        self.textShortHelp.setOpenLinks(False)

        def linkClicked(url):
            webbrowser.open(url.toString())
        self.textShortHelp.anchorClicked.connect(linkClicked)

        self.textHelp.page().setNetworkAccessManager(QgsNetworkAccessManager.instance())

        isText, algHelp = self.alg.help()
        if algHelp is not None:
            algHelp = algHelp if isText else QUrl(algHelp)
            try:
                if isText:
                    self.textHelp.setHtml(algHelp)
                else:
                    self.textHelp.settings().clearMemoryCaches()
                    self.textHelp.load(algHelp)
            except:
                self.tabWidget.removeTab(2)
        else:
            self.tabWidget.removeTab(2)

        self.showDebug = ProcessingConfig.getSetting(
            ProcessingConfig.SHOW_DEBUG_IN_DIALOG)
Esempio n. 5
0
 def __init__(self, alg):
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     name = AlgorithmClassification.getDisplayName(alg)
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
Esempio n. 6
0
 def __init__(self, alg):
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     name = AlgorithmClassification.getDisplayName(alg)
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
Esempio n. 7
0
 def __init__(self, alg):
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     nameEn, name = AlgorithmClassification.getDisplayNames(alg)
     name = name if name != '' else nameEn
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
     self.setData(0, Qt.UserRole, nameEn)
Esempio n. 8
0
 def __init__(self, alg):
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     nameEn, name = AlgorithmClassification.getDisplayNames(alg)
     name = name if name != '' else nameEn
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
     self.setData(0, Qt.UserRole, nameEn)
Esempio n. 9
0
 def __init__(self, alg):
     settings = QSettings()
     useCategories = settings.value(ModelerDialog.USE_CATEGORIES, type=bool)
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     if useCategories:
         icon = GeoAlgorithm.getDefaultIcon()
     name = AlgorithmClassification.getDisplayName(alg)
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
Esempio n. 10
0
 def __init__(self, alg):
     settings = QSettings()
     useCategories = settings.value(ModelerDialog.USE_CATEGORIES, type=bool)
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     if useCategories:
         icon = GeoAlgorithm.getDefaultIcon()
     name = AlgorithmClassification.getDisplayName(alg)
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
Esempio n. 11
0
    def initialize():
        # Add the basic providers
        Processing.addProvider(QGISAlgorithmProvider(), updateList=False)
        Processing.addProvider(ModelerOnlyAlgorithmProvider(), updateList=False)
        Processing.addProvider(GdalOgrAlgorithmProvider(), updateList=False)
        Processing.addProvider(LidarToolsAlgorithmProvider(), updateList=False)
        Processing.addProvider(OTBAlgorithmProvider(), updateList=False)
        Processing.addProvider(RAlgorithmProvider(), updateList=False)
        Processing.addProvider(SagaAlgorithmProvider(), updateList=False)
        Processing.addProvider(GrassAlgorithmProvider(), updateList=False)
        Processing.addProvider(Grass7AlgorithmProvider(), updateList=False)
        Processing.addProvider(ScriptAlgorithmProvider(), updateList=False)
        Processing.addProvider(TauDEMAlgorithmProvider(), updateList=False)
        Processing.addProvider(PreconfiguredAlgorithmProvider(), updateList=False)
        Processing.addProvider(Processing.modeler, updateList=False)
        Processing.modeler.initializeSettings()

        # And initialize
        AlgorithmClassification.loadClassification()
        ProcessingConfig.initialize()
        ProcessingConfig.readSettings()
        RenderingStyles.loadStyles()
        Processing.loadFromProviders()
Esempio n. 12
0
    def __init__(self, alg):
        super(AlgorithmDialogBase, self).__init__(iface.mainWindow())
        self.setupUi(self)

        self.settings = QSettings()
        self.restoreGeometry(self.settings.value("/Processing/dialogBase", QByteArray()))

        self.executed = False
        self.mainWidget = None
        self.alg = alg

        # Rename OK button to Run
        self.btnRun = self.buttonBox.button(QDialogButtonBox.Ok)
        self.btnRun.setText(self.tr('Run'))

        self.btnClose = self.buttonBox.button(QDialogButtonBox.Close)

        self.setWindowTitle(AlgorithmClassification.getDisplayName(self.alg))

        self.txtHelp.page().setNetworkAccessManager(QgsNetworkAccessManager.instance())

        # load algorithm help if available
        isText, algHelp = self.alg.help()
        if algHelp is not None:
            algHelp = algHelp if isText else QUrl(algHelp)
        else:
            algHelp = self.tr('<h2>Sorry, no help is available for this '
                              'algorithm.</h2>')
        try:
            if isText:
                self.txtHelp.setHtml(algHelp)
            else:
                self.txtHelp.settings().clearMemoryCaches()
                self.tabWidget.setTabText(2, self.tr("Help (loading...)"))
                self.tabWidget.setTabEnabled(2, False)
                self.txtHelp.loadFinished.connect(self.loadFinished)
                self.tabWidget.currentChanged.connect(self.loadHelp)
                self.txtHelp.load(algHelp)
                self.algHelp = algHelp
        except:
            self.txtHelp.setHtml(
                self.tr('<h2>Could not open help file :-( </h2>'))

        self.showDebug = ProcessingConfig.getSetting(
            ProcessingConfig.SHOW_DEBUG_IN_DIALOG)
Esempio n. 13
0
    def populate(self):
        groups = {}
        count = 0
        provider = Processing.algs[self.providerName]
        algs = provider.values()

        # Add algorithms
        for alg in algs:
            if not alg.showInToolbox:
                continue
            if alg.group in groups:
                groupItem = groups[alg.group]
            else:
                groupItem = QTreeWidgetItem()
                name = AlgorithmClassification.getDisplayGroup(alg.group)
                groupItem.setText(0, name)
                groupItem.setToolTip(0, name)
                groups[alg.group] = groupItem
            algItem = TreeAlgorithmItem(alg)
            groupItem.addChild(algItem)
            count += 1

        actions = Processing.actions[self.providerName]
        for action in actions:
            if action.group in groups:
                groupItem = groups[action.group]
            else:
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, action.group)
                groups[action.group] = groupItem
            algItem = TreeActionItem(action)
            groupItem.addChild(algItem)

        self.setText(0, self.provider.getDescription()
                  + QCoreApplication.translate( "TreeProviderItem", " [{0} geoalgorithms]" ).format( count ) )
        self.setToolTip(0, self.text(0))
        for groupItem in groups.values():
            self.addChild(groupItem)
Esempio n. 14
0
    def fillAlgorithmTreeUsingCategories(self):
        providersToExclude = ['model', 'script']
        self.algorithmTree.clear()
        text = unicode(self.searchBox.text())
        groups = {}
        allAlgs = ModelerUtils.allAlgs
        for providerName in allAlgs.keys():
            provider = allAlgs[providerName]
            name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
            if not ProcessingConfig.getSetting(name):
                continue
            if providerName in providersToExclude \
                    or len(ModelerUtils.providers[providerName].actions) != 0:
                continue
            algs = provider.values()

            # Add algorithms
            for alg in algs:
                if not alg.showInModeler or alg.allowOnlyOpenedLayers:
                    continue
                altgroup, altsubgroup = AlgorithmClassification.getClassification(alg)
                if altgroup is None:
                    continue
                algName = AlgorithmClassification.getDisplayName(alg)
                if text == '' or text.lower() in algName.lower():
                    if altgroup not in groups:
                        groups[altgroup] = {}
                    group = groups[altgroup]
                    if altsubgroup not in group:
                        groups[altgroup][altsubgroup] = []
                    subgroup = groups[altgroup][altsubgroup]
                    subgroup.append(alg)

        if len(groups) > 0:
            mainItem = QTreeWidgetItem()
            mainItem.setText(0, self.tr('Geoalgorithms'))
            mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
            mainItem.setToolTip(0, mainItem.text(0))
            for (groupname, group) in groups.items():
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, groupname)
                groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                groupItem.setToolTip(0, groupItem.text(0))
                mainItem.addChild(groupItem)
                for (subgroupname, subgroup) in group.items():
                    subgroupItem = QTreeWidgetItem()
                    subgroupItem.setText(0, subgroupname)
                    subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                    subgroupItem.setToolTip(0, subgroupItem.text(0))
                    groupItem.addChild(subgroupItem)
                    for alg in subgroup:
                        algItem = TreeAlgorithmItem(alg)
                        subgroupItem.addChild(algItem)
            self.algorithmTree.addTopLevelItem(mainItem)

        for providerName in allAlgs.keys():
            groups = {}
            provider = allAlgs[providerName]
            name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
            if not ProcessingConfig.getSetting(name):
                continue
            if providerName not in providersToExclude:
                continue
            algs = provider.values()

            # Add algorithms
            for alg in algs:
                if not alg.showInModeler or alg.allowOnlyOpenedLayers:
                    continue
                if text == '' or text.lower() in alg.name.lower():
                    if alg.group in groups:
                        groupItem = groups[alg.group]
                    else:
                        groupItem = QTreeWidgetItem()
                        name = alg.i18n_group
                        groupItem.setText(0, name)
                        groupItem.setToolTip(0, name)
                        groups[alg.group] = groupItem
                    algItem = TreeAlgorithmItem(alg)
                    groupItem.addChild(algItem)

            if len(groups) > 0:
                providerItem = QTreeWidgetItem()
                providerItem.setText(0,
                                     ModelerUtils.providers[providerName].getDescription())
                providerItem.setIcon(0,
                                     ModelerUtils.providers[providerName].getIcon())
                providerItem.setToolTip(0, providerItem.text(0))
                for groupItem in groups.values():
                    providerItem.addChild(groupItem)
                self.algorithmTree.addTopLevelItem(providerItem)
                providerItem.setExpanded(text != '')
                for groupItem in groups.values():
                    if text != '':
                        groupItem.setExpanded(True)
Esempio n. 15
0
    def fillTreeUsingCategories(self):
        providersToExclude = ['model', 'script']
        self.algorithmTree.clear()
        text = unicode(self.searchBox.text())
        groups = {}
        for providerName in Processing.algs.keys():
            provider = Processing.algs[providerName]
            name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
            if not ProcessingConfig.getSetting(name):
                continue
            if providerName in providersToExclude or \
                    len(ModelerUtils.providers[providerName].actions) != 0:
                continue
            algs = provider.values()

            # add algorithms

            for alg in algs:
                if not alg.showInToolbox:
                    continue
                altgroup, altsubgroup = AlgorithmClassification.getClassification(alg)
                if altgroup is None:
                    continue
                algName = AlgorithmClassification.getDisplayName(alg)
                if text == '' or text.lower() in algName.lower():
                    if altgroup not in groups:
                        groups[altgroup] = {}
                    group = groups[altgroup]
                    if altsubgroup not in group:
                        groups[altgroup][altsubgroup] = []
                    subgroup = groups[altgroup][altsubgroup]
                    subgroup.append(alg)

        if len(groups) > 0:
            mainItem = QTreeWidgetItem()
            mainItem.setText(0, 'Geoalgorithms')
            mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
            mainItem.setToolTip(0, mainItem.text(0))
            for (groupname, group) in groups.items():
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, groupname)
                groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                groupItem.setToolTip(0, groupItem.text(0))
                mainItem.addChild(groupItem)
                for (subgroupname, subgroup) in group.items():
                    subgroupItem = QTreeWidgetItem()
                    subgroupItem.setText(0, subgroupname)
                    subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                    subgroupItem.setToolTip(0, subgroupItem.text(0))
                    groupItem.addChild(subgroupItem)
                    for alg in subgroup:
                        algItem = TreeAlgorithmItem(alg)
                        subgroupItem.addChild(algItem)

            self.algorithmTree.addTopLevelItem(mainItem)

        for providerName in Processing.algs.keys():
            if providerName not in providersToExclude:
                continue
            name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
            if not ProcessingConfig.getSetting(name):
                continue
            providerItem = TreeProviderItem(providerName)
            self.algorithmTree.addTopLevelItem(providerItem)
Esempio n. 16
0
    def fillAlgorithmTreeUsingCategories(self):
        providersToExclude = ['model', 'script']
        self.algorithmTree.clear()
        text = unicode(self.searchBox.text())
        groups = {}
        allAlgs = ModelerUtils.allAlgs
        for providerName in allAlgs.keys():
            provider = allAlgs[providerName]
            name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
            if not ProcessingConfig.getSetting(name):
                continue
            if providerName in providersToExclude \
                    or len(ModelerUtils.providers[providerName].actions) != 0:
                continue
            algs = provider.values()

            # Add algorithms
            for alg in algs:
                if not alg.showInModeler or alg.allowOnlyOpenedLayers:
                    continue
                altgroup, altsubgroup = AlgorithmClassification.getClassification(
                    alg)
                if altgroup is None:
                    continue
                algName = AlgorithmClassification.getDisplayName(alg)
                if text == '' or text.lower() in algName.lower():
                    if altgroup not in groups:
                        groups[altgroup] = {}
                    group = groups[altgroup]
                    if altsubgroup not in group:
                        groups[altgroup][altsubgroup] = []
                    subgroup = groups[altgroup][altsubgroup]
                    subgroup.append(alg)

        if len(groups) > 0:
            mainItem = QTreeWidgetItem()
            mainItem.setText(0, self.tr('Geoalgorithms'))
            mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
            mainItem.setToolTip(0, mainItem.text(0))
            for (groupname, group) in groups.items():
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, groupname)
                groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                groupItem.setToolTip(0, groupItem.text(0))
                mainItem.addChild(groupItem)
                for (subgroupname, subgroup) in group.items():
                    subgroupItem = QTreeWidgetItem()
                    subgroupItem.setText(0, subgroupname)
                    subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                    subgroupItem.setToolTip(0, subgroupItem.text(0))
                    groupItem.addChild(subgroupItem)
                    for alg in subgroup:
                        algItem = TreeAlgorithmItem(alg)
                        subgroupItem.addChild(algItem)
            self.algorithmTree.addTopLevelItem(mainItem)

        for providerName in allAlgs.keys():
            groups = {}
            provider = allAlgs[providerName]
            name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
            if not ProcessingConfig.getSetting(name):
                continue
            if providerName not in providersToExclude:
                continue
            algs = provider.values()

            # Add algorithms
            for alg in algs:
                if not alg.showInModeler or alg.allowOnlyOpenedLayers:
                    continue
                if text == '' or text.lower() in alg.name.lower():
                    if alg.group in groups:
                        groupItem = groups[alg.group]
                    else:
                        groupItem = QTreeWidgetItem()
                        name = alg.i18n_group
                        groupItem.setText(0, name)
                        groupItem.setToolTip(0, name)
                        groups[alg.group] = groupItem
                    algItem = TreeAlgorithmItem(alg)
                    groupItem.addChild(algItem)

            if len(groups) > 0:
                providerItem = QTreeWidgetItem()
                providerItem.setText(
                    0, ModelerUtils.providers[providerName].getDescription())
                providerItem.setIcon(
                    0, ModelerUtils.providers[providerName].getIcon())
                providerItem.setToolTip(0, providerItem.text(0))
                for groupItem in groups.values():
                    providerItem.addChild(groupItem)
                self.algorithmTree.addTopLevelItem(providerItem)
                providerItem.setExpanded(text != '')
                for groupItem in groups.values():
                    if text != '':
                        groupItem.setExpanded(True)