30 Commits

Author SHA1 Message Date
Nyall Dawson
7879c0a20b Fix processing rendering styles for output dialog, functionality 2017-08-19 00:47:21 +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
e5b156b86a Make processing algorithms safe to run in threads 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
d667bf595f Move iterator exception handling to c++ 2017-06-24 08:15:06 +10:00
Nyall Dawson
57f2c623ce Move invalid geometry callback from Python to c++ 2017-06-23 12:08:54 +10:00
Nyall Dawson
29f50b72ee [processing] Catch transform errors in when iterating features 2017-06-12 08:05:32 +10:00
Nyall Dawson
81da209bf5 Use a QgsProject pointer instead of bool loadIntoProject
Allows potential future use case of loading results into
a different open project
2017-06-06 08:40:23 +10:00
Nyall Dawson
46596c50f2 Restore correct layer naming when loading results 2017-06-06 07:41:20 +10:00
Nyall Dawson
3bd74aef52 Remove no longer required QgsProcessingContext::UseSelectionIfPresent flag
Since using selection is now a per-feature-source setting
2017-06-06 07:41:20 +10:00
Nyall Dawson
c1d9d57dd2 First working pure c++ algorithms 2017-06-06 07:41:19 +10:00
Nyall Dawson
271a1e38db Convert remaining parameters from python 2017-05-10 17:04:11 +10:00
Nyall Dawson
3706d88045 [processing] c++ framework for parameters and running algorithms (WIP)
This commit adds the virtual method for running processing algs
to the base c++ class, and adds the initial framework
for c++ algorithm parameters.

When running an algorithm, a QVariantMap is passed
as the algorithm parameters. The high level API provided
by QgsProcessingParameters should be used to retrieve
strings/layers/doubles/etc from this QVariantMap.

This allows advanced use cases, such as passing QgsProperty
with the QVariantMap for "dynamic" parameters, where the
value should be evaluated for every feature processed.

E.g. if the buffer algorithm uses a dynamic property for distance,
then the distance could be bound to either a field value or
to a custom expression. This gets evaluated before buffering
each feature to allow for advanced variable buffering.

Support for dynamic parameters will be "opt in", and non default.
So algorithms will need to specifically add support for
dynamic properties as required.
2017-05-10 10:14:37 +10:00
Nyall Dawson
a8a3cc82ed [processing] Port vector.createVectorWriter to c++
This implements an improved version of vector.createVectorWriter
in QgsProcessingUtils. The improved version relies on the
core class QgsVectorLayerImport to create empty layers,
which:
- reduces duplicate code and reuses the mature QgsVectorLayerImport
routines
- avoids manual conversion of field types to destination provider
field types
- potentially allows any writable provider to be used as a feature
sink for algorithms (e.g. output direct to MSSQL/Oracle/db2). This
should work now - it just needs exposing via UI.
2017-05-07 08:02:53 +10:00
Nyall Dawson
32e06f486a Make QgsProcessingContext::temporaryLayerStore() return a pointer to store 2017-05-03 08:43:31 +10:00
Nyall Dawson
348c886602 Use a QgsMapLayerStore instead of whole QgsProject for
temporary layer storage in QgsProcessingContext
2017-05-03 07:09:44 +10:00
Matthias Kuhn
28a21209b9 [sipify] seealso 2017-04-30 16:52:05 +02:00
Nyall Dawson
ccb4ac98b4 Merge pull request #4417 from nyalldawson/processing_writer
Refactor processing writer to use QgsFeatureSink
2017-04-27 10:14:33 +10:00
Denis Rouzaud
4cc4a27068 [sipify] operators, remove argument
* skip some operators
 * allow to remove an argument with SIP_PYARGREMOVE
2017-04-26 15:06:16 +02:00
Nyall Dawson
fd2c18ee16 Refactor processing writer to use QgsFeatureSink, and to store
temporary output layers in the provided processing context

Should fix loss of intermediate memory layers when running
a multi-step model
2017-04-26 17:38:40 +10:00
Nyall Dawson
6b4ddb3b0d Add temporary layer store to processing context
This temporary layer store (a QgsProject) is used as a
store for layers that are added if a parameter that
is evaluated to a layer requires that a new, non-active-project
layer is loaded. It means that these layers will remain accessible
for the duration of the algorithm's execution (or models
execution if an algorithm is run as part of a model), before
being automatically discarded when the QgsProcessingContext
used to run the algorithm/model goes out of scope.

This approach has several benefits:
- it means that algorithms (including c++ algorithms) are able
to use both project and non-project layers without needing
to handle any memory management themselves.
- it means that layers are guaranteed to last for the duration
of a model execution. This is currently an issue where models
which use memory layers as intermediate outputs do not
function correctly as the memory layers are destroyed before
the model has finished executing
- there should be no leakage of layers remaining open
after an algorithm exits
2017-04-26 14:06:59 +10:00
Nyall Dawson
a28bc086eb Indentation/sipify 2017-04-26 12:53:35 +10:00
Nyall Dawson
b067bd786a Rename UseSelection -> UseSelectionIfPresent, clarify docs 2017-04-26 12:53:35 +10:00
Nyall Dawson
1c6f165ff5 Add missing doc 2017-04-26 12:53:35 +10:00
Nyall Dawson
e6a33e876c Allow setting the invalid geometry callback in processing context 2017-04-26 12:53:35 +10:00
Nyall Dawson
f3cfb8b759 Add invalid geometry handling method to processing context 2017-04-26 12:53:35 +10:00
Nyall Dawson
06a20b935d Add UseSelection flag to QgsProcessingContext
Indicates whether only selected features should be used in
algorithms
2017-04-26 12:53:35 +10:00
Nyall Dawson
241d283bb8 Create a context object for processing algorithm execution 2017-04-26 12:53:35 +10:00