64 Commits

Author SHA1 Message Date
Denis Rouzaud
631c7016db
scope enum for QgsProcessing::LayerHint (#9639) 2019-03-27 17:23:36 -05:00
Nyall Dawson
32fbf0a92b [processing][FEATURE] New parameter type for map scales
This adds a new parameter type specifically for map scales,
QgsProcessingParameterScale. The values are evaluated using
self.parameterAsDouble, which returns the map scale
denominator (matching the standard in other parts of the
QGIS API).

Scale parameters are displayed to users using the standard
QgsScaleWidget, which includes the combo box of predefined
scales and a shortcut button to match the current map scale.
2019-03-13 16:52:29 +10:00
Nyall Dawson
e31fb920e7 [processing] Add API to allow custom expression variables to be set
for a model
2019-02-23 05:23:23 +10:00
Nyall Dawson
7418c189d0 [processing] Also generate friendly names for outputs when converting models to scripts 2019-02-14 15:36:55 +10:00
Nyall Dawson
d342ce939b [processing] When converting models to Python, use friendlier (more
descriptive) names when storing child algorithm results

Makes for much easier to understand scripts
2019-02-14 15:36:55 +10:00
Nyall Dawson
fc8fd1e26b [processing] When converting models to python, correctly use a
multi-step feedback object to give scripts accurate progress reports

And also add in checks for cancelation between child algorithm
execution to allow generated scripts to early exit
2019-02-13 19:17:30 +10:00
Nyall Dawson
69f45e389c Refactor QgsExpressionContext and move QgsExpressionContextUtils
out to its own header

Avoids slow recompilation caused by changes to the frequently
modified QgsExpressionContextUtils class
2019-02-13 07:59:30 +10:00
Nyall Dawson
e533a4078c [processing] Expose some model related variables to expressions
run inside models

Allows expressions to access important variables like the current
model path
2019-02-13 07:59:30 +10:00
Nyall Dawson
7e106ef4b7 [processing] Ensure that distance inputs become expression variables for model child algorithms 2019-02-08 19:00:39 +10:00
Nyall Dawson
62e09d9467 [processing] If model name starts with a digit, we need to remove that when generating a class name 2019-02-05 22:45:43 +11:00
Nyall Dawson
0250cab307 [processing] Reorganise python script generated from model, to
move "guts" of script to top (initAlgorithm/processAlgorithm)
and boilerplate methods (createInstance, etc) to end
2019-02-04 11:58:55 +11:00
Etienne Trimaille
57695bd036 use upper camel case for the class name 2019-02-03 07:18:34 +11:00
Etienne Trimaille
122d5c3efd fix some PEP8 in Processing Model as python code 2019-02-02 09:29:58 +11:00
Nyall Dawson
bc76678e74 Fix multiline description strings 2019-02-01 17:54:28 +11:00
Nyall Dawson
9b2e60130f [processing] Update QgsProcessingModelAlgorithm::asPythonCode for 3.x API 2019-02-01 17:54:28 +11:00
Nyall Dawson
63b6a77702 [processing] Add API to convert a parameter definition to an equivalent
Python constructor string
2019-01-29 18:15:40 +11:00
Pierre-Eric Pelloux-Prayer
f1760ee56b Remove include "qgsapplication.h" from qgswkbptr.h
qgswkbptr.h is included indirectly by a large number of source files.
So this commit does the following:
  - remove #include "qgsapplication.h" from qgswkbptr.h, and copy-paste the swap_endian
    function where it's used.
  - add the missing #include "qgsapplication.h" in other files

The rationale for this change is:
  - qgswkbptr.h doesn't really needs QgsApplication, since it only used swap_endian.
    We don't need to add a fake dependency on QgsApplication on every (indirect) "includers"
    of qgswkbptr.h
 - qgsapplication.h depends on qgsconfig.h which itself changes quite often (on every git op
   at least). Before this change, a 'git commit' would trigger a rebuild of about 3500 files.
   With this change we're down to ~700.
2019-01-22 21:45:38 +01:00
Nyall Dawson
11ea28a5b3 [FEATURE][processing] Add a new parameter type for authentication config
This adds a new available parameter type for processing algorithms,
QgsProcessingParameterAuthConfig, allowing selection from available
authentication configurations (and creation of new ones).

It allows creation of processing algorithm which can fully take
advantage of QGIS' mature authentication handling, avoiding the
need to use insecure string parameters for users to input
sensitive logon credentials.

QgsProcessingParameterAuthConfig parameters are evaluated using
QgsProcessingAlgorithm.parameterAsString(), which returns the
selected authentication configuration ID.
2018-12-15 08:23:10 +10:00
Nyall Dawson
844a3fb1b1 [processing] Allow help url to be set for models within help edit dialog
Refs #18767
2018-09-26 04:26:49 +10:00
Nyall Dawson
95d68e9172 [processing] Default to hiding help button for algorithms
And require that showing help is opt-in. Apart from a handful
of built-in providers, most providers will not have help pages
available within the QGIS documentation (including model and
script algorithms). Accordingly, we should hide the help button
by default and only show it for these selected providers.

Note that 3rd party algorithms can still specify custom helpUrl
urls, in which case the button WILL be shown.
2018-09-26 04:26:49 +10:00
Nyall Dawson
e2082a0935 [processing] Fix modeler help/description generation, allow setting
of model short description text

Fixes #18767
2018-09-26 04:26:49 +10:00
Luigi Pirelli
d641b306d3 fix lack of management of input as QgsProcessingOutputLayerDefinition 2018-09-21 09:00:56 +10:00
Nyall Dawson
cdd72e51e5 [processing] Fix use of models as child algorithms in other models
Fixes #19857
2018-09-19 05:04:09 +10:00
luz.paz
0908daaa0e Misc. typos
Found via `codespell -q 3 -I ../qgis-word-whitelist.txt --skip="*.ts,*.po,./scripts/spell_check"`
2018-09-07 00:30:54 +02:00
Matthias Kuhn
17279a42e2 Only include qgsvectorlayer.h where required 2018-09-05 08:54:11 +02:00
Luigi Pirelli
30eddf5a20 remove unuseful %s 2018-09-04 15:47:08 +02:00
Luigi Pirelli
365e952cd9 removed comment 2018-09-03 13:59:30 +02:00
Luigi Pirelli
3a67c5d287 use QVariant::fromValue as suggested in review 2018-08-28 17:06:09 +02:00
Luigi Pirelli
0acb766412 add model variables in expressionContext scope to be mapped in case used in symbolic formulas 2018-08-28 17:06:08 +02:00
Nyall Dawson
4930061b21 [processing] Fix incorrect OGR warnings when loading raster layer results
Fixes #19597
2018-08-16 06:37:18 +10:00
Nyall Dawson
dab3f5137f Hide inactive providers from model 2018-07-16 11:38:13 +10:00
Nyall Dawson
41825cab1b [processing] Also accept QgsProcessingOutputLayerDefinition for
layer input values

Since these may result from the output of an earlier child algorithm running
in a processing model.

Fixes #19372
2018-07-12 10:14:03 +10:00
Nyall Dawson
e91aed6617 [processing] Force model outputs to respect constraints set by
their underlying algorithm's provider

E.g. for model outputs generated by a saga algorithm, only
sdat and shp files are valid outputs. So only give users choices
of these instead of all formats.

Also fixes temporary file names generated as part of model
execution may use formats which are not compatible with the
algorithm's provider.

Fixes #18908
2018-06-05 10:05:32 +10:00
Nyall Dawson
1a45a79719 [processing][model] Fix handling of mandatory checkbox in output definitions 2018-05-14 22:12:32 +10:00
arnaud.morvan@camptocamp.com
4ccd4446fe [processing] Add default values in model for destination parameters 2018-05-14 22:12:32 +10:00
Nyall Dawson
3791bac432 [processing][modeler] Fix some child algorithm vector results
are not shown as input choices for other child algorithms
2018-05-07 18:50:19 +10:00
Blottiere Paul
4f4844fa8a Add a new source type for parameters 2018-04-26 09:47:40 +01:00
Matthias Kuhn
0b149f5282 [processing] Show model outputs even if they are hidden in the child 2018-04-09 13:10:47 +02:00
Matthias Kuhn
31d7e4b6a0 Do not crash when using a parameter with FlagHidden 2018-04-09 13:10:47 +02:00
Matthias Kuhn
9e8c995ac8 [processing] Pass algorithm configuration on run
Because if it's not passed here, it's basically like writing it to /dev/null right from the beginning.
2018-04-09 12:34:35 +02:00
Nyall Dawson
eb39579837 Fix some Coverity use-after-free warnings 2018-04-03 16:35:32 +10:00
Matthias Kuhn
cb84b832f9 Add log output in case of loading models with missing parameters 2018-03-07 09:00:33 +11:00
Nyall Dawson
f8c3f39670 [processing] Fix dependency calculation for model child algs 2018-02-21 20:34:40 +11:00
Nyall Dawson
5e0745140f Fix double registration of model outputs 2018-02-01 13:02:59 +11:00
Nyall Dawson
a05d941e4e [processing] Default to allowing background execution of algorithms
Since the underlying issues with the Python bindings are now fixed,
in most cases we can safely default to allowing an algorithm to
run in a background thread!!

So now we make this the default, and require individual algorithms
which are NOT thread safe to declare this. This includes algorithms
which directly manipulate the current project or layers (such as
setting layer styles), alter the selections in layers, or which
rely on 3rd party libraries (for now, SAGA and GRASS algorithms
are marked as not thread safe... TODO - someone more familiar with
these libraries can investigate and remove the flag if appropriate).

Also models are marked as non-thread safe. TODO: only flag an
individual model as thread-unsafe if any of its child algorithms
report this flag.
2018-01-29 17:37:05 +11:00
Alexander Bruy
1d482cf953 [processing] add groupId() method to algorithms to get unique ID of the
algorithm group.

Adapt native algorithms
2017-12-14 14:12:00 +02:00
Nyall Dawson
4b9986eb8c [processing] Add a generic map layer output type
For occasions when an algorithm creates a map layer, but the type
is not known in advance (i.e. could be raster OR vector)
2017-11-27 06:38:21 +11:00
Nyall Dawson
e6d86bba53 [processing] Generalise modeler multi-step feedback proxy for use
outside of modeler

This can be useful too for individual algorithms
2017-11-23 10:01:13 +10:00
Nyall Dawson
92af1dacaf Replace default constructors/destructors with = default 2017-10-01 06:52:14 +10:00
Nyall Dawson
31c1ae1c6a Add missing QStringLiterals 2017-09-25 17:12:03 +10:00