60 Commits

Author SHA1 Message Date
Even Rouault
15ea5c46bc
Header files: remove all mentions of '\since QGIS 3.0' 2024-02-18 20:57:23 +01:00
Even Rouault
02caeb9db7
Header files: remove all mentions of '\since QGIS 2.' 2024-02-18 20:46:01 +01:00
Nyall Dawson
c7563cec70 Add generic API to allow map layer renderers to show temporary in
progress preview render results while drawing the layer, which
differ from the final layer render

The immediate use case here is for rendering tiled scene layers.
In order to generate the actual final render for these layers,
we need to first fetch ALL content for the render and then sort
the primitives by z value. But this means that the layer renders
can be extremely slow, with no visible changes on the map until
all the content fetching is complete. Not great user experience!

Instead, here we add the infrastructure so that a layer renderer
can get a temporary image to paint to for any partial renders.
This image gets used during map composition up until the layer
finally finishes rendering, at which time the layer's actual
destination image will be used for the composition.

This means that tiled scene renderers can now draw all tiles
(with unsorted primitives, and the artifacts which come with
that) as soon as we fetch each tile. This gives the user an
immediate visual reflection that the tiles are being fetched
and that how quickly (or slowly) that is happening. As soon
as we've got all tiles, the layer render will be immediately
switched to the version in which all content is rendered
in the correct z order.

As a bonus, we draw these temporary in progress renders
over any previously transformed cache version of the layer
available. So eg when you zoom in, you'll get a zoomed in pixelated
version of the last render which gets progressively drawn
over with each tile as it is fetched.

