QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 #include "qgslayoutitemmap.h"
20 #include "qgslayout.h"
21 #include "qgssymbollayerutils.h"
22 #include "qgssymbol.h"
23 #include "qgsmapsettings.h"
24 #include "qgspainting.h"
25 #include "qgspathresolver.h"
26 #include "qgsreadwritecontext.h"
27 #include "qgslayoututils.h"
28 #include "qgsexception.h"
29 #include "qgsvectorlayer.h"
31 #include "qgsstyleentityvisitor.h"
32 
33 #include <QPainter>
34 
36  : QgsLayoutItemMapItem( name, map )
37  , mExtentLayer( qgis::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=EPSG:4326" ), QStringLiteral( "overview" ), QStringLiteral( "memory" ), QgsVectorLayer::LayerOptions( map && map->layout() && map->layout()->project() ? map->layout()->project()->transformContext() : QgsCoordinateTransformContext() ) ) )
38 {
39  createDefaultFrameSymbol();
40 }
41 
43 
44 void QgsLayoutItemMapOverview::createDefaultFrameSymbol()
45 {
46  QgsStringMap properties;
47  properties.insert( QStringLiteral( "color" ), QStringLiteral( "255,0,0,75" ) );
48  properties.insert( QStringLiteral( "style" ), QStringLiteral( "solid" ) );
49  properties.insert( QStringLiteral( "style_border" ), QStringLiteral( "no" ) );
50  mFrameSymbol.reset( QgsFillSymbol::createSimple( properties ) );
51 
52  mExtentLayer->setRenderer( new QgsSingleSymbolRenderer( mFrameSymbol->clone() ) );
53 }
54 
55 void QgsLayoutItemMapOverview::draw( QPainter *painter )
56 {
57  if ( !mEnabled || !mFrameMap || !mMap || !mMap->layout() )
58  {
59  return;
60  }
61  if ( !painter )
62  {
63  return;
64  }
65 
66  const QgsLayoutItemMap *overviewFrameMap = linkedMap();
67  if ( !overviewFrameMap )
68  {
69  return;
70  }
71 
72  //get polygon for other overview frame map's extent (use visibleExtentPolygon as it accounts for map rotation)
73  QPolygonF otherExtent = overviewFrameMap->visibleExtentPolygon();
74  if ( overviewFrameMap->crs() !=
75  mMap->crs() )
76  {
77  QgsGeometry g = QgsGeometry::fromQPolygonF( otherExtent );
78 
79  // reproject extent
80  QgsCoordinateTransform ct( overviewFrameMap->crs(),
81  mMap->crs(), mLayout->project() );
82  g = g.densifyByCount( 20 );
83  try
84  {
85  g.transform( ct );
86  }
87  catch ( QgsCsException & )
88  {
89  }
90 
91  otherExtent = g.asQPolygonF();
92  }
93 
94  //get current map's extent as a QPolygonF
95  QPolygonF thisExtent = mMap->visibleExtentPolygon();
96  //intersect the two
97  QPolygonF intersectExtent = thisExtent.intersected( otherExtent );
98 
99  //setup painter scaling to dots so that raster symbology is drawn to scale
100  double dotsPerMM = painter->device()->logicalDpiX() / 25.4;
101 
102  //setup render context
104  context.setForceVectorOutput( true );
105  QgsExpressionContext expressionContext = createExpressionContext();
106  context.setExpressionContext( expressionContext );
107 
108  painter->save();
109  painter->setCompositionMode( mBlendMode );
110  painter->translate( mMap->mXOffset, mMap->mYOffset );
111  painter->scale( 1 / dotsPerMM, 1 / dotsPerMM ); // scale painter from mm to dots
112  painter->setRenderHint( QPainter::Antialiasing );
113 
114  mFrameSymbol->startRender( context );
115 
116  //construct a polygon corresponding to the intersecting map extent
117  //need to scale line to dots, rather then mm, since the painter has been scaled to dots
118  QTransform mapTransform;
119  QPolygonF thisRectPoly = QPolygonF( QRectF( 0, 0, dotsPerMM * mMap->rect().width(), dotsPerMM * mMap->rect().height() ) );
120 
121  //workaround QT Bug #21329
122  thisRectPoly.pop_back();
123  thisExtent.pop_back();
124 
125  //create transform from map coordinates to painter coordinates
126  QTransform::quadToQuad( thisExtent, thisRectPoly, mapTransform );
127  QPolygonF intersectPolygon;
128  intersectPolygon = mapTransform.map( intersectExtent );
129 
130  QList<QPolygonF> rings; //empty list
131  if ( !mInverted )
132  {
133  //Render the intersecting map extent
134  mFrameSymbol->renderPolygon( intersectPolygon, &rings, nullptr, context );
135  }
136  else
137  {
138  //We are inverting the overview frame (ie, shading outside the intersecting extent)
139  //Construct a polygon corresponding to the overview map extent
140  QPolygonF outerPolygon;
141  outerPolygon << QPointF( 0, 0 )
142  << QPointF( mMap->rect().width() * dotsPerMM, 0 )
143  << QPointF( mMap->rect().width() * dotsPerMM, mMap->rect().height() * dotsPerMM )
144  << QPointF( 0, mMap->rect().height() * dotsPerMM )
145  << QPointF( 0, 0 );
146 
147  //Intersecting extent is an inner ring for the shaded area
148  rings.append( intersectPolygon );
149  mFrameSymbol->renderPolygon( outerPolygon, &rings, nullptr, context );
150  }
151 
152  mFrameSymbol->stopRender( context );
153  painter->restore();
154 }
155 
156 bool QgsLayoutItemMapOverview::writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const
157 {
158  if ( elem.isNull() )
159  {
160  return false;
161  }
162 
163  //overview map frame
164  QDomElement overviewFrameElem = doc.createElement( QStringLiteral( "ComposerMapOverview" ) );
165 
166  overviewFrameElem.setAttribute( QStringLiteral( "frameMap" ), mFrameMap ? mFrameMap ->uuid() : QString() );
167  overviewFrameElem.setAttribute( QStringLiteral( "blendMode" ), QgsPainting::getBlendModeEnum( mBlendMode ) );
168  overviewFrameElem.setAttribute( QStringLiteral( "inverted" ), mInverted );
169  overviewFrameElem.setAttribute( QStringLiteral( "centered" ), mCentered );
170 
171  QDomElement frameStyleElem = QgsSymbolLayerUtils::saveSymbol( QString(), mFrameSymbol.get(), doc, context );
172  overviewFrameElem.appendChild( frameStyleElem );
173 
174  bool ok = QgsLayoutItemMapItem::writeXml( overviewFrameElem, doc, context );
175  elem.appendChild( overviewFrameElem );
176  return ok;
177 }
178 
179 bool QgsLayoutItemMapOverview::readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context )
180 {
181  Q_UNUSED( doc )
182  if ( itemElem.isNull() )
183  {
184  return false;
185  }
186 
187  bool ok = QgsLayoutItemMapItem::readXml( itemElem, doc, context );
188 
189  mFrameMapUuid = itemElem.attribute( QStringLiteral( "frameMap" ) );
190  setLinkedMap( nullptr );
191 
192  mBlendMode = QgsPainting::getCompositionMode( static_cast< QgsPainting::BlendMode >( itemElem.attribute( QStringLiteral( "blendMode" ), QStringLiteral( "0" ) ).toUInt() ) );
193  mInverted = ( itemElem.attribute( QStringLiteral( "inverted" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) );
194  mCentered = ( itemElem.attribute( QStringLiteral( "centered" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) );
195 
196  QDomElement frameStyleElem = itemElem.firstChildElement( QStringLiteral( "symbol" ) );
197  if ( !frameStyleElem.isNull() )
198  {
199  mFrameSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( frameStyleElem, context ) );
200  }
201  return ok;
202 }
203 
205 {
206  if ( !mFrameMapUuid.isEmpty() )
207  {
208  setLinkedMap( qobject_cast< QgsLayoutItemMap * >( mLayout->itemByUuid( mFrameMapUuid, true ) ) );
209  }
210 }
211 
213 {
214  return mBlendMode != QPainter::CompositionMode_SourceOver;
215 }
216 
218 {
219  if ( mFrameMap == map )
220  {
221  //no change
222  return;
223  }
224 
225  //disconnect old map
226  if ( mFrameMap )
227  {
230  }
231  mFrameMap = map;
232  //connect to new map signals
233  connectSignals();
235 }
236 
238 {
239  return mFrameMap;
240 }
241 
243 {
244  if ( !mMap )
245  {
246  return;
247  }
248 
249  if ( mFrameMap )
250  {
253  }
254 }
255 
257 {
258  if ( !mEnabled || !mFrameMap || !mMap || !mMap->layout() )
259  {
260  return nullptr;
261  }
262 
263  const QgsLayoutItemMap *overviewFrameMap = linkedMap();
264  if ( !overviewFrameMap )
265  {
266  return nullptr;
267  }
268 
269  //get polygon for other overview frame map's extent (use visibleExtentPolygon as it accounts for map rotation)
270  QPolygonF otherExtent = overviewFrameMap->visibleExtentPolygon();
271  QgsGeometry g = QgsGeometry::fromQPolygonF( otherExtent );
272 
273  if ( overviewFrameMap->crs() != mMap->crs() )
274  {
275  // reproject extent
276  QgsCoordinateTransform ct( overviewFrameMap->crs(),
277  mMap->crs(), mLayout->project() );
278  g = g.densifyByCount( 20 );
279  try
280  {
281  g.transform( ct );
282  }
283  catch ( QgsCsException & )
284  {
285  }
286  }
287 
288  //get current map's extent as a QPolygonF
289  QPolygonF thisExtent = mMap->visibleExtentPolygon();
290  QgsGeometry thisGeom = QgsGeometry::fromQPolygonF( thisExtent );
291  //intersect the two
292  QgsGeometry intersectExtent = thisGeom.intersection( g );
293 
294  mExtentLayer->setBlendMode( mBlendMode );
295 
296  static_cast< QgsSingleSymbolRenderer * >( mExtentLayer->renderer() )->setSymbol( mFrameSymbol->clone() );
297  mExtentLayer->dataProvider()->truncate();
298  mExtentLayer->setCrs( mMap->crs() );
299 
300  if ( mInverted )
301  {
302  intersectExtent = thisGeom.difference( intersectExtent );
303  }
304 
305  QgsFeature f;
306  f.setGeometry( intersectExtent );
307  mExtentLayer->dataProvider()->addFeature( f );
308 
309  return mExtentLayer.get();
310 }
311 
313 {
314  if ( mFrameSymbol )
315  {
316  QgsStyleSymbolEntity entity( mFrameSymbol.get() );
317  if ( !visitor->visit( QgsStyleEntityVisitorInterface::StyleLeaf( &entity, QStringLiteral( "overview" ), QObject::tr( "Overview" ) ) ) )
318  return false;
319  }
320 
321  return true;
322 }
323 
325 {
326  mFrameSymbol.reset( symbol );
327 }
328 
330 {
331  return mFrameSymbol.get();
332 }
333 
335 {
336  return mFrameSymbol.get();
337 }
338 
339 void QgsLayoutItemMapOverview::setBlendMode( const QPainter::CompositionMode blendMode )
340 {
341  mBlendMode = blendMode;
342 }
343 
345 {
346  mInverted = inverted;
347 }
348 
350 {
351  mCentered = centered;
353 }
354 
356 {
357  if ( !mMap )
358  {
359  return;
360  }
361 
362  //if using overview centering, update the map's extent
363  if ( mMap->layout() && mCentered && mFrameMap )
364  {
365  QgsRectangle extent = mMap->extent();
366  QgsRectangle otherExtent = mFrameMap->extent();
367 
368  QgsPointXY center = otherExtent.center();
369  QgsRectangle movedExtent( center.x() - extent.width() / 2,
370  center.y() - extent.height() / 2,
371  center.x() - extent.width() / 2 + extent.width(),
372  center.y() - extent.height() / 2 + extent.height() );
373  mMap->setExtent( movedExtent );
374  }
375 
376  //repaint map so that overview gets updated
378 }
379 
380 
381 //
382 // QgsLayoutItemMapOverviewStack
383 //
384 
387 {
388 
389 }
390 
392 {
394 }
395 
396 void QgsLayoutItemMapOverviewStack::removeOverview( const QString &overviewId )
397 {
399 }
400 
401 void QgsLayoutItemMapOverviewStack::moveOverviewUp( const QString &overviewId )
402 {
404 }
405 
406 void QgsLayoutItemMapOverviewStack::moveOverviewDown( const QString &overviewId )
407 {
409 }
410 
412 {
414  return qobject_cast<QgsLayoutItemMapOverview *>( item );
415 }
416 
418 {
420  return qobject_cast<QgsLayoutItemMapOverview *>( item );
421 }
422 
424 {
425  QgsLayoutItemMapItem *item = mItems.at( idx );
427  return *overview;
428 }
429 
430 QList<QgsLayoutItemMapOverview *> QgsLayoutItemMapOverviewStack::asList() const
431 {
432  QList< QgsLayoutItemMapOverview * > list;
433  QList< QgsLayoutItemMapItem * >::const_iterator it = mItems.begin();
434  for ( ; it != mItems.end(); ++it )
435  {
437  if ( overview )
438  {
439  list.append( overview );
440  }
441  }
442  return list;
443 }
444 
445 bool QgsLayoutItemMapOverviewStack::readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context )
446 {
447  removeItems();
448 
449  //read overview stack
450  QDomNodeList mapOverviewNodeList = elem.elementsByTagName( QStringLiteral( "ComposerMapOverview" ) );
451  for ( int i = 0; i < mapOverviewNodeList.size(); ++i )
452  {
453  QDomElement mapOverviewElem = mapOverviewNodeList.at( i ).toElement();
454  QgsLayoutItemMapOverview *mapOverview = new QgsLayoutItemMapOverview( mapOverviewElem.attribute( QStringLiteral( "name" ) ), mMap );
455  mapOverview->readXml( mapOverviewElem, doc, context );
456  mItems.append( mapOverview );
457  }
458 
459  return true;
460 }
461 
462 QList<QgsMapLayer *> QgsLayoutItemMapOverviewStack::modifyMapLayerList( const QList<QgsMapLayer *> &layers )
463 {
464  QList<QgsMapLayer *> res = layers;
465  res.reserve( layers.count() + mItems.count() );
466  for ( QgsLayoutItemMapItem *item : qgis::as_const( mItems ) )
467  {
468  if ( !item )
469  continue;
470 
471  QgsVectorLayer *l = static_cast< QgsLayoutItemMapOverview * >( item )->asMapLayer();
472  if ( !l )
473  continue;
474 
475  switch ( item->stackingPosition() )
476  {
478  continue;
479 
482  {
483  QgsMapLayer *stackLayer = item->stackingLayer();
484  if ( !stackLayer )
485  continue;
486 
487  auto pos = std::find( res.begin(), res.end(), stackLayer );
488  if ( pos == res.end() )
489  continue;
490 
492  {
493  pos++;
494  if ( pos == res.end() )
495  {
496  res.push_back( l );
497  break;
498  }
499  }
500  res.insert( pos, l );
501  break;
502  }
503 
505  res.push_back( l );
506  break;
507 
509  res.push_front( l );
510  break;
511  }
512  }
513 
514  return res;
515 }
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
The class is used as a container of context for various read/write operations on other objects...
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map to show the overview extent of.
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Base class for all map layer types.
Definition: qgsmaplayer.h:79
A symbol entity for QgsStyle databases.
Definition: qgsstyle.h:971
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 moveOverviewUp(const QString &overviewId)
Moves an overview with matching overviewId up the stack, causing it to be rendered above other overvi...
void setFrameSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used for drawing the overview extent.
An individual overview which is drawn above the map content in a QgsLayoutItemMap, and shows the extent of another QgsLayoutItemMap.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
void setInverted(bool inverted)
Sets whether the overview frame is inverted, ie, whether the shaded area is drawn outside the extent ...
void setExtent(const QgsRectangle &extent)
Sets a new extent for the map.
QgsLayoutItemMapOverview(const QString &name, QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapOverview.
double y
Definition: qgspointxy.h:48
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
Definition: qgssymbol.cpp:1251
A class to represent a 2D point.
Definition: qgspointxy.h:43
void extentChanged()
Emitted when the map&#39;s extent changes.
void draw(QPainter *painter) override
Draws the item on to a destination painter.
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
Render above a specific map layer (see stackingLayer())
A collection of map items which are drawn above the map content in a QgsLayoutItemMap.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:122
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 &#39;Layout...
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
QList< QgsLayoutItemMapOverview *> asList() const
Returns a list of QgsLayoutItemMapOverviews contained by the stack.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
void invalidateCache() override
void finalizeRestoreFromXml() override
Called after all pending items have been restored from XML.
QgsFillSymbol * frameSymbol()
Returns the fill symbol used for drawing the overview extent.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
An interface for classes which can visit style entity (e.g.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the overview.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:612
void connectSignals()
Reconnects signals for overview map, so that overview correctly follows changes to source map&#39;s exten...
Render below a specific map layer (see stackingLayer())
void removeItems()
Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack.
QgsLayoutItemMapOverview * overview(const QString &overviewId) const
Returns a reference to an overview with matching overviewId within the stack.
Render above all map layers, but below map labels.
QgsLayoutItemMapOverview & operator[](int index)
Returns a reference to an overview at the specified index within the stack.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
void addOverview(QgsLayoutItemMapOverview *overview)
Adds a new map overview to the stack and takes ownership of the overview.
QgsLayoutItemMap * mMap
Associated map.
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
bool mEnabled
True if item is to be displayed on map.
QgsRectangle extent() const
Returns the current map extent.
Layout graphical items for displaying a map.
const QgsLayout * layout() const
Returns the layout the object is attached to.
double width() const
Returns the width of the rectangle.
Definition: qgsrectangle.h:202
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void addItem(QgsLayoutItemMapItem *item)
Adds a new map item to the stack and takes ownership of the item.
~QgsLayoutItemMapOverview() override
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
StackingPosition stackingPosition() const
Returns the item&#39;s stacking position, which specifies where the in the map&#39;s stack the item should be...
static QgsRenderContext createRenderContextForLayout(QgsLayout *layout, QPainter *painter, double dpi=-1)
Creates a render context suitable for the specified layout and painter destination.
QPointer< QgsLayout > mLayout
void moveOverviewDown(const QString &overviewId)
Moves an overview with matching overviewId down the stack, causing it to be rendered below other over...
QgsMapLayer * stackingLayer() const
Returns the item&#39;s stacking layer, which specifies where the in the map&#39;s stack the item should be re...
bool readXml(const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context) override
Sets the item stack&#39;s state from a DOM document, where element is a DOM node corresponding to a &#39;Layo...
Contains information about the context in which a coordinate transform is executed.
void moveItemUp(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items...
QgsLayoutItemMapItem * item(int index) const
Returns a reference to the item at the specified index within the stack.
void setCentered(bool centered)
Sets whether the extent of the map is forced to center on the overview.
double x
Definition: qgspointxy.h:47
QPolygonF visibleExtentPolygon() const
Returns a polygon representing the current visible map extent, considering map extents and rotation...
void mapRotationChanged(double newRotation)
Emitted when the map&#39;s rotation changes.
const QgsLayoutItemMap * map() const
Returns the layout item map for the item.
QgsLayoutItemMapOverviewStack(QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapOverviewStack, attached to the specified 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 &#39;Layout...
void removeOverview(const QString &overviewId)
Removes an overview with matching overviewId from the stack and deletes the corresponding QgsLayoutIt...
Contains information about the context of a rendering operation.
void overviewExtentChanged()
Handles recentering of the map and redrawing of the map&#39;s overview.
bool usesAdvancedEffects() const override
Returns true if the item is drawn using advanced effects, such as blend modes.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used for rendering the map.
void setGeometry(const QgsGeometry &geometry)
Set the feature&#39;s geometry.
Definition: qgsfeature.cpp:137
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
Class for doing transforms between two map coordinate systems.
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgssymbol.h:1155
void removeItem(const QString &itemId)
Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapIt...
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:65
QgsVectorLayer * asMapLayer()
Returns a vector layer to render as part of the QgsLayoutItemMap render, containing a feature represe...
QgsPointXY center() const
Returns the center point of the rectangle.
Definition: qgsrectangle.h:230
void moveItemDown(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items...
QList< QgsLayoutItemMapItem *> mItems
Represents a vector layer which manages a vector based data sets.
Contains information relating to the style entity currently being visited.
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 &#39;LayoutMa...
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
Render above all map layers and labels.
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 &#39;LayoutMa...
double height() const
Returns the height of the rectangle.
Definition: qgsrectangle.h:209
QgsLayoutItemMap * linkedMap()
Returns the source map to show the overview extent of.
Render below all map layers.
QgsGeometry difference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...