17#ifndef QGSLAYOUTITEMMAP_H
18#define QGSLAYOUTITEMMAP_H
64 void setEnabled(
bool enabled );
85 bool forceLabelsInsideFeature()
const;
92 void setForceLabelsInsideFeature(
bool forceInside );
100 bool restrictToLayers()
const;
108 void setRestrictToLayers(
bool enabled );
118 QList< QgsMapLayer * > layersToClip()
const;
128 void setLayersToClip(
const QList< QgsMapLayer * > &layers );
135 bool writeXml( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const;
142 bool readXml(
const QDomElement &element,
const QDomDocument &doc,
const QgsReadWriteContext &context );
152 void layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers );
157 bool mClipToAtlasFeature =
false;
158 bool mRestrictToLayers =
false;
159 QList< QgsMapLayerRef > mLayersToClip;
161 bool mForceLabelsInsideFeature =
false;
188 bool isActive()
const;
195 bool enabled()
const;
202 void setEnabled(
bool enabled );
263 bool forceLabelsInsideClipPath()
const;
270 void setForceLabelsInsideClipPath(
bool forceInside );
277 bool writeXml( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const;
285 bool readXml(
const QDomElement &element,
const QDomDocument &doc,
const QgsReadWriteContext &context );
291 void finalizeRestoreFromXml();
303 bool mEnabled =
false;
305 bool mForceLabelsInsideClipPath =
false;
307 QPointer< QgsLayoutItem > mClipPathSource;
308 QString mClipPathUuid;
361 ShowPartialLabels = 1 << 0,
362 ShowUnplacedLabels = 1 << 1,
372 int type()
const override;
373 QIcon icon()
const override;
396 QString displayName()
const override;
406 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
411 Q_DECL_DEPRECATED
int numberExportLayers() const override
SIP_DEPRECATED;
413 void startLayeredExport() override;
414 void stopLayeredExport() override;
415 bool nextExportPart() override;
425 double scale() const;
434 void setScale(
double scale,
bool forceUpdate = true );
469 QPolygonF visibleExtentPolygon() const;
526 QList<QgsMapLayer *> layers()
const;
537 void setLayers(
const QList<QgsMapLayer *> &layers );
561 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
566 void storeCurrentLayerStyles();
583 void setFollowVisibilityPreset(
bool follow );
600 void setFollowVisibilityPresetName(
const QString &name );
602 void moveContent(
double dx,
double dy )
override;
603 void setMoveContentPreviewOffset(
double dx,
double dy )
override;
605 void zoomContent(
double factor, QPointF point )
override;
609 bool containsWmsLayer()
const;
611 bool requiresRasterization()
const override;
612 bool containsAdvancedEffects()
const override;
620 void setMapRotation(
double rotation );
659 void setAtlasDriven(
bool enabled );
763 double mapUnitsToLayoutUnits()
const;
774 void finalizeRestoreFromXml()
override;
863 QTransform layoutToMapCoordsTransform()
const;
886 void setZRangeEnabled(
bool enabled );
896 bool zRangeEnabled()
const;
923 double estimatedFrameBleed()
const override;
928 bool writePropertiesToElement( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const override;
929 bool readPropertiesFromElement(
const QDomElement &element,
const QDomDocument &document,
const QgsReadWriteContext &context )
override;
930 QPainterPath framePath()
const override;
936 QRectF boundingRect()
const override;
939 QPolygonF transformedMapPolygon()
const;
942 QPointF mapToItemCoords( QPointF mapCoords )
const;
1000 void refresh()
override;
1002 void invalidateCache()
override;
1005 void updateBoundingRect();
1010 void layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers );
1012 void painterJobFinished();
1014 void shapeChanged();
1016 void mapThemeChanged(
const QString &theme );
1019 void currentMapThemeRenamed(
const QString &theme,
const QString &newTheme );
1022 void recreateCachedImageInBackground();
1024 void updateAtlasFeature();
1032 std::unique_ptr< QgsLayoutItemMapGridStack > mGridStack;
1033 std::unique_ptr< QgsLayoutItemMapOverviewStack > mOverviewStack;
1055 std::unique_ptr< QImage > mCacheFinalImage;
1056 std::unique_ptr< QImage > mCacheRenderingImage;
1057 bool mUpdatesEnabled =
true;
1060 bool mCacheInvalidated =
true;
1063 int mNumCachedLayers;
1066 bool mDrawing =
false;
1068 QTimer *mBackgroundUpdateTimer =
nullptr;
1069 double mPreviewScaleFactor = 0;
1070 double mPreviewDevicePixelRatio = 1.0;
1072 bool mDrawingPreview =
false;
1075 double mXOffset = 0.0;
1077 double mYOffset = 0.0;
1079 double mLastRenderedImageOffsetX = 0.0;
1080 double mLastRenderedImageOffsetY = 0.0;
1083 double mMapRotation = 0;
1089 double mEvaluatedMapRotation = 0;
1091 bool mZRangeEnabled =
false;
1095 bool mKeepLayerSet =
false;
1098 QList< QgsMapLayerRef > mLayers;
1100 bool mKeepLayerStyles =
false;
1102 QMap<QString, QString> mLayerStyleOverrides;
1105 mutable QString mCachedLayerStyleOverridesPresetName;
1107 mutable QMap<QString, QString> mCachedPresetLayerStyleOverrides;
1114 bool mFollowVisibilityPreset =
false;
1120 QString mFollowVisibilityPresetName;
1123 QString mLastEvaluatedThemeName;
1132 void drawMap( QPainter *painter,
const QgsRectangle &extent, QSizeF size,
double dpi );
1135 void connectUpdateSlot();
1138 void syncLayerSet();
1150 QList< QgsLabelBlockingRegion > createLabelBlockingRegions(
const QgsMapSettings &mapSettings )
const;
1153 QRectF mCurrentRectangle;
1155 bool mDrawAnnotations =
true;
1158 bool mAtlasDriven =
false;
1162 double mAtlasMargin = 0.10;
1164 std::unique_ptr< QPainter > mPainter;
1165 std::unique_ptr< QgsMapRendererCustomPainterJob > mPainterJob;
1166 bool mPainterCancelWait =
false;
1171 QStringList mBlockingLabelItemUuids;
1172 QList< QPointer< QgsLayoutItem > > mBlockingLabelItems;
1177 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
1179 std::unique_ptr< QgsMapRendererStagedRenderJob > mStagedRendererJob;
1181 std::unique_ptr< QgsLabelingResults > mPreviewLabelingResults;
1182 std::unique_ptr< QgsLabelingResults > mExportLabelingResults;
1187 void updateToolTip();
1192 QMap<QString, QString> layerStyleOverridesToRender(
const QgsExpressionContext &context )
const;
1198 void mapPolygon(
const QgsRectangle &extent, QPolygonF &poly )
const;
1205 void transformShift(
double &xShift,
double &yShift )
const;
1207 void drawAnnotations( QPainter *painter );
1209 QPointF layoutMapPosForItem(
const QgsAnnotation *item )
const;
1211 void drawMapFrame( QPainter *p );
1212 void drawMapBackground( QPainter *p );
1228 bool shouldDrawPart( PartType part )
const;
1230 PartType mCurrentExportPart = NotLayered;
1231 QStringList mExportThemes;
1232 QStringList::iterator mExportThemeIt;
1237 std::unique_ptr<QgsGroupedFeatureFilterProvider> mAtlasFeatureFilterProvider;
1245 void refreshLabelMargin(
bool updateItem );
1249 void createStagedRenderJob(
const QgsRectangle &extent,
const QSizeF size,
double dpi );
1251 QPolygonF calculateVisibleExtentPolygon(
bool includeClipping )
const;
1256 std::map<QString, std::unique_ptr<QgsGroupLayer>> mGroupLayers;
1261 friend class TestQgsLayoutMap;
1263 friend class QgsGeospatialPdfRenderedFeatureHandler;
Abstract base class for annotation items which are drawn over a map.
Converts a QGIS 2.x composition to a QGIS 3.x layout.
Represents a coordinate reference system (CRS).
QgsRange which stores a range of double values.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A geometry is the spatial representation of a feature.
A filter filter provider grouping several filter providers.
Stores computed placement from labeling engine.
Handles rendering and exports of layouts to various formats.
A layout item subclass for map legends.
Contains settings relating to clipping a layout map by the current atlas feature.
void changed()
Emitted when the atlas clipping settings are changed.
A collection of grids which is drawn above the map content in a QgsLayoutItemMap.
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
Contains settings relating to clipping a layout map by another layout item.
void changed()
Emitted when the item clipping settings are changed.
A collection of overviews which are drawn above the map content in a QgsLayoutItemMap.
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
Layout graphical items for displaying a map.
void extentChanged()
Emitted when the map's extent changes.
void preparedForAtlas()
Emitted when the map has been prepared for atlas rendering, just before actual rendering.
QgsMapRendererJob::Errors renderingErrors() const
Returns map rendering errors.
bool keepLayerSet() const
Returns whether a stored layer set should be used or the current layer set from the project associate...
void setKeepLayerSet(bool enabled)
Sets whether the stored layer set should be used or the current layer set of the associated project.
AtlasScalingMode
Scaling modes used for the serial rendering (atlas)
@ Predefined
A scale is chosen from the predefined scales.
@ Fixed
The current scale of the map is used for each feature of the atlas.
void layerStyleOverridesChanged()
Emitted when layer style overrides are changed... a means to let associated legend items know they sh...
void mapRotationChanged(double newRotation)
Emitted when the map's rotation changes.
bool isDrawing() const
True if a draw is already in progress.
QString followVisibilityPresetName() const
Preset name that decides which layers and layer styles are used for map rendering.
void previewRefreshed()
Emitted whenever the item's map preview has been refreshed.
void setDrawAnnotations(bool draw)
Sets whether annotations are drawn within the map.
QFlags< MapItemFlag > MapItemFlags
bool followVisibilityPreset() const
Returns whether the map should follow a map theme.
void crsChanged()
Emitted when the map's coordinate reference system is changed.
QgsLayoutItemMapOverviewStack * overviews()
Returns the map item's overview stack, which is used to control how overviews are drawn over the map'...
bool atlasDriven() const
Returns whether the map extent is set to follow the current atlas feature.
bool keepLayerStyles() const
Returns whether current styles of layers should be overridden by previously stored styles.
QMap< QString, QString > layerStyleOverrides() const
Returns stored overrides of styles for layers.
AtlasScalingMode atlasScalingMode() const
Returns the current atlas scaling mode.
void setAtlasScalingMode(AtlasScalingMode mode)
Sets the current atlas scaling mode.
void themeChanged(const QString &theme)
Emitted when the map's associated theme is changed.
MapItemFlag
Various flags that affect drawing of map items.
bool drawAnnotations() const
Returns whether annotations are drawn within 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...
QgsLayoutItemMapAtlasClippingSettings * atlasClippingSettings()
Returns the map's atlas clipping settings.
void setAtlasMargin(double margin)
Sets the margin size (percentage) used when the map is in atlas mode.
void setKeepLayerStyles(bool enabled)
Sets whether current styles of layers should be overridden by previously stored styles.
QgsLayoutItemMapItemClipPathSettings * itemClippingSettings()
Returns the map's item based clip path settings.
Contains settings and helpers relating to a render of a QgsLayoutItem.
Base class for graphical items within a QgsLayout.
ExportLayerBehavior
Behavior of item when exporting to layered outputs.
Provides a method of storing measurements for use in QGIS layouts using a variety of different measur...
DataDefinedProperty
Data defined properties for different item types.
@ AllProperties
All properties for item.
PropertyValueType
Specifies whether the value returned by a function should be the original, user set value,...
@ EvaluatedValue
Return the current evaluated value for the property.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
A map clipping region (in map coordinates and CRS).
FeatureClippingType
Feature clipping behavior, which controls how features from vector layers will be clipped.
@ ClipPainterOnly
Applying clipping on the painter only (i.e. feature boundaries will be unchanged, but may be invisibl...
QList< QgsMapRendererJob::Error > Errors
Contains configuration for rendering maps.
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
An interface for classes which provide custom handlers for features rendered as part of a map render ...
A boolean settings entry.
An interface for classes which can visit style entity (e.g.
Base class for objects with an associated (optional) temporal range.
#define SIP_ENUM_BASETYPE(type)
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)
const QgsCoordinateReferenceSystem & crs
Contains details of a particular export layer relating to a layout item.