This same API could be used in future eg with point cloud
rendering when points are being sorted by z value to give
timely visual feedback.
2023-08-16 11:00:37 +10:00
Nyall Dawson
50c76929e1
Followup 30700f1, ensure links to Qgis members are set in docstrings 2023-03-31 10:46:24 +10:00
Julien Cabieces
8f32f07433 Treat review comments
Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
2023-02-27 09:24:40 +01:00
Julien Cabieces
7a2a252d0d fix doc and typos 2023-02-27 09:24:40 +01:00
Julien Cabieces
11e88ad425 fix documentation 2023-02-27 09:24:40 +01:00
Julien Cabieces
b3af80e3e4 [Selective masking]Fixes #34352 : use QUUid to identify symbol layer
Don't use pointers anymore because there are not stable when it comes
to clone
2023-02-27 09:23:16 +01:00
Nyall Dawson
f9c3da1e06 Move unit enums to Qgis, promote to enum class 2023-02-19 13:29:06 +10:00
Vincent Cloarec
3ca858af66
Global map terrain shading (#51535)
* QgsShadingRendering and pipe to render global elevation map

* gdal utils with datatype and resampling method enum

* raster layer elevation map

* optimize raster elevation map with rotation

* handle  no data value in the map elevation raster pipe

* mesh layer and some little fixes

* fix nodata and hillshading z factor

* render shading on layout

* activate/deactivate the shading from ui

* shading only for layer that have elevation

* apply Z scale and offset of layer elevation properties

* ui settings

* allow elevation from point cloud even edl is deactivate for pointcloud

* fix ui

* sipify

* Shading renderer widget in styling panel

* icone for shading renderer settings widget

* two methods to combin elevation

* rewording

* remove check box at the bottom of canvas

* use band of elevation properties

* fix styling pannel

* render shading in layout

* keep EDL point cloud shading individually

* add shading rendering tests

* add missing code for local EDL for point cloud

* shading inactive by default

* rework raster layer resampling

* improve nodata in elevation map

* don't allow elevation map with != size to be combined

* remove EDL from point cloud

* renaming

* sipify

* colorize tests

* renaming

* RGB32

* renaming leftover

* some ui fixes

* fix border for EDL alg

* fix EDL closed next to nodata value

* fix first shading when activated

* renaming and typo

* fixes for doc, doxygen, indentation and spelling

* remove leftover member

* fix clang-tidy

* fix edl tests

* fix dll export

* minor fixes

* adapt images of tests

* fix narrowing

* fix indentation

* sipify

* WIP

* minor ui changes
2023-01-26 15:02:16 +01:00
Julien Cabieces
a57281c836 Vectorization of selective masking 2022-05-12 11:45:39 +10:00
Nyall Dawson
2e960aaeed Add map frame rate and current frame numbers to QgsMapSettings/QgsRenderContext
Makes this information available for symbol rendering logic when
a map is being rendered as part of an animation.
2022-03-27 15:40:05 +10:00
Vincent Cloarec
9965eccdce
Template parameter {usage} for XYZ raster and vector tiles (#46731) 2022-01-13 15:11:31 +01:00
nirvn
4dbcd389fc [feature][api] Allow a custom label sink to be used with map renderer jobs 2021-12-28 20:04:49 +07:00
Nyall Dawson
b54001c358 Copy output image format and output size to QgsRenderContext
These QgsMapSettings properties are useful to rendering operations
to use when they need to create temporary QImages during the
rendering
2021-10-02 07:16:40 +10:00
Nyall Dawson
f2856db943 Implement a more robust way of limiting sizes for symbol preview icons 2021-09-27 11:42:33 +10:00
Nyall Dawson
0ab6113e88 Promote QgsMapSettings and QgsRenderContext enums to enum class, move to Qgis 2021-09-26 11:24:51 +10:00
Nyall Dawson
7027d72b3d Spelling 2021-09-24 12:15:43 +10:00
Nyall Dawson
d838ce709e Allow a QgsFeedback object to be associated with a render context,
for cancelation check support

While there is the existing QgsRenderContext::renderingStopped()
check, this doesn't play well with other parts of QGIS which utilise
a QgsFeedback object for cancelation support. By adding support
for a proper QgsFeedback object in render contexts then it becomes
trivial to pass this on to feature requests, expression contexts,
and other potentially expensive functions so that these can
all be canceled responsively too.

(At some stage in the future we should consider deprecating
QgsRenderContext::rendereringStopped(), but that's not done here)
2021-09-24 12:15:43 +10:00
Nyall Dawson
849819cd0d [api] Allow reference scale for vector layer renderer to be set
Gives a means of setting the reference scale for a vector layer
renderer, so that symbol sizes in the rendered layer will be
scaled accordingly depending on the actual scale of the
rendered map.
2021-06-29 07:33:35 +10:00
Nyall Dawson
54610b293c [api] Allow a symbology reference scale to be set on a QgsRenderContext
This should match the desired scale denominator for the rendered map,
eg 1000.0 for a 1:1000 map render. Set (by default) to -1 to disable
symbology scaling by reference scale.

The symbology reference scale is an optional property which specifies
the reference scale at which symbology in paper units (such as
millimeters or points) is fixed to. For instance, if \a scale is set
to 1000 then a 2mm thick line will be rendered at exactly 2mm thick
when a map is rendered at 1:1000, or 1mm thick when rendered at
1:2000, or 4mm thick at 1:500.
2021-06-29 07:33:35 +10:00
Mathieu Pellerin
8299547682 Address review 2021-05-03 20:43:37 +07:00
Mathieu Pellerin
8d1371f3e9 [layouts] Respect XYZ output zoom level when previewing map items in the layout designer 2021-05-03 18:01:24 +07:00
Denis Rouzaud
ba8a445850 run sipify 2021-03-22 21:13:52 +01:00
Nyall Dawson
7dfef3a0b1 Newer doxygen versions don't auto convert the first line in a class'
documentation to a brief note, so we have to do it explicitly...
2021-02-19 08:15:29 +10:00
Nyall Dawson
50b9beaad6 [sipify] Catch more class references and insert :py:class: annotations 2021-01-31 05:41:22 +10:00
Nyall Dawson
f6f03cd8e1 [api] Add z range filtering option to QgsMapSettings/QgsRenderContext/QgsMapCanvas
Allows for map renders to be filtered by a z or elevation range,
such that only parts of the layer which are considered within
this range will be rendered.

Implements https://github.com/qgis/QGIS-Enhancement-Proposals/issues/201

*Requires support for respecting the QgsRenderContext zRange to be added
to the relevant map layer renderers
2020-11-26 04:18:01 +10:00
Nyall Dawson
f3f226aa69 In cases where we cannot convert the map extent back to a layer's
extent and have had to resort to fetching all features from a layer,
defer the geometry clipping the map extent so that it occurs
AFTER transforming the layer's geometries to the target map extent.

This allows us to correctly clip the feature geometries in the case
that the visible extent available from the render context for the layer
is not accurate (i.e. it's a whole of globe fallback), and avoids
rendering features which fall far outside of the visible map
region.

Fixes #38878
2020-09-22 06:50:34 +10:00
Nyall Dawson
9e1cddaa8e Add render context flag to use when a map render job is part of a 3d map 2020-07-29 04:21:56 +10:00
Nyall Dawson
28c8eefa6e Avoid texture jump when panning maps
We don't need the whole expense of the "Avoid artifacts when rendering as map tiles"
option, because that disables to default clipping of geometry parts which fall
outside the visible canvas extent and accordingly results in a lot of wasted rendering
calculations. Instead, we can just always use the upper left corner of the original
feature geometry before the optimisations like clipping to visible regions are applied,
and use this as the texture origin.

This means we can safely make this handling always applied and not an opt-in setting
2020-07-11 12:54:07 +10:00
Nyall Dawson
6eee1fa69f Don't apply font scaling workaround by default, but instead make it
opt-in through the render context flags

Avoids potential performance regression when rendering labels
2020-07-08 08:49:57 +10:00
Nyall Dawson
b2cef7377c [feature][layouts] Expose option to control PDF image compression
method when exporting layouts to PDF

Options are for Lossy compression, which is the default JPEG compression
used, and Lossless compression (which creates bigger files in most
cases, but is much more suitable for professional printing outputs
or for post-production in Illustrator/etc)

The Bad news: this option is available in builds based on Qt 5.14
or later.
2020-07-05 15:40:48 +10:00
Nyall Dawson
61193fc841 Simplify some painter related operations and make safer 2020-07-04 19:11:10 +10:00
Nyall Dawson
5cbdc4c896 Ensure feature clipping occurs for render only, and doesn't affect
feature geometry when used in rule based renderers and other
geometry dependent rendering options
2020-07-02 12:07:51 +10:00
Nyall Dawson
e38bb541a6 Add clipping regions to QgsMapSettings/QgsRenderContext API 2020-07-02 12:07:51 +10:00
Nyall Dawson
b7eac07721 Add a render context flag so we know when a render operation is
occurring for drawing a symbol preview

Because these have no map association, certain settings like
sizes in "meters in map units" will have no meaning, and may need
special handling

Refs #28690
2020-06-17 08:02:49 +10:00
Nyall Dawson
81a9db9f57 [sipify] Fix creation of cross references 2020-06-15 13:43:58 +10:00
Nyall Dawson
1af8b8178b Add some helpful scoped RAII classes for use with QgsRenderContext
QgsScopedRenderContextPainterSwap: allows for temporarily swapping
the destination painter object for a QgsRenderContext for the lifetime
of the object

QgsScopedRenderContextScaleToMm: temporarily rescales a render context
destination painter device to use millimeter based units for the lifetime
of the object

QgsScopedRenderContextScaleToPixels: temporarily rescales a render
context (which has been scaled to millimeter based units) back
to pixel based units, for the lifetime of the object
2020-04-24 04:07:33 +10:00
Samweli
618f257874 moved qgsabstracttemporal class to qgstemporalrangeobject class as per review suggestions 2020-02-08 08:26:21 +03:00
Samweli
62efb55af2 updates on tests and abstract temporal class 2020-02-08 08:26:21 +03:00
Harrissou Sant-anna
224d6bc03f Add some missing dox and reference 2020-02-06 13:22:12 +10:00
Sandro Mani
c4a2bb0df0
Merge pull request #33827 from kadas-albireo/custom_render_flags
Add QgsRenderContext::setCustomRenderFlags
2020-01-22 13:14:35 +01:00
Sandro Mani
d604ab72f4 Add QgsRenderContext::setCustomRenderingFlags and QgsMapSettings::setCustromRenderingFlags 2020-01-22 10:38:44 +01:00
Sandro Mani
60b4cad050 Add const version of QgsRenderContext::painter 2020-01-16 15:22:58 +10:00
Hugo Mercier
845894b313
[FEATURE] Selective masking (#30747)
* [FEATURE] Selective masking

Advanced rendering feature that allows the definition of 'masks' areas around labels or with a new typ of symbol layer. These masks will "un-draw" symbol layers of other layers underneath.
It modifies the rendering process by adding an optional second pass.
2019-11-07 08:17:25 +01:00
rldhont
6625c7ba62 [Bugfix] Get remote SVG synchronously - in the server context 2019-10-11 14:08:17 +10:00
Nyall Dawson
c71cd4b5fc Initial work on rendered feature handler interface
Adds an interface for classes which provider custom
handlers for features rendered as part of a map render job.

QgsRenderedFeatureHandlerInterface objects are registered
in the QgsMapSettings objects used to construct map render
jobs. During the rendering operation, the handleRenderedFeature()
method will be called once for every rendered feature, allowing
the handler to perform some custom task based on the provided
information.

They can be used for custom tasks which operate on a set of
rendered features, such as creating spatial indexes of the
location and rendered symbology bounding box of all features
rendered on a map.
2019-08-07 21:53:16 +10:00
Nyall Dawson
615e245b18 Add method to specify global vector simplification overrides on a
QgsMapSettings object

If specified (they default to off), these simplification settings
will override any layer-specific simplification settings, and
provide a way for specifying a global simplication to apply
to vector layers while exporting maps.
2019-08-07 15:57:26 +10:00
Nyall Dawson
d8a5dfef06 Add missing dox to QgsRenderContext 2019-05-22 07:12:06 +10:00
Nyall Dawson
85ff9aea31 Add method to retrieve map extent to QgsRenderContext
Previously only a "layer clipping extent" was available for retrieval
from a QgsRenderContext instance, yet there's a need for rendering
operations to have access to the original full extent of the map
being rendered.
2019-05-10 06:31:00 +10:00