Esempio n. 1
0
    def runAlgorithm(self):
        if self.algType == self.SCRIPT_PYTHON:
            alg = ScriptAlgorithm(None, self.editor.text())
            alg.provider = QgsApplication.processingRegistry().providerById(
                'script')
        if self.algType == self.SCRIPT_R:
            alg = RAlgorithm(None, self.editor.text())
            alg.provider = QgsApplication.processingRegistry().providerById(
                'r')

        dlg = alg.getCustomParametersDialog()
        if not dlg:
            dlg = AlgorithmDialog(alg)

        canvas = iface.mapCanvas()
        prevMapTool = canvas.mapTool()

        dlg.show()
        dlg.exec_()

        if canvas.mapTool() != prevMapTool:
            try:
                canvas.mapTool().reset()
            except:
                pass
            canvas.setMapTool(prevMapTool)
Esempio n. 2
0
 def getAlgorithmFromHookFile(self, hookFile):
     if hookFile.endswith('py'):
         script = ScriptAlgorithm(hookFile)
         script.provider = Providers.providers['script']
         return script
     elif hookFile.endswith('model'):
         model = ModelerAlgorithm()
         model.openModel(hookFile)                
         model.provider = Providers.providers['model']
         return model
     else:
         raise Exception ("Wrong hook file")
Esempio n. 3
0
 def getAlgorithmFromHookFile(self, hookFile):
     if hookFile.endswith('py'):
         script = ScriptAlgorithm(hookFile)
         script.provider = Providers.providers['script']
         return script
     elif hookFile.endswith('model'):
         model = ModelerAlgorithm()
         model.openModel(hookFile)
         model.provider = Providers.providers['model']
         return model
     else:
         raise Exception("Wrong hook file")
Esempio n. 4
0
 def getAlgorithmFromHookFile(self, hookFile):
     if hookFile.endswith("py"):
         script = ScriptAlgorithm(hookFile)
         script.provider = ModelerUtils.providers["script"]
         return script
     elif hookFile.endswith("model"):
         model = ModelerAlgorithm()
         model.openModel(hookFile)
         model.provider = ModelerUtils.providers["model"]
         return model
     else:
         raise Exception("Wrong hook file")
Esempio n. 5
0
    def runAlgorithm(self):
        if self.algType == self.SCRIPT_PYTHON:
            alg = ScriptAlgorithm(None, self.editor.text())
            alg.provider = QgsApplication.processingRegistry().providerById('script')
        if self.algType == self.SCRIPT_R:
            alg = RAlgorithm(None, self.editor.text())
            alg.provider = QgsApplication.processingRegistry().providerById('r')

        dlg = alg.getCustomParametersDialog()
        if not dlg:
            dlg = AlgorithmDialog(alg)

        canvas = iface.mapCanvas()
        prevMapTool = canvas.mapTool()

        dlg.show()
        dlg.exec_()

        if canvas.mapTool() != prevMapTool:
            try:
                canvas.mapTool().reset()
            except:
                pass
            canvas.setMapTool(prevMapTool)
Esempio n. 6
0
    def runAlgorithm(self):
        if self.algType == self.SCRIPT_PYTHON:
            alg = ScriptAlgorithm(None, unicode(self.editor.text()))
            alg.provider = ModelerUtils.providers['script']
        if self.algType == self.SCRIPT_R:
            alg = RAlgorithm(None, unicode(self.editor.text()))
            alg.provider = ModelerUtils.providers['r']

        dlg = alg.getCustomParametersDialog()
        if not dlg:
            dlg = AlgorithmDialog(alg)

        canvas = iface.mapCanvas()
        prevMapTool = canvas.mapTool()

        dlg.show()
        dlg.exec_()

        if canvas.mapTool() != prevMapTool:
            try:
                canvas.mapTool().reset()
            except:
                pass
            canvas.setMapTool(prevMapTool)
Esempio n. 7
0
    def runAlgorithm(self):
        if self.algType == self.SCRIPT_PYTHON:
            alg = ScriptAlgorithm(None, unicode(self.editor.text()))
            alg.provider = Providers.providers["script"]
        if self.algType == self.SCRIPT_R:
            alg = RAlgorithm(None, unicode(self.editor.text()))
            alg.provider = Providers.providers["r"]

        dlg = alg.getCustomParametersDialog()
        if not dlg:
            dlg = ParametersDialog(alg)

        canvas = iface.mapCanvas()
        prevMapTool = canvas.mapTool()

        dlg.show()
        dlg.exec_()

        if canvas.mapTool() != prevMapTool:
            try:
                canvas.mapTool().reset()
            except:
                pass
            canvas.setMapTool(prevMapTool)