QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
17 #ifndef QGSLAYOUTITEMMAP_H
18 #define QGSLAYOUTITEMMAP_H
20 #include "qgis_core.h"
75 ShowPartialLabels = 1 << 0,
76 ShowUnplacedLabels = 1 << 1,
78 Q_DECLARE_FLAGS( MapItemFlags, MapItemFlag )
86 int type()
const override;
87 QIcon
icon()
const override;
88 QgsLayoutItem::Flags
itemFlags()
const override;
95 QgsLayoutItemMap::MapItemFlags mapFlags()
const;
102 void setMapFlags( QgsLayoutItemMap::MapItemFlags flags );
120 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
122 void startLayeredExport() override;
123 void stopLayeredExport() override;
124 bool nextExportPart() override;
125 ExportLayerBehavior exportLayerBehavior() const override;
126 QgsLayoutItem::ExportLayerDetail exportLayerDetails() const override;
134 double scale() const;
143 void setScale(
double scale,
bool forceUpdate = true );
178 QPolygonF visibleExtentPolygon() const;
235 QList<QgsMapLayer *> layers()
const;
243 void setLayers(
const QList<QgsMapLayer *> &layers );
267 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
272 void storeCurrentLayerStyles();
289 void setFollowVisibilityPreset(
bool follow );
306 void setFollowVisibilityPresetName(
const QString &name );
311 void zoomContent(
double factor, QPointF point )
override;
315 bool containsWmsLayer()
const;
326 void setMapRotation(
double rotation );
365 void setAtlasDriven(
bool enabled );
469 double mapUnitsToLayoutUnits()
const;
560 QTransform layoutToMapCoordsTransform()
const;
572 QRectF boundingRect()
const override;
575 QPolygonF transformedMapPolygon()
const;
578 QPointF mapToItemCoords( QPointF mapCoords )
const;
592 void extentChanged();
599 void mapRotationChanged(
double newRotation );
602 void preparedForAtlas();
608 void layerStyleOverridesChanged();
618 void themeChanged(
const QString &theme );
627 void updateBoundingRect();
632 void layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers );
634 void painterJobFinished();
638 void mapThemeChanged(
const QString &theme );
641 void currentMapThemeRenamed(
const QString &theme,
const QString &newTheme );
644 void recreateCachedImageInBackground();
646 void updateAtlasFeature();
649 QgsLayoutItemMap::MapItemFlags mMapFlags =
nullptr;
654 std::unique_ptr< QgsLayoutItemMapGridStack > mGridStack;
655 std::unique_ptr< QgsLayoutItemMapOverviewStack > mOverviewStack;
677 std::unique_ptr< QImage > mCacheFinalImage;
678 std::unique_ptr< QImage > mCacheRenderingImage;
679 bool mUpdatesEnabled =
true;
682 bool mCacheInvalidated =
true;
685 int mNumCachedLayers;
688 bool mDrawing =
false;
690 QTimer *mBackgroundUpdateTimer =
nullptr;
691 double mPreviewScaleFactor = 0;
693 bool mDrawingPreview =
false;
696 double mXOffset = 0.0;
698 double mYOffset = 0.0;
700 double mLastRenderedImageOffsetX = 0.0;
701 double mLastRenderedImageOffsetY = 0.0;
704 double mMapRotation = 0;
709 double mEvaluatedMapRotation = 0;
712 bool mKeepLayerSet =
false;
715 QList< QgsMapLayerRef > mLayers;
717 bool mKeepLayerStyles =
false;
719 QMap<QString, QString> mLayerStyleOverrides;
722 mutable QString mCachedLayerStyleOverridesPresetName;
724 mutable QMap<QString, QString> mCachedPresetLayerStyleOverrides;
730 bool mFollowVisibilityPreset =
false;
735 QString mFollowVisibilityPresetName;
738 QString mLastEvaluatedThemeName;
747 void drawMap( QPainter *painter,
const QgsRectangle &extent, QSizeF size,
double dpi );
750 void connectUpdateSlot();
765 QList< QgsLabelBlockingRegion > createLabelBlockingRegions(
const QgsMapSettings &mapSettings )
const;
768 QRectF mCurrentRectangle;
770 bool mDrawAnnotations =
true;
773 bool mAtlasDriven =
false;
775 AtlasScalingMode mAtlasScalingMode = Auto;
777 double mAtlasMargin = 0.10;
779 std::unique_ptr< QPainter > mPainter;
780 std::unique_ptr< QgsMapRendererCustomPainterJob > mPainterJob;
781 bool mPainterCancelWait =
false;
786 QStringList mBlockingLabelItemUuids;
787 QList< QPointer< QgsLayoutItem > > mBlockingLabelItems;
792 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
794 std::unique_ptr< QgsMapRendererStagedRenderJob > mStagedRendererJob;
799 void updateToolTip();
804 QMap<QString, QString> layerStyleOverridesToRender(
const QgsExpressionContext &context )
const;
810 void mapPolygon(
const QgsRectangle &extent, QPolygonF &poly )
const;
817 void transformShift(
double &xShift,
double &yShift )
const;
819 void drawAnnotations( QPainter *painter );
821 QPointF layoutMapPosForItem(
const QgsAnnotation *item )
const;
823 void drawMapFrame( QPainter *p );
824 void drawMapBackground( QPainter *p );
840 bool shouldDrawPart( PartType part )
const;
842 PartType mCurrentExportPart = NotLayered;
843 QStringList mExportThemes;
844 QStringList::iterator mExportThemeIt;
852 void refreshLabelMargin(
bool updateItem );
856 void createStagedRenderJob(
const QgsRectangle &extent,
const QSizeF size,
double dpi );
861 friend class TestQgsLayoutMap;
863 friend class QgsGeoPdfRenderedFeatureHandler;
867 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayoutItemMap::MapItemFlags )
869 #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'...
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...
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.
const QgsCoordinateReferenceSystem & crs
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
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)
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....
bool drawAnnotations() const
Returns whether annotations are drawn within the map.
bool followVisibilityPreset() const
Returns whether the map should follow a map theme.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
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.
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.
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.
@ 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.
A collection of overviews which are drawn above the map content in a QgsLayoutItemMap....
Base class for graphical items within a QgsLayout.
QgsMapRendererJob::Errors renderingErrors() const
Returns map rendering errors.
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.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
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
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...
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.
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...