43 Commits

Author SHA1 Message Date
Nyall Dawson
ffa99b7b64 Fix doxygen blocks which don't use the * prefix on all lines, which
prevents the auto format and sipify scripts from doing their full
formatting magic
2021-04-19 12:54:13 +10:00
Denis Rouzaud
ba8a445850 run sipify 2021-03-22 21:13:52 +01:00
Nyall Dawson
14f2ab53b1 When attempting to precalculated nodes during an expression prepare
stage, be more intelligent about compiling AND or OR nodes

We can take advantage of the fact that and AND node will ALWAYS
be false if either input node is static and evaluates to FALSE,
and that OR nodes will always be true if either input is static
and evaluates to TRUE.

In some cases this allows us the shortcut and cut out non-static
nodes during preparation, resulting in faster evaluation and
more easily compiled expressions...
2021-02-24 12:39:36 +10:00
Nyall Dawson
48ce042c84 Take advantage of pre-computed static expression nodes when determining
the referenced fields of an expression

Avoids some cases where use of various expression functions which
normally trigger all attributes to be requested, yet can be pre-computed
during prepare stages, cause non-provider fields to be listed in
the referenced columns and accordingly prevent expression compilation.

Notably this can occur when using an expression like:

   aggregate( .... , filter:=
"some_child_field"=attribute(@atlas_feature, 'some_atlas_field_name') )

where the whole attribute(@atlas_feature....) part is a constant
static value and can be compiled down to a trivial, index-friendly
"some_child_field"=### filter for the aggregate provider request.
Ultimately giving a big performance boost to the atlas!
2021-02-15 12:12:00 +10:00
Nyall Dawson
8fa29ac6d2 When we are compiling expressions to handoff to backend providers,
check if a node has already been determined to evaluate to a static,
precalculated value, and if so, use this value for the node instead
of attempting to compile the actual contents of the node itself

If we are certain that a node is static and will never change,
the this potentially allows us to short-cut a large part of the
filter expressions content. We already use this short-cut when
evaluating expressions on the QGIS side since years, and its
proven to be stable and reliable. By respecting this during
expression compilation we can offer a huge speed up to certain
filter expressions, especially those which utilise QGIS variables
which are known to be static (such as atlas variables, map scales,
etc). Previously ANY use of a qgis variable would always cause
expression compilation to fail and require a full set of feature
fetching from the provider.

(Resulted in orders of magnitude faster atlas export for a complex
atlas.)
2021-02-12 06:05:56 +10:00
Nyall Dawson
50b9beaad6 [sipify] Catch more class references and insert :py:class: annotations 2021-01-31 05:41:22 +10:00
Denis Rouzaud
e071f31a58 add an argument to configure preview length in QgsExpression::formatPreviewString 2021-01-28 15:18:32 +01:00
Nyall Dawson
44c2a26074 Add utility functions to determine if a QgsExpression is a simple
"field=value" type expression, and for condensing a list of similar
expressions to an equivalent "field IN (value, value2,...)" expression
wherever possible
2021-01-12 12:16:50 +10:00
Harrissou Sant-anna
d4e60173bc Fix after review 2020-07-21 10:13:45 +10:00
Harrissou Sant-anna
140425b1e3 Fix file formatting for better output rendering 2020-07-21 10:13:45 +10:00
Harrissou Sant-anna
5c83cd07cc Move some cpp code samples to python 2020-07-21 10:13:45 +10:00
Nyall Dawson
81a9db9f57 [sipify] Fix creation of cross references 2020-06-15 13:43:58 +10:00
Alessandro Pasotti
195efa42a1 Final touches to the parent form API 2020-03-04 08:52:52 +01:00
signedav
20ac7e3c22 Update python/core/auto_generated/expression/qgsexpression.sip.in
Co-Authored-By: Matthias Kuhn <matthias@opengis.ch>

and

set parameter to const
2019-12-03 15:29:17 +01:00
David Signer
7fbf2c867d tags helping to find the correct function are integrated into the help of the expression
defined in the json files and used by the expression builder to find the function (not using as alias)
2019-12-03 15:29:16 +01:00
David Signer
161af6ad26 search tags in expression function to look up the functionality in the expression builder 2019-11-28 16:47:48 +01:00
Matthias Kuhn
65fe231ee9 Q_GLOBAL_STATIC for expressions 2019-11-02 15:01:59 +01:00
Nyall Dawson
ffc71c4f57 Remove const_cast 2019-09-18 07:55:46 +10:00
Nyall Dawson
8f6f04885b [FEATURE] Add @scale_value expression variable for use when evaluating
data defined text format properties while rendering scale bar text

