QGIS API Documentation 4.1.0-Master (60fea48833c)
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#include <QString>
35
36#include "moc_qgslayoutitemmapoverview.cpp"
37
38using namespace Qt::StringLiterals;
39
42 , mExtentLayer(
43 std::make_unique<
44 QgsVectorLayer >( u"Polygon?crs=EPSG:4326"_s, tr( "Overview" ), u"memory"_s, QgsVectorLayer::LayerOptions( map && map->layout() && map->layout()->project() ? map->layout()->project()->transformContext() : QgsCoordinateTransformContext() ) )
45 )
46{
47 createDefaultFrameSymbol();
48}
49
51
52void QgsLayoutItemMapOverview::createDefaultFrameSymbol()
53{
54 QVariantMap properties;
55 properties.insert( u"color"_s, u"255,0,0,75"_s );
56 properties.insert( u"style"_s, u"solid"_s );
57 properties.insert( u"style_border"_s, u"no"_s );
58 mFrameSymbol = QgsFillSymbol::createSimple( properties );
59
60 mExtentLayer->setRenderer( new QgsSingleSymbolRenderer( mFrameSymbol->clone() ) );
61}
62
63void QgsLayoutItemMapOverview::draw( QPainter *painter )
64{
65 if ( !mEnabled || !mFrameMap || !mMap || !mMap->layout() )
66 {
67 return;
68 }
69 if ( !painter )
70 {
71 return;
72 }
73
74 const QgsLayoutItemMap *overviewFrameMap = linkedMap();
75 if ( !overviewFrameMap )
76 {
77 return;
78 }
79
80 //get polygon for other overview frame map's extent (use visibleExtentPolygon as it accounts for map rotation)
81 QPolygonF otherExtent = overviewFrameMap->visibleExtentPolygon();
82 if ( overviewFrameMap->crs() != mMap->crs() )
83 {
84 QgsGeometry g = QgsGeometry::fromQPolygonF( otherExtent );
85
86 // reproject extent
87 QgsCoordinateTransform ct( overviewFrameMap->crs(), mMap->crs(), mLayout->project() );
88 g = g.densifyByCount( 20 );
89 try
90 {
91 g.transform( ct );
92 }
93 catch ( QgsCsException & )
94 {}
95
96 otherExtent = g.asQPolygonF();
97 }
98
99 //get current map's extent as a QPolygonF
100 QPolygonF thisExtent = mMap->visibleExtentPolygon();
101 //intersect the two
102 QPolygonF intersectExtent = thisExtent.intersected( otherExtent );
103
104 //setup painter scaling to dots so that raster symbology is drawn to scale
105 double dotsPerMM = painter->device()->logicalDpiX() / 25.4;
106
107 //setup render context
111 QgsExpressionContext expressionContext = createExpressionContext();
112 context.setExpressionContext( expressionContext );
113
114 QgsScopedQPainterState painterState( painter );
115 context.setPainterFlagsUsingContext( painter );
116
117 painter->setCompositionMode( mBlendMode );
118 painter->translate( mMap->mXOffset, mMap->mYOffset );
119 painter->scale( 1 / dotsPerMM, 1 / dotsPerMM ); // scale painter from mm to dots
120
121 mFrameSymbol->startRender( context );
122
123 //construct a polygon corresponding to the intersecting map extent
124 //need to scale line to dots, rather then mm, since the painter has been scaled to dots
125 QTransform mapTransform;
126 QPolygonF thisRectPoly = QPolygonF( QRectF( 0, 0, dotsPerMM * mMap->rect().width(), dotsPerMM * mMap->rect().height() ) );
127
128 //workaround QT Bug #21329
129 thisRectPoly.pop_back();
130 thisExtent.pop_back();
131
132 //create transform from map coordinates to painter coordinates
133 QTransform::quadToQuad( thisExtent, thisRectPoly, mapTransform );
134 QPolygonF intersectPolygon;
135 intersectPolygon = mapTransform.map( intersectExtent );
136
137 QVector<QPolygonF> rings; //empty list
138 if ( !mInverted )
139 {
140 //Render the intersecting map extent
141 mFrameSymbol->renderPolygon( intersectPolygon, &rings, nullptr, context );
142 }
143 else
144 {
145 //We are inverting the overview frame (ie, shading outside the intersecting extent)
146 //Construct a polygon corresponding to the overview map extent
147 QPolygonF outerPolygon;
148 outerPolygon
149 << QPointF( 0, 0 )
150 << QPointF( mMap->rect().width() * dotsPerMM, 0 )
151 << QPointF( mMap->rect().width() * dotsPerMM, mMap->rect().height() * dotsPerMM )
152 << QPointF( 0, mMap->rect().height() * dotsPerMM )
153 << QPointF( 0, 0 );
154
155 //Intersecting extent is an inner ring for the shaded area
156 rings.append( intersectPolygon );
157 mFrameSymbol->renderPolygon( outerPolygon, &rings, nullptr, context );
158 }
159
160 mFrameSymbol->stopRender( context );
161}
162
163bool QgsLayoutItemMapOverview::writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const
164{
165 if ( elem.isNull() )
166 {
167 return false;
168 }
169
170 //overview map frame
171 QDomElement overviewFrameElem = doc.createElement( u"ComposerMapOverview"_s );
172
173 overviewFrameElem.setAttribute( u"frameMap"_s, mFrameMap ? mFrameMap->uuid() : QString() );
174 overviewFrameElem.setAttribute( u"blendMode"_s, static_cast< int >( QgsPainting::getBlendModeEnum( mBlendMode ) ) );
175 overviewFrameElem.setAttribute( u"inverted"_s, mInverted );
176 overviewFrameElem.setAttribute( u"centered"_s, mCentered );
177
178 QDomElement frameStyleElem = QgsSymbolLayerUtils::saveSymbol( QString(), mFrameSymbol.get(), doc, context );
179 overviewFrameElem.appendChild( frameStyleElem );
180
181 bool ok = QgsLayoutItemMapItem::writeXml( overviewFrameElem, doc, context );
182 elem.appendChild( overviewFrameElem );
183 return ok;
184}
185
186bool QgsLayoutItemMapOverview::readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context )
187{
188 Q_UNUSED( doc )
189 if ( itemElem.isNull() )
190 {
191 return false;
192 }
193
194 bool ok = QgsLayoutItemMapItem::readXml( itemElem, doc, context );
195
196 mFrameMapUuid = itemElem.attribute( u"frameMap"_s );
197 setLinkedMap( nullptr );
198
199 mBlendMode = QgsPainting::getCompositionMode( static_cast< Qgis::BlendMode >( itemElem.attribute( u"blendMode"_s, u"0"_s ).toUInt() ) );
200 mInverted = ( itemElem.attribute( u"inverted"_s, u"0"_s ) != "0"_L1 );
201 mCentered = ( itemElem.attribute( u"centered"_s, u"0"_s ) != "0"_L1 );
202
203 QDomElement frameStyleElem = itemElem.firstChildElement( u"symbol"_s );
204 if ( !frameStyleElem.isNull() )
205 {
206 mFrameSymbol = QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( frameStyleElem, context );
207 }
208 return ok;
209}
210
212{
213 if ( !mFrameMapUuid.isEmpty() )
214 {
215 setLinkedMap( qobject_cast< QgsLayoutItemMap * >( mLayout->itemByUuid( mFrameMapUuid, true ) ) );
216 }
217}
218
220{
221 return mBlendMode != QPainter::CompositionMode_SourceOver;
222}
223
225{
226 if ( mFrameMap == map )
227 {
228 //no change
229 return;
230 }
231
232 //disconnect old map
233 if ( mFrameMap )
234 {
237 }
238 mFrameMap = map;
239 //connect to new map signals
241 mMap->invalidateCache();
242}
243
245{
246 return mFrameMap;
247}
248
250{
251 if ( !mMap )
252 {
253 return;
254 }
255
256 if ( mFrameMap )
257 {
260 }
261}
262
264{
265 if ( !mEnabled || !mFrameMap || !mMap || !mMap->layout() )
266 {
267 return nullptr;
268 }
269
270 const QgsLayoutItemMap *overviewFrameMap = linkedMap();
271 if ( !overviewFrameMap )
272 {
273 return nullptr;
274 }
275
276 //get polygon for other overview frame map's extent (use visibleExtentPolygon as it accounts for map rotation)
277 QPolygonF otherExtent = overviewFrameMap->visibleExtentPolygon();
278 QgsGeometry g = QgsGeometry::fromQPolygonF( otherExtent );
279
280 if ( overviewFrameMap->crs() != mMap->crs() )
281 {
282 // reproject extent
283 QgsCoordinateTransform ct( overviewFrameMap->crs(), mMap->crs(), mLayout->project() );
284 g = g.densifyByCount( 20 );
285 try
286 {
287 g.transform( ct );
288 }
289 catch ( QgsCsException & )
290 {}
291 }
292
293 //get current map's extent as a QPolygonF
294 QPolygonF thisExtent = mMap->visibleExtentPolygon();
295 QgsGeometry thisGeom = QgsGeometry::fromQPolygonF( thisExtent );
296 //intersect the two
297 QgsGeometry intersectExtent = thisGeom.intersection( g );
298
299 mExtentLayer->setBlendMode( mBlendMode );
300
301 static_cast< QgsSingleSymbolRenderer * >( mExtentLayer->renderer() )->setSymbol( mFrameSymbol->clone() );
302 mExtentLayer->dataProvider()->truncate();
303 mExtentLayer->setCrs( mMap->crs() );
304
305 if ( mInverted )
306 {
307 intersectExtent = thisGeom.difference( intersectExtent );
308 }
309
310 QgsFeature f;
311 f.setGeometry( intersectExtent );
312 mExtentLayer->dataProvider()->addFeature( f );
313
314 return mExtentLayer.get();
315}
316
318{
319 return mExtentLayer.get();
320}
321
323{
324 if ( mFrameSymbol )
325 {
326 QgsStyleSymbolEntity entity( mFrameSymbol.get() );
327 if ( !visitor->visit( QgsStyleEntityVisitorInterface::StyleLeaf( &entity, u"overview"_s, QObject::tr( "Overview" ) ) ) )
328 return false;
329 }
330
331 return true;
332}
333
335{
336 mFrameSymbol.reset( symbol );
337}
338
340{
341 return mFrameSymbol.get();
342}
343
345{
346 return mFrameSymbol.get();
347}
348
349void QgsLayoutItemMapOverview::setBlendMode( const QPainter::CompositionMode blendMode )
350{
351 mBlendMode = blendMode;
352}
353
355{
356 mInverted = inverted;
357}
358
360{
361 mCentered = centered;
363}
364
366{
367 if ( !mMap )
368 {
369 return;
370 }
371
372 //if using overview centering, update the map's extent
373 if ( mMap->layout() && mCentered && mFrameMap )
374 {
375 QgsRectangle extent = mMap->extent();
376 QgsRectangle otherExtent = mFrameMap->extent();
377
378 QgsPointXY center = otherExtent.center();
379 QgsRectangle movedExtent( center.x() - extent.width() / 2, center.y() - extent.height() / 2, center.x() - extent.width() / 2 + extent.width(), center.y() - extent.height() / 2 + extent.height() );
380 mMap->setExtent( movedExtent );
381 }
382
383 //repaint map so that overview gets updated
384 mMap->invalidateCache();
385}
386
387
388//
389// QgsLayoutItemMapOverviewStack
390//
391
395
400
401void QgsLayoutItemMapOverviewStack::removeOverview( const QString &overviewId )
402{
404}
405
406void QgsLayoutItemMapOverviewStack::moveOverviewUp( const QString &overviewId )
407{
409}
410
411void QgsLayoutItemMapOverviewStack::moveOverviewDown( const QString &overviewId )
412{
414}
415
417{
419 return qobject_cast<QgsLayoutItemMapOverview *>( item );
420}
421
423{
425 return qobject_cast<QgsLayoutItemMapOverview *>( item );
426}
427
428QgsLayoutItemMapOverview &QgsLayoutItemMapOverviewStack::operator[]( int idx ) // cppcheck-suppress duplInheritedMember
429{
430 QgsLayoutItemMapItem *item = mItems.at( idx );
431 QgsLayoutItemMapOverview *overview = qobject_cast<QgsLayoutItemMapOverview *>( item );
432 return *overview;
433}
434
435QList<QgsLayoutItemMapOverview *> QgsLayoutItemMapOverviewStack::asList() const // cppcheck-suppress duplInheritedMember
436{
437 QList< QgsLayoutItemMapOverview * > list;
438 QList< QgsLayoutItemMapItem * >::const_iterator it = mItems.begin();
439 for ( ; it != mItems.end(); ++it )
440 {
441 QgsLayoutItemMapOverview *overview = qobject_cast<QgsLayoutItemMapOverview *>( *it );
442 if ( overview )
443 {
444 list.append( overview );
445 }
446 }
447 return list;
448}
449
450bool QgsLayoutItemMapOverviewStack::readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context )
451{
452 removeItems();
453
454 //read overview stack
455 QDomNodeList mapOverviewNodeList = elem.elementsByTagName( u"ComposerMapOverview"_s );
456 for ( int i = 0; i < mapOverviewNodeList.size(); ++i )
457 {
458 QDomElement mapOverviewElem = mapOverviewNodeList.at( i ).toElement();
459 QgsLayoutItemMapOverview *mapOverview = new QgsLayoutItemMapOverview( mapOverviewElem.attribute( u"name"_s ), mMap );
460 mapOverview->readXml( mapOverviewElem, doc, context );
461 mItems.append( mapOverview );
462 }
463
464 return true;
465}
466
467QList<QgsMapLayer *> QgsLayoutItemMapOverviewStack::modifyMapLayerList( const QList<QgsMapLayer *> &layers )
468{
469 QList<QgsMapLayer *> res = layers;
470 res.reserve( layers.count() + mItems.count() );
471 for ( QgsLayoutItemMapItem *item : std::as_const( mItems ) )
472 {
473 if ( !item )
474 continue;
475
476 QgsVectorLayer *l = static_cast< QgsLayoutItemMapOverview * >( item )->asMapLayer();
477 if ( !l )
478 continue;
479
480 l->setCustomProperty( u"_noset_layer_expression_context"_s, true );
481
482 switch ( item->stackingPosition() )
483 {
485 continue;
486
489 {
490 QgsMapLayer *stackLayer = item->stackingLayer();
491 if ( !stackLayer )
492 continue;
493
494 auto pos = std::find( res.begin(), res.end(), stackLayer );
495 if ( pos == res.end() )
496 continue;
497
498 if ( item->stackingPosition() == QgsLayoutItemMapItem::StackBelowMapLayer )
499 {
500 pos++;
501 if ( pos == res.end() )
502 {
503 res.push_back( l );
504 break;
505 }
506 }
507 res.insert( pos, l );
508 break;
509 }
510
512 res.push_back( l );
513 break;
514
516 res.push_front( l );
517 break;
518 }
519 }
520
521 return res;
522}
@ Default
Allow raster-based rendering in situations where it is required for correct rendering or where it wil...
Definition qgis.h:2799
@ PreferVector
Prefer vector-based rendering, when the result will still be visually near-identical to a raster-base...
Definition qgis.h:2800
BlendMode
Blending modes defining the available composition modes that can be used when painting.
Definition qgis.h:5087
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:60
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:83
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:62
double y
Definition qgspointxy.h:66
double x
Definition qgspointxy.h:65
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:1393
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.