17 #ifndef QGSLAYOUTITEMMAP_H 18 #define QGSLAYOUTITEMMAP_H 20 #include "qgis_core.h" 72 int type()
const override;
73 QIcon
icon()
const override;
91 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
100 double scale()
const;
109 void setScale(
double scale,
bool forceUpdate =
true );
144 QPolygonF visibleExtentPolygon()
const;
201 QList<QgsMapLayer *> layers()
const;
209 void setLayers(
const QList<QgsMapLayer *> &layers );
233 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
238 void storeCurrentLayerStyles();
273 void zoomContent(
double factor, QPointF point )
override;
277 bool containsWmsLayer()
const;
288 void setMapRotation(
double rotation );
327 void setAtlasDriven(
bool enabled );
407 double mapUnitsToLayoutUnits()
const;
430 QRectF boundingRect()
const override;
433 QPolygonF transformedMapPolygon()
const;
436 QPointF mapToItemCoords( QPointF mapCoords )
const;
450 void extentChanged();
457 void mapRotationChanged(
double newRotation );
460 void preparedForAtlas();
466 void layerStyleOverridesChanged();
475 void updateBoundingRect();
480 void layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers );
482 void painterJobFinished();
486 void mapThemeChanged(
const QString &theme );
489 void recreateCachedImageInBackground();
497 std::unique_ptr< QgsLayoutItemMapGridStack > mGridStack;
498 std::unique_ptr< QgsLayoutItemMapOverviewStack > mOverviewStack;
520 std::unique_ptr< QImage > mCacheFinalImage;
521 std::unique_ptr< QImage > mCacheRenderingImage;
522 bool mUpdatesEnabled =
true;
525 bool mCacheInvalidated =
true;
528 int mNumCachedLayers;
531 bool mDrawing =
false;
533 QTimer *mBackgroundUpdateTimer =
nullptr;
534 double mPreviewScaleFactor = 0;
536 bool mDrawingPreview =
false;
539 double mXOffset = 0.0;
541 double mYOffset = 0.0;
543 double mLastRenderedImageOffsetX = 0.0;
544 double mLastRenderedImageOffsetY = 0.0;
547 double mMapRotation = 0;
552 double mEvaluatedMapRotation = 0;
555 bool mKeepLayerSet =
false;
558 QList< QgsMapLayerRef > mLayers;
560 bool mKeepLayerStyles =
false;
562 QMap<QString, QString> mLayerStyleOverrides;
565 mutable QString mCachedLayerStyleOverridesPresetName;
567 mutable QMap<QString, QString> mCachedPresetLayerStyleOverrides;
573 bool mFollowVisibilityPreset =
false;
578 QString mFollowVisibilityPresetName;
587 void drawMap( QPainter *painter,
const QgsRectangle &extent, QSizeF size,
double dpi );
590 void connectUpdateSlot();
602 QRectF mCurrentRectangle;
604 bool mDrawAnnotations =
true;
607 bool mAtlasDriven =
false;
611 double mAtlasMargin = 0.10;
613 std::unique_ptr< QPainter > mPainter;
614 std::unique_ptr< QgsMapRendererCustomPainterJob > mPainterJob;
615 bool mPainterCancelWait =
false;
620 void updateToolTip();
626 QMap<QString, QString> layerStyleOverridesToRender(
const QgsExpressionContext &context )
const;
632 void mapPolygon(
const QgsRectangle &extent, QPolygonF &poly )
const;
639 void transformShift(
double &xShift,
double &yShift )
const;
641 void drawAnnotations( QPainter *painter );
643 QPointF layoutMapPosForItem(
const QgsAnnotation *item )
const;
645 void drawMapFrame( QPainter *p );
646 void drawMapBackground( QPainter *p );
659 bool shouldDrawPart( PartType part )
const;
667 void updateAtlasFeature();
674 friend class TestQgsLayoutMap;
679 #endif //QGSLAYOUTITEMMAP_H The class is used as a container of context for various read/write operations on other objects...
bool isDrawing() const
True if a draw is already in progress.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
bool followVisibilityPreset() const
Returns whether the map should follow a map theme.
virtual QIcon icon() const
Returns the item's icon.
void setFollowVisibilityPresetName(const QString &name)
Sets preset name for map rendering.
A rectangle specified with double values.
AtlasScalingMode atlasScalingMode() const
Returns the current atlas scaling mode.
Base class for graphical items within a QgsLayout.
An individual overview which is drawn above the map content in a QgsLayoutItemMap, and shows the extent of another QgsLayoutItemMap.
int type() const override
Returns a unique graphics item type identifier.
virtual bool containsAdvancedEffects() const
Returns true if the item contains contents with blend modes or transparency effects which can only be...
void setKeepLayerStyles(bool enabled)
Sets whether current styles of layers should be overridden by previously stored styles.
bool keepLayerStyles() const
Returns whether current styles of layers should be overridden by previously stored styles...
A collection of overviews which are drawn above the map content in a QgsLayoutItemMap.
bool drawAnnotations() const
Returns whether annotations are drawn within the map.
void setKeepLayerSet(bool enabled)
Sets whether the stored layer set should be used or the current layer set of the associated project...
Abstract base class for annotation items which are drawn over a map.
The QgsMapSettings class contains configuration for rendering of the map.
PropertyValueType
Specifies whether the value returned by a function should be the original, user set value...
virtual void invalidateCache()
Forces a deferred update of any cached image the item uses.
Layout graphical items for displaying a map.
A collection of grids which is drawn above the map content in a QgsLayoutItemMap. ...
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
Handles preparing a paint surface for the layout item and painting the item's content.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual int numberExportLayers() const
Returns the number of layers that this item requires for exporting during layered exports (e...
virtual void setFrameStrokeWidth(const QgsLayoutMeasurement &width)
Sets the frame stroke width.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
void setAtlasScalingMode(AtlasScalingMode mode)
Sets the current atlas scaling mode.
virtual bool requiresRasterization() const
Returns true if the item is drawn in such a way that forces the whole layout to be rasterized when ex...
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
bool keepLayerSet() const
Returns whether a stored layer set should be used or the current layer set from the project associate...
Contains settings and helpers relating to a render of a QgsLayoutItem.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
void setAtlasMargin(double margin)
Sets the margin size (percentage) used when the map is in atlas mode.
virtual QString displayName() const
Get item display name.
void setFollowVisibilityPreset(bool follow)
Sets whether the map should follow a map theme.
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
Return the current evaluated value for the property.
Contains information about the context of a rendering operation.
QgsCoordinateReferenceSystem presetCrs() const
Returns the map's preset coordinate reference system.
void setDrawAnnotations(bool draw)
Sets whether annotations are drawn within the map.
virtual void setMoveContentPreviewOffset(double dx, double dy)
Sets temporary offset for the item, by a specified dx and dy in layout units.
The current scale of the map is used for each feature of the atlas.
virtual void moveContent(double dx, double dy)
Moves the content of the item, by a specified dx and dy in layout units.
This class represents a coordinate reference system (CRS).
virtual void zoomContent(double factor, QPointF point)
Zooms content of item.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
virtual void refreshDataDefinedProperty(const QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties)
Refreshes a data defined property for the item by reevaluating the property's value and redrawing the...
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
bool atlasDriven() const
Returns whether the map extent is set to follow the current atlas feature.
AtlasScalingMode
Scaling modes used for the serial rendering (atlas)
A layout item subclass for map legends.
QString followVisibilityPresetName() const
Preset name that decides which layers and layer styles are used for map rendering.
DataDefinedProperty
Data defined properties for different item types.
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...
QgsLayoutItemMapOverviewStack * overviews()
Returns the map item's overview stack, which is used to control how overviews are drawn over the map'...
QgsLayoutItemMapGridStack * grids()
Returns the map item's grid stack, which is used to control how grids are drawn over the map's conten...
A scale is chosen from the predefined scales.
QMap< QString, QString > layerStyleOverrides() const
Returns stored overrides of styles for layers.