17 #ifndef QGSLAYOUTITEMMAP_H 18 #define QGSLAYOUTITEMMAP_H 20 #include "qgis_core.h" 72 int type()
const override;
73 QIcon
icon()
const override;
74 QgsLayoutItem::Flags
itemFlags()
const override;
92 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
101 double scale()
const;
110 void setScale(
double scale,
bool forceUpdate =
true );
145 QPolygonF visibleExtentPolygon()
const;
202 QList<QgsMapLayer *> layers()
const;
210 void setLayers(
const QList<QgsMapLayer *> &layers );
234 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
239 void storeCurrentLayerStyles();
274 void zoomContent(
double factor, QPointF point )
override;
278 bool containsWmsLayer()
const;
289 void setMapRotation(
double rotation );
328 void setAtlasDriven(
bool enabled );
408 double mapUnitsToLayoutUnits()
const;
437 QRectF boundingRect()
const override;
440 QPolygonF transformedMapPolygon()
const;
443 QPointF mapToItemCoords( QPointF mapCoords )
const;
457 void extentChanged();
464 void mapRotationChanged(
double newRotation );
467 void preparedForAtlas();
473 void layerStyleOverridesChanged();
482 void updateBoundingRect();
487 void layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers );
489 void painterJobFinished();
493 void mapThemeChanged(
const QString &theme );
496 void recreateCachedImageInBackground();
504 std::unique_ptr< QgsLayoutItemMapGridStack > mGridStack;
505 std::unique_ptr< QgsLayoutItemMapOverviewStack > mOverviewStack;
527 std::unique_ptr< QImage > mCacheFinalImage;
528 std::unique_ptr< QImage > mCacheRenderingImage;
529 bool mUpdatesEnabled =
true;
532 bool mCacheInvalidated =
true;
535 int mNumCachedLayers;
538 bool mDrawing =
false;
540 QTimer *mBackgroundUpdateTimer =
nullptr;
541 double mPreviewScaleFactor = 0;
543 bool mDrawingPreview =
false;
546 double mXOffset = 0.0;
548 double mYOffset = 0.0;
550 double mLastRenderedImageOffsetX = 0.0;
551 double mLastRenderedImageOffsetY = 0.0;
554 double mMapRotation = 0;
559 double mEvaluatedMapRotation = 0;
562 bool mKeepLayerSet =
false;
565 QList< QgsMapLayerRef > mLayers;
567 bool mKeepLayerStyles =
false;
569 QMap<QString, QString> mLayerStyleOverrides;
572 mutable QString mCachedLayerStyleOverridesPresetName;
574 mutable QMap<QString, QString> mCachedPresetLayerStyleOverrides;
580 bool mFollowVisibilityPreset =
false;
585 QString mFollowVisibilityPresetName;
594 void drawMap( QPainter *painter,
const QgsRectangle &extent, QSizeF size,
double dpi );
597 void connectUpdateSlot();
609 QRectF mCurrentRectangle;
611 bool mDrawAnnotations =
true;
614 bool mAtlasDriven =
false;
618 double mAtlasMargin = 0.10;
620 std::unique_ptr< QPainter > mPainter;
621 std::unique_ptr< QgsMapRendererCustomPainterJob > mPainterJob;
622 bool mPainterCancelWait =
false;
627 void updateToolTip();
630 QMap<QString, QString> layerStyleOverridesToRender(
const QgsExpressionContext &context )
const;
636 void mapPolygon(
const QgsRectangle &extent, QPolygonF &poly )
const;
643 void transformShift(
double &xShift,
double &yShift )
const;
645 void drawAnnotations( QPainter *painter );
647 QPointF layoutMapPosForItem(
const QgsAnnotation *item )
const;
649 void drawMapFrame( QPainter *p );
650 void drawMapBackground( QPainter *p );
663 bool shouldDrawPart( PartType part )
const;
671 void updateAtlasFeature();
678 friend class TestQgsLayoutMap;
683 #endif //QGSLAYOUTITEMMAP_H The class is used as a container of context for various read/write operations on other objects...
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void setFollowVisibilityPresetName(const QString &name)
Sets preset name for map rendering.
A rectangle specified with double values.
virtual QIcon icon() const
Returns the item's icon.
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.
void setKeepLayerStyles(bool enabled)
Sets whether current styles of layers should be overridden by previously stored styles.
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.
virtual int numberExportLayers() const
Returns the number of layers that this item requires for exporting during layered exports (e...
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
bool drawAnnotations() const
Returns whether annotations are drawn within the map.
A collection of overviews which are drawn above the map content in a QgsLayoutItemMap.
virtual void setFrameStrokeWidth(QgsLayoutMeasurement width)
Sets the frame stroke width.
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
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. ...
QString followVisibilityPresetName() const
Preset name that decides which layers and layer styles are used for map rendering.
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.
virtual Flags itemFlags() const
Returns the item's flags, which indicate how the item behaves.
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...
QgsCoordinateReferenceSystem presetCrs() const
Returns the map's preset coordinate reference system.
bool isDrawing() const
True if a draw is already in progress.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
void setAtlasScalingMode(AtlasScalingMode mode)
Sets the current atlas scaling mode.
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
Contains settings and helpers relating to a render of a QgsLayoutItem.
bool followVisibilityPreset() const
Returns whether the map should follow a map theme.
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.
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.
void setDrawAnnotations(bool draw)
Sets whether annotations are drawn within the map.
virtual bool containsAdvancedEffects() const
Returns true if the item contains contents with blend modes or transparency effects which can only be...
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.
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...
This class represents a coordinate reference system (CRS).
virtual void zoomContent(double factor, QPointF point)
Zooms content of item.
virtual QString displayName() const
Gets item display name.
AtlasScalingMode atlasScalingMode() const
Returns the current atlas scaling mode.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
AtlasScalingMode
Scaling modes used for the serial rendering (atlas)
A layout item subclass for map legends.
bool atlasDriven() const
Returns whether the map extent is set to follow the current atlas feature.
bool keepLayerSet() const
Returns whether a stored layer set should be used or the current layer set from the project associate...
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.