39859 Commits

Author SHA1 Message Date
Nyall Dawson
d8086e549d Use c++ method for available sources 2017-07-07 11:35:31 +10:00
Nyall Dawson
17199c8ffd Reimplement getAvailableValuesOfType in QgsProcessingModelAlgorithm 2017-07-07 11:35:31 +10:00
Nyall Dawson
26cd6017b8 Use an expression context when evaluating child parameters with expression sources 2017-07-07 11:35:31 +10:00
Nyall Dawson
3243a1a34c Allow model child parameters to take values from an expression
The expression is evaluated just before the child algorithm is
executed, so can utilise results already calculated by other
children in the model through the use of expression context
functions
2017-07-07 11:34:17 +10:00
Nyall Dawson
52f4c5e975 Merge pull request #4799 from nyalldawson/m2
Run processing algorithms using task manager
2017-07-07 11:31:22 +10:00
Nyall Dawson
240dd19f97 Update tests 2017-07-07 11:15:05 +10:00
Nyall Dawson
2c91df4c12 Expand on docs 2017-07-07 10:14:51 +10:00
Nyall Dawson
da02c9a7ba Fix deadlock when running algs in task manager and python exception occurs 2017-07-07 09:28:20 +10:00
Nyall Dawson
1ab9c992b5 Fix possible error when messagebar items are popped and events are queued 2017-07-07 09:28:20 +10:00
Nyall Dawson
ac9a39f09a Fix processing.runAndLoadResults 2017-07-07 09:28:20 +10:00
Nyall Dawson
55ce31b371 When calling procesing.run(), map layer results are automatically
converted to QgsMapLayer objects with the ownership transferred
to the Python caller

This should make it super-easy for PyQGIS scripts to run processing
algorithms and immediately utilise the results, even if they
are memory layers. They call processing.run(), and get a dict of
results back which includes those layers ready for adding to the
current project or doing some other processing or operations
with, and if they don't transfer to ownership off then these
layers will be correctly garbaged collected by Python.
2017-07-07 09:28:20 +10:00
Nyall Dawson
a2af3a9345 Make concave hull alg more efficient
- remove temporary layers from context, delete them as soon as they
are finished with
- directly remove features via data provider, instead of selecting
and using edit buffer
- use native geometry methods for splitting to single features
and removing rings
2017-07-07 09:28:20 +10:00
Nyall Dawson
70cc19687d Add a method to take result layers (and ownership) from processing context 2017-07-07 09:28:20 +10:00
Nyall Dawson
db816ec3fe Port a multi-step algorithm to new API (concave hull) 2017-07-07 09:28:20 +10:00
Nyall Dawson
a15d283cd6 Port delaunay triangulation alg to new API 2017-07-07 09:28:19 +10:00
Nyall Dawson
75cd91b1a0 Port voronoi polygons algorithm to new API 2017-07-07 09:28:19 +10:00
Nyall Dawson
ebd346c407 runPrepared rethrows exceptions 2017-07-07 09:28:19 +10:00
Nyall Dawson
90f10ae853 Port snap geometries algorithm to new API 2017-07-07 09:28:19 +10:00
Nyall Dawson
05364aa5f0 When running algorithm tests, if two parameters share the same
layer source, ensure that the actual parameter values point
to the same layer
2017-07-07 09:28:19 +10:00
Nyall Dawson
d9fca48217 Add missing signal 2017-07-07 09:28:19 +10:00
Nyall Dawson
ab06973d6a Don't try to load default styles in processing test layers 2017-07-07 09:28:19 +10:00
Nyall Dawson
3cbcd75d2f Add equality operator for QgsProcessingFeatureSourceDefinition 2017-07-07 09:28:19 +10:00
Nyall Dawson
3601138d2a Use a feature source instead of vector layer for QgsGeometrySnapper 2017-07-07 09:28:19 +10:00
Nyall Dawson
8a84e134cc Algorithms don't have to be split to prepare/process/postProcess
Since it's safe to evaluate parameters in background threads
now, it's usually going to be ok to evaluate everything in
the processAlgorithm step.

This keeps the algorithm code as simple as possible, and will
make porting faster.

