Skip to content

Commit

Permalink
Port conversion to/from script code to c++
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 26, 2017
1 parent 178a415 commit d16f117
Show file tree
Hide file tree
Showing 9 changed files with 1,458 additions and 440 deletions.
162 changes: 162 additions & 0 deletions python/core/processing/qgsprocessingparameters.sip
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,20 @@ class QgsProcessingParameters
:rtype: QgsProcessingParameterDefinition
%End

static QString descriptionFromName( const QString &name );
%Docstring
Creates an autogenerated parameter description from a parameter ``name``.
:rtype: str
%End

static QgsProcessingParameterDefinition *parameterFromScriptCode( const QString &code ) /Factory/;
%Docstring
Creates a new QgsProcessingParameterDefinition using the configuration from a
supplied script ``code`` string.
The caller takes responsibility for deleting the returned object.
:rtype: QgsProcessingParameterDefinition
%End

};


Expand Down Expand Up @@ -580,6 +594,12 @@ class QgsProcessingParameterBoolean : QgsProcessingParameterDefinition

virtual QString asScriptCode() const;


static QgsProcessingParameterBoolean *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterBoolean
%End
};

class QgsProcessingParameterCrs : QgsProcessingParameterDefinition
Expand All @@ -605,6 +625,13 @@ class QgsProcessingParameterCrs : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterCrs *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterCrs
%End

};

class QgsProcessingParameterMapLayer : QgsProcessingParameterDefinition
Expand All @@ -630,6 +657,13 @@ class QgsProcessingParameterMapLayer : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterMapLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterMapLayer
%End

};

class QgsProcessingParameterExtent : QgsProcessingParameterDefinition
Expand All @@ -656,6 +690,12 @@ class QgsProcessingParameterExtent : QgsProcessingParameterDefinition
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterExtent *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterExtent
%End

};


Expand All @@ -681,6 +721,12 @@ class QgsProcessingParameterPoint : QgsProcessingParameterDefinition
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;


static QgsProcessingParameterPoint *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterPoint
%End

};

class QgsProcessingParameterFile : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -744,6 +790,12 @@ class QgsProcessingParameterFile : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterFile *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior = File ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFile
%End

};

class QgsProcessingParameterMatrix : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -822,6 +874,12 @@ class QgsProcessingParameterMatrix : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterMatrix *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterMatrix
%End

};

class QgsProcessingParameterMultipleLayers : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -884,6 +942,12 @@ class QgsProcessingParameterMultipleLayers : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterMultipleLayers *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterMultipleLayers
%End

};

class QgsProcessingParameterNumber : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -965,6 +1029,12 @@ class QgsProcessingParameterNumber : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterNumber *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterNumber
%End

};

class QgsProcessingParameterRange : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -1011,6 +1081,12 @@ class QgsProcessingParameterRange : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterRange *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterRange
%End

};

class QgsProcessingParameterRasterLayer : QgsProcessingParameterDefinition
Expand All @@ -1037,6 +1113,12 @@ class QgsProcessingParameterRasterLayer : QgsProcessingParameterDefinition
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterRasterLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterRasterLayer
%End

};

class QgsProcessingParameterEnum : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -1064,6 +1146,8 @@ class QgsProcessingParameterEnum : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;


QStringList options() const;
%Docstring
Expand Down Expand Up @@ -1096,6 +1180,12 @@ class QgsProcessingParameterEnum : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterEnum *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterEnum
%End

};

class QgsProcessingParameterString : QgsProcessingParameterDefinition
Expand All @@ -1120,6 +1210,8 @@ class QgsProcessingParameterString : QgsProcessingParameterDefinition
virtual QString type() const;
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;


bool multiLine() const;
%Docstring
Expand All @@ -1139,6 +1231,12 @@ class QgsProcessingParameterString : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterString *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterString
%End

};

class QgsProcessingParameterExpression : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -1182,6 +1280,12 @@ class QgsProcessingParameterExpression : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterExpression *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterExpression
%End

};

class QgsProcessingParameterVectorLayer : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -1209,6 +1313,12 @@ class QgsProcessingParameterVectorLayer : QgsProcessingParameterDefinition
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterVectorLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterVectorLayer
%End

};

class QgsProcessingParameterField : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -1245,6 +1355,8 @@ class QgsProcessingParameterField : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;


QString parentLayerParameter() const;
%Docstring
Expand Down Expand Up @@ -1290,6 +1402,12 @@ class QgsProcessingParameterField : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterField *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterField
%End

};

class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition
Expand All @@ -1316,6 +1434,8 @@ class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;


QList< int > dataTypes() const;
%Docstring
Expand All @@ -1335,6 +1455,12 @@ class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterFeatureSource *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFeatureSource
%End

};

class QgsProcessingDestinationParameter : QgsProcessingParameterDefinition
Expand Down Expand Up @@ -1427,6 +1553,8 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;

virtual QgsProcessingOutputDefinition *toOutputDefinition() const /Factory/;

virtual QString defaultFileExtension() const;
Expand Down Expand Up @@ -1459,6 +1587,12 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter
virtual QString generateTemporaryDestination() const;


static QgsProcessingParameterFeatureSink *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFeatureSink
%End

};


Expand Down Expand Up @@ -1486,6 +1620,8 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;

virtual QgsProcessingOutputDefinition *toOutputDefinition() const /Factory/;

virtual QString defaultFileExtension() const;
Expand Down Expand Up @@ -1516,6 +1652,13 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterVectorOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterVectorOutput
%End


};

class QgsProcessingParameterRasterOutput : QgsProcessingDestinationParameter
Expand Down Expand Up @@ -1546,6 +1689,12 @@ class QgsProcessingParameterRasterOutput : QgsProcessingDestinationParameter

virtual QString defaultFileExtension() const;


static QgsProcessingParameterRasterOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterRasterOutput
%End
};

class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter
Expand Down Expand Up @@ -1596,6 +1745,13 @@ class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterFileOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFileOutput
%End


};

class QgsProcessingParameterFolderOutput : QgsProcessingDestinationParameter
Expand Down Expand Up @@ -1625,6 +1781,12 @@ class QgsProcessingParameterFolderOutput : QgsProcessingDestinationParameter
virtual QString defaultFileExtension() const;


static QgsProcessingParameterFolderOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFolderOutput
%End

};


Expand Down
5 changes: 2 additions & 3 deletions python/plugins/processing/algs/qgis/IdwInterpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
from processing.core.parameters import (Parameter,
ParameterNumber,
ParameterExtent,
_splitParameterOptions,
_createDescriptiveName)
_splitParameterOptions)
from processing.core.outputs import OutputRaster

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
Expand Down Expand Up @@ -105,7 +104,7 @@ def getAsScriptCode(self):
@classmethod
def fromScriptCode(self, line):
isOptional, name, definition = _splitParameterOptions(line)
descName = _createDescriptiveName(name)
descName = QgsProcessingParameters.descriptionFromName(name)
parent = definition.lower().strip()[len('interpolation data') + 1:]
return ParameterInterpolationData(name, descName, parent)

Expand Down
Loading

0 comments on commit d16f117

Please sign in to comment.