QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgslayoutitemmapoverview.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemmapoverview.cpp
3 --------------------
4 begin : October 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include "qgsexception.h"
21#include "qgsfillsymbol.h"
22#include "qgslayout.h"
23#include "qgslayoutitemmap.h"
24#include "qgslayoututils.h"
25#include "qgspainting.h"
26#include "qgsreadwritecontext.h"
29#include "qgssymbol.h"
30#include "qgssymbollayerutils.h"
31#include "qgsvectorlayer.h"
32
33#include <QPainter>
34
35#include "moc_qgslayoutitemmapoverview.cpp"
36
39 , mExtentLayer( std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=EPSG:4326" ), tr( "Overview" ), QStringLiteral( "memory" ), QgsVectorLayer::LayerOptions( map && map->layout() && map->layout()->project() ? map->layout()->project()->transformContext() : QgsCoordinateTransformContext() ) ) )
40{
41 createDefaultFrameSymbol();
42}
43
45
46void QgsLayoutItemMapOverview::createDefaultFrameSymbol()
47{
48 QVariantMap properties;
49 properties.insert( QStringLiteral( "color" ), QStringLiteral( "255,0,0,75" ) );
50 properties.insert( QStringLiteral( "style" ), QStringLiteral( "solid" ) );
51 properties.insert( QStringLiteral( "style_border" ), QStringLiteral( "no" ) );
52 mFrameSymbol = QgsFillSymbol::createSimple( properties );
53
54 mExtentLayer->setRenderer( new QgsSingleSymbolRenderer( mFrameSymbol->clone() ) );
55}
56
57void QgsLayoutItemMapOverview::draw( QPainter *painter )
58{
59 if ( !mEnabled || !mFrameMap || !mMap || !mMap->layout() )
60 {
61 return;
62 }
63 if ( !painter )
64 {
65 return;
66 }
67
68 const QgsLayoutItemMap *overviewFrameMap = linkedMap();
69 if ( !overviewFrameMap )
70 {
71 return;
72 }
73
74 //get polygon for other overview frame map's extent (use visibleExtentPolygon as it accounts for map rotation)
75 QPolygonF otherExtent = overviewFrameMap->visibleExtentPolygon();
76 if ( overviewFrameMap->crs() !=
77 mMap->crs() )
78 {
79 QgsGeometry g = QgsGeometry::fromQPolygonF( otherExtent );
80
81 // reproject extent
82 QgsCoordinateTransform ct( overviewFrameMap->crs(),
83 mMap->crs(), mLayout->project() );
84 g = g.densifyByCount( 20 );
85 try
86 {
87 g.transform( ct );
88 }
89 catch ( QgsCsException & )
90 {
91 }
92
93 otherExtent = g.asQPolygonF();
94 }
95
96 //get current map's extent as a QPolygonF
97 QPolygonF thisExtent = mMap->visibleExtentPolygon();
98 //intersect the two
99 QPolygonF intersectExtent = thisExtent.intersected( otherExtent );
100
101 //setup painter scaling to dots so that raster symbology is drawn to scale
102 double dotsPerMM = painter->device()->logicalDpiX() / 25.4;
103
104 //setup render context
108 QgsExpressionContext expressionContext = createExpressionContext();
109 context.setExpressionContext( expressionContext );
110
111 QgsScopedQPainterState painterState( painter );
112 context.setPainterFlagsUsingContext( painter );
113
114 painter->setCompositionMode( mBlendMode );
115 painter->translate( mMap->mXOffset, mMap->mYOffset );
116 painter->scale( 1 / dotsPerMM, 1 / dotsPerMM ); // scale painter from mm to dots
117
118 mFrameSymbol->startRender( context );
119
120 //construct a polygon corresponding to the intersecting map extent
121 //need to scale line to dots, rather then mm, since the painter has been scaled to dots
122 QTransform mapTransform;
123 QPolygonF thisRectPoly = QPolygonF( QRectF( 0, 0, dotsPerMM * mMap->rect().width(), dotsPerMM * mMap->rect().height() ) );
124
125 //workaround QT Bug #21329
126 thisRectPoly.pop_back();
127 thisExtent.pop_back();
128
129 //create transform from map coordinates to painter coordinates
130 QTransform::quadToQuad( thisExtent, thisRectPoly, mapTransform );
131 QPolygonF intersectPolygon;
132 intersectPolygon = mapTransform.map( intersectExtent );
133
134 QVector<QPolygonF> rings; //empty list
135 if ( !mInverted )
136 {
137 //Render the intersecting map extent
138 mFrameSymbol->renderPolygon( intersectPolygon, &rings, nullptr, context );
139 }
140 else
141 {
142 //We are inverting the overview frame (ie, shading outside the intersecting extent)
143 //Construct a polygon corresponding to the overview map extent
144 QPolygonF outerPolygon;
145 outerPolygon << QPointF( 0, 0 )
146 << QPointF( mMap->rect().width() * dotsPerMM, 0 )
147 << QPointF( mMap->rect().width() * dotsPerMM, mMap->rect().height() * dotsPerMM )
148 << QPointF( 0, mMap->rect().height() * dotsPerMM )
149 << QPointF( 0, 0 );
150
151 //Intersecting extent is an inner ring for the shaded area
152 rings.append( intersectPolygon );
153 mFrameSymbol->renderPolygon( outerPolygon, &rings, nullptr, context );
154 }
155
156 mFrameSymbol->stopRender( context );
157}
158
159bool QgsLayoutItemMapOverview::writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const
160{
161 if ( elem.isNull() )
162 {
163 return false;
164 }
165
166 //overview map frame
167 QDomElement overviewFrameElem = doc.createElement( QStringLiteral( "ComposerMapOverview" ) );
168
169 overviewFrameElem.setAttribute( QStringLiteral( "frameMap" ), mFrameMap ? mFrameMap ->uuid() : QString() );
170 overviewFrameElem.setAttribute( QStringLiteral( "blendMode" ), static_cast< int >( QgsPainting::getBlendModeEnum( mBlendMode ) ) );
171 overviewFrameElem.setAttribute( QStringLiteral( "inverted" ), mInverted );
172 overviewFrameElem.setAttribute( QStringLiteral( "centered" ), mCentered );
173
174 QDomElement frameStyleElem = QgsSymbolLayerUtils::saveSymbol( QString(), mFrameSymbol.get(), doc, context );
175 overviewFrameElem.appendChild( frameStyleElem );
176
177 bool ok = QgsLayoutItemMapItem::writeXml( overviewFrameElem, doc, context );
178 elem.appendChild( overviewFrameElem );
179 return ok;
180}
181
182bool QgsLayoutItemMapOverview::readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context )
183{
184 Q_UNUSED( doc )
185 if ( itemElem.isNull() )
186 {
187 return false;
188 }
189
190 bool ok = QgsLayoutItemMapItem::readXml( itemElem, doc, context );
191
192 mFrameMapUuid = itemElem.attribute( QStringLiteral( "frameMap" ) );
193 setLinkedMap( nullptr );
194
195 mBlendMode = QgsPainting::getCompositionMode( static_cast< Qgis::BlendMode >( itemElem.attribute( QStringLiteral( "blendMode" ), QStringLiteral( "0" ) ).toUInt() ) );
196 mInverted = ( itemElem.attribute( QStringLiteral( "inverted" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) );
197 mCentered = ( itemElem.attribute( QStringLiteral( "centered" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) );
198
199 QDomElement frameStyleElem = itemElem.firstChildElement( QStringLiteral( "symbol" ) );
200 if ( !frameStyleElem.isNull() )
201 {
202 mFrameSymbol = QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( frameStyleElem, context );
203 }
204 return ok;
205}
206
208{
209 if ( !mFrameMapUuid.isEmpty() )
210 {
211 setLinkedMap( qobject_cast< QgsLayoutItemMap * >( mLayout->itemByUuid( mFrameMapUuid, true ) ) );
212 }
213}
214
216{
217 return mBlendMode != QPainter::CompositionMode_SourceOver;
218}
219
221{
222 if ( mFrameMap == map )
223 {
224 //no change
225 return;
226 }
227
228 //disconnect old map
229 if ( mFrameMap )
230 {
233 }
234 mFrameMap = map;
235 //connect to new map signals
237 mMap->invalidateCache();
238}
239
241{
242 return mFrameMap;
243}
244
246{
247 if ( !mMap )
248 {
249 return;
250 }
251
252 if ( mFrameMap )
253 {
256 }
257}
258
260{
261 if ( !mEnabled || !mFrameMap || !mMap || !mMap->layout() )
262 {
263 return nullptr;
264 }
265
266 const QgsLayoutItemMap *overviewFrameMap = linkedMap();
267 if ( !overviewFrameMap )
268 {
269 return nullptr;
270 }
271
272 //get polygon for other overview frame map's extent (use visibleExtentPolygon as it accounts for map rotation)
273 QPolygonF otherExtent = overviewFrameMap->visibleExtentPolygon();
274 QgsGeometry g = QgsGeometry::fromQPolygonF( otherExtent );
275
276 if ( overviewFrameMap->crs() != mMap->crs() )
277 {
278 // reproject extent
279 QgsCoordinateTransform ct( overviewFrameMap->crs(),
280 mMap->crs(), mLayout->project() );
281 g = g.densifyByCount( 20 );
282 try
283 {
284 g.transform( ct );
285 }
286 catch ( QgsCsException & )
287 {
288 }
289 }
290
291 //get current map's extent as a QPolygonF
292 QPolygonF thisExtent = mMap->visibleExtentPolygon();
293 QgsGeometry thisGeom = QgsGeometry::fromQPolygonF( thisExtent );
294 //intersect the two
295 QgsGeometry intersectExtent = thisGeom.intersection( g );
296
297 mExtentLayer->setBlendMode( mBlendMode );
298
299 static_cast< QgsSingleSymbolRenderer * >( mExtentLayer->renderer() )->setSymbol( mFrameSymbol->clone() );
300 mExtentLayer->dataProvider()->truncate();
301 mExtentLayer->setCrs( mMap->crs() );
302
303 if ( mInverted )
304 {
305 intersectExtent = thisGeom.difference( intersectExtent );
306 }
307
308 QgsFeature f;
309 f.setGeometry( intersectExtent );
310 mExtentLayer->dataProvider()->addFeature( f );
311
312 return mExtentLayer.get();
313}
314
316{
317 return mExtentLayer.get();
318}
319
321{
322 if ( mFrameSymbol )
323 {
324 QgsStyleSymbolEntity entity( mFrameSymbol.get() );
325 if ( !visitor->visit( QgsStyleEntityVisitorInterface::StyleLeaf( &entity, QStringLiteral( "overview" ), QObject::tr( "Overview" ) ) ) )
326 return false;
327 }
328
329 return true;
330}
331
333{
334 mFrameSymbol.reset( symbol );
335}
336
338{
339 return mFrameSymbol.get();
340}
341
343{
344 return mFrameSymbol.get();
345}
346
347void QgsLayoutItemMapOverview::setBlendMode( const QPainter::CompositionMode blendMode )
348{
349 mBlendMode = blendMode;
350}
351
353{
354 mInverted = inverted;
355}
356
358{
359 mCentered = centered;
361}
362
364{
365 if ( !mMap )
366 {
367 return;
368 }
369
370 //if using overview centering, update the map's extent
371 if ( mMap->layout() && mCentered && mFrameMap )
372 {
373 QgsRectangle extent = mMap->extent();
374 QgsRectangle otherExtent = mFrameMap->extent();
375
376 QgsPointXY center = otherExtent.center();
377 QgsRectangle movedExtent( center.x() - extent.width() / 2,
378 center.y() - extent.height() / 2,
379 center.x() - extent.width() / 2 + extent.width(),
380 center.y() - extent.height() / 2 + extent.height() );
381 mMap->setExtent( movedExtent );
382 }
383
384 //repaint map so that overview gets updated
385 mMap->invalidateCache();
386}
387
388
389//
390// QgsLayoutItemMapOverviewStack
391//
392
398
403
404void QgsLayoutItemMapOverviewStack::removeOverview( const QString &overviewId )
405{
407}
408
409void QgsLayoutItemMapOverviewStack::moveOverviewUp( const QString &overviewId )
410{
412}
413
414void QgsLayoutItemMapOverviewStack::moveOverviewDown( const QString &overviewId )
415{
417}
418
420{
422 return qobject_cast<QgsLayoutItemMapOverview *>( item );
423}
424
426{
428 return qobject_cast<QgsLayoutItemMapOverview *>( item );
429}
430
431QgsLayoutItemMapOverview &QgsLayoutItemMapOverviewStack::operator[]( int idx ) // cppcheck-suppress duplInheritedMember
432{
433 QgsLayoutItemMapItem *item = mItems.at( idx );
434 QgsLayoutItemMapOverview *overview = qobject_cast<QgsLayoutItemMapOverview *>( item );
435 return *overview;
436}
437
438QList<QgsLayoutItemMapOverview *> QgsLayoutItemMapOverviewStack::asList() const // cppcheck-suppress duplInheritedMember
439{
440 QList< QgsLayoutItemMapOverview * > list;
441 QList< QgsLayoutItemMapItem * >::const_iterator it = mItems.begin();
442 for ( ; it != mItems.end(); ++it )
443 {
444 QgsLayoutItemMapOverview *overview = qobject_cast<QgsLayoutItemMapOverview *>( *it );
445 if ( overview )
446 {
447 list.append( overview );
448 }
449 }
450 return list;
451}
452
453bool QgsLayoutItemMapOverviewStack::readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context )
454{
455 removeItems();
456
457 //read overview stack
458 QDomNodeList mapOverviewNodeList = elem.elementsByTagName( QStringLiteral( "ComposerMapOverview" ) );
459 for ( int i = 0; i < mapOverviewNodeList.size(); ++i )
460 {
461 QDomElement mapOverviewElem = mapOverviewNodeList.at( i ).toElement();
462 QgsLayoutItemMapOverview *mapOverview = new QgsLayoutItemMapOverview( mapOverviewElem.attribute( QStringLiteral( "name" ) ), mMap );
463 mapOverview->readXml( mapOverviewElem, doc, context );
464 mItems.append( mapOverview );
465 }
466
467 return true;
468}
469
470QList<QgsMapLayer *> QgsLayoutItemMapOverviewStack::modifyMapLayerList( const QList<QgsMapLayer *> &layers )
471{
472 QList<QgsMapLayer *> res = layers;
473 res.reserve( layers.count() + mItems.count() );
474 for ( QgsLayoutItemMapItem *item : std::as_const( mItems ) )
475 {
476 if ( !item )
477 continue;
478
479 QgsVectorLayer *l = static_cast< QgsLayoutItemMapOverview * >( item )->asMapLayer();
480 if ( !l )
481 continue;
482
483 l->setCustomProperty( QStringLiteral( "_noset_layer_expression_context" ), true );
484
485 switch ( item->stackingPosition() )
486 {
488 continue;
489
492 {
493 QgsMapLayer *stackLayer = item->stackingLayer();
494 if ( !stackLayer )
495 continue;
496
497 auto pos = std::find( res.begin(), res.end(), stackLayer );
498 if ( pos == res.end() )
499 continue;
500
501 if ( item->stackingPosition() == QgsLayoutItemMapItem::StackBelowMapLayer )
502 {
503 pos++;
504 if ( pos == res.end() )
505 {
506 res.push_back( l );
507 break;
508 }
509 }
510 res.insert( pos, l );
511 break;
512 }
513
515 res.push_back( l );
516 break;
517
519 res.push_front( l );
520 break;
521 }
522 }
523
524 return res;
525}
@ Default
Allow raster-based rendering in situations where it is required for correct rendering or where it wil...
Definition qgis.h:2704
@ PreferVector
Prefer vector-based rendering, when the result will still be visually near-identical to a raster-base...
Definition qgis.h:2705
BlendMode
Blending modes defining the available composition modes that can be used when painting.
Definition qgis.h:4930
Contains information about the context in which a coordinate transform is executed.
Handles coordinate transforms between two coordinate systems.
Custom exception class for Coordinate Reference System related exceptions.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
static std::unique_ptr< QgsFillSymbol > createSimple(const QVariantMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
A geometry is the spatial representation of a feature.
QPolygonF asQPolygonF() const
Returns contents of the geometry as a QPolygonF.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
QgsGeometry difference(const QgsGeometry &geometry, const QgsGeometryParameters &parameters=QgsGeometryParameters()) const
Returns a geometry representing the points making up this geometry that do not make up other.
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
QgsGeometry intersection(const QgsGeometry &geometry, const QgsGeometryParameters &parameters=QgsGeometryParameters()) const
Returns a geometry representing the points shared by this geometry and other.
void addItem(QgsLayoutItemMapItem *item)
Adds a new map item to the stack and takes ownership of the item.
void removeItem(const QString &itemId)
Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapIt...
QgsLayoutItemMapItem * item(int index) const
Returns a reference to the item at the specified index within the stack.
void moveItemUp(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items.
void removeItems()
Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack.
QgsLayoutItemMapItemStack(QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItemStack, attached to the specified map.
QList< QgsLayoutItemMapItem * > mItems
void moveItemDown(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items.
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
@ StackBelowMapLabels
Render above all map layers, but below map labels.
@ StackAboveMapLabels
Render above all map layers and labels.
@ StackBelowMapLayer
Render below a specific map layer (see stackingLayer()).
@ StackAboveMapLayer
Render above a specific map layer (see stackingLayer()).
@ StackBelowMap
Render below all map layers.
QgsLayoutItemMap * mMap
Associated map.
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)
Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'Layout...
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMa...
bool mEnabled
True if item is to be displayed on map.
QString name() const
Returns the friendly display name for the item.
QgsLayoutItemMapItem(const QString &name, QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItem, attached to the specified map.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
const QgsLayoutItemMap * map() const
Returns the layout item map for the item.
void moveOverviewUp(const QString &overviewId)
Moves an overview with matching overviewId up the stack, causing it to be rendered above other overvi...
QgsLayoutItemMapOverviewStack(QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapOverviewStack, attached to the specified map.
QgsLayoutItemMapOverview & operator[](int index)
Returns a reference to an overview at the specified index within the stack.
void addOverview(QgsLayoutItemMapOverview *overview)
Adds a new map overview to the stack and takes ownership of the overview.
bool readXml(const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context) override
Sets the item stack's state from a DOM document, where element is a DOM node corresponding to a 'Layo...
QList< QgsMapLayer * > modifyMapLayerList(const QList< QgsMapLayer * > &layers)
Alters the list of map layers which will be rendered for the link map item, inserting temporary layer...
void moveOverviewDown(const QString &overviewId)
Moves an overview with matching overviewId down the stack, causing it to be rendered below other over...
void removeOverview(const QString &overviewId)
Removes an overview with matching overviewId from the stack and deletes the corresponding QgsLayoutIt...
QList< QgsLayoutItemMapOverview * > asList() const
Returns a list of QgsLayoutItemMapOverviews contained by the stack.
QgsLayoutItemMapOverview * overview(const QString &overviewId) const
Returns a reference to an overview with matching overviewId within the stack.
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
QgsFillSymbol * frameSymbol()
Returns the fill symbol used for drawing the overview extent.
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
bool usesAdvancedEffects() const override
Returns true if the item is drawn using advanced effects, such as blend modes.
void connectSignals()
Reconnects signals for overview map, so that overview correctly follows changes to source map's exten...
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the overview.
QgsMapLayer * mapLayer() override
Returns the internal map layer used by this item, if available.
QgsVectorLayer * asMapLayer()
Returns a vector layer to render as part of the QgsLayoutItemMap render, containing a feature represe...
void draw(QPainter *painter) override
Draws the item on to a destination painter.
void overviewExtentChanged()
Handles recentering of the map and redrawing of the map's overview.
bool writeXml(QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMa...
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
~QgsLayoutItemMapOverview() override
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map to show the overview extent of.
void finalizeRestoreFromXml() override
Called after all pending items have been restored from XML.
void setFrameSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used for drawing the overview extent.
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
void setInverted(bool inverted)
Sets whether the overview frame is inverted, ie, whether the shaded area is drawn outside the extent ...
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
QgsLayoutItemMapOverview(const QString &name, QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapOverview.
bool readXml(const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context) override
Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'Layout...
void setCentered(bool centered)
Sets whether the extent of the map is forced to center on the overview.
QgsLayoutItemMap * linkedMap()
Returns the source map to show the overview extent of.
Layout graphical items for displaying a map.
void extentChanged()
Emitted when the map's extent changes.
void mapRotationChanged(double newRotation)
Emitted when the map's rotation changes.
QPolygonF visibleExtentPolygon() const
Returns a polygon representing the current visible map extent, considering map extents and rotation.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used for rendering the map.
const QgsLayout * layout() const
Returns the layout the object is attached to.
QPointer< QgsLayout > mLayout
static QgsRenderContext createRenderContextForLayout(QgsLayout *layout, QPainter *painter, double dpi=-1)
Creates a render context suitable for the specified layout and painter destination.
Base class for all map layer types.
Definition qgsmaplayer.h:80
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
static Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a Qgis::BlendMode corresponding to a QPainter::CompositionMode.
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a Qgis::BlendMode.
Represents a 2D point.
Definition qgspointxy.h:60
double y
Definition qgspointxy.h:64
double x
Definition qgspointxy.h:63
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
QgsPointXY center
Contains information about the context of a rendering operation.
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
void setRasterizedRenderingPolicy(Qgis::RasterizedRenderingPolicy policy)
Sets the policy controlling when rasterisation of content during renders is permitted.
Qgis::RasterizedRenderingPolicy rasterizedRenderingPolicy() const
Returns the policy controlling when rasterisation of content during renders is permitted.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
Scoped object for saving and restoring a QPainter object's state.
A feature renderer which renders all features with the same symbol.
void setSymbol(QgsSymbol *s)
Sets the symbol which will be rendered for every feature.
An interface for classes which can visit style entity (e.g.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
A symbol entity for QgsStyle databases.
Definition qgsstyle.h:1397
static std::unique_ptr< QgsSymbol > loadSymbol(const QDomElement &element, const QgsReadWriteContext &context)
Attempts to load a symbol from a DOM element.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
Represents a vector layer which manages a vector based dataset.
Contains information relating to the style entity currently being visited.