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() )
438 dest = val.toString();
443 dest = destParam->generateTemporaryDestination();
446 if ( dest.isEmpty() )
450 destinationIdentifier = dest;
452 if ( destinationProject )
454 if ( destName.isEmpty() && definition )
460 outputName = definition->
name();
464 return sink.release();
472 return parameterAsSource( definition, parameters.value( definition->
name() ), context );
488 QVariant val = parameters.value( definition->
name() );
490 bool selectedFeaturesOnly =
false;
511 vl = qobject_cast<
QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
520 else if ( !val.isValid() || val.toString().isEmpty() )
526 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
532 layerRef = val.toString();
537 if ( layerRef.isEmpty() )
549 compatibleFormats, preferredFormat, context, feedback, *layerName );
552 compatibleFormats, preferredFormat, context, feedback );
562 QString *destLayer = layerName;
578 return parameterAsLayer( definition, parameters.value( definition->
name() ), context );
586 QVariant val = value;
592 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
609 if ( !val.isValid() || val.toString().isEmpty() )
615 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
620 QString layerRef = val.toString();
621 if ( layerRef.isEmpty() )
624 if ( layerRef.isEmpty() )
632 return qobject_cast<
QgsRasterLayer *>( parameterAsLayer( definition, parameters, context ) );
637 return qobject_cast<
QgsRasterLayer *>( parameterAsLayer( definition, value, context ) );
642 return qobject_cast<
QgsMeshLayer *>( parameterAsLayer( definition, parameters, context ) );
647 return qobject_cast<
QgsMeshLayer *>( parameterAsLayer( definition, value, context ) );
655 val = parameters.value( definition->
name() );
657 return parameterAsOutputLayer( definition, val, context );
662 QVariant val = value;
682 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
689 dest = val.toString();
694 dest = destParam->generateTemporaryDestination();
697 if ( destinationProject )
700 if ( destName.isEmpty() && definition )
705 outputName = definition->
name();
724 val = parameters.value( definition->
name() );
726 return parameterAsFileOutput( definition, val, context );
731 QVariant val = value;
745 else if ( !val.isValid() || val.toString().isEmpty() )
752 dest = val.toString();
757 dest = destParam->generateTemporaryDestination();
764 return qobject_cast<
QgsVectorLayer *>( parameterAsLayer( definition, parameters, context ) );
769 return qobject_cast<
QgsVectorLayer *>( parameterAsLayer( definition, value, context ) );
777 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
785 QVariant val = value;
811 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
817 if ( !val.isValid() )
823 QString crsText = val.toString();
824 if ( crsText.isEmpty() )
827 if ( crsText.isEmpty() )
831 if ( context.
project() && crsText.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
850 return parameterAsExtent( definition, parameters.value( definition->
name() ), context, crs );
858 QVariant val = value;
907 rectText = val.toString();
909 if ( rectText.isEmpty() && !layer )
912 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
913 QRegularExpressionMatch match = rx.match( rectText );
914 if ( match.hasMatch() )
917 double xMin = match.captured( 1 ).toDouble( &xMinOk );
919 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
921 double yMin = match.captured( 3 ).toDouble( &yMinOk );
923 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
924 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
928 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
973 QVariant val = parameters.value( definition->
name() );
981 g = g.densifyByCount( 20 );
1017 rectText = val.toString();
1019 if ( !rectText.isEmpty() )
1021 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1022 QRegularExpressionMatch match = rx.match( rectText );
1023 if ( match.hasMatch() )
1025 bool xMinOk =
false;
1026 double xMin = match.captured( 1 ).toDouble( &xMinOk );
1027 bool xMaxOk =
false;
1028 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1029 bool yMinOk =
false;
1030 double yMin = match.captured( 3 ).toDouble( &yMinOk );
1031 bool yMaxOk =
false;
1032 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1033 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1038 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
1040 g = g.densifyByCount( 20 );
1088 QVariant val = parameters.value( definition->
name() );
1117 QString valueAsString;
1121 valueAsString = val.toString();
1123 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1125 QRegularExpressionMatch match = rx.match( valueAsString );
1126 if ( match.hasMatch() )
1152 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1153 return layer->crs();
1155 return layer->crs();
1168 return parameterAsPoint( definition, parameters.value( definition->
name() ), context, crs );
1176 QVariant val = value;
1205 QString pointText = parameterAsString( definition, value, context );
1206 if ( pointText.isEmpty() )
1209 if ( pointText.isEmpty() )
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() )
1219 double x = match.captured( 1 ).toDouble( &xOk );
1221 double y = match.captured( 2 ).toDouble( &yOk );
1228 if ( crs.
isValid() && pointCrs.isValid() && crs != pointCrs )
1249 QVariant val = parameters.value( definition->
name() );
1250 return parameterAsPointCrs( definition, val, context );
1264 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1266 QString valueAsString = parameterAsString( definition, value, context );
1267 QRegularExpressionMatch match = rx.match( valueAsString );
1268 if ( match.hasMatch() )
1286 QString fileText = parameterAsString( definition, parameters, context );
1287 if ( fileText.isEmpty() )
1297 QString fileText = parameterAsString( definition, value, context );
1298 if ( fileText.isEmpty() )
1306 return QVariantList();
1308 return parameterAsMatrix( definition, parameters.value( definition->
name() ), context );
1314 return QVariantList();
1316 QString resultString;
1317 QVariant val = value;
1320 else if ( val.type() == QVariant::List )
1321 return val.toList();
1323 resultString = val.toString();
1325 if ( resultString.isEmpty() )
1328 if ( definition->
defaultValue().type() == QVariant::List )
1334 QVariantList result;
1335 const auto constSplit = resultString.split(
',' );
1336 for (
const QString &s : constSplit )
1345 return QList<QgsMapLayer *>();
1347 return parameterAsLayerList( definition, parameters.value( definition->
name() ), context );
1353 return QList<QgsMapLayer *>();
1355 QVariant val = value;
1356 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1358 return QList<QgsMapLayer *>() << layer;
1361 QList<QgsMapLayer *> layers;
1363 std::function< void( const QVariant &var ) > processVariant;
1364 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1366 if ( var.type() == QVariant::List )
1368 const auto constToList = var.toList();
1369 for (
const QVariant &listVar : constToList )
1371 processVariant( listVar );
1374 else if ( var.type() == QVariant::StringList )
1376 const auto constToStringList = var.toStringList();
1377 for (
const QString &s : constToStringList )
1379 processVariant( s );
1383 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1391 processVariant( sink.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1394 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1406 processVariant( val );
1408 if ( layers.isEmpty() )
1411 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->defaultValue() ) ) )
1415 else if ( definition->defaultValue().type() == QVariant::List )
1417 const auto constToList = definition->defaultValue().toList();
1418 for (
const QVariant &var : constToList )
1420 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1426 processVariant( var );
1431 processVariant( definition->defaultValue() );
1440 return QStringList();
1442 QVariant val = value;
1446 std::function< void( const QVariant &var ) > processVariant;
1447 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1449 if ( var.type() == QVariant::List )
1451 const auto constToList = var.toList();
1452 for (
const QVariant &listVar : constToList )
1454 processVariant( listVar );
1457 else if ( var.type() == QVariant::StringList )
1459 const auto constToStringList = var.toStringList();
1460 for (
const QString &s : constToStringList )
1462 processVariant( s );
1466 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1469 files << var.toString();
1473 processVariant( val );
1475 if ( files.isEmpty() )
1477 processVariant( definition->defaultValue() );
1486 return QStringList();
1488 return parameterAsFileList( definition, parameters.value( definition->
name() ), context );
1494 return QList<double>();
1496 return parameterAsRange( definition, parameters.value( definition->
name() ), context );
1502 return QList<double>();
1504 QStringList resultStringList;
1505 QVariant val = value;
1508 else if ( val.type() == QVariant::List )
1510 const auto constToList = val.toList();
1511 for (
const QVariant &var : constToList )
1512 resultStringList << var.toString();
1515 resultStringList << val.toString();
1517 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1519 resultStringList.clear();
1521 if ( definition->
defaultValue().type() == QVariant::List )
1523 const auto constToList = definition->
defaultValue().toList();
1524 for (
const QVariant &var : constToList )
1525 resultStringList << var.toString();
1528 resultStringList << definition->
defaultValue().toString();
1531 if ( resultStringList.size() == 1 )
1533 resultStringList = resultStringList.at( 0 ).split(
',' );
1536 if ( resultStringList.size() < 2 )
1537 return QList< double >() << 0.0 << 0.0;
1539 return QList< double >() << resultStringList.at( 0 ).toDouble() << resultStringList.at( 1 ).toDouble();
1545 return QStringList();
1547 QStringList resultStringList;
1548 return parameterAsFields( definition, parameters.value( definition->
name() ), context );
1554 return QStringList();
1556 QStringList resultStringList;
1557 QVariant val = value;
1558 if ( val.isValid() )
1562 else if ( val.type() == QVariant::List )
1564 const auto constToList = val.toList();
1565 for (
const QVariant &var : constToList )
1566 resultStringList << var.toString();
1569 resultStringList.append( val.toString().split(
';' ) );
1572 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1574 resultStringList.clear();
1578 if ( definition->
defaultValue().type() == QVariant::List )
1580 const auto constToList = definition->
defaultValue().toList();
1581 for (
const QVariant &var : constToList )
1582 resultStringList << var.toString();
1585 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
1589 return resultStringList;
1597 return parameterAsLayout( definition, parameters.value( definition->
name() ), context );
1602 const QString layoutName = parameterAsString( definition, value, context );
1603 if ( layoutName.isEmpty() )
1611 return static_cast< QgsPrintLayout * >( l );
1621 return parameterAsLayoutItem( definition, parameters.value( definition->
name() ), context, layout );
1629 const QString
id = parameterAsString( definition, value, context );
1647 return parameterAsColor( definition, parameters.value( definition->
name() ), context );
1655 QVariant val = value;
1660 if ( val.type() == QVariant::Color )
1662 QColor
c = val.value< QColor >();
1664 if ( !colorParam->opacityEnabled() )
1669 QString colorText = parameterAsString( definition, value, context );
1672 if ( definition->
defaultValue().type() == QVariant::Color )
1678 if ( colorText.isEmpty() )
1681 bool containsAlpha =
false;
1684 if ( c.isValid() && !colorParam->opacityEnabled() )
1691 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
1692 QString name = map.value( QStringLiteral(
"name" ) ).toString();
1693 std::unique_ptr< QgsProcessingParameterDefinition > def;
1754 def.reset( paramType->
create( name ) );
1760 def->fromVariantMap( map );
1761 return def.release();
1766 QString desc = name;
1767 desc.replace(
'_',
' ' );
1773 bool isOptional =
false;
1777 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
1780 QString description = descriptionFromName( name );
1782 if ( type == QStringLiteral(
"boolean" ) )
1784 else if ( type == QStringLiteral(
"crs" ) )
1786 else if ( type == QStringLiteral(
"layer" ) )
1788 else if ( type == QStringLiteral(
"extent" ) )
1790 else if ( type == QStringLiteral(
"point" ) )
1792 else if ( type == QStringLiteral(
"file" ) )
1794 else if ( type == QStringLiteral(
"folder" ) )
1796 else if ( type == QStringLiteral(
"matrix" ) )
1798 else if ( type == QStringLiteral(
"multiple" ) )
1800 else if ( type == QStringLiteral(
"number" ) )
1802 else if ( type == QStringLiteral(
"distance" ) )
1804 else if ( type == QStringLiteral(
"scale" ) )
1806 else if ( type == QStringLiteral(
"range" ) )
1808 else if ( type == QStringLiteral(
"raster" ) )
1810 else if ( type == QStringLiteral(
"enum" ) )
1812 else if ( type == QStringLiteral(
"string" ) )
1814 else if ( type == QStringLiteral(
"authcfg" ) )
1816 else if ( type == QStringLiteral(
"expression" ) )
1818 else if ( type == QStringLiteral(
"field" ) )
1820 else if ( type == QStringLiteral(
"vector" ) )
1822 else if ( type == QStringLiteral(
"source" ) )
1824 else if ( type == QStringLiteral(
"sink" ) )
1826 else if ( type == QStringLiteral(
"vectordestination" ) )
1828 else if ( type == QStringLiteral(
"rasterdestination" ) )
1830 else if ( type == QStringLiteral(
"filedestination" ) )
1832 else if ( type == QStringLiteral(
"folderdestination" ) )
1834 else if ( type == QStringLiteral(
"band" ) )
1836 else if ( type == QStringLiteral(
"mesh" ) )
1838 else if ( type == QStringLiteral(
"layout" ) )
1840 else if ( type == QStringLiteral(
"layoutitem" ) )
1842 else if ( type == QStringLiteral(
"color" ) )
1848 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
1850 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
1851 QRegularExpressionMatch m = re.match( code );
1852 if ( !m.hasMatch() )
1855 name = m.captured( 1 );
1856 QString tokens = m.captured( 2 );
1857 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
1860 tokens.remove( 0, 8 );
1867 tokens = tokens.trimmed();
1869 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
1870 m = re2.match( tokens );
1871 if ( !m.hasMatch() )
1873 type = tokens.toLower().trimmed();
1878 type = m.captured( 1 ).toLower().trimmed();
1879 definition = m.captured( 2 );
1890 , mDescription( description )
1891 , mDefault( defaultValue )
1892 , mFlags( optional ? FlagOptional : 0 )
1897 if ( !input.isValid() && !
mDefault.isValid() )
1900 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
1901 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
1909 if ( !value.isValid() )
1910 return QStringLiteral(
"None" );
1913 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1920 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1922 code += QStringLiteral(
"optional " );
1923 code +=
type() +
' ';
1925 return code.trimmed();
1933 switch ( outputType )
1937 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
1939 code += QStringLiteral(
", optional=True" );
1955 map.insert( QStringLiteral(
"parameter_type" ),
type() );
1956 map.insert( QStringLiteral(
"name" ),
mName );
1957 map.insert( QStringLiteral(
"description" ),
mDescription );
1958 map.insert( QStringLiteral(
"default" ),
mDefault );
1959 map.insert( QStringLiteral(
"flags" ), static_cast< int >(
mFlags ) );
1960 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
1966 mName = map.value( QStringLiteral(
"name" ) ).toString();
1967 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
1968 mDefault = map.value( QStringLiteral(
"default" ) );
1969 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
1970 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
1986 return QStringLiteral(
"<p><b>%1</b></p><p>%2</p>" ).arg(
1988 QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
2002 if ( !val.isValid() )
2003 return QStringLiteral(
"None" );
2007 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
2012 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2014 code += QStringLiteral(
"optional " );
2015 code +=
type() +
' ';
2016 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
2017 return code.trimmed();
2038 if ( !input.isValid() )
2060 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2063 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2071 if ( !value.isValid() )
2072 return QStringLiteral(
"None" );
2077 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
2083 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2086 p.insert(
name(), value );
2096 return new QgsProcessingParameterCrs( name, description, definition.compare( QLatin1String(
"none" ), Qt::CaseInsensitive ) == 0 ? QVariant() : definition, isOptional );
2112 if ( !input.isValid() )
2120 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2125 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2143 if ( !val.isValid() )
2144 return QStringLiteral(
"None" );
2150 p.insert(
name(), val );
2174 if ( !input.isValid() )
2203 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2206 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2215 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
2216 QRegularExpressionMatch match = rx.match( input.toString() );
2217 if ( match.hasMatch() )
2219 bool xMinOk =
false;
2220 ( void )match.captured( 1 ).toDouble( &xMinOk );
2221 bool xMaxOk =
false;
2222 ( void )match.captured( 2 ).toDouble( &xMaxOk );
2223 bool yMinOk =
false;
2224 ( void )match.captured( 3 ).toDouble( &yMinOk );
2225 bool yMaxOk =
false;
2226 ( void )match.captured( 4 ).toDouble( &yMaxOk );
2227 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
2237 if ( !value.isValid() )
2238 return QStringLiteral(
"None" );
2241 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2261 p.insert(
name(), value );
2287 if ( !input.isValid() )
2308 if ( input.type() == QVariant::String )
2310 if ( input.toString().isEmpty() )
2314 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
2316 QRegularExpressionMatch match = rx.match( input.toString() );
2317 if ( match.hasMatch() )
2320 ( void )match.captured( 1 ).toDouble( &xOk );
2322 ( void )match.captured( 2 ).toDouble( &yOk );
2331 if ( !value.isValid() )
2332 return QStringLiteral(
"None" );
2335 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2355 const QString wkt = g.
asWkt();
2356 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
2370 , mBehavior( behavior )
2371 , mExtension( fileFilter.isEmpty() ? extension : QString() )
2372 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
2384 if ( !input.isValid() )
2392 QString
string = input.toString().trimmed();
2394 if ( input.type() != QVariant::String ||
string.isEmpty() )
2397 switch ( mBehavior )
2401 if ( !mExtension.isEmpty() )
2403 return string.endsWith( mExtension, Qt::CaseInsensitive );
2405 else if ( !mFileFilter.isEmpty() )
2408 return test == string;
2424 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2426 code += QStringLiteral(
"optional " );
2427 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
2429 return code.trimmed();
2434 switch ( outputType )
2439 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', '%2'" ).arg(
name(),
description() );
2441 code += QStringLiteral(
", optional=True" );
2442 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
2443 if ( !mExtension.isEmpty() )
2444 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
2445 if ( !mFileFilter.isEmpty() )
2446 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
2458 mFileFilter.clear();
2468 mFileFilter = filter;
2475 map.insert( QStringLiteral(
"behavior" ), mBehavior );
2476 map.insert( QStringLiteral(
"extension" ), mExtension );
2477 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
2484 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
2485 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
2486 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
2497 , mHeaders( headers )
2498 , mNumberRows( numberRows )
2499 , mFixedNumberRows( fixedNumberRows )
2511 if ( !input.isValid() )
2514 if ( input.type() == QVariant::String )
2516 if ( input.toString().isEmpty() )
2520 else if ( input.type() == QVariant::List )
2522 if ( input.toList().isEmpty() )
2526 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
2536 if ( !value.isValid() )
2537 return QStringLiteral(
"None" );
2540 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2543 p.insert(
name(), value );
2547 const auto constList = list;
2548 for (
const QVariant &v : constList )
2550 if ( v.type() == QVariant::List )
2553 const auto constToList = v.toList();
2554 for (
const QVariant &v2 : constToList )
2556 if ( v2.isNull() || !v2.isValid() )
2557 parts2 << QStringLiteral(
"None" );
2558 else if ( v2.toString().isEmpty() )
2559 parts2 << QStringLiteral(
"''" );
2561 parts2 << v2.toString();
2563 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
2567 if ( v.isNull() || !v.isValid() )
2568 parts << QStringLiteral(
"None" );
2569 else if ( v.toString().isEmpty() )
2570 parts << QStringLiteral(
"''" );
2572 parts << v.toString();
2576 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2581 switch ( outputType )
2585 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', '%2'" ).arg(
name(),
description() );
2587 code += QStringLiteral(
", optional=True" );
2588 code += QStringLiteral(
", numberRows=" ).arg( mNumberRows );
2589 code += QStringLiteral(
", hasFixedNumberRows=" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
2592 headers.reserve( mHeaders.size() );
2593 for (
const QString &h : mHeaders )
2595 code += QStringLiteral(
", headers=[%1]" ).arg( headers.join(
',' ) );
2627 return mFixedNumberRows;
2632 mFixedNumberRows = fixedNumberRows;
2638 map.insert( QStringLiteral(
"headers" ), mHeaders );
2639 map.insert( QStringLiteral(
"rows" ), mNumberRows );
2640 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
2647 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
2648 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
2649 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
2655 return new QgsProcessingParameterMatrix( name, description, 0,
false, QStringList(), definition.isEmpty() ? QVariant() : definition, isOptional );
2660 , mLayerType( layerType )
2672 if ( !input.isValid() )
2677 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2683 if ( input.type() == QVariant::String )
2685 if ( input.toString().isEmpty() )
2688 if ( mMinimumNumberInputs > 1 )
2699 else if ( input.type() == QVariant::List )
2701 if ( input.toList().count() < mMinimumNumberInputs )
2704 if ( mMinimumNumberInputs > input.toList().count() )
2712 const auto constToList = input.toList();
2713 for (
const QVariant &v : constToList )
2715 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
2724 else if ( input.type() == QVariant::StringList )
2726 if ( input.toStringList().count() < mMinimumNumberInputs )
2729 if ( mMinimumNumberInputs > input.toStringList().count() )
2737 const auto constToStringList = input.toStringList();
2738 for (
const QString &v : constToStringList )
2751 if ( !value.isValid() )
2752 return QStringLiteral(
"None" );
2755 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2760 if ( value.type() == QVariant::StringList )
2762 const QStringList list = value.toStringList();
2763 parts.reserve( list.count() );
2764 for (
const QString &v : list )
2767 else if ( value.type() == QVariant::List )
2769 const QVariantList list = value.toList();
2770 parts.reserve( list.count() );
2771 for (
const QVariant &v : list )
2774 if ( !parts.isEmpty() )
2775 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2780 p.insert(
name(), value );
2782 if ( !list.isEmpty() )
2785 parts.reserve( list.count() );
2790 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2799 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2801 code += QStringLiteral(
"optional " );
2802 switch ( mLayerType )
2805 code += QStringLiteral(
"multiple raster" );
2809 code += QStringLiteral(
"multiple file" );
2813 code += QStringLiteral(
"multiple vector" );
2817 if (
mDefault.type() == QVariant::List )
2820 const auto constToList =
mDefault.toList();
2821 for (
const QVariant &var : constToList )
2823 parts << var.toString();
2825 code += parts.join(
',' );
2827 else if (
mDefault.type() == QVariant::StringList )
2829 code +=
mDefault.toStringList().join(
',' );
2835 return code.trimmed();
2840 switch ( outputType )
2844 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', '%2'" ).arg(
name(),
description() );
2846 code += QStringLiteral(
", optional=True" );
2850 code += QStringLiteral(
", layerType=%1" ).arg( layerType );
2871 return mMinimumNumberInputs;
2883 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
2884 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
2892 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
2898 QString
type = definition;
2900 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2901 QRegularExpressionMatch m = re.match( definition );
2904 type = m.captured( 1 ).toLower().trimmed();
2905 defaultVal = m.captured( 2 );
2908 if ( type == QStringLiteral(
"vector" ) )
2910 else if ( type == QStringLiteral(
"raster" ) )
2912 else if ( type == QStringLiteral(
"file" ) )
2925 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg( name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
2936 QVariant input = value;
2937 if ( !input.isValid() )
2951 double res = input.toDouble( &ok );
2955 return !( res < mMin || res > mMax );
2960 if ( !value.isValid() )
2961 return QStringLiteral(
"None" );
2964 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2966 return value.toString();
2973 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
2974 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
2975 if ( mMax < std::numeric_limits<double>::max() )
2976 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
2978 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
2979 QString extra = parts.join( QStringLiteral(
"<br />" ) );
2980 if ( !extra.isEmpty() )
2981 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
2987 switch ( outputType )
2991 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', '%2'" ).arg(
name(),
description() );
2993 code += QStringLiteral(
", optional=True" );
2995 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
2997 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
2998 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
2999 if ( mMax != std::numeric_limits<double>::max() )
3000 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
3042 map.insert( QStringLiteral(
"min" ), mMin );
3043 map.insert( QStringLiteral(
"max" ), mMax );
3044 map.insert( QStringLiteral(
"data_type" ), mDataType );
3051 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
3052 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
3053 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
3060 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
3077 if ( !input.isValid() )
3085 if ( input.type() == QVariant::String )
3087 QStringList list = input.toString().split(
',' );
3088 if ( list.count() != 2 )
3091 list.at( 0 ).toDouble( &ok );
3093 list.at( 1 ).toDouble( &ok2 );
3098 else if ( input.type() == QVariant::List )
3100 if ( input.toList().count() != 2 )
3104 input.toList().at( 0 ).toDouble( &ok );
3106 input.toList().at( 1 ).toDouble( &ok2 );
3117 if ( !value.isValid() )
3118 return QStringLiteral(
"None" );
3121 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3124 p.insert(
name(), value );
3127 QStringList stringParts;
3128 const auto constParts = parts;
3129 for (
double v : constParts )
3131 stringParts << QString::number( v );
3133 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
3138 switch ( outputType )
3142 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', '%2'" ).arg(
name(),
description() );
3144 code += QStringLiteral(
", optional=True" );
3146 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
3169 map.insert( QStringLiteral(
"data_type" ), mDataType );
3198 if ( !input.isValid() )
3206 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
3209 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3227 if ( !val.isValid() )
3228 return QStringLiteral(
"None" );
3234 p.insert(
name(), val );
3247 , mOptions( options )
3248 , mAllowMultiple( allowMultiple )
3260 QVariant input = value;
3261 if ( !input.isValid() )
3274 if ( input.type() == QVariant::List )
3276 if ( !mAllowMultiple )
3279 const QVariantList values = input.toList();
3283 for (
const QVariant &val : values )
3286 int res = val.toInt( &ok );
3289 else if ( res < 0 || res >= mOptions.count() )
3295 else if ( input.type() == QVariant::String )
3297 QStringList parts = input.toString().split(
',' );
3298 if ( parts.count() > 1 && !mAllowMultiple )
3301 const auto constParts = parts;
3302 for (
const QString &part : constParts )
3305 int res = part.toInt( &ok );
3308 else if ( res < 0 || res >= mOptions.count() )
3313 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
3316 int res = input.toInt( &ok );
3319 else if ( res >= 0 && res < mOptions.count() )
3327 if ( !value.isValid() )
3328 return QStringLiteral(
"None" );
3331 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3333 if ( value.type() == QVariant::List )
3336 const auto constToList = value.toList();
3337 for (
const QVariant &val : constToList )
3339 parts << QString::number( static_cast< int >( val.toDouble() ) );
3341 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3343 else if ( value.type() == QVariant::String )
3345 QStringList parts = value.toString().split(
',' );
3346 if ( parts.count() > 1 )
3348 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3352 return QString::number( static_cast< int >( value.toDouble() ) );
3357 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3359 code += QStringLiteral(
"optional " );
3360 code += QStringLiteral(
"enum " );
3362 if ( mAllowMultiple )
3363 code += QStringLiteral(
"multiple " );
3365 code += mOptions.join(
';' ) +
' ';
3368 return code.trimmed();
3373 switch ( outputType )
3377 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', '%2'" ).arg(
name(),
description() );
3379 code += QStringLiteral(
", optional=True" );
3382 options.reserve( mOptions.size() );
3383 for (
const QString &o : mOptions )
3385 code += QStringLiteral(
", options=[%1]" ).arg( options.join(
',' ) );
3387 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3409 return mAllowMultiple;
3420 map.insert( QStringLiteral(
"options" ), mOptions );
3421 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
3428 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
3429 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
3436 bool multiple =
false;
3437 QString def = definition;
3438 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
3444 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
3445 QRegularExpressionMatch m = re.match( def );
3446 QString values = def;
3449 values = m.captured( 1 ).trimmed();
3450 defaultVal = m.captured( 2 );
3453 return new QgsProcessingParameterEnum( name, description, values.split(
';' ), multiple, defaultVal.isEmpty() ? QVariant() : defaultVal, isOptional );
3458 , mMultiLine( multiLine )
3470 if ( !value.isValid() || value.isNull() )
3471 return QStringLiteral(
"None" );
3474 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3476 QString s = value.toString();
3482 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3484 code += QStringLiteral(
"optional " );
3485 code += QStringLiteral(
"string " );
3488 code += QStringLiteral(
"long " );
3491 return code.trimmed();
3496 switch ( outputType )
3500 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', '%2'" ).arg(
name(),
description() );
3502 code += QStringLiteral(
", optional=True" );
3503 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3526 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
3533 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
3539 QString def = definition;
3541 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
3547 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
3549 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
3553 if ( def == QStringLiteral(
"None" ) )
3554 defaultValue = QVariant();
3576 if ( !value.isValid() )
3577 return QStringLiteral(
"None" );
3579 QString s = value.toString();
3585 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3587 code += QStringLiteral(
"optional " );
3588 code += QStringLiteral(
"authcfg " );
3591 return code.trimmed();
3596 QString def = definition;
3598 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
3600 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
3604 if ( def == QStringLiteral(
"None" ) )
3605 defaultValue = QVariant();
3617 , mParentLayerParameterName( parentLayerParameterName )
3629 if ( !value.isValid() )
3630 return QStringLiteral(
"None" );
3633 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3635 QString s = value.toString();
3641 QStringList depends;
3642 if ( !mParentLayerParameterName.isEmpty() )
3643 depends << mParentLayerParameterName;
3649 switch ( outputType )
3653 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', '%2'" ).arg(
name(),
description() );
3655 code += QStringLiteral(
", optional=True" );
3657 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
3669 return mParentLayerParameterName;
3680 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
3687 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
3728 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
3731 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3749 if ( !val.isValid() )
3750 return QStringLiteral(
"None" );
3756 p.insert(
name(), val );
3764 switch ( outputType )
3768 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', '%2'" ).arg(
name(),
description() );
3770 code += QStringLiteral(
", optional=True" );
3774 QStringList options;
3777 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
3803 for (
int type : constMDataTypes )
3807 map.insert( QStringLiteral(
"data_types" ), types );
3815 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3816 const auto constValues = values;
3817 for (
const QVariant &val : constValues )
3863 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
3866 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3884 if ( !val.isValid() )
3885 return QStringLiteral(
"None" );
3891 p.insert(
name(), val );
3904 , mParentLayerParameterName( parentLayerParameterName )
3906 , mAllowMultiple( allowMultiple )
3919 if ( !input.isValid() )
3927 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
3929 if ( !mAllowMultiple )
3935 else if ( input.type() == QVariant::String )
3937 if ( input.toString().isEmpty() )
3940 QStringList parts = input.toString().split(
';' );
3941 if ( parts.count() > 1 && !mAllowMultiple )
3946 if ( input.toString().isEmpty() )
3954 if ( !value.isValid() )
3955 return QStringLiteral(
"None" );
3958 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3960 if ( value.type() == QVariant::List )
3963 const auto constToList = value.toList();
3964 for (
const QVariant &val : constToList )
3968 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3970 else if ( value.type() == QVariant::StringList )
3973 const auto constToStringList = value.toStringList();
3974 for ( QString s : constToStringList )
3978 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3986 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3988 code += QStringLiteral(
"optional " );
3989 code += QStringLiteral(
"field " );
3991 switch ( mDataType )
3994 code += QStringLiteral(
"numeric " );
3998 code += QStringLiteral(
"string " );
4002 code += QStringLiteral(
"datetime " );
4009 if ( mAllowMultiple )
4010 code += QStringLiteral(
"multiple " );
4012 code += mParentLayerParameterName +
' ';
4015 return code.trimmed();
4020 switch ( outputType )
4024 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', '%2'" ).arg(
name(),
description() );
4026 code += QStringLiteral(
", optional=True" );
4029 switch ( mDataType )
4032 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
4036 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
4040 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
4044 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
4047 code += QStringLiteral(
", type=%1" ).arg( dataType );
4049 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4050 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4062 QStringList depends;
4063 if ( !mParentLayerParameterName.isEmpty() )
4064 depends << mParentLayerParameterName;
4070 return mParentLayerParameterName;
4090 return mAllowMultiple;
4101 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
4102 map.insert( QStringLiteral(
"data_type" ), mDataType );
4103 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
4110 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
4111 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
4112 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
4121 QString def = definition;
4123 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
4128 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
4133 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
4139 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
4141 allowMultiple =
true;
4142 def = def.mid( 8 ).trimmed();
4145 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
4146 QRegularExpressionMatch m = re.match( def );
4149 parent = m.captured( 1 ).trimmed();
4150 def = m.captured( 2 );
4175 QVariant var = input;
4176 if ( !var.isValid() )
4203 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
4208 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4226 if ( !value.isValid() )
4227 return QStringLiteral(
"None" );
4230 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4239 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', True)" ).arg( fromVar.
source.
staticValue().toString() );
4246 layerString = layer->source();
4254 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), True)" ).arg( fromVar.
source.
asExpression() );
4258 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
4262 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
4267 QString layerString = value.toString();
4271 layerString = layer->source();
4278 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4280 code += QStringLiteral(
"optional " );
4281 code += QStringLiteral(
"source " );
4284 for (
int type : constMDataTypes )
4289 code += QStringLiteral(
"point " );
4293 code += QStringLiteral(
"line " );
4297 code += QStringLiteral(
"polygon " );
4304 return code.trimmed();
4309 switch ( outputType )
4313 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', '%2'" ).arg(
name(),
description() );
4315 code += QStringLiteral(
", optional=True" );
4319 QStringList options;
4323 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
4345 for (
int type : constMDataTypes )
4349 map.insert( QStringLiteral(
"data_types" ), types );
4357 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
4358 const auto constValues = values;
4359 for (
const QVariant &val : constValues )
4369 QString def = definition;
4372 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
4378 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
4384 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
4409 QVariant var = input;
4410 if ( !var.isValid() )
4432 if ( var.type() != QVariant::String )
4435 if ( var.toString().isEmpty() )
4443 if ( !value.isValid() )
4444 return QStringLiteral(
"None" );
4447 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4458 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4467 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4469 code += QStringLiteral(
"optional " );
4470 code += QStringLiteral(
"sink " );
4472 switch ( mDataType )
4475 code += QStringLiteral(
"point " );
4479 code += QStringLiteral(
"line " );
4483 code += QStringLiteral(
"polygon " );
4487 code += QStringLiteral(
"table " );
4495 return code.trimmed();
4511 return p->defaultVectorFileExtension(
hasGeometry() );
4521 return QStringLiteral(
"dbf" );
4528 switch ( outputType )
4532 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', '%2'" ).arg(
name(),
description() );
4534 code += QStringLiteral(
", optional=True" );
4538 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4560 return p->supportedOutputVectorLayerExtensions();
4562 return p->supportedOutputTableExtensions();
4577 switch ( mDataType )
4603 map.insert( QStringLiteral(
"data_type" ), mDataType );
4617 return QStringLiteral(
"memory:%1" ).arg(
description() );
4625 QString def = definition;
4626 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
4631 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
4636 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
4641 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
4662 QVariant var = input;
4663 if ( !var.isValid() )
4685 if ( var.type() != QVariant::String )
4688 if ( var.toString().isEmpty() )
4696 if ( !value.isValid() )
4697 return QStringLiteral(
"None" );
4700 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4711 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4731 return p->defaultRasterFileExtension();
4747 return p->supportedOutputRasterLayerExtensions();
4763 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
4775 QVariant var = input;
4776 if ( !var.isValid() )
4798 if ( var.type() != QVariant::String )
4801 if ( var.toString().isEmpty() )
4811 if ( !value.isValid() )
4812 return QStringLiteral(
"None" );
4815 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4826 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4835 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
4847 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
4848 return QStringLiteral(
"file" );
4851 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
4852 QRegularExpressionMatch match = rx.match( mFileFilter );
4853 if ( !match.hasMatch() )
4854 return QStringLiteral(
"file" );
4856 return match.captured( 1 );
4861 switch ( outputType )
4865 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', '%2'" ).arg(
name(),
description() );
4867 code += QStringLiteral(
", optional=True" );
4871 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4894 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
4901 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
4922 QVariant var = input;
4923 if ( !var.isValid() )
4939 if ( var.type() != QVariant::String )
4942 if ( var.toString().isEmpty() )
4965 , mCreateByDefault( createByDefault )
4973 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
4974 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
4981 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
4982 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
4988 switch ( outputType )
4995 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
4997 code += QStringLiteral(
", optional=True" );
4999 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5026 return mCreateByDefault;
5048 QVariant var = input;
5049 if ( !var.isValid() )
5071 if ( var.type() != QVariant::String )
5074 if ( var.toString().isEmpty() )
5082 if ( !value.isValid() )
5083 return QStringLiteral(
"None" );
5086 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5097 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5106 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5108 code += QStringLiteral(
"optional " );
5109 code += QStringLiteral(
"vectorDestination " );
5111 switch ( mDataType )
5114 code += QStringLiteral(
"point " );
5118 code += QStringLiteral(
"line " );
5122 code += QStringLiteral(
"polygon " );
5130 return code.trimmed();
5146 return p->defaultVectorFileExtension(
hasGeometry() );
5156 return QStringLiteral(
"dbf" );
5163 switch ( outputType )
5167 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', '%2'" ).arg(
name(),
description() );
5169 code += QStringLiteral(
", optional=True" );
5173 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5195 return p->supportedOutputVectorLayerExtensions();
5197 return p->supportedOutputTableExtensions();
5212 switch ( mDataType )
5238 map.insert( QStringLiteral(
"data_type" ), mDataType );
5252 QString def = definition;
5253 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5258 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5263 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5274 , mParentLayerParameterName( parentLayerParameterName )
5275 , mAllowMultiple( allowMultiple )
5287 if ( !input.isValid() )
5295 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5297 if ( !mAllowMultiple )
5306 double res = input.toInt( &ok );
5316 return mAllowMultiple;
5326 if ( !value.isValid() )
5327 return QStringLiteral(
"None" );
5330 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5332 if ( value.type() == QVariant::List )
5335 QVariantList values = value.toList();
5336 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
5338 parts << QString::number( static_cast< int >( it->toDouble() ) );
5340 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5342 else if ( value.type() == QVariant::StringList )
5345 QStringList values = value.toStringList();
5346 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
5348 parts << QString::number( static_cast< int >( it->toDouble() ) );
5350 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5353 return value.toString();
5358 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5360 code += QStringLiteral(
"optional " );
5361 code += QStringLiteral(
"band " );
5363 if ( mAllowMultiple )
5364 code += QStringLiteral(
"multiple " );
5366 code += mParentLayerParameterName +
' ';
5369 return code.trimmed();
5374 QStringList depends;
5375 if ( !mParentLayerParameterName.isEmpty() )
5376 depends << mParentLayerParameterName;
5382 switch ( outputType )
5386 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', '%2'" ).arg(
name(),
description() );
5388 code += QStringLiteral(
", optional=True" );
5390 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5391 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5403 return mParentLayerParameterName;
5414 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5415 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5422 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5423 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5430 QString def = definition;
5433 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5435 allowMultiple =
true;
5436 def = def.mid( 8 ).trimmed();
5439 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
5440 QRegularExpressionMatch m = re.match( def );
5443 parent = m.captured( 1 ).trimmed();
5444 def = m.captured( 2 );
5461 , mParentParameterName( parentParameterName )
5478 QStringList depends;
5479 if ( !mParentParameterName.isEmpty() )
5480 depends << mParentParameterName;
5486 switch ( outputType )
5490 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', '%2'" ).arg(
name(),
description() );
5492 code += QStringLiteral(
", optional=True" );
5494 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
5496 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
5497 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
5498 if (
maximum() != std::numeric_limits<double>::max() )
5499 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
5510 return mParentParameterName;
5521 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
5522 map.insert( QStringLiteral(
"default_unit" ), static_cast< int >( mDefaultUnit ) );
5529 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
5557 switch ( outputType )
5561 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', '%2'" ).arg(
name(),
description() );
5563 code += QStringLiteral(
", optional=True" );
5575 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
5594 if ( !value.isValid() || value.isNull() )
5595 return QStringLiteral(
"None" );
5598 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5600 QString s = value.toString();
5606 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5608 code += QStringLiteral(
"optional " );
5609 code += QStringLiteral(
"layout " );
5612 return code.trimmed();
5617 switch ( outputType )
5621 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', '%2'" ).arg(
name(),
description() );
5623 code += QStringLiteral(
", optional=True" );
5634 QString def = definition;
5636 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5638 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5642 if ( def == QStringLiteral(
"None" ) )
5643 defaultValue = QVariant();
5655 , mParentLayoutParameterName( parentLayoutParameterName )
5656 , mItemType( itemType )
5668 if ( !value.isValid() || value.isNull() )
5669 return QStringLiteral(
"None" );
5672 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5674 QString s = value.toString();
5680 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5682 code += QStringLiteral(
"optional " );
5683 code += QStringLiteral(
"layoutitem " );
5684 if ( mItemType >= 0 )
5685 code += QString::number( mItemType ) +
' ';
5687 code += mParentLayoutParameterName +
' ';
5690 return code.trimmed();
5695 switch ( outputType )
5699 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', '%2'" ).arg(
name(),
description() );
5701 code += QStringLiteral(
", optional=True" );
5703 if ( mItemType >= 0 )
5704 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
5706 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
5719 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
5720 map.insert( QStringLiteral(
"item_type" ), mItemType );
5727 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
5728 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
5734 QStringList depends;
5735 if ( !mParentLayoutParameterName.isEmpty() )
5736 depends << mParentLayoutParameterName;
5743 QString def = definition;
5745 QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
5746 QRegularExpressionMatch m = re.match( def );
5749 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
5750 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
5751 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
5764 return mParentLayoutParameterName;
5769 mParentLayoutParameterName =
name;
5788 , mAllowOpacity( opacityEnabled )
5800 if ( !value.isValid() || value.isNull() )
5801 return QStringLiteral(
"None" );
5804 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5806 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
5807 return QStringLiteral(
"QColor()" );
5809 if ( value.canConvert< QColor >() )
5811 QColor
c = value.value< QColor >();
5812 if ( !mAllowOpacity || c.alpha() == 255 )
5813 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg( c.red() ).arg( c.green() ).arg( c.blue() );
5815 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg( c.red() ).arg( c.green() ).arg( c.blue() ).arg( c.alpha() );
5818 QString s = value.toString();
5824 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5826 code += QStringLiteral(
"optional " );
5827 code += QStringLiteral(
"color " );
5829 if ( mAllowOpacity )
5830 code += QStringLiteral(
"withopacity " );
5833 return code.trimmed();
5838 switch ( outputType )
5842 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', '%2'" ).arg(
name(),
description() );
5844 code += QStringLiteral(
", optional=True" );
5846 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5858 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
5861 if ( !input.isValid() )
5864 if ( input.type() == QVariant::Color )
5873 if ( input.type() != QVariant::String || input.toString().isEmpty() )
5876 bool containsAlpha =
false;
5883 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
5890 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
5896 return mAllowOpacity;
5901 mAllowOpacity = enabled;
5906 QString def = definition;
5908 bool allowOpacity =
false;
5909 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
5911 allowOpacity =
true;
5912 def = def.mid( 12 );
5915 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5917 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5921 if ( def == QStringLiteral(
"None" ) )
5922 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.
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.
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.
bool createFromString(const QString &definition)
Set up this CRS from a string definition.
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.
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.
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.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
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.
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...
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...
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.
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...
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.
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.
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.
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.
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.
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.
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.
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.
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 compositions within the project.
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...
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.
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.
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...
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 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.
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)
Constructor for QgsProcessingParameterField.
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.
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...
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.
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.