22using namespace Qt::StringLiterals;
49 code +=
", optional=True"_L1;
59 if ( !input.isValid() && !
mDefault.isValid() )
62 const QString stringValue = input.toString();
63 if ( stringValue.isEmpty() || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
66 const QStringList colorParts = stringValue.split(
';' );
67 for (
const QString &part : colorParts )
69 if ( part.trimmed().isEmpty() )
72 const QStringList v = part.split(
',' );
79 ( void ) v.at( 0 ).toDouble( &ok );
82 ( void ) v.at( 1 ).toDouble( &ok );
85 ( void ) v.at( 2 ).toInt( &ok );
88 ( void ) v.at( 3 ).toInt( &ok );
91 ( void ) v.at( 4 ).toInt( &ok );
102 map.insert( u
"parent"_s, mParentLayer );
109 mParentLayer = map.value( u
"parent"_s ).toString();
115 QList<QgsRasterReliefColor> reliefColors;
117 const QStringList colorParts = colorsString.split(
';' );
118 for (
const QString &part : colorParts )
120 if ( part.trimmed().isEmpty() )
123 const QStringList v = part.split(
',' );
124 if ( v.count() >= 5 )
126 const double minElev = v.at( 0 ).toDouble();
127 const double maxElev = v.at( 1 ).toDouble();
128 const QColor color( v.at( 2 ).toInt(), v.at( 3 ).toInt(), v.at( 4 ).toInt() );
138 parts.reserve( colors.size() );
143 return parts.join(
';' );
@ Optional
Parameter is optional.
Contains information about the context in which a processing algorithm is executed.
Qgis::ProcessingParameterFlags mFlags
Parameter flags.
QString description() const
Returns the description for the parameter.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
QString name() const
Returns the name of the parameter.
QVariant mDefault
Default value for parameter.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
QList< QgsRasterReliefColor > valueAsReliefColors(const QVariant &value, const QgsProcessingContext &context) const
Returns the parameter value interpreted as a list of raster relief colors.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QVariant colorsAsVariant(const QList< QgsRasterReliefColor > &colors)
Returns a list of raster relief colors encoded as a variant value.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
QString parentLayerParameter() const
Returns the linked parent layer parameter name.
QgsProcessingParameterReliefColors * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterReliefColors(const QString &name, const QString &description=QString(), const QString &parentLayerParameter=QString(), bool optional=true)
Constructor for QgsProcessingParameterReliefColors.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterString(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool multiLine=false, bool optional=false)
Constructor for QgsProcessingParameterString.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
PythonOutputType
Available Python output types.
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
Defines elevation range and color for raster relief coloring.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.