QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
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 );
398 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
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;
524 void setLayers(
const QList<QgsMapLayer *> &layers );
548 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
553 void storeCurrentLayerStyles();
570 void setFollowVisibilityPreset(
bool follow );
587 void setFollowVisibilityPresetName(
const QString &name );
592 void zoomContent(
double factor, QPointF point )
override;
596 bool containsWmsLayer()
const;
607 void setMapRotation(
double rotation );
646 void setAtlasDriven(
bool enabled );
750 double mapUnitsToLayoutUnits()
const;
850 QTransform layoutToMapCoordsTransform()
const;
877 QRectF boundingRect()
const override;
880 QPolygonF transformedMapPolygon()
const;
883 QPointF mapToItemCoords( QPointF mapCoords )
const;
897 void extentChanged();
904 void mapRotationChanged(
double newRotation );
907 void preparedForAtlas();
913 void layerStyleOverridesChanged();
923 void themeChanged(
const QString &theme );
937 void previewRefreshed();
946 void updateBoundingRect();
951 void layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers );
953 void painterJobFinished();
957 void mapThemeChanged(
const QString &theme );
960 void currentMapThemeRenamed(
const QString &theme,
const QString &newTheme );
963 void recreateCachedImageInBackground();
965 void updateAtlasFeature();
968 QgsLayoutItemMap::MapItemFlags mMapFlags = QgsLayoutItemMap::MapItemFlags();
973 std::unique_ptr< QgsLayoutItemMapGridStack > mGridStack;
974 std::unique_ptr< QgsLayoutItemMapOverviewStack > mOverviewStack;
996 std::unique_ptr< QImage > mCacheFinalImage;
997 std::unique_ptr< QImage > mCacheRenderingImage;
998 bool mUpdatesEnabled =
true;
1001 bool mCacheInvalidated =
true;
1004 int mNumCachedLayers;
1007 bool mDrawing =
false;
1009 QTimer *mBackgroundUpdateTimer =
nullptr;
1010 double mPreviewScaleFactor = 0;
1012 bool mDrawingPreview =
false;
1015 double mXOffset = 0.0;
1017 double mYOffset = 0.0;
1019 double mLastRenderedImageOffsetX = 0.0;
1020 double mLastRenderedImageOffsetY = 0.0;
1023 double mMapRotation = 0;
1029 double mEvaluatedMapRotation = 0;
1032 bool mKeepLayerSet =
false;
1035 QList< QgsMapLayerRef > mLayers;
1037 bool mKeepLayerStyles =
false;
1039 QMap<QString, QString> mLayerStyleOverrides;
1042 mutable QString mCachedLayerStyleOverridesPresetName;
1044 mutable QMap<QString, QString> mCachedPresetLayerStyleOverrides;
1051 bool mFollowVisibilityPreset =
false;
1057 QString mFollowVisibilityPresetName;
1060 QString mLastEvaluatedThemeName;
1069 void drawMap( QPainter *painter,
const QgsRectangle &extent, QSizeF size,
double dpi );
1072 void connectUpdateSlot();
1075 void syncLayerSet();
1087 QList< QgsLabelBlockingRegion > createLabelBlockingRegions(
const QgsMapSettings &mapSettings )
const;
1090 QRectF mCurrentRectangle;
1092 bool mDrawAnnotations =
true;
1095 bool mAtlasDriven =
false;
1097 AtlasScalingMode mAtlasScalingMode = Auto;
1099 double mAtlasMargin = 0.10;
1101 std::unique_ptr< QPainter > mPainter;
1102 std::unique_ptr< QgsMapRendererCustomPainterJob > mPainterJob;
1103 bool mPainterCancelWait =
false;
1108 QStringList mBlockingLabelItemUuids;
1109 QList< QPointer< QgsLayoutItem > > mBlockingLabelItems;
1114 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
1116 std::unique_ptr< QgsMapRendererStagedRenderJob > mStagedRendererJob;
1118 std::unique_ptr< QgsLabelingResults > mPreviewLabelingResults;
1119 std::unique_ptr< QgsLabelingResults > mExportLabelingResults;
1124 void updateToolTip();
1129 QMap<QString, QString> layerStyleOverridesToRender(
const QgsExpressionContext &context )
const;
1135 void mapPolygon(
const QgsRectangle &extent, QPolygonF &poly )
const;
1142 void transformShift(
double &xShift,
double &yShift )
const;
1144 void drawAnnotations( QPainter *painter );
1146 QPointF layoutMapPosForItem(
const QgsAnnotation *item )
const;
1148 void drawMapFrame( QPainter *p );
1149 void drawMapBackground( QPainter *p );
1165 bool shouldDrawPart( PartType part )
const;
1167 PartType mCurrentExportPart = NotLayered;
1168 QStringList mExportThemes;
1169 QStringList::iterator mExportThemeIt;
1180 void refreshLabelMargin(
bool updateItem );
1184 void createStagedRenderJob(
const QgsRectangle &extent,
const QSizeF size,
double dpi );
1186 QPolygonF calculateVisibleExtentPolygon(
bool includeClipping )
const;
1191 friend class TestQgsLayoutMap;
1193 friend class QgsGeoPdfRenderedFeatureHandler;
1200 #endif //QGSLAYOUTITEMMAP_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
QgsLayoutItemMapOverviewStack * overviews()
Returns the map item's overview stack, which is used to control how overviews are drawn over the map'...
A map clipping region (in map coordinates and CRS).
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
QgsLayoutItemMapGridStack * grids()
Returns the map item's grid stack, which is used to control how grids are drawn over the map's conten...
The class is used as a container of context for various read/write operations on other objects.
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.
virtual QIcon icon() const
Returns the item's icon.
QgsLayoutItemMapAtlasClippingSettings * atlasClippingSettings()
Returns the map's atlas clipping settings.
const QgsCoordinateReferenceSystem & crs
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
Contains settings and helpers relating to a render of a QgsLayoutItem.
Class that stores computed placement from labeling engine.
bool atlasDriven() const
Returns whether the map extent is set to follow the current atlas feature.
Contains information about the context of a rendering operation.
AtlasScalingMode
Scaling modes used for the serial rendering (atlas)
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
virtual void refreshDataDefinedProperty(QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties)
Refreshes a data defined property for the item by reevaluating the property's value and redrawing the...
virtual Q_DECL_DEPRECATED int numberExportLayers() const
Returns the number of layers that this item requires for exporting during layered exports (e....
QgsLayoutItemMapItemClipPathSettings * itemClippingSettings()
Returns the map's item based clip path settings.
bool drawAnnotations() const
Returns whether annotations are drawn within the map.
bool followVisibilityPreset() const
Returns whether the map should follow a map theme.
A rectangle specified with double values.
Contains settings relating to clipping a layout map by another layout item.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
An interface for classes which provider custom handlers for features rendered as part of a map render...
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
int type() const override
Returns a unique graphics item type identifier.
A layout item subclass for map legends.
virtual bool containsAdvancedEffects() const
Returns true if the item contains contents with blend modes or transparency effects which can only be...
bool isDrawing() const
True if a draw is already in progress.
@ AllProperties
All properties for item.
virtual QPainterPath framePath() const
Returns the path to use when drawing the item's frame or background.
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.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
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...
virtual void invalidateCache()
Forces a deferred update of any cached image the item uses.
virtual void zoomContent(double factor, QPointF point)
Zooms content of item.
MapItemFlag
Various flags that affect drawing of map items.
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.
@ Fixed
The current scale of the map is used for each feature of the atlas.
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.
Handles rendering and exports of layouts to various formats.
A collection of overviews which are drawn above the map content in a QgsLayoutItemMap....
Base class for graphical items within a QgsLayout.
FeatureClippingType
Feature clipping behavior, which controls how features from vector layers will be clipped.
QgsMapRendererJob::Errors renderingErrors() const
Returns map rendering errors.
This class represents a coordinate reference system (CRS).
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
Layout graphical items for displaying a map.
QString followVisibilityPresetName() const
Preset name that decides which layers and layer styles are used for map rendering.
virtual Flags itemFlags() const
Returns the item's flags, which indicate how the item behaves.
@ Predefined
A scale is chosen from the predefined scales.
A geometry is the spatial representation of a feature.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
@ ClipPainterOnly
Applying clipping on the painter only (i.e. feature boundaries will be unchanged, but may be invisibl...
virtual QString displayName() const
Gets item display name.
void setKeepLayerStyles(bool enabled)
Sets whether current styles of layers should be overridden by previously stored styles.
void setAtlasMargin(double margin)
Sets the margin size (percentage) used when the map is in atlas mode.
PropertyValueType
Specifies whether the value returned by a function should be the original, user set value,...
virtual void moveContent(double dx, double dy)
Moves the content of the item, by a specified dx and dy in layout units.
virtual void setMoveContentPreviewOffset(double dx, double dy)
Sets temporary offset for the item, by a specified dx and dy in layout units.
QList< QgsMapRendererJob::Error > Errors
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
A collection of grids which is drawn above the map content in a QgsLayoutItemMap. The grid stack cont...
@ EvaluatedValue
Return the current evaluated value for the property.
void setKeepLayerSet(bool enabled)
Sets whether the stored layer set should be used or the current layer set of the associated project.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Base class for objects with an associated (optional) temporal range.
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.
Contains settings relating to clipping a layout map by the current atlas feature.
void setDrawAnnotations(bool draw)
Sets whether annotations are drawn within the map.
bool keepLayerSet() const
Returns whether a stored layer set should be used or the current layer set from the project associate...