2017-05-15 16:16:32 +10:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
QgisAlgorithm.py
|
|
|
|
----------------
|
|
|
|
Date : May 2017
|
|
|
|
Copyright : (C) 2017 by Nyall Dawson
|
|
|
|
Email : nyall dot dawson at gmail dot com
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Nyall Dawson'
|
|
|
|
__date__ = 'May2017'
|
|
|
|
__copyright__ = '(C) 2017, Nyall Dawson'
|
|
|
|
|
2017-07-17 10:43:38 +10:00
|
|
|
from qgis.core import QgsProcessingAlgorithm, QgsProcessingFeatureBasedAlgorithm
|
2017-05-22 15:46:50 +10:00
|
|
|
from qgis.PyQt.QtCore import QCoreApplication
|
2017-05-15 16:16:32 +10:00
|
|
|
from processing.algs.help import shortHelp
|
|
|
|
|
|
|
|
|
2017-05-22 15:46:50 +10:00
|
|
|
class QgisAlgorithm(QgsProcessingAlgorithm):
|
2017-05-15 16:16:32 +10:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
def shortHelpString(self):
|
|
|
|
return shortHelp.get(self.id(), None)
|
2017-05-22 15:46:50 +10:00
|
|
|
|
|
|
|
def tr(self, string, context=''):
|
|
|
|
if context == '':
|
|
|
|
context = self.__class__.__name__
|
|
|
|
return QCoreApplication.translate(context, string)
|
|
|
|
|
|
|
|
def trAlgorithm(self, string, context=''):
|
|
|
|
if context == '':
|
|
|
|
context = self.__class__.__name__
|
|
|
|
return string, QCoreApplication.translate(context, string)
|
2017-06-27 13:45:22 +10:00
|
|
|
|
2017-07-10 10:07:32 +10:00
|
|
|
def createInstance(self):
|
2017-06-27 13:45:22 +10:00
|
|
|
return type(self)()
|
2017-07-17 10:43:38 +10:00
|
|
|
|
|
|
|
|
|
|
|
class QgisFeatureBasedAlgorithm(QgsProcessingFeatureBasedAlgorithm):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
def shortHelpString(self):
|
|
|
|
return shortHelp.get(self.id(), None)
|
|
|
|
|
|
|
|
def tr(self, string, context=''):
|
|
|
|
if context == '':
|
|
|
|
context = self.__class__.__name__
|
|
|
|
return QCoreApplication.translate(context, string)
|
|
|
|
|
|
|
|
def trAlgorithm(self, string, context=''):
|
|
|
|
if context == '':
|
|
|
|
context = self.__class__.__name__
|
|
|
|
return string, QCoreApplication.translate(context, string)
|
|
|
|
|
|
|
|
def createInstance(self):
|
|
|
|
return type(self)()
|