17 #ifndef QGSLAYOUTITEMMAP_H 18 #define QGSLAYOUTITEMMAP_H 20 #include "qgis_core.h" 74 ShowPartialLabels = 1 << 0,
75 ShowUnplacedLabels = 1 << 1,
85 int type()
const override;
86 QIcon
icon()
const override;
87 QgsLayoutItem::Flags
itemFlags()
const override;
94 QgsLayoutItemMap::MapItemFlags mapFlags()
const;
101 void setMapFlags( QgsLayoutItemMap::MapItemFlags flags );
119 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
121 void startLayeredExport() override;
122 void stopLayeredExport() override;
123 bool nextExportPart() override;
133 double scale() const;
142 void setScale(
double scale,
bool forceUpdate = true );
177 QPolygonF visibleExtentPolygon() const;
234 QList<QgsMapLayer *> layers()
const;
242 void setLayers(
const QList<QgsMapLayer *> &layers );
266 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
271 void storeCurrentLayerStyles();
306 void zoomContent(
double factor, QPointF point )
override;
310 bool containsWmsLayer()
const;
321 void setMapRotation(
double rotation );
360 void setAtlasDriven(
bool enabled );
464 double mapUnitsToLayoutUnits()
const;
555 QTransform layoutToMapCoordsTransform()
const;
567 QRectF boundingRect()
const override;
570 QPolygonF transformedMapPolygon()
const;
573 QPointF mapToItemCoords( QPointF mapCoords )
const;
587 void extentChanged();
594 void mapRotationChanged(
double newRotation );
597 void preparedForAtlas();
603 void layerStyleOverridesChanged();
612 void updateBoundingRect();
617 void layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers );
619 void painterJobFinished();
623 void mapThemeChanged(
const QString &theme );
626 void recreateCachedImageInBackground();
628 void updateAtlasFeature();
631 QgsLayoutItemMap::MapItemFlags mMapFlags =
nullptr;
636 std::unique_ptr< QgsLayoutItemMapGridStack > mGridStack;
637 std::unique_ptr< QgsLayoutItemMapOverviewStack > mOverviewStack;
659 std::unique_ptr< QImage > mCacheFinalImage;
660 std::unique_ptr< QImage > mCacheRenderingImage;
661 bool mUpdatesEnabled =
true;
664 bool mCacheInvalidated =
true;
667 int mNumCachedLayers;
670 bool mDrawing =
false;
672 QTimer *mBackgroundUpdateTimer =
nullptr;
673 double mPreviewScaleFactor = 0;
675 bool mDrawingPreview =
false;
678 double mXOffset = 0.0;
680 double mYOffset = 0.0;
682 double mLastRenderedImageOffsetX = 0.0;
683 double mLastRenderedImageOffsetY = 0.0;
686 double mMapRotation = 0;
691 double mEvaluatedMapRotation = 0;
694 bool mKeepLayerSet =
false;
697 QList< QgsMapLayerRef > mLayers;
699 bool mKeepLayerStyles =
false;
701 QMap<QString, QString> mLayerStyleOverrides;
704 mutable QString mCachedLayerStyleOverridesPresetName;
706 mutable QMap<QString, QString> mCachedPresetLayerStyleOverrides;
712 bool mFollowVisibilityPreset =
false;
717 QString mFollowVisibilityPresetName;
726 void drawMap( QPainter *painter,
const QgsRectangle &extent, QSizeF size,
double dpi );
729 void connectUpdateSlot();
744 QList< QgsLabelBlockingRegion > createLabelBlockingRegions(
const QgsMapSettings &mapSettings )
const;
747 QRectF mCurrentRectangle;
749 bool mDrawAnnotations =
true;
752 bool mAtlasDriven =
false;
756 double mAtlasMargin = 0.10;
758 std::unique_ptr< QPainter > mPainter;
759 std::unique_ptr< QgsMapRendererCustomPainterJob > mPainterJob;
760 bool mPainterCancelWait =
false;
765 QStringList mBlockingLabelItemUuids;
766 QList< QPointer< QgsLayoutItem > > mBlockingLabelItems;
771 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
773 std::unique_ptr< QgsMapRendererStagedRenderJob > mStagedRendererJob;
778 void updateToolTip();
783 QMap<QString, QString> layerStyleOverridesToRender(
const QgsExpressionContext &context )
const;
789 void mapPolygon(
const QgsRectangle &extent, QPolygonF &poly )
const;
796 void transformShift(
double &xShift,
double &yShift )
const;
798 void drawAnnotations( QPainter *painter );
800 QPointF layoutMapPosForItem(
const QgsAnnotation *item )
const;
802 void drawMapFrame( QPainter *p );
803 void drawMapBackground( QPainter *p );
819 bool shouldDrawPart( PartType part )
const;
821 PartType mCurrentExportPart = NotLayered;
822 QStringList mExportThemes;
823 QStringList::iterator mExportThemeIt;
831 void refreshLabelMargin(
bool updateItem );
835 void createStagedRenderJob(
const QgsRectangle &extent,
const QSizeF size,
double dpi );
840 friend class TestQgsLayoutMap;
842 friend class QgsGeoPdfRenderedFeatureHandler;
846 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayoutItemMap::MapItemFlags )
848 #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.
virtual Q_DECL_DEPRECATED int numberExportLayers() const
Returns the number of layers that this item requires for exporting during layered exports (e...
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...
const QgsCoordinateReferenceSystem & crs
An interface for classes which can visit style entity (e.g.
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...
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...
An interface for classes which provider custom handlers for features rendered as part of a map render...
QgsMapRendererJob::Errors renderingErrors() const
Returns map rendering errors.
MapItemFlag
Various flags that affect drawing of map items.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
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...
virtual Flags itemFlags() const
Returns the item's flags, which indicate how the item behaves.
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
Gets 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.
ExportLayerBehavior
Behavior of item when exporting to layered outputs.
QList< QgsMapRendererJob::Error > Errors
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 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.
Contains details of a particular export layer relating to a layout item.
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.