Allows for per-label customisation of the text format inside scale bars
2019-07-22 11:34:32 +10:00
Nyall Dawson
ef97fefbaa [layouts] Add API to set expression variables at a multiframe level 2019-06-28 07:12:40 +10:00
Nyall Dawson
16a64ed84d Deprecate some methods, dox++ 2019-03-22 12:16:22 +10:00
Nyall Dawson
107b48a430 Add NULLPTR macro for use in doxygen comments
For the c++ api dox this expands to "\c nullptr" (the
\c directive indicates a code literal value), and for sipify/Python
it expands to ``None`` (`` is sphinx annotation for literal values)

Makes for nicer dox for both c++ and Python!
2019-02-27 09:41:11 +10:00
Nyall Dawson
a7ca08784c Nullptr consistency in dox 2019-02-27 09:41:11 +10:00
Nyall Dawson
b6d66becab Sipify 2019-02-27 09:41:11 +10:00
Hugo Mercier
e4288e5dea QgsExpression: set setGeomCalculator precedence
setGeomCalculator, setDistanceUnits and setAreaUnits have now
 precedence over expression scopes.
2019-02-14 13:40:12 +01: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
384d310233 Minor improvements to PyQGIS returns for SIP_OUT params 2019-02-05 04:55:34 +11:00
Denis Rouzaud
166e952c33 run sipify 2018-12-19 08:04:27 -04:00
Denis Rouzaud
6bb0720bb7
Merge pull request #8708 from 3nids/sipify_sip_out
[sipify] handles SIP_OUT arguments
2018-12-18 22:08:42 -04:00
Denis Rouzaud
edfb7e1465 run sipify 2018-12-18 17:17:25 -04:00
Nyall Dawson
06d5f924f6 More square brackets 2018-12-19 05:21:49 +10:00
Even Rouault
7e81226b51 Replace toUtf8().data() by toUtf8().constData()
All your uses of toUtf8().data() actually just need a const char*
So use constData() that is semantically more correct, and documented
to be faster.

From http://doc.qt.io/qt-5/qbytearray.html#data
"For read-only access, constData() is faster because it never
causes a deep copy to occur."
2018-10-07 07:23:42 +10:00
Nyall Dawson
c8191ffd50 Allow unformatted preview text for expression results 2018-08-27 14:43:02 +10:00
Denis Rouzaud
c0dd00615a
[pyqgis] __repr__ method for QgsExpression, QgsField (#7464)
* [pyqgis] __repr__ method for QgsExpression, QgsField

* add tests for __repr__ methods

* Fix test
2018-07-28 08:06:08 +02:00
Nyall Dawson
77d22849d9 Fix calculation of relation aggregate in virtual field with same name as related field 2018-06-20 15:23:55 +10:00
Nyall Dawson
2ed144ac59 Apply clang-tidy readability-avoid-const-params-in-decls fixit
Checks whether a function declaration has parameters that are
top level const.

const values in declarations do not affect the signature of a
function, so they should not be put there.
2018-06-05 10:19:13 +10:00
Denis Rouzaud
65bb60e96c run sipify 2018-05-28 10:39:34 -08:00
Nyall Dawson
38850bdb94 [pyqgis] Ensure that multiline param tags are indented for additional lines 2018-05-27 18:54:09 +10:00
Nyall Dawson
c864d22d1f Add "get ..." to doxygen compliance blacklist
Should be "gets ..." for consistent tense, or better yet
"returns ..." for consistency.
2018-05-27 14:05:06 +10:00
Nyall Dawson
1c615c15cc More documentation compliance
Use Qt style "returns .." tense instead of "return ..", and lock
this in with a documentation compliance unit test
2018-05-25 15:09:00 +10:00
Alessandro Pasotti
673fac0c88 Added methods to search expression nodes and drop RegExp
- nodes() return the list of all nodes
- findNodes<T> returns a list of the nodes matching the class

Also drops the regexp for finding form attrs in the value-relation
expressions.

Other minor fixes as suggested in the PR review.
2018-05-15 18:32:40 +02:00
Alessandro Pasotti
b4f86147c7 Add referencedFunctions() to expressions 2018-05-15 09:20:10 +02:00
Denis Rouzaud
7df2593caf move auto generated sip file in dedicated folder 2018-05-14 10:23:37 -04:00