45 map.insert( QStringLiteral(
"create_options" ),
createOptions );
52 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
58 QVariant val = parameters.value( name );
70 return parameterAsString( definition, parameters.value( definition->
name() ), context );
91 return destParam->generateTemporaryDestination();
94 return val.toString();
102 return parameterAsExpression( definition, parameters.value( definition->
name() ), context );
110 QVariant val = value;
114 if ( val.isValid() && !val.toString().isEmpty() )
118 return val.toString();
130 return parameterAsDouble( definition, parameters.value( definition->
name() ), context );
138 QVariant val = value;
143 double res = val.toDouble( &ok );
149 return val.toDouble();
157 return parameterAsInt( definition, parameters.value( definition->
name() ), context );
165 QVariant val = value;
170 double dbl = val.toDouble( &ok );
175 dbl = val.toDouble( &ok );
182 double round = std::round( dbl );
183 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
188 return static_cast< int >( std::round( dbl ) );
197 return QList< int >();
199 return parameterAsInts( definition, parameters.value( definition->
name() ), context );
205 return QList< int >();
207 QList< int > resultList;
208 QVariant val = value;
213 else if ( val.type() == QVariant::List )
215 QVariantList list = val.toList();
216 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
217 resultList << it->toInt();
221 QStringList parts = val.toString().split(
';' );
222 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
223 resultList << it->toInt();
227 if ( ( resultList.isEmpty() || resultList.at( 0 ) == 0 ) )
233 if ( definition->
defaultValue().type() == QVariant::List )
235 QVariantList list = definition->
defaultValue().toList();
236 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
237 resultList << it->toInt();
241 QStringList parts = definition->
defaultValue().toString().split(
';' );
242 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
243 resultList << it->toInt();
256 return parameterAsEnum( definition, parameters.value( definition->
name() ), context );
264 int val = parameterAsInt( definition, value, context );
266 if ( enumDef && val >= enumDef->
options().size() )
278 return parameterAsEnums( definition, parameters.value( definition->
name() ), context );
286 QVariantList resultList;
287 QVariant val = value;
290 else if ( val.type() == QVariant::List )
292 const auto constToList = val.toList();
293 for (
const QVariant &var : constToList )
296 else if ( val.type() == QVariant::String )
298 const auto constSplit = val.toString().split(
',' );
299 for (
const QString &var : constSplit )
305 if ( resultList.isEmpty() )
306 return QList< int >();
308 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
312 if ( definition->
defaultValue().type() == QVariant::List )
314 const auto constToList = definition->
defaultValue().toList();
315 for (
const QVariant &var : constToList )
318 else if ( definition->
defaultValue().type() == QVariant::String )
320 const auto constSplit = definition->
defaultValue().toString().split(
',' );
321 for (
const QString &var : constSplit )
330 const auto constResultList = resultList;
331 for (
const QVariant &var : constResultList )
333 int resInt = var.toInt();
334 if ( !enumDef || resInt < enumDef->options().size() )
347 return parameterAsBool( definition, parameters.value( definition->
name() ), context );
355 return parameterAsBoolean( definition, parameters.value( definition->
name() ), context );
365 QVariant val = value;
368 else if ( val.isValid() )
381 QVariant val = value;
384 else if ( val.isValid() )
392 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags )
397 val = parameters.value( definition->
name() );
400 return parameterAsSink( definition, val, fields, geometryType, crs, context, destinationIdentifier, sinkFlags );
405 QVariant val = value;
426 else if ( !val.isValid() || val.toString().isEmpty() )
442 dest = val.toString();
447 dest = destParam->generateTemporaryDestination();
450 if ( dest.isEmpty() )
454 destinationIdentifier = dest;
456 if ( destinationProject )
458 if ( destName.isEmpty() && definition )
464 outputName = definition->
name();
468 return sink.release();
476 return parameterAsSource( definition, parameters.value( definition->
name() ), context );
492 QVariant val = parameters.value( definition->
name() );
494 bool selectedFeaturesOnly =
false;
515 vl = qobject_cast<
QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
524 else if ( !val.isValid() || val.toString().isEmpty() )
530 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
536 layerRef = val.toString();
541 if ( layerRef.isEmpty() )
553 compatibleFormats, preferredFormat, context, feedback, *layerName );
556 compatibleFormats, preferredFormat, context, feedback );
566 QString *destLayer = layerName;
582 return parameterAsLayer( definition, parameters.value( definition->
name() ), context );
590 QVariant val = value;
596 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
613 if ( !val.isValid() || val.toString().isEmpty() )
619 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
624 QString layerRef = val.toString();
625 if ( layerRef.isEmpty() )
628 if ( layerRef.isEmpty() )
636 return qobject_cast<
QgsRasterLayer *>( parameterAsLayer( definition, parameters, context ) );
641 return qobject_cast<
QgsRasterLayer *>( parameterAsLayer( definition, value, context ) );
646 return qobject_cast<
QgsMeshLayer *>( parameterAsLayer( definition, parameters, context ) );
651 return qobject_cast<
QgsMeshLayer *>( parameterAsLayer( definition, value, context ) );
659 val = parameters.value( definition->
name() );
661 return parameterAsOutputLayer( definition, val, context );
666 QVariant val = value;
686 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
693 dest = val.toString();
698 dest = destParam->generateTemporaryDestination();
701 if ( destinationProject )
704 if ( destName.isEmpty() && definition )
709 outputName = definition->
name();
728 val = parameters.value( definition->
name() );
730 return parameterAsFileOutput( definition, val, context );
735 QVariant val = value;
749 else if ( !val.isValid() || val.toString().isEmpty() )
756 dest = val.toString();
761 dest = destParam->generateTemporaryDestination();
768 return qobject_cast<
QgsVectorLayer *>( parameterAsLayer( definition, parameters, context ) );
773 return qobject_cast<
QgsVectorLayer *>( parameterAsLayer( definition, value, context ) );
781 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
798 return parameterAsExtent( definition, parameters.value( definition->
name() ), context, crs );
806 QVariant val = value;
855 rectText = val.toString();
857 if ( rectText.isEmpty() && !layer )
860 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
861 QRegularExpressionMatch match = rx.match( rectText );
862 if ( match.hasMatch() )
865 double xMin = match.captured( 1 ).toDouble( &xMinOk );
867 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
869 double yMin = match.captured( 3 ).toDouble( &yMinOk );
871 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
872 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
876 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
921 QVariant val = parameters.value( definition->
name() );
929 g = g.densifyByCount( 20 );
965 rectText = val.toString();
967 if ( !rectText.isEmpty() )
969 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
970 QRegularExpressionMatch match = rx.match( rectText );
971 if ( match.hasMatch() )
974 double xMin = match.captured( 1 ).toDouble( &xMinOk );
976 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
978 double yMin = match.captured( 3 ).toDouble( &yMinOk );
980 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
981 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
986 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
988 g = g.densifyByCount( 20 );
1036 QVariant val = parameters.value( definition->
name() );
1065 QString valueAsString;
1069 valueAsString = val.toString();
1071 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1073 QRegularExpressionMatch match = rx.match( valueAsString );
1074 if ( match.hasMatch() )
1100 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1101 return layer->crs();
1103 return layer->crs();
1116 return parameterAsPoint( definition, parameters.value( definition->
name() ), context, crs );
1124 QVariant val = value;
1153 QString pointText = parameterAsString( definition, value, context );
1154 if ( pointText.isEmpty() )
1157 if ( pointText.isEmpty() )
1160 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1162 QString valueAsString = parameterAsString( definition, value, context );
1163 QRegularExpressionMatch match = rx.match( valueAsString );
1164 if ( match.hasMatch() )
1167 double x = match.captured( 1 ).toDouble( &xOk );
1169 double y = match.captured( 2 ).toDouble( &yOk );
1176 if ( crs.
isValid() && pointCrs.isValid() && crs != pointCrs )
1197 QVariant val = parameters.value( definition->
name() );
1198 return parameterAsPointCrs( definition, val, context );
1212 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1214 QString valueAsString = parameterAsString( definition, value, context );
1215 QRegularExpressionMatch match = rx.match( valueAsString );
1216 if ( match.hasMatch() )
1234 QString fileText = parameterAsString( definition, parameters, context );
1235 if ( fileText.isEmpty() )
1245 QString fileText = parameterAsString( definition, value, context );
1246 if ( fileText.isEmpty() )
1254 return QVariantList();
1256 return parameterAsMatrix( definition, parameters.value( definition->
name() ), context );
1262 return QVariantList();
1264 QString resultString;
1265 QVariant val = value;
1268 else if ( val.type() == QVariant::List )
1269 return val.toList();
1271 resultString = val.toString();
1273 if ( resultString.isEmpty() )
1276 if ( definition->
defaultValue().type() == QVariant::List )
1282 QVariantList result;
1283 const auto constSplit = resultString.split(
',' );
1284 for (
const QString &s : constSplit )
1293 return QList<QgsMapLayer *>();
1295 return parameterAsLayerList( definition, parameters.value( definition->
name() ), context );
1301 return QList<QgsMapLayer *>();
1303 QVariant val = value;
1304 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1306 return QList<QgsMapLayer *>() << layer;
1309 QList<QgsMapLayer *> layers;
1311 std::function< void( const QVariant &var ) > processVariant;
1312 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1314 if ( var.type() == QVariant::List )
1316 const auto constToList = var.toList();
1317 for (
const QVariant &listVar : constToList )
1319 processVariant( listVar );
1322 else if ( var.type() == QVariant::StringList )
1324 const auto constToStringList = var.toStringList();
1325 for (
const QString &s : constToStringList )
1327 processVariant( s );
1331 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1339 processVariant( sink.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1342 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1354 processVariant( val );
1356 if ( layers.isEmpty() )
1359 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->defaultValue() ) ) )
1363 else if ( definition->defaultValue().type() == QVariant::List )
1365 const auto constToList = definition->defaultValue().toList();
1366 for (
const QVariant &var : constToList )
1368 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1374 processVariant( var );
1379 processVariant( definition->defaultValue() );
1388 return QStringList();
1390 QVariant val = value;
1394 std::function< void( const QVariant &var ) > processVariant;
1395 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1397 if ( var.type() == QVariant::List )
1399 const auto constToList = var.toList();
1400 for (
const QVariant &listVar : constToList )
1402 processVariant( listVar );
1405 else if ( var.type() == QVariant::StringList )
1407 const auto constToStringList = var.toStringList();
1408 for (
const QString &s : constToStringList )
1410 processVariant( s );
1414 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1417 files << var.toString();
1421 processVariant( val );
1423 if ( files.isEmpty() )
1425 processVariant( definition->defaultValue() );
1434 return QStringList();
1436 return parameterAsFileList( definition, parameters.value( definition->
name() ), context );
1442 return QList<double>();
1444 return parameterAsRange( definition, parameters.value( definition->
name() ), context );
1450 return QList<double>();
1452 QStringList resultStringList;
1453 QVariant val = value;
1457 else if ( val.type() == QVariant::List )
1459 const auto constToList = val.toList();
1460 for (
const QVariant &var : constToList )
1461 resultStringList << var.toString();
1464 resultStringList << val.toString();
1466 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1468 resultStringList.clear();
1470 if ( definition->
defaultValue().type() == QVariant::List )
1472 const auto constToList = definition->
defaultValue().toList();
1473 for (
const QVariant &var : constToList )
1474 resultStringList << var.toString();
1477 resultStringList << definition->
defaultValue().toString();
1480 if ( resultStringList.size() == 1 )
1482 resultStringList = resultStringList.at( 0 ).split(
',' );
1485 if ( resultStringList.size() < 2 )
1486 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1488 QList< double > result;
1490 double n = resultStringList.at( 0 ).toDouble( &ok );
1494 result << std::numeric_limits<double>::quiet_NaN() ;
1496 n = resultStringList.at( 1 ).toDouble( &ok );
1500 result << std::numeric_limits<double>::quiet_NaN() ;
1508 return QStringList();
1510 QStringList resultStringList;
1511 return parameterAsFields( definition, parameters.value( definition->
name() ), context );
1517 return QStringList();
1519 QStringList resultStringList;
1520 QVariant val = value;
1521 if ( val.isValid() )
1525 else if ( val.type() == QVariant::List )
1527 const auto constToList = val.toList();
1528 for (
const QVariant &var : constToList )
1529 resultStringList << var.toString();
1531 else if ( val.type() == QVariant::StringList )
1533 resultStringList = val.toStringList();
1536 resultStringList.append( val.toString().split(
';' ) );
1539 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1541 resultStringList.clear();
1545 if ( definition->
defaultValue().type() == QVariant::List )
1547 const auto constToList = definition->
defaultValue().toList();
1548 for (
const QVariant &var : constToList )
1549 resultStringList << var.toString();
1551 else if ( definition->
defaultValue().type() == QVariant::StringList )
1553 resultStringList = definition->
defaultValue().toStringList();
1556 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
1560 return resultStringList;
1568 return parameterAsLayout( definition, parameters.value( definition->
name() ), context );
1573 const QString layoutName = parameterAsString( definition, value, context );
1574 if ( layoutName.isEmpty() )
1582 return static_cast< QgsPrintLayout * >( l );
1592 return parameterAsLayoutItem( definition, parameters.value( definition->
name() ), context, layout );
1600 const QString
id = parameterAsString( definition, value, context );
1618 return parameterAsColor( definition, parameters.value( definition->
name() ), context );
1626 QVariant val = value;
1631 if ( val.type() == QVariant::Color )
1633 QColor
c = val.value< QColor >();
1635 if ( !colorParam->opacityEnabled() )
1640 QString colorText = parameterAsString( definition, value, context );
1643 if ( definition->
defaultValue().type() == QVariant::Color )
1649 if ( colorText.isEmpty() )
1652 bool containsAlpha =
false;
1655 if ( c.isValid() && !colorParam->opacityEnabled() )
1662 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
1663 QString name = map.value( QStringLiteral(
"name" ) ).toString();
1664 std::unique_ptr< QgsProcessingParameterDefinition > def;
1726 def.reset( paramType->
create( name ) );
1732 def->fromVariantMap( map );
1733 return def.release();
1738 QString desc = name;
1739 desc.replace(
'_',
' ' );
1745 bool isOptional =
false;
1749 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
1752 QString description = descriptionFromName( name );
1754 if ( type == QStringLiteral(
"boolean" ) )
1756 else if ( type == QStringLiteral(
"crs" ) )
1758 else if ( type == QStringLiteral(
"layer" ) )
1760 else if ( type == QStringLiteral(
"extent" ) )
1762 else if ( type == QStringLiteral(
"point" ) )
1764 else if ( type == QStringLiteral(
"file" ) )
1766 else if ( type == QStringLiteral(
"folder" ) )
1768 else if ( type == QStringLiteral(
"matrix" ) )
1770 else if ( type == QStringLiteral(
"multiple" ) )
1772 else if ( type == QStringLiteral(
"number" ) )
1774 else if ( type == QStringLiteral(
"distance" ) )
1776 else if ( type == QStringLiteral(
"scale" ) )
1778 else if ( type == QStringLiteral(
"range" ) )
1780 else if ( type == QStringLiteral(
"raster" ) )
1782 else if ( type == QStringLiteral(
"enum" ) )
1784 else if ( type == QStringLiteral(
"string" ) )
1786 else if ( type == QStringLiteral(
"authcfg" ) )
1788 else if ( type == QStringLiteral(
"expression" ) )
1790 else if ( type == QStringLiteral(
"field" ) )
1792 else if ( type == QStringLiteral(
"vector" ) )
1794 else if ( type == QStringLiteral(
"source" ) )
1796 else if ( type == QStringLiteral(
"sink" ) )
1798 else if ( type == QStringLiteral(
"vectordestination" ) )
1800 else if ( type == QStringLiteral(
"rasterdestination" ) )
1802 else if ( type == QStringLiteral(
"filedestination" ) )
1804 else if ( type == QStringLiteral(
"folderdestination" ) )
1806 else if ( type == QStringLiteral(
"band" ) )
1808 else if ( type == QStringLiteral(
"mesh" ) )
1810 else if ( type == QStringLiteral(
"layout" ) )
1812 else if ( type == QStringLiteral(
"layoutitem" ) )
1814 else if ( type == QStringLiteral(
"color" ) )
1816 else if ( type == QStringLiteral(
"coordinateoperation" ) )
1818 else if ( type == QStringLiteral(
"maptheme" ) )
1824 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
1826 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
1827 QRegularExpressionMatch m = re.match( code );
1828 if ( !m.hasMatch() )
1831 name = m.captured( 1 );
1832 QString tokens = m.captured( 2 );
1833 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
1836 tokens.remove( 0, 8 );
1843 tokens = tokens.trimmed();
1845 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
1846 m = re2.match( tokens );
1847 if ( !m.hasMatch() )
1849 type = tokens.toLower().trimmed();
1854 type = m.captured( 1 ).toLower().trimmed();
1855 definition = m.captured( 2 );
1866 , mDescription( description )
1867 , mDefault( defaultValue )
1868 , mFlags( optional ? FlagOptional : 0 )
1873 if ( !input.isValid() && !
mDefault.isValid() )
1876 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
1877 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
1885 if ( !value.isValid() )
1886 return QStringLiteral(
"None" );
1889 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1896 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1898 code += QStringLiteral(
"optional " );
1899 code +=
type() +
' ';
1901 return code.trimmed();
1909 switch ( outputType )
1913 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
1915 code += QStringLiteral(
", optional=True" );
1931 map.insert( QStringLiteral(
"parameter_type" ),
type() );
1932 map.insert( QStringLiteral(
"name" ),
mName );
1933 map.insert( QStringLiteral(
"description" ),
mDescription );
1934 map.insert( QStringLiteral(
"default" ),
mDefault );
1935 map.insert( QStringLiteral(
"flags" ), static_cast< int >(
mFlags ) );
1936 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
1942 mName = map.value( QStringLiteral(
"name" ) ).toString();
1943 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
1944 mDefault = map.value( QStringLiteral(
"default" ) );
1945 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
1946 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
1962 return QStringLiteral(
"<p><b>%1</b></p><p>%2</p>" ).arg(
1964 QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
1978 if ( !val.isValid() )
1979 return QStringLiteral(
"None" );
1983 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
1988 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1990 code += QStringLiteral(
"optional " );
1991 code +=
type() +
' ';
1992 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
1993 return code.trimmed();
2014 if ( !input.isValid() )
2036 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2039 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2047 if ( !value.isValid() )
2048 return QStringLiteral(
"None" );
2053 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
2059 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2062 p.insert(
name(), value );
2072 return new QgsProcessingParameterCrs( name, description, definition.compare( QLatin1String(
"none" ), Qt::CaseInsensitive ) == 0 ? QVariant() : definition, isOptional );
2088 if ( !input.isValid() )
2096 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2101 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2119 if ( !val.isValid() )
2120 return QStringLiteral(
"None" );
2126 p.insert(
name(), val );
2150 if ( !input.isValid() )
2179 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2182 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2191 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
2192 QRegularExpressionMatch match = rx.match( input.toString() );
2193 if ( match.hasMatch() )
2195 bool xMinOk =
false;
2196 ( void )match.captured( 1 ).toDouble( &xMinOk );
2197 bool xMaxOk =
false;
2198 ( void )match.captured( 2 ).toDouble( &xMaxOk );
2199 bool yMinOk =
false;
2200 ( void )match.captured( 3 ).toDouble( &yMinOk );
2201 bool yMaxOk =
false;
2202 ( void )match.captured( 4 ).toDouble( &yMaxOk );
2203 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
2213 if ( !value.isValid() )
2214 return QStringLiteral(
"None" );
2217 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2237 p.insert(
name(), value );
2263 if ( !input.isValid() )
2284 if ( input.type() == QVariant::String )
2286 if ( input.toString().isEmpty() )
2290 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
2292 QRegularExpressionMatch match = rx.match( input.toString() );
2293 if ( match.hasMatch() )
2296 ( void )match.captured( 1 ).toDouble( &xOk );
2298 ( void )match.captured( 2 ).toDouble( &yOk );
2307 if ( !value.isValid() )
2308 return QStringLiteral(
"None" );
2311 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2331 const QString wkt = g.
asWkt();
2332 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
2346 , mBehavior( behavior )
2347 , mExtension( fileFilter.isEmpty() ? extension : QString() )
2348 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
2360 if ( !input.isValid() )
2368 QString
string = input.toString().trimmed();
2370 if ( input.type() != QVariant::String ||
string.isEmpty() )
2373 switch ( mBehavior )
2377 if ( !mExtension.isEmpty() )
2379 return string.endsWith( mExtension, Qt::CaseInsensitive );
2381 else if ( !mFileFilter.isEmpty() )
2384 return test == string;
2400 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2402 code += QStringLiteral(
"optional " );
2403 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
2405 return code.trimmed();
2410 switch ( outputType )
2415 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', '%2'" ).arg(
name(),
description() );
2417 code += QStringLiteral(
", optional=True" );
2418 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
2419 if ( !mExtension.isEmpty() )
2420 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
2421 if ( !mFileFilter.isEmpty() )
2422 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
2434 mFileFilter.clear();
2444 mFileFilter = filter;
2451 map.insert( QStringLiteral(
"behavior" ), mBehavior );
2452 map.insert( QStringLiteral(
"extension" ), mExtension );
2453 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
2460 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
2461 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
2462 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
2473 , mHeaders( headers )
2474 , mNumberRows( numberRows )
2475 , mFixedNumberRows( fixedNumberRows )
2487 if ( !input.isValid() )
2490 if ( input.type() == QVariant::String )
2492 if ( input.toString().isEmpty() )
2496 else if ( input.type() == QVariant::List )
2498 if ( input.toList().isEmpty() )
2502 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
2512 if ( !value.isValid() )
2513 return QStringLiteral(
"None" );
2516 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2519 p.insert(
name(), value );
2523 const auto constList = list;
2524 for (
const QVariant &v : constList )
2526 if ( v.type() == QVariant::List )
2529 const auto constToList = v.toList();
2530 for (
const QVariant &v2 : constToList )
2532 if ( v2.isNull() || !v2.isValid() )
2533 parts2 << QStringLiteral(
"None" );
2534 else if ( v2.toString().isEmpty() )
2535 parts2 << QStringLiteral(
"''" );
2537 parts2 << v2.toString();
2539 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
2543 if ( v.isNull() || !v.isValid() )
2544 parts << QStringLiteral(
"None" );
2545 else if ( v.toString().isEmpty() )
2546 parts << QStringLiteral(
"''" );
2548 parts << v.toString();
2552 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2557 switch ( outputType )
2561 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', '%2'" ).arg(
name(),
description() );
2563 code += QStringLiteral(
", optional=True" );
2564 code += QStringLiteral(
", numberRows=" ).arg( mNumberRows );
2565 code += QStringLiteral(
", hasFixedNumberRows=" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
2568 headers.reserve( mHeaders.size() );
2569 for (
const QString &h : mHeaders )
2571 code += QStringLiteral(
", headers=[%1]" ).arg( headers.join(
',' ) );
2603 return mFixedNumberRows;
2608 mFixedNumberRows = fixedNumberRows;
2614 map.insert( QStringLiteral(
"headers" ), mHeaders );
2615 map.insert( QStringLiteral(
"rows" ), mNumberRows );
2616 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
2623 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
2624 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
2625 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
2631 return new QgsProcessingParameterMatrix( name, description, 0,
false, QStringList(), definition.isEmpty() ? QVariant() : definition, isOptional );
2636 , mLayerType( layerType )
2648 if ( !input.isValid() )
2653 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2659 if ( input.type() == QVariant::String )
2661 if ( input.toString().isEmpty() )
2664 if ( mMinimumNumberInputs > 1 )
2675 else if ( input.type() == QVariant::List )
2677 if ( input.toList().count() < mMinimumNumberInputs )
2680 if ( mMinimumNumberInputs > input.toList().count() )
2688 const auto constToList = input.toList();
2689 for (
const QVariant &v : constToList )
2691 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
2700 else if ( input.type() == QVariant::StringList )
2702 if ( input.toStringList().count() < mMinimumNumberInputs )
2705 if ( mMinimumNumberInputs > input.toStringList().count() )
2713 const auto constToStringList = input.toStringList();
2714 for (
const QString &v : constToStringList )
2727 if ( !value.isValid() )
2728 return QStringLiteral(
"None" );
2731 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2736 if ( value.type() == QVariant::StringList )
2738 const QStringList list = value.toStringList();
2739 parts.reserve( list.count() );
2740 for (
const QString &v : list )
2743 else if ( value.type() == QVariant::List )
2745 const QVariantList list = value.toList();
2746 parts.reserve( list.count() );
2747 for (
const QVariant &v : list )
2750 if ( !parts.isEmpty() )
2751 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2756 p.insert(
name(), value );
2758 if ( !list.isEmpty() )
2761 parts.reserve( list.count() );
2766 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2775 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2777 code += QStringLiteral(
"optional " );
2778 switch ( mLayerType )
2781 code += QStringLiteral(
"multiple raster" );
2785 code += QStringLiteral(
"multiple file" );
2789 code += QStringLiteral(
"multiple vector" );
2793 if (
mDefault.type() == QVariant::List )
2796 const auto constToList =
mDefault.toList();
2797 for (
const QVariant &var : constToList )
2799 parts << var.toString();
2801 code += parts.join(
',' );
2803 else if (
mDefault.type() == QVariant::StringList )
2805 code +=
mDefault.toStringList().join(
',' );
2811 return code.trimmed();
2816 switch ( outputType )
2820 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', '%2'" ).arg(
name(),
description() );
2822 code += QStringLiteral(
", optional=True" );
2826 code += QStringLiteral(
", layerType=%1" ).arg( layerType );
2847 return mMinimumNumberInputs;
2859 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
2860 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
2868 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
2874 QString
type = definition;
2876 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2877 QRegularExpressionMatch m = re.match( definition );
2880 type = m.captured( 1 ).toLower().trimmed();
2881 defaultVal = m.captured( 2 );
2884 if ( type == QStringLiteral(
"vector" ) )
2886 else if ( type == QStringLiteral(
"raster" ) )
2888 else if ( type == QStringLiteral(
"file" ) )
2901 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg( name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
2912 QVariant input = value;
2913 if ( !input.isValid() )
2927 double res = input.toDouble( &ok );
2931 return !( res < mMin || res > mMax );
2936 if ( !value.isValid() )
2937 return QStringLiteral(
"None" );
2940 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2942 return value.toString();
2949 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
2950 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
2951 if ( mMax < std::numeric_limits<double>::max() )
2952 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
2954 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
2955 QString extra = parts.join( QStringLiteral(
"<br />" ) );
2956 if ( !extra.isEmpty() )
2957 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
2963 switch ( outputType )
2967 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', '%2'" ).arg(
name(),
description() );
2969 code += QStringLiteral(
", optional=True" );
2971 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
2973 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
2974 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
2975 if ( mMax != std::numeric_limits<double>::max() )
2976 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
3018 map.insert( QStringLiteral(
"min" ), mMin );
3019 map.insert( QStringLiteral(
"max" ), mMax );
3020 map.insert( QStringLiteral(
"data_type" ), mDataType );
3027 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
3028 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
3029 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
3036 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
3053 if ( !input.isValid() )
3061 if ( input.type() == QVariant::String )
3063 QStringList list = input.toString().split(
',' );
3064 if ( list.count() != 2 )
3067 list.at( 0 ).toDouble( &ok );
3069 list.at( 1 ).toDouble( &ok2 );
3074 else if ( input.type() == QVariant::List )
3076 if ( input.toList().count() != 2 )
3080 input.toList().at( 0 ).toDouble( &ok );
3082 input.toList().at( 1 ).toDouble( &ok2 );
3093 if ( !value.isValid() )
3094 return QStringLiteral(
"None" );
3097 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3100 p.insert(
name(), value );
3103 QStringList stringParts;
3104 const auto constParts = parts;
3105 for (
double v : constParts )
3107 stringParts << QString::number( v );
3109 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
3114 switch ( outputType )
3118 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', '%2'" ).arg(
name(),
description() );
3120 code += QStringLiteral(
", optional=True" );
3122 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
3145 map.insert( QStringLiteral(
"data_type" ), mDataType );
3159 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
3175 if ( !input.isValid() )
3183 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
3186 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3204 if ( !val.isValid() )
3205 return QStringLiteral(
"None" );
3211 p.insert(
name(), val );
3224 , mOptions( options )
3225 , mAllowMultiple( allowMultiple )
3237 QVariant input = value;
3238 if ( !input.isValid() )
3251 if ( input.type() == QVariant::List )
3253 if ( !mAllowMultiple )
3256 const QVariantList values = input.toList();
3260 for (
const QVariant &val : values )
3263 int res = val.toInt( &ok );
3266 else if ( res < 0 || res >= mOptions.count() )
3272 else if ( input.type() == QVariant::String )
3274 QStringList parts = input.toString().split(
',' );
3275 if ( parts.count() > 1 && !mAllowMultiple )
3278 const auto constParts = parts;
3279 for (
const QString &part : constParts )
3282 int res = part.toInt( &ok );
3285 else if ( res < 0 || res >= mOptions.count() )
3290 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
3293 int res = input.toInt( &ok );
3296 else if ( res >= 0 && res < mOptions.count() )
3304 if ( !value.isValid() )
3305 return QStringLiteral(
"None" );
3308 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3310 if ( value.type() == QVariant::List )
3313 const auto constToList = value.toList();
3314 for (
const QVariant &val : constToList )
3316 parts << QString::number( static_cast< int >( val.toDouble() ) );
3318 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3320 else if ( value.type() == QVariant::String )
3322 QStringList parts = value.toString().split(
',' );
3323 if ( parts.count() > 1 )
3325 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3329 return QString::number( static_cast< int >( value.toDouble() ) );
3334 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3336 code += QStringLiteral(
"optional " );
3337 code += QStringLiteral(
"enum " );
3339 if ( mAllowMultiple )
3340 code += QStringLiteral(
"multiple " );
3342 code += mOptions.join(
';' ) +
' ';
3345 return code.trimmed();
3350 switch ( outputType )
3354 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', '%2'" ).arg(
name(),
description() );
3356 code += QStringLiteral(
", optional=True" );
3359 options.reserve( mOptions.size() );
3360 for (
const QString &o : mOptions )
3362 code += QStringLiteral(
", options=[%1]" ).arg( options.join(
',' ) );
3364 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3386 return mAllowMultiple;
3397 map.insert( QStringLiteral(
"options" ), mOptions );
3398 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
3405 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
3406 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
3413 bool multiple =
false;
3414 QString def = definition;
3415 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
3421 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
3422 QRegularExpressionMatch m = re.match( def );
3423 QString values = def;
3426 values = m.captured( 1 ).trimmed();
3427 defaultVal = m.captured( 2 );
3430 return new QgsProcessingParameterEnum( name, description, values.split(
';' ), multiple, defaultVal.isEmpty() ? QVariant() : defaultVal, isOptional );
3435 , mMultiLine( multiLine )
3447 if ( !value.isValid() || value.isNull() )
3448 return QStringLiteral(
"None" );
3451 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3453 QString s = value.toString();
3459 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3461 code += QStringLiteral(
"optional " );
3462 code += QStringLiteral(
"string " );
3465 code += QStringLiteral(
"long " );
3468 return code.trimmed();
3473 switch ( outputType )
3477 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', '%2'" ).arg(
name(),
description() );
3479 code += QStringLiteral(
", optional=True" );
3480 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3503 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
3510 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
3516 QString def = definition;
3518 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
3524 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
3526 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
3530 if ( def == QStringLiteral(
"None" ) )
3531 defaultValue = QVariant();
3553 if ( !value.isValid() )
3554 return QStringLiteral(
"None" );
3556 QString s = value.toString();
3562 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3564 code += QStringLiteral(
"optional " );
3565 code += QStringLiteral(
"authcfg " );
3568 return code.trimmed();
3573 QString def = definition;
3575 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
3577 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
3581 if ( def == QStringLiteral(
"None" ) )
3582 defaultValue = QVariant();
3594 , mParentLayerParameterName( parentLayerParameterName )
3606 if ( !value.isValid() )
3607 return QStringLiteral(
"None" );
3610 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3612 QString s = value.toString();
3618 QStringList depends;
3619 if ( !mParentLayerParameterName.isEmpty() )
3620 depends << mParentLayerParameterName;
3626 switch ( outputType )
3630 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', '%2'" ).arg(
name(),
description() );
3632 code += QStringLiteral(
", optional=True" );
3634 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
3646 return mParentLayerParameterName;
3657 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
3664 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
3705 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
3708 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3726 if ( !val.isValid() )
3727 return QStringLiteral(
"None" );
3733 p.insert(
name(), val );
3741 switch ( outputType )
3745 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', '%2'" ).arg(
name(),
description() );
3747 code += QStringLiteral(
", optional=True" );
3751 QStringList options;
3754 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
3780 for (
int type : constMDataTypes )
3784 map.insert( QStringLiteral(
"data_types" ), types );
3792 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3793 const auto constValues = values;
3794 for (
const QVariant &val : constValues )
3840 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
3843 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3861 if ( !val.isValid() )
3862 return QStringLiteral(
"None" );
3868 p.insert(
name(), val );
3881 , mParentLayerParameterName( parentLayerParameterName )
3883 , mAllowMultiple( allowMultiple )
3884 , mDefaultToAllFields( defaultToAllFields )
3897 if ( !input.isValid() )
3905 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
3907 if ( !mAllowMultiple )
3913 else if ( input.type() == QVariant::String )
3915 if ( input.toString().isEmpty() )
3918 QStringList parts = input.toString().split(
';' );
3919 if ( parts.count() > 1 && !mAllowMultiple )
3924 if ( input.toString().isEmpty() )
3932 if ( !value.isValid() )
3933 return QStringLiteral(
"None" );
3936 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3938 if ( value.type() == QVariant::List )
3941 const auto constToList = value.toList();
3942 for (
const QVariant &val : constToList )
3946 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3948 else if ( value.type() == QVariant::StringList )
3951 const auto constToStringList = value.toStringList();
3952 for ( QString s : constToStringList )
3956 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3964 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3966 code += QStringLiteral(
"optional " );
3967 code += QStringLiteral(
"field " );
3969 switch ( mDataType )
3972 code += QStringLiteral(
"numeric " );
3976 code += QStringLiteral(
"string " );
3980 code += QStringLiteral(
"datetime " );
3987 if ( mAllowMultiple )
3988 code += QStringLiteral(
"multiple " );
3990 if ( mDefaultToAllFields )
3991 code += QStringLiteral(
"default_to_all_fields " );
3993 code += mParentLayerParameterName +
' ';
3996 return code.trimmed();
4001 switch ( outputType )
4005 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', '%2'" ).arg(
name(),
description() );
4007 code += QStringLiteral(
", optional=True" );
4010 switch ( mDataType )
4013 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
4017 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
4021 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
4025 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
4028 code += QStringLiteral(
", type=%1" ).arg( dataType );
4030 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4031 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4035 if ( mDefaultToAllFields )
4036 code += QStringLiteral(
", defaultToAllFields=True" );
4048 QStringList depends;
4049 if ( !mParentLayerParameterName.isEmpty() )
4050 depends << mParentLayerParameterName;
4056 return mParentLayerParameterName;
4076 return mAllowMultiple;
4086 return mDefaultToAllFields;
4091 mDefaultToAllFields = enabled;
4097 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
4098 map.insert( QStringLiteral(
"data_type" ), mDataType );
4099 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
4100 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
4107 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
4108 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
4109 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
4110 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
4120 QString def = definition;
4122 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
4127 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
4132 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
4138 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
4140 allowMultiple =
true;
4141 def = def.mid( 8 ).trimmed();
4144 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
4146 defaultToAllFields =
true;
4147 def = def.mid( 21 ).trimmed();
4150 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
4151 QRegularExpressionMatch m = re.match( def );
4154 parent = m.captured( 1 ).trimmed();
4155 def = m.captured( 2 );
4180 QVariant var = input;
4181 if ( !var.isValid() )
4208 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
4213 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4231 if ( !value.isValid() )
4232 return QStringLiteral(
"None" );
4235 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4244 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', True)" ).arg( fromVar.
source.
staticValue().toString() );
4251 layerString = layer->source();
4259 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), True)" ).arg( fromVar.
source.
asExpression() );
4263 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
4267 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
4272 QString layerString = value.toString();
4276 layerString = layer->source();
4283 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4285 code += QStringLiteral(
"optional " );
4286 code += QStringLiteral(
"source " );
4289 for (
int type : constMDataTypes )
4294 code += QStringLiteral(
"point " );
4298 code += QStringLiteral(
"line " );
4302 code += QStringLiteral(
"polygon " );
4309 return code.trimmed();
4314 switch ( outputType )
4318 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', '%2'" ).arg(
name(),
description() );
4320 code += QStringLiteral(
", optional=True" );
4324 QStringList options;
4328 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
4350 for (
int type : constMDataTypes )
4354 map.insert( QStringLiteral(
"data_types" ), types );
4362 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
4363 const auto constValues = values;
4364 for (
const QVariant &val : constValues )
4374 QString def = definition;
4377 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
4383 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
4389 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
4414 QVariant var = input;
4415 if ( !var.isValid() )
4437 if ( var.type() != QVariant::String )
4440 if ( var.toString().isEmpty() )
4448 if ( !value.isValid() )
4449 return QStringLiteral(
"None" );
4452 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4463 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4472 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4474 code += QStringLiteral(
"optional " );
4475 code += QStringLiteral(
"sink " );
4477 switch ( mDataType )
4480 code += QStringLiteral(
"point " );
4484 code += QStringLiteral(
"line " );
4488 code += QStringLiteral(
"polygon " );
4492 code += QStringLiteral(
"table " );
4500 return code.trimmed();
4516 return p->defaultVectorFileExtension(
hasGeometry() );
4526 return QStringLiteral(
"dbf" );
4533 switch ( outputType )
4537 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', '%2'" ).arg(
name(),
description() );
4539 code += QStringLiteral(
", optional=True" );
4543 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4565 return p->supportedOutputVectorLayerExtensions();
4567 return p->supportedOutputTableExtensions();
4582 switch ( mDataType )
4608 map.insert( QStringLiteral(
"data_type" ), mDataType );
4622 return QStringLiteral(
"memory:%1" ).arg(
description() );
4630 QString def = definition;
4631 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
4636 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
4641 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
4646 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
4667 QVariant var = input;
4668 if ( !var.isValid() )
4690 if ( var.type() != QVariant::String )
4693 if ( var.toString().isEmpty() )
4701 if ( !value.isValid() )
4702 return QStringLiteral(
"None" );
4705 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4716 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4736 return p->defaultRasterFileExtension();
4752 return p->supportedOutputRasterLayerExtensions();
4768 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
4780 QVariant var = input;
4781 if ( !var.isValid() )
4803 if ( var.type() != QVariant::String )
4806 if ( var.toString().isEmpty() )
4816 if ( !value.isValid() )
4817 return QStringLiteral(
"None" );
4820 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4831 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4840 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
4852 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
4853 return QStringLiteral(
"file" );
4856 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
4857 QRegularExpressionMatch match = rx.match( mFileFilter );
4858 if ( !match.hasMatch() )
4859 return QStringLiteral(
"file" );
4861 return match.captured( 1 );
4866 switch ( outputType )
4870 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', '%2'" ).arg(
name(),
description() );
4872 code += QStringLiteral(
", optional=True" );
4876 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4899 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
4906 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
4927 QVariant var = input;
4928 if ( !var.isValid() )
4944 if ( var.type() != QVariant::String )
4947 if ( var.toString().isEmpty() )
4970 , mCreateByDefault( createByDefault )
4978 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
4979 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
4986 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
4987 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
4993 switch ( outputType )
5000 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
5002 code += QStringLiteral(
", optional=True" );
5004 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5031 return mCreateByDefault;
5053 QVariant var = input;
5054 if ( !var.isValid() )
5076 if ( var.type() != QVariant::String )
5079 if ( var.toString().isEmpty() )
5087 if ( !value.isValid() )
5088 return QStringLiteral(
"None" );
5091 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5102 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5111 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5113 code += QStringLiteral(
"optional " );
5114 code += QStringLiteral(
"vectorDestination " );
5116 switch ( mDataType )
5119 code += QStringLiteral(
"point " );
5123 code += QStringLiteral(
"line " );
5127 code += QStringLiteral(
"polygon " );
5135 return code.trimmed();
5151 return p->defaultVectorFileExtension(
hasGeometry() );
5161 return QStringLiteral(
"dbf" );
5168 switch ( outputType )
5172 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', '%2'" ).arg(
name(),
description() );
5174 code += QStringLiteral(
", optional=True" );
5178 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5200 return p->supportedOutputVectorLayerExtensions();
5202 return p->supportedOutputTableExtensions();
5217 switch ( mDataType )
5243 map.insert( QStringLiteral(
"data_type" ), mDataType );
5257 QString def = definition;
5258 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5263 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5268 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5279 , mParentLayerParameterName( parentLayerParameterName )
5280 , mAllowMultiple( allowMultiple )
5292 if ( !input.isValid() )
5300 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5302 if ( !mAllowMultiple )
5311 double res = input.toInt( &ok );
5321 return mAllowMultiple;
5331 if ( !value.isValid() )
5332 return QStringLiteral(
"None" );
5335 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5337 if ( value.type() == QVariant::List )
5340 QVariantList values = value.toList();
5341 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
5343 parts << QString::number( static_cast< int >( it->toDouble() ) );
5345 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5347 else if ( value.type() == QVariant::StringList )
5350 QStringList values = value.toStringList();
5351 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
5353 parts << QString::number( static_cast< int >( it->toDouble() ) );
5355 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5358 return value.toString();
5363 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5365 code += QStringLiteral(
"optional " );
5366 code += QStringLiteral(
"band " );
5368 if ( mAllowMultiple )
5369 code += QStringLiteral(
"multiple " );
5371 code += mParentLayerParameterName +
' ';
5374 return code.trimmed();
5379 QStringList depends;
5380 if ( !mParentLayerParameterName.isEmpty() )
5381 depends << mParentLayerParameterName;
5387 switch ( outputType )
5391 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', '%2'" ).arg(
name(),
description() );
5393 code += QStringLiteral(
", optional=True" );
5395 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5396 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5408 return mParentLayerParameterName;
5419 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5420 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5427 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5428 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5435 QString def = definition;
5438 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5440 allowMultiple =
true;
5441 def = def.mid( 8 ).trimmed();
5444 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
5445 QRegularExpressionMatch m = re.match( def );
5448 parent = m.captured( 1 ).trimmed();
5449 def = m.captured( 2 );
5466 , mParentParameterName( parentParameterName )
5483 QStringList depends;
5484 if ( !mParentParameterName.isEmpty() )
5485 depends << mParentParameterName;
5491 switch ( outputType )
5495 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', '%2'" ).arg(
name(),
description() );
5497 code += QStringLiteral(
", optional=True" );
5499 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
5501 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
5502 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
5503 if (
maximum() != std::numeric_limits<double>::max() )
5504 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
5515 return mParentParameterName;
5526 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
5527 map.insert( QStringLiteral(
"default_unit" ), static_cast< int >( mDefaultUnit ) );
5534 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
5562 switch ( outputType )
5566 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', '%2'" ).arg(
name(),
description() );
5568 code += QStringLiteral(
", optional=True" );
5580 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
5599 if ( !value.isValid() || value.isNull() )
5600 return QStringLiteral(
"None" );
5603 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5605 QString s = value.toString();
5611 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5613 code += QStringLiteral(
"optional " );
5614 code += QStringLiteral(
"layout " );
5617 return code.trimmed();
5622 switch ( outputType )
5626 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', '%2'" ).arg(
name(),
description() );
5628 code += QStringLiteral(
", optional=True" );
5639 QString def = definition;
5641 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5643 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5647 if ( def == QStringLiteral(
"None" ) )
5648 defaultValue = QVariant();
5660 , mParentLayoutParameterName( parentLayoutParameterName )
5661 , mItemType( itemType )
5673 if ( !value.isValid() || value.isNull() )
5674 return QStringLiteral(
"None" );
5677 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5679 QString s = value.toString();
5685 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5687 code += QStringLiteral(
"optional " );
5688 code += QStringLiteral(
"layoutitem " );
5689 if ( mItemType >= 0 )
5690 code += QString::number( mItemType ) +
' ';
5692 code += mParentLayoutParameterName +
' ';
5695 return code.trimmed();
5700 switch ( outputType )
5704 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', '%2'" ).arg(
name(),
description() );
5706 code += QStringLiteral(
", optional=True" );
5708 if ( mItemType >= 0 )
5709 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
5711 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
5724 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
5725 map.insert( QStringLiteral(
"item_type" ), mItemType );
5732 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
5733 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
5739 QStringList depends;
5740 if ( !mParentLayoutParameterName.isEmpty() )
5741 depends << mParentLayoutParameterName;
5748 QString def = definition;
5750 QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
5751 QRegularExpressionMatch m = re.match( def );
5754 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
5755 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
5756 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
5769 return mParentLayoutParameterName;
5774 mParentLayoutParameterName =
name;
5793 , mAllowOpacity( opacityEnabled )
5805 if ( !value.isValid() || value.isNull() )
5806 return QStringLiteral(
"None" );
5809 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5811 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
5812 return QStringLiteral(
"QColor()" );
5814 if ( value.canConvert< QColor >() )
5816 QColor
c = value.value< QColor >();
5817 if ( !mAllowOpacity || c.alpha() == 255 )
5818 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg( c.red() ).arg( c.green() ).arg( c.blue() );
5820 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg( c.red() ).arg( c.green() ).arg( c.blue() ).arg( c.alpha() );
5823 QString s = value.toString();
5829 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5831 code += QStringLiteral(
"optional " );
5832 code += QStringLiteral(
"color " );
5834 if ( mAllowOpacity )
5835 code += QStringLiteral(
"withopacity " );
5838 return code.trimmed();
5843 switch ( outputType )
5847 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', '%2'" ).arg(
name(),
description() );
5849 code += QStringLiteral(
", optional=True" );
5851 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5863 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
5866 if ( !input.isValid() )
5869 if ( input.type() == QVariant::Color )
5878 if ( input.type() != QVariant::String || input.toString().isEmpty() )
5881 bool containsAlpha =
false;
5888 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
5895 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
5901 return mAllowOpacity;
5906 mAllowOpacity = enabled;
5911 QString def = definition;
5913 bool allowOpacity =
false;
5914 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
5916 allowOpacity =
true;
5917 def = def.mid( 12 );
5920 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5922 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5926 if ( def == QStringLiteral(
"None" ) )
5927 defaultValue = QVariant();
5937 , mSourceParameterName( sourceCrsParameterName )
5938 , mDestParameterName( destinationCrsParameterName )
5939 , mSourceCrs( staticSourceCrs )
5940 , mDestCrs( staticDestinationCrs )
5952 if ( !value.isValid() || value.isNull() )
5953 return QStringLiteral(
"None" );
5958 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
5964 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5967 p.insert(
name(), value );
5972 QString s = value.toString();
5978 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5980 code += QStringLiteral(
"optional " );
5981 code += QStringLiteral(
"coordinateoperation " );
5984 return code.trimmed();
5989 switch ( outputType )
5994 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', '%2'" ).arg(
name(),
description() );
5996 code += QStringLiteral(
", optional=True" );
5997 if ( !mSourceParameterName.isEmpty() )
5998 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName, c ) );
5999 if ( !mDestParameterName.isEmpty() )
6000 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName, c ) );
6002 if ( mSourceCrs.isValid() )
6003 code += QStringLiteral(
", staticSourceCrs=%1" ).arg(
valueAsPythonString( mSourceCrs, c ) );
6004 if ( mDestCrs.isValid() )
6005 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs, c ) );
6017 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
6018 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
6019 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
6020 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
6027 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
6028 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
6029 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
6030 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
6036 QString def = definition;
6038 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6040 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6044 if ( def == QStringLiteral(
"None" ) )
6045 defaultValue = QVariant();
6069 if ( !input.isValid() && !
mDefault.isValid() )
6072 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
6073 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
6081 if ( !value.isValid() )
6082 return QStringLiteral(
"None" );
6085 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6092 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6094 code += QStringLiteral(
"optional " );
6095 code += QStringLiteral(
"maptheme " );
6098 return code.trimmed();
6103 switch ( outputType )
6107 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', '%2'" ).arg(
name(),
description() );
6109 code += QStringLiteral(
", optional=True" );
6136 QString def = definition;
6137 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6139 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6144 if ( defaultValue == QStringLiteral(
"None" ) || defaultValue.toString().isEmpty() )
6145 defaultValue = QVariant();
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterDefinition.
QgsProperty sink
Sink/layer definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
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::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
A boolean parameter for processing algorithms.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
Class for parsing and evaluation of expressions (formerly called "search strings").
void setDataTypes(const QList< int > &types)
Sets the geometry types for sources acceptable by the parameter.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
A parameter for processing algorithms which accepts multiple map layers.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string which can be used within a Processing script...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterLayoutItem * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
A rectangle specified with double values.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
Base class for all map layer types.
static QString descriptionFromName(const QString &name)
Creates an autogenerated parameter description from a parameter name.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
QgsLayoutItem * itemById(const QString &id) const
Returns a layout item given its id.
static QgsProcessingParameterRasterLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static QString typeName()
Returns the type name for the parameter class.
Base class for providing feedback from a processing algorithm.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsMasterLayoutInterface * layoutByName(const QString &name) const
Returns the layout with a matching name, or nullptr if no matching layouts were found.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterVectorDestination(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterVectorDestination.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
Base class for graphical items within a QgsLayout.
virtual QStringList supportedOutputTableExtensions() const
Returns a list of the table (geometry-less vector layers) file extensions supported by this provider...
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterFolderDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFolderDestination.
QString type() const override
Unique parameter type name.
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
QString type() const override
Unique parameter type name.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
A vector layer or feature source field parameter for processing algorithms.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
QgsProcessingParameterField(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), DataType type=Any, bool allowMultiple=false, bool optional=false, bool defaultToAllFields=false)
Constructor for QgsProcessingParameterField.
static QgsProcessingParameterExtent * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterBand(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false, bool allowMultiple=false)
Constructor for QgsProcessingParameterBand.
QgsProcessingParameterColor(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool opacityEnabled=true, bool optional=false)
Constructor for QgsProcessingParameterColor.
DataType dataType() const
Returns the acceptable data type for the field.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString type() const override
Unique parameter type name.
static QString defaultVectorExtension()
Returns the default vector extension to use, in the absence of all other constraints (e...
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported for this parameter. ...
void setHasFixedNumberRows(bool hasFixedNumberRows)
Sets whether the table has a fixed number of rows.
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), QgsProcessing::SourceType layerType=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterExpression.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
LayerHint
Layer type hints.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), QgsProcessingParameterNumber::Type type=QgsProcessingParameterNumber::Integer, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRange.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterFeatureSource(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFeatureSource.
void setDataType(QgsProcessingParameterNumber::Type dataType)
Sets the acceptable data type for the range.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
void setDefaultToAllFields(bool enabled)
Sets whether a parameter which allows multiple selections (see allowMultiple()) should automatically ...
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
static QString typeName()
Returns the type name for the parameter class.
Represents a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
A print layout parameter, allowing users to select a print layout.
QString type() const override
Unique parameter type name.
A map layer parameter for processing algorithms.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QStringList headers() const
Returns a list of column headers (if set).
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
A class to represent a 2D point.
A color parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
A HTML file output for processing algorithms.
QgsProcessingParameterLayout(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterLayout.
QgsProcessingProvider * provider() const
Returns a pointer to the provider for the algorithm which owns this parameter.
An expression parameter for processing algorithms.
A QgsPointXY with associated coordinate reference system.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterRange * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsLayoutItem * itemByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout item with matching uuid unique identifier, or nullptr if a matching item could not...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterString(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool multiLine=false, bool optional=false)
Constructor for QgsProcessingParameterString.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool createByDefault() const
Returns true if the destination should be created by default.
An interface for objects which accept features via addFeature(s) methods.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
PythonOutputType
Available Python output types.
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter. ...
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported by this provider.
static QString typeName()
Returns the type name for the parameter class.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and beh...
QString type() const override
Unique parameter type name.
double minimum() const
Returns the minimum value acceptable by the parameter.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource, modifying results according to the settings in a QgsProcessingContext.
Container of fields for a vector layer.
static QgsProcessingParameterCrs * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
A geometry is the spatial representation of a feature.
static QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a map layer.
static QString typeName()
Returns the type name for the parameter class.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
static QgsProcessingParameterMultipleLayers * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Abstract base class for processing providers.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QgsProcessingParameterMapLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMapLayer.
A raster band parameter for Processing algorithms.
QString type() const override
Unique parameter type name.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterDefinition * parameterFromVariantMap(const QVariantMap &map)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterEnum(const QString &name, const QString &description=QString(), const QStringList &options=QStringList(), bool allowMultiple=false, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterEnum.
QgsProcessingParameterBoolean(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterBoolean.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterColor * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
static QgsProcessingParameterMapLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
const QgsCoordinateReferenceSystem & crs
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
Converts a source vector layer to a file path of a vector layer of compatible format.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setMaximum(double maximum)
Sets the maximum value acceptable by the parameter.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
static QString normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
Base class for all parameter definitions which represent file or layer destinations, e.g.
Abstract base class for processing algorithms.
A coordinate operation parameter for processing algorithms, for selection between available coordinat...
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
A vector layer output for processing algorithms.
static QgsProcessingParameterBand * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterMapTheme(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMapTheme.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A feature sink output for processing algorithms.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
Files (i.e. non map layer sources, such as text files)
bool selectedFeaturesOnly
true if only selected features in the source should be used by algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
virtual QgsRectangle extent() const
Returns the extent of the layer.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
QgsProcessingParameterScale(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterScale.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
int minimumNumberInputs() const
Returns the minimum number of layers required for the parameter.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QgsProcessingParameterBoolean * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessing::SourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
static QgsGeometry parameterAsExtentGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry cove...
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QString typeName()
Returns the type name for the parameter class.
A numeric range parameter for processing algorithms.
A double numeric parameter for map scale values.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType)
Interprets a string as a map layer within the supplied context.
QString parentLayoutParameterName() const
Returns the name of the parent layout parameter, or an empty string if this is not set...
static QgsProcessingParameterField * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
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
QgsProcessingParameterCrs(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCrs.
QVariant toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QList< int > dataTypes() const
Returns the geometry types for sources acceptable by the parameter.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set...
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), QgsFeatureSink::SinkFlags sinkFlags=nullptr)
Creates a feature sink ready for adding features.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Can be inherited by parameters which require limits to their acceptable data types.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
A raster layer parameter for processing algorithms.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFeatureSink.
Type
The WKB type describes the number of dimensions a geometry has.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
void setOpacityEnabled(bool enabled)
Sets whether the parameter allows opacity control.
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
static QgsProcessingParameterNumber * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Mesh layer type, since QGIS 3.6.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value. ...
QString valueAsString(const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a string.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
static QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags=nullptr)
Evaluates the parameter with matching definition to a feature sink.
QgsProperty source
Source definition.
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Type propertyType() const
Returns the property type.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString type() const override
Unique parameter type name.
An enum based parameter for processing algorithms, allowing for selection from predefined values...
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
void setMinimum(double minimum)
Sets the minimum value acceptable by the parameter.
Flags flags() const
Returns any flags associated with the parameter.
QgsProcessing::SourceType dataType() const
Returns the layer type for this created vector layer.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterFeatureSink * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
QVariant defaultValue() const
Returns the default value for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool hasGeometry() const
Returns true if the created layer is likely to include geometries.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
static QColor parseColorWithAlpha(const QString &colorStr, bool &containsAlpha, bool strictEval=false)
Attempts to parse a string as a color using a variety of common formats, including hex codes...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
static QString convertToCompatibleFormatAndLayerName(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, QString &layerName)
Converts a source vector layer to a file path and layer name of a vector layer of compatible format...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
bool allowMultiple() const
Returns whether multiple band selections are permitted.
static QString typeName()
Returns the type name for the parameter class.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
virtual QString defaultRasterFileExtension() const
Returns the default file extension to use for raster outputs created by the provider.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
A double numeric parameter for distance values.
A file output for processing algorithms.
QgsCoordinateReferenceSystem crs
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QgsProcessingDestinationParameter(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingDestinationParameter.
QString parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e...
static QgsProcessingParameterScale * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
Parameter is a single file.
static const QString TEMPORARY_OUTPUT
Constant used to indicate that a Processing algorithm output should be a temporary layer/file...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterFolderDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Custom exception class for processing related exceptions.
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
virtual QgsMasterLayoutInterface::Type layoutType() const =0
Returns the master layout type.
virtual QString type() const =0
Unique parameter type name.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
static QgsProcessingParameterMeshLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static bool parameterAsBoolean(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
A vector layer (with or without geometry) parameter for processing algorithms.
static QgsProcessingParameterExpression * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool multiLine() const
Returns true if the parameter allows multiline strings.
static QString parameterAsCompatibleSourceLayerPathAndLayerName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr, QString *layerName=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path and layer name of...
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterScale * clone() const override
Creates a clone of the parameter definition.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
static QStringList parameterAsFileList(const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultip...
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
QStringList options() const
Returns the list of acceptable options for the parameter.
A QgsRectangle with associated coordinate reference system.
void setItemType(int type)
Sets the acceptable item type, or -1 if any item type is allowed.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A print layout item parameter, allowing users to select a particular item from a print layout...
A mesh layer parameter for processing algorithms.
QgsProcessingParameterNumber(const QString &name, const QString &description=QString(), Type type=Integer, const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterNumber.
A coordinate reference system parameter for processing algorithms.
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
A store for object properties.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
A rectangular map extent parameter for processing algorithms.
void setMinimumNumberInputs(int minimum)
Sets the minimum number of layers required for the parameter.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
void setLayerType(QgsProcessing::SourceType type)
Sets the layer type for layers acceptable by the parameter.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple band selections are permitted.
Details for layers to load into projects.
void setAllowMultiple(bool allowMultiple)
Sets whether the parameter allows multiple selected values.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A numeric parameter for processing algorithms.
bool loadVariant(const QVariantMap &map)
Loads this output layer definition from a QVariantMap, wrapped in a QVariant.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
static QgsProcessingParameterVectorDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
void setExtension(const QString &extension)
Sets a file extension for the parameter.
QgsExpressionContext & expressionContext()
Returns the expression context.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
QgsProcessingParameterDistance(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentParameterName=QString(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterDistance.
void setOptions(const QStringList &options)
Sets the list of acceptable options for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString parameterAsCompatibleSourceLayerPathInternal(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback, QString *layerName)
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QString name() const
Returns the name of the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QList< int > mDataTypes
List of acceptable data types for the parameter.
Encapsulates settings relating to a feature source input to a processing algorithm.
void setMultiLine(bool multiLine)
Sets whether the parameter allows multiline strings.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
void setDataType(Type type)
Sets the acceptable data type for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
Behavior behavior() const
Returns the parameter behavior (e.g.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString generateTempFilename(const QString &basename)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
QString type() const override
Unique parameter type name.
DistanceUnit
Units of distance.
QVariant toVariant() const
Saves this output layer definition to a QVariantMap, wrapped in a QVariant.
void addLayerToLoadOnCompletion(const QString &layer, const QgsProcessingContext::LayerDetails &details)
Adds a layer to load (by ID or datasource) into the canvas upon completion of the algorithm or model...
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString extension() const
Returns any specified file extension for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
virtual QString defaultVectorFileExtension(bool hasGeometry=true) const
Returns the default file extension to use for vector outputs created by the provider.
static QgsProcessingParameterFile * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior=File)
Creates a new parameter using the definition from a script code.
static QgsProcessingParameterMatrix * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Base class for the definition of processing outputs.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessing::SourceType dataType() const
Returns the layer type for sinks associated with the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
QgsProcessingParameterLimitedDataTypes(const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterLimitedDataTypes, with a list of acceptable data types...
void setNumberRows(int rows)
Sets the fixed number of rows in the table.
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
A point parameter for processing algorithms.
static QgsMeshLayer * parameterAsMeshLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition and value to a mesh layer.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setDataType(DataType type)
Sets the acceptable data type for the field.
static QgsProcessingParameterAuthConfig * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
static QgsProcessingParameterString * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString source() const
Returns the source for the layer.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
An input feature source (such as vector layers) parameter for processing algorithms.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
int valueAsInt(const QgsExpressionContext &context, int defaultValue=0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as an integer.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString destinationName
Name to use for sink if it's to be loaded into a destination project.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Flags mFlags
Parameter flags.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterVectorLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Any map layer type (raster or vector or mesh)
Makes metadata of processing parameters available.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
QgsProcessingParameterFile(const QString &name, const QString &description=QString(), Behavior behavior=File, const QString &extension=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &fileFilter=QString())
Constructor for QgsProcessingParameterFile.
QgsProject * destinationProject
Destination project.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
This class represents a coordinate reference system (CRS).
int numberRows() const
Returns the fixed number of rows in the table.
Base class for the definition of processing parameters.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterDefinition * parameterFromScriptCode(const QString &code)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code st...
QVariant staticValue() const
Returns the current static value for the property.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
QVariant mDefault
Default value for parameter.
SourceType
Data source types enum.
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString typeName()
Returns the type name for the parameter class.
QString mName
Parameter name.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterMeshLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMeshLayer.
static QString addExtensionFromFilter(const QString &fileName, const QString &filter)
Ensures that a fileName ends with an extension from the specified filter string.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Represents a mesh layer supporting display of data on structured or unstructured meshes.
static QString typeName()
Returns the type name for the parameter class.
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterCoordinateOperation(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &sourceCrsParameterName=QString(), const QString &destinationCrsParameterName=QString(), const QVariant &staticSourceCrs=QVariant(), const QVariant &staticDestinationCrs=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCoordinateOperation.
Behavior
Parameter behavior.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
A folder output for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
DataType
Field data types.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterPoint * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterPoint(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPoint.
A table (matrix) parameter for processing algorithms.
Full Python QgsProcessingAlgorithm subclass.
Custom exception class for Coordinate Reference System related exceptions.
Type dataType() const
Returns the acceptable data type for the parameter.
QString type() const override
Unique parameter type name.
QgsProcessingParameterLayoutItem(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayoutParameterName=QString(), int itemType=-1, bool optional=false)
Constructor for QgsProcessingParameterLayoutItem.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
A string parameter for authentication configuration ID values.
static QgsProcessingParameterEnum * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this provider.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString mDescription
Parameter description.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter. ...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString parameterAsCompatibleSourceLayerPath(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path of compatible for...
bool hasGeometry() const
Returns true if sink is likely to include geometries.
QgsProcessingParameterAuthConfig(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAuthConfig.
Interface for master layout type objects, such as print layouts and reports.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterExtent(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterExtent.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterCoordinateOperation * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
static QgsProcessingParameterFeatureSource * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Represents a vector layer which manages a vector based data sets.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
Static property (QgsStaticProperty)
Contains information about the context in which a processing algorithm is executed.
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsProcessingParameterLayout * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString sourceTypeToString(SourceType type)
Converts a source type to a string representation.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the created vector layer.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A string parameter for processing algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString description() const
Returns the description for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
static QgsProcessingParameterMapTheme * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterVectorLayer(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterVectorLayer.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the sinks associated with the parameter.
Any vector layer with geometry.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
QgsProcessingParameterMatrix(const QString &name, const QString &description=QString(), int numberRows=3, bool hasFixedNumberRows=false, const QStringList &headers=QStringList(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMatrix.
QString type() const override
Unique parameter type name.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
QString authid() const
Returns the authority identifier for the CRS.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
QString generateTemporaryDestination() const override
Generates a temporary destination value for this parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsCoordinateReferenceSystem crs
void setParentLayoutParameterName(const QString &name)
Sets the name of the parent layout parameter.
QgsProcessingParameterRasterLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRasterLayer.
QgsProcessingParameterFileDestination(const QString &name, const QString &description=QString(), const QString &fileFilter=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFileDestination.
double maximum() const
Returns the maximum value acceptable by the parameter.
QVariantMap createOptions
Map of optional sink/layer creation options, which are passed to the underlying provider when creatin...
Individual print layout (QgsPrintLayout)
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
static QgsProcessingParameterFileDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterRasterDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterRasterDestination.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString typeName()
Returns the type name for the parameter class.
A raster layer output for processing algorithms.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers, algorithms, and various parameters and outputs.
static QString parameterAsFileOutput(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file based output destination.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
static QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
void setHeaders(const QStringList &headers)
Sets the list of column headers.