Note that the prepare/postProcess virtual methods still exist
and can be used when an algorithm MUST do setup/cleanup work
in the main thread.
2017-07-07 09:28:19 +10:00
Nyall Dawson
f39b7a0c4c Fix build warning 2017-07-07 09:28:19 +10:00
Nyall Dawson
3108d68f87 Indentation 2017-07-07 09:28:19 +10:00
Nyall Dawson
4fa2bc025c Keep correct order for zonal stats options, set some stats by default 2017-07-07 09:28:19 +10:00
Nyall Dawson
4eca20f28d Fix zonal stats algorithm execution 2017-07-07 09:28:19 +10:00
Nyall Dawson
274d684f64 Fix procesing test layer loading 2017-07-07 09:28:19 +10:00
Nyall Dawson
b917a82662 Better debuging from processing alg tests 2017-07-07 09:28:19 +10:00
Nyall Dawson
6654aec6a5 Fix execution of script algorithms was not releasing layers/sinks 2017-07-07 09:28:19 +10:00
Nyall Dawson
f82899540e Fix build 2017-07-07 09:28:19 +10:00
Nyall Dawson
5f02e9c89d Avoid QgsFeedback flooding progress report signals
We only emit the progress changed signal when there's been at
least a 0.1% change since the last progress report. Otherwise
it's possible that things like processing algorithms which
are reporting feedback every feature in a 500k feature dataset
cause a gazillion signals to be emitted and everything to
slow to a crawl
2017-07-07 09:28:19 +10:00
Nyall Dawson
e9e335a7bd Don't set thinking cursors when running processing algorithms
Since now they're run in a background thread, it's not appropriate
anymore
2017-07-07 09:28:19 +10:00
Nyall Dawson
e1184cd69a Make QgsProcessingAlgRunnerTask work correctly
It now safely can execute algorithms in background threads
without issues
2017-07-07 09:28:19 +10:00
Nyall Dawson
e5b156b86a Make processing algorithms safe to run in threads 2017-07-07 09:28:19 +10:00
Nyall Dawson
0231e773a1 Remove unused member 2017-07-07 09:28:19 +10:00
Nyall Dawson
5350483c90 Add method to take results from another processing context and
add to the current context

With appropriate note and tests to ensure that both the current
context and that which the results being taken from share the
same thread affinity
2017-07-07 09:28:19 +10:00
Nyall Dawson
d20c68d3f1 Add method to copy thread safe settings between processing contexts 2017-07-07 09:28:19 +10:00
Nyall Dawson
6c6f646291 Add methods to retrieve current thread affinity and push contexts
to another thread

With suitable assert in place to ensure that pushes are only
made when current thread == existing thread affinity
2017-07-07 09:27:35 +10:00
Nyall Dawson
1dce459610 Add method to transfer all layers from one map store to another
With a note and assert that both stores must have the same
thread affinity
2017-07-07 09:27:35 +10:00
Nyall Dawson
2543e079a5 Better assert messages
Issues is actually when prepare/postProcess is called in a different
thread to context - it doesn't have to be the main thread
2017-07-07 09:27:35 +10:00
Nyall Dawson
1b2086e8a6 Make algorithm dialog use background tasks to execute algorithms 2017-07-07 09:27:35 +10:00
Nyall Dawson
8cfcf57541 Fix tests 2017-07-07 09:27:35 +10:00
Nyall Dawson
7a1fd93ace Flush sink buffers instead of deleting sink/sources in processAlgorithm
Avoids potential issues if processAlgorithm is run in a different
thread
2017-07-07 09:27:35 +10:00
Nyall Dawson
e0c7daa2d8 Rename QgsProcessingAlgorithm::clone to ::create
Since it better describes what the function does. It returns a new
pristine copy of the algorithm, not a clone of its current state
2017-07-07 09:27:35 +10:00
Nyall Dawson
cd7776ca1c Upgrade ported python algs to be thread ready 2017-07-07 09:27:35 +10:00
Nyall Dawson
c2621b1275 Split algorithm execution into separate prepare/process/postProcess steps
The prepare and postProcess steps are designed to be run in main
thread only, while the process step can safely be run in a background
thread.
2017-07-07 09:26:17 +10:00
Nyall Dawson
5c4f64270d Add clone method to ScriptAlgorithm 2017-07-07 09:26:17 +10:00
Nyall Dawson
cd9328d259 Fix some processing algorithm exception handling 2017-07-07 09:26:17 +10:00