17 #ifndef QGSLAYOUTITEMMAP_H
18 #define QGSLAYOUTITEMMAP_H
20 #include "qgis_core.h"
62 void setEnabled(
bool enabled );
83 bool forceLabelsInsideFeature()
const;
90 void setForceLabelsInsideFeature(
bool forceInside );
98 bool restrictToLayers()
const;
106 void setRestrictToLayers(
bool enabled );
116 QList< QgsMapLayer * > layersToClip()
const;
126 void setLayersToClip(
const QList< QgsMapLayer * > &layers );
133 bool writeXml( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const;
140 bool readXml(
const QDomElement &element,
const QDomDocument &doc,
const QgsReadWriteContext &context );
150 void layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers );
155 bool mClipToAtlasFeature =
false;
156 bool mRestrictToLayers =
false;
157 QList< QgsMapLayerRef > mLayersToClip;
159 bool mForceLabelsInsideFeature =
false;
186 bool isActive()
const;
193 bool enabled()
const;
200 void setEnabled(
bool enabled );
261 bool forceLabelsInsideClipPath()
const;
268 void setForceLabelsInsideClipPath(
bool forceInside );
275 bool writeXml( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const;
283 bool readXml(
const QDomElement &element,
const QDomDocument &doc,
const QgsReadWriteContext &context );
289 void finalizeRestoreFromXml();
301 bool mEnabled =
false;
303 bool mForceLabelsInsideClipPath =
false;
305 QPointer< QgsLayoutItem > mClipPathSource;
306 QString mClipPathUuid;
353 ShowPartialLabels = 1 << 0,
354 ShowUnplacedLabels = 1 << 1,
356 Q_DECLARE_FLAGS( MapItemFlags, MapItemFlag )
364 int type()
const override;
365 QIcon icon()
const override;
366 QgsLayoutItem::Flags itemFlags()
const override;
373 QgsLayoutItemMap::MapItemFlags mapFlags()
const;
380 void setMapFlags( QgsLayoutItemMap::MapItemFlags flags );
388 QString displayName()
const override;
398 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
399 Q_DECL_DEPRECATED
int numberExportLayers() const override
SIP_DEPRECATED;
400 void startLayeredExport() override;
401 void stopLayeredExport() override;
402 bool nextExportPart() override;
403 ExportLayerBehavior exportLayerBehavior() const override;
404 QgsLayoutItem::ExportLayerDetail exportLayerDetails() const override;
412 double scale() const;
421 void setScale(
double scale,
bool forceUpdate = true );
456 QPolygonF visibleExtentPolygon() const;
513 QList<QgsMapLayer *> layers()
const;
521 void setLayers(
const QList<QgsMapLayer *> &layers );
545 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
550 void storeCurrentLayerStyles();
567 void setFollowVisibilityPreset(
bool follow );
584 void setFollowVisibilityPresetName(
const QString &name );
586 void moveContent(
double dx,
double dy )
override;
587 void setMoveContentPreviewOffset(
double dx,
double dy )
override;
589 void zoomContent(
double factor, QPointF point )
override;
593 bool containsWmsLayer()
const;
595 bool requiresRasterization()
const override;
596 bool containsAdvancedEffects()
const override;
604 void setMapRotation(
double rotation );
643 void setAtlasDriven(
bool enabled );
747 double mapUnitsToLayoutUnits()
const;
758 void finalizeRestoreFromXml()
override;
838 QTransform layoutToMapCoordsTransform()
const;
857 bool writePropertiesToElement( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const override;
858 bool readPropertiesFromElement(
const QDomElement &element,
const QDomDocument &document,
const QgsReadWriteContext &context )
override;
859 QPainterPath framePath()
const override;
865 QRectF boundingRect()
const override;
868 QPolygonF transformedMapPolygon()
const;
871 QPointF mapToItemCoords( QPointF mapCoords )
const;
922 void refresh()
override;
924 void invalidateCache()
override;
927 void updateBoundingRect();
932 void layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers );
934 void painterJobFinished();
938 void mapThemeChanged(
const QString &theme );
941 void currentMapThemeRenamed(
const QString &theme,
const QString &newTheme );
944 void recreateCachedImageInBackground();
946 void updateAtlasFeature();
949 QgsLayoutItemMap::MapItemFlags mMapFlags = QgsLayoutItemMap::MapItemFlags();
954 std::unique_ptr< QgsLayoutItemMapGridStack > mGridStack;
955 std::unique_ptr< QgsLayoutItemMapOverviewStack > mOverviewStack;
977 std::unique_ptr< QImage > mCacheFinalImage;
978 std::unique_ptr< QImage > mCacheRenderingImage;
979 bool mUpdatesEnabled =
true;
982 bool mCacheInvalidated =
true;
985 int mNumCachedLayers;
988 bool mDrawing =
false;
990 QTimer *mBackgroundUpdateTimer =
nullptr;
991 double mPreviewScaleFactor = 0;
993 bool mDrawingPreview =
false;
996 double mXOffset = 0.0;
998 double mYOffset = 0.0;
1000 double mLastRenderedImageOffsetX = 0.0;
1001 double mLastRenderedImageOffsetY = 0.0;
1004 double mMapRotation = 0;
1010 double mEvaluatedMapRotation = 0;
1013 bool mKeepLayerSet =
false;
1016 QList< QgsMapLayerRef > mLayers;
1018 bool mKeepLayerStyles =
false;
1020 QMap<QString, QString> mLayerStyleOverrides;
1023 mutable QString mCachedLayerStyleOverridesPresetName;
1025 mutable QMap<QString, QString> mCachedPresetLayerStyleOverrides;
1032 bool mFollowVisibilityPreset =
false;
1038 QString mFollowVisibilityPresetName;
1041 QString mLastEvaluatedThemeName;
1050 void drawMap( QPainter *painter,
const QgsRectangle &extent, QSizeF size,
double dpi );
1053 void connectUpdateSlot();
1056 void syncLayerSet();
1068 QList< QgsLabelBlockingRegion > createLabelBlockingRegions(
const QgsMapSettings &mapSettings )
const;
1071 QRectF mCurrentRectangle;
1073 bool mDrawAnnotations =
true;
1076 bool mAtlasDriven =
false;
1080 double mAtlasMargin = 0.10;
1082 std::unique_ptr< QPainter > mPainter;
1083 std::unique_ptr< QgsMapRendererCustomPainterJob > mPainterJob;
1084 bool mPainterCancelWait =
false;
1089 QStringList mBlockingLabelItemUuids;
1090 QList< QPointer< QgsLayoutItem > > mBlockingLabelItems;
1095 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
1097 std::unique_ptr< QgsMapRendererStagedRenderJob > mStagedRendererJob;
1102 void updateToolTip();
1107 QMap<QString, QString> layerStyleOverridesToRender(
const QgsExpressionContext &context )
const;
1113 void mapPolygon(
const QgsRectangle &extent, QPolygonF &poly )
const;
1120 void transformShift(
double &xShift,
double &yShift )
const;
1122 void drawAnnotations( QPainter *painter );
1124 QPointF layoutMapPosForItem(
const QgsAnnotation *item )
const;
1126 void drawMapFrame( QPainter *p );
1127 void drawMapBackground( QPainter *p );
1143 bool shouldDrawPart( PartType part )
const;
1145 PartType mCurrentExportPart = NotLayered;
1146 QStringList mExportThemes;
1147 QStringList::iterator mExportThemeIt;
1158 void refreshLabelMargin(
bool updateItem );
1162 void createStagedRenderJob(
const QgsRectangle &extent,
const QSizeF size,
double dpi );
1164 QPolygonF calculateVisibleExtentPolygon(
bool includeClipping )
const;
1169 friend class TestQgsLayoutMap;
1171 friend class QgsGeoPdfRenderedFeatureHandler;
Abstract base class for annotation items which are drawn over a map.
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
This class represents a coordinate reference system (CRS).
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 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...
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.
QMap< QString, QString > layerStyleOverrides() const
Returns stored overrides of styles for layers.
void setDrawAnnotations(bool draw)
Sets whether annotations are drawn within the map.
bool followVisibilityPreset() const
Returns whether the map should follow a map theme.
void crsChanged()
Emitted when the map's coordinate reference system is changed.
QgsLayoutItemMapItemClipPathSettings * itemClippingSettings()
Returns the map's item based clip path settings.
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.
AtlasScalingMode atlasScalingMode() const
Returns the current atlas scaling mode.
void setAtlasScalingMode(AtlasScalingMode mode)
Sets the current atlas scaling mode.
QgsLayoutItemMapAtlasClippingSettings * atlasClippingSettings()
Returns the map's atlas clipping settings.
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.
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...
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.
Contains settings and helpers relating to a render of a QgsLayoutItem.
Base class for graphical items within a QgsLayout.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
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
The QgsMapSettings class contains configuration for rendering of the map.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
An interface for classes which provider custom handlers for features rendered as part of a map render...
An interface for classes which can visit style entity (e.g.
Base class for objects with an associated (optional) temporal range.
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
const QgsCoordinateReferenceSystem & crs