QGIS API Documentation  2.99.0-Master (7d4f81d)
Public Types | Public Slots | Signals | Public Member Functions | Friends | List of all members
QgsComposerMap Class Reference

Object representing map window. More...

#include <qgscomposermap.h>

Inheritance diagram for QgsComposerMap:
Inheritance graph
[legend]

Public Types

enum  AtlasScalingMode { Fixed, Predefined, Auto }
 Scaling modes used for the serial rendering (atlas) More...
 
- Public Types inherited from QgsComposerItem
enum  ItemPositionMode {
  UpperLeft, UpperMiddle, UpperRight, MiddleLeft,
  Middle, MiddleRight, LowerLeft, LowerMiddle,
  LowerRight
}
 
enum  ItemType {
  ComposerItem = UserType + 100, ComposerArrow, ComposerItemGroup, ComposerLabel,
  ComposerLegend, ComposerMap, ComposerPaper, ComposerPicture,
  ComposerScaleBar, ComposerShape, ComposerPolygon, ComposerPolyline,
  ComposerTable, ComposerAttributeTable, ComposerTextTable, ComposerFrame
}
 
enum  MouseMoveAction {
  MoveItem, ResizeUp, ResizeDown, ResizeLeft,
  ResizeRight, ResizeLeftUp, ResizeRightUp, ResizeLeftDown,
  ResizeRightDown, NoAction
}
 Describes the action (move or resize in different directon) to be done during mouse move. More...
 
enum  ZoomMode { Zoom = 0, ZoomRecenter, ZoomToPoint, NoZoom }
 Modes for zooming item content. More...
 
- Public Types inherited from QgsComposerObject
enum  DataDefinedProperty {
  NoProperty = 0, AllProperties, TestProperty, PresetPaperSize,
  PaperWidth, PaperHeight, NumPages, PaperOrientation,
  PageNumber, PositionX, PositionY, ItemWidth,
  ItemHeight, ItemRotation, Transparency, Opacity,
  BlendMode, ExcludeFromExports, FrameColor, BackgroundColor,
  MapRotation, MapScale, MapXMin, MapYMin,
  MapXMax, MapYMax, MapAtlasMargin, MapLayers,
  MapStylePreset, PictureSource, PictureSvgBackgroundColor, PictureSvgStrokeColor,
  PictureSvgStrokeWidth, SourceUrl, LegendTitle, LegendColumnCount,
  ScalebarFillColor, ScalebarFillColor2, ScalebarLineColor, ScalebarLineWidth
}
 Data defined properties for different item types. More...
 
enum  PropertyValueType { EvaluatedValue = 0, OriginalValue }
 Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property. More...
 

Public Slots

void invalidateCache ()
 Forces a deferred update of the cached map image on next paint. More...
 
virtual void refreshDataDefinedProperty (const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties, const QgsExpressionContext *context=nullptr) override
 
void updateBoundingRect ()
 Updates the bounding rect of this item. Call this function before doing any changes related to annotation out of the map rectangle. More...
 
- Public Slots inherited from QgsComposerItem
virtual void refreshDataDefinedProperty (const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties, const QgsExpressionContext *context=nullptr) override
 Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value. More...
 
void repaint () override
 
virtual void setItemRotation (const double rotation, const bool adjustPosition=false)
 Sets the item rotation, in degrees clockwise. More...
 
- Public Slots inherited from QgsComposerObject
virtual void refreshDataDefinedProperty (const DataDefinedProperty property=AllProperties, const QgsExpressionContext *context=nullptr)
 Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value. More...
 
virtual void repaint ()
 Triggers a redraw for the item. More...
 

Signals

void extentChanged ()
 
void layerStyleOverridesChanged ()
 Emitted when layer style overrides are changed... More...
 
void mapRotationChanged (double newRotation)
 Is emitted on rotation change to notify north arrow pictures. More...
 
void preparedForAtlas ()
 Is emitted when the map has been prepared for atlas rendering, just before actual rendering. More...
 
- Signals inherited from QgsComposerItem
void frameChanged ()
 Emitted if the item's frame style changes. More...
 
void itemRotationChanged (double newRotation)
 Is emitted on item rotation change. More...
 
void lockChanged ()
 Emitted if the item's lock status changes. More...
 
void sizeChanged ()
 Emitted if the rectangle changes. More...
 
- Signals inherited from QgsComposerObject
void itemChanged ()
 Emitted when the item changes. More...
 

Public Member Functions

 QgsComposerMap (QgsComposition *composition, int x, int y, int width, int height)
 Constructor. More...
 
 QgsComposerMap (QgsComposition *composition)
 Constructor. Settings are read from project. More...
 
virtual ~QgsComposerMap ()
 
void assignFreeId ()
 Sets mId to a number not yet used in the composition. More...
 
bool atlasDriven () const
 Returns whether the map extent is set to follow the current atlas feature. More...
 
double atlasMargin (const QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue)
 Returns the margin size (percentage) used when the map is in atlas mode. More...
 
AtlasScalingMode atlasScalingMode () const
 Returns the current atlas scaling mode. More...
 
QRectF boundingRect () const override
 In case of annotations, the bounding rectangle can be larger than the map item rectangle. More...
 
bool containsAdvancedEffects () const
 True if composer map contains layers with blend modes or flattened layers for vectors. More...
 
bool containsWmsLayer () const
 True if composer map renders a WMS layer. More...
 
virtual QgsExpressionContext createExpressionContext () const override
 Creates an expression context relating to the item's current state. More...
 
QgsCoordinateReferenceSystem crs () const
 Returns coordinate reference system used for rendering the map. More...
 
const QgsRectanglecurrentMapExtent () const
 Returns a pointer to the current map extent, which is either the original user specified extent or the temporary atlas-driven feature extent depending on the current atlas state of the composition. More...
 
QgsRectanglecurrentMapExtent ()
 
virtual QString displayName () const override
 Get item display name. More...
 
void draw (QPainter *painter, const QgsRectangle &extent, QSizeF size, double dpi, double *forceWidthScale=nullptr)
 Draw to paint device. More...
 
bool drawAnnotations () const
 Returns whether annotations are drawn within the composer map. More...
 
QgsRectangle extent () const
 
bool followVisibilityPreset () const
 Whether the map should follow a map theme. More...
 
QString followVisibilityPresetName () const
 Preset name that decides which layers and layer styles are used for map rendering. More...
 
QgsComposerMapGridgrid ()
 Returns the map item's first grid. More...
 
QgsComposerMapGridStackgrids ()
 Returns the map item's grid stack, which is used to control how grids are drawn over the map's contents. More...
 
int id () const
 Get identification number. More...
 
bool isDrawing () const
 True if a draw is already in progress. More...
 
bool keepLayerSet () const
 Getter for flag that determines if a stored layer set should be used or the current layer set of the QGIS map canvas. More...
 
bool keepLayerStyles () const
 Getter for flag that determines if current styles of layers should be overridden by previously stored styles. More...
 
QList< QgsMapLayer * > layers () const
 Getter for stored layer set. More...
 
QMap< QString, QString > layerStyleOverrides () const
 Getter for stored overrides of styles for layers. More...
 
double mapRotation (QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue) const
 Returns the rotation used for drawing the map within the composer item, in degrees clockwise. More...
 
QgsMapSettings mapSettings (const QgsRectangle &extent, QSizeF size, int dpi) const
 Return map settings that would be used for drawing of the map. More...
 
QPointF mapToItemCoords (QPointF mapCoords) const
 Transforms map coordinates to item coordinates (considering rotation and move offset) More...
 
double mapUnitsToMM () const
 Returns the conversion factor map units -> mm. More...
 
void moveContent (double dx, double dy) override
 Move content of map. More...
 
int numberExportLayers () const override
 Get the number of layers that this item requires for exporting as layers. More...
 
QgsComposerMapOverviewoverview ()
 Returns the map item's first overview. More...
 
QgsComposerMapOverviewStackoverviews ()
 Returns the map item's overview stack, which is used to control how overviews are drawn over the map's contents. More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
 
QgsCoordinateReferenceSystem presetCrs () const
 Returns the map's preset coordinate reference system. More...
 
bool readXml (const QDomElement &itemElem, const QDomDocument &doc) override
 Sets state from Dom document. More...
 
void requestedExtent (QgsRectangle &extent) const
 Calculates the extent to request and the yShift of the top-left point in case of rotation. More...
 
void resize (double dx, double dy)
 Resizes an item in x- and y direction (canvas coordinates) More...
 
double scale () const
 Returns the map scale. More...
 
void setAtlasDriven (bool enabled)
 Sets whether the map extent will follow the current atlas feature. More...
 
void setAtlasMargin (double margin)
 Sets the margin size (percentage) used when the map is in atlas mode. More...
 
void setAtlasScalingMode (AtlasScalingMode mode)
 Sets the current atlas scaling mode. More...
 
void setCrs (const QgsCoordinateReferenceSystem &crs)
 Sets the map's preset coordinate reference system. More...
 
void setDrawAnnotations (bool draw)
 Sets whether annotations are drawn within the composer map. More...
 
void setFollowVisibilityPreset (bool follow)
 Sets whether the map should follow a map theme. More...
 
void setFollowVisibilityPresetName (const QString &name)
 Sets preset name for map rendering. More...
 
virtual void setFrameStrokeWidth (const double strokeWidth) override
 Sets frame stroke width. More...
 
void setKeepLayerSet (bool enabled)
 Setter for flag that determines if the stored layer set should be used or the current layer set of the QGIS map canvas. More...
 
void setKeepLayerStyles (bool enabled)
 Setter for flag that determines if current styles of layers should be overridden by previously stored styles. More...
 
void setLayers (const QList< QgsMapLayer *> &layers)
 Setter for stored layer set. More...
 
void setLayerStyleOverrides (const QMap< QString, QString > &overrides)
 Setter for stored overrides of styles for layers. More...
 
void setMapRotation (double rotation)
 Sets the rotation for the map - this does not affect the composer item shape, only the way the map is drawn within the item. More...
 
void setNewAtlasFeatureExtent (const QgsRectangle &extent)
 Sets new Extent for the current atlas preview and changes width, height (and implicitly also scale). More...
 
void setNewExtent (const QgsRectangle &extent)
 Sets new extent for the map. More...
 
void setNewScale (double scaleDenominator, bool forceUpdate=true)
 Sets new map scale and changes only the map extent. More...
 
void setOffset (double xOffset, double yOffset)
 Sets offset values to shift image (useful for live updates when moving item content) More...
 
void setSceneRect (const QRectF &rectangle) override
 Sets new scene rectangle bounds and recalculates hight and extent. More...
 
void storeCurrentLayerStyles ()
 Stores the current layer styles into style overrides. More...
 
QPolygonF transformedMapPolygon () const
 Returns extent that considers rotation and shift with mOffsetX / mOffsetY. More...
 
virtual int type () const override
 Return correct graphics item type. More...
 
QPolygonF visibleExtentPolygon () const
 Returns a polygon representing the current visible map extent, considering map extents and rotation. More...
 
bool writeXml (QDomElement &elem, QDomDocument &doc) const override
 Stores state in Dom node. More...
 
virtual void zoomContent (const double factor, const QPointF point, const ZoomMode mode=QgsComposerItem::Zoom) override
 Zoom content of item. More...
 
void zoomToExtent (const QgsRectangle &extent)
 Zooms the map so that the specified extent is fully visible within the map item. More...
 
- Public Member Functions inherited from QgsComposerItem
 QgsComposerItem (QgsComposition *composition, bool manageZValue=true)
 Constructor. More...
 
 QgsComposerItem (qreal x, qreal y, qreal width, qreal height, QgsComposition *composition, bool manageZValue=true)
 Constructor with box position and composer object. More...
 
virtual ~QgsComposerItem ()
 
bool _readXml (const QDomElement &itemElem, const QDomDocument &doc)
 Reads parameter that are not subclass specific in document. Usually called from readXml methods of subclasses. More...
 
bool _writeXml (QDomElement &itemElem, QDomDocument &doc) const
 Writes parameter that are not subclass specific in document. Usually called from writeXml methods of subclasses. More...
 
virtual void addItem (QgsComposerItem *item)
 Composite operations for item groups do nothing per default. More...
 
QColor backgroundColor () const
 Gets the background color for this item. More...
 
void beginCommand (const QString &commandText, QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown)
 Starts new composer undo command. More...
 
virtual void beginItemCommand (const QString &text)
 
QPainter::CompositionMode blendMode () const
 Returns the item's composition blending mode. More...
 
void cancelCommand ()
 
bool effectsEnabled () const
 Returns whether effects (e.g., blend modes) are enabled for the item. More...
 
void endCommand ()
 Finish current command and push it onto the undo stack. More...
 
virtual void endItemCommand ()
 
virtual double estimatedFrameBleed () const
 Returns the estimated amount the item's frame bleeds outside the item's actual rectangle. More...
 
bool excludeFromExports (const QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue)
 Returns whether the item should be excluded from composer exports and prints. More...
 
Qt::PenJoinStyle frameJoinStyle () const
 Returns the join style used for drawing the item's frame. More...
 
QColor frameStrokeColor () const
 Returns the frame's stroke color. More...
 
double frameStrokeWidth () const
 Returns the frame's stroke width. More...
 
bool hasBackground () const
 Whether this item has a Background or not. More...
 
bool hasFrame () const
 Whether this item has a frame or not. More...
 
QString id () const
 Get item's id (which is not necessarly unique) More...
 
bool isGroupMember () const
 Returns whether this item is part of a group. More...
 
virtual bool isRemoved () const
 Returns whether this item has been removed from the composition. More...
 
double itemOpacity () const
 Returns the item's opacity. More...
 
double itemRotation (const QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue) const
 Returns the current rotation for the composer item, in degrees clockwise. More...
 
ItemPositionMode lastUsedPositionMode ()
 Returns item's last used position mode. More...
 
void move (double dx, double dy)
 Moves item in canvas coordinates. More...
 
int page () const
 Gets the page the item is currently on. More...
 
QPointF pagePos () const
 Returns the item's position relative to its current page. More...
 
bool positionLock () const
 Returns whether position lock for mouse drags is enabled returns true if item is locked for mouse movement and resizing. More...
 
virtual QRectF rectWithFrame () const
 Returns the item's rectangular bounds, including any bleed caused by the item's frame. More...
 
virtual void removeItems ()
 
virtual bool selected () const
 Is selected. More...
 
void setBackgroundColor (const QColor &backgroundColor)
 Sets the background color for this item. More...
 
void setBackgroundEnabled (const bool drawBackground)
 Set whether this item has a Background drawn around it or not. More...
 
void setBlendMode (const QPainter::CompositionMode blendMode)
 Sets the item's composition blending mode. More...
 
virtual void setCurrentExportLayer (const int layerIdx=-1)
 Sets the current layer to draw for exporting. More...
 
void setEffectsEnabled (const bool effectsEnabled)
 Sets whether effects (e.g., blend modes) are enabled for the item. More...
 
virtual void setExcludeFromExports (const bool exclude)
 Sets whether the item should be excluded from composer exports and prints. More...
 
virtual void setFrameEnabled (const bool drawFrame)
 Set whether this item has a frame drawn around it or not. More...
 
void setFrameJoinStyle (const Qt::PenJoinStyle style)
 Sets join style used when drawing the item's frame. More...
 
virtual void setFrameStrokeColor (const QColor &color)
 Sets frame stroke color. More...
 
virtual void setId (const QString &id)
 Set item's id (which is not necessarly unique) More...
 
void setIsGroupMember (const bool isGroupMember)
 Sets whether this item is part of a group. More...
 
void setIsRemoved (const bool removed)
 Sets whether this item has been removed from the composition. More...
 
void setItemOpacity (const double opacity)
 Sets the item's opacity. More...
 
void setItemPosition (double x, double y, ItemPositionMode itemPoint=UpperLeft, int page=-1)
 Moves the item to a new position (in canvas coordinates) More...
 
void setItemPosition (double x, double y, double width, double height, ItemPositionMode itemPoint=UpperLeft, bool posIncludesFrame=false, int page=-1)
 Sets item position and width / height in one go. More...
 
void setPositionLock (const bool lock)
 Locks / unlocks the item position for mouse drags. More...
 
virtual void setSelected (bool s)
 Set selected, selected item should be highlighted. More...
 
void setUpdatesEnabled (bool enabled)
 Sets whether updates to the item are enabled. More...
 
virtual void setVisibility (const bool visible)
 Sets visibility for item. More...
 
virtual void updateItem ()
 Updates (redraws) the item, with the possibility to do custom update for subclasses. More...
 
void updatePagePos (double newPageWidth, double newPageHeight)
 Moves the item so that it retains its relative position on the page when the paper size changes. More...
 
bool updatesEnabled () const
 Returns whether updates to the item are enabled. More...
 
QString uuid () const
 Get item identification name. More...
 
- Public Member Functions inherited from QgsComposerObject
 QgsComposerObject (QgsComposition *composition)
 Constructor. More...
 
virtual ~QgsComposerObject ()=default
 
const QgsCompositioncomposition () const
 Returns the composition the item is attached to. More...
 
QgsCompositioncomposition ()
 
QStringList customProperties () const
 Return list of keys stored in custom properties for the object. More...
 
QVariant customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const
 Read a custom property from the object. More...
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the object's property collection, used for data defined overrides. More...
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the object's property collection, used for data defined overrides. More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from the object. More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for the object. More...
 
void setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the objects's property collection, used for data defined overrides. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Friends

class QgsComposerMapOverview
 
class TestQgsComposerMap
 

Additional Inherited Members

- Static Public Member Functions inherited from QgsComposerObject
static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the composer object property definitions. More...
 
- Protected Member Functions inherited from QgsComposerItem
void deleteAlignItems ()
 
void deleteHAlignSnapItem ()
 
void deleteVAlignSnapItem ()
 
virtual void drawBackground (QPainter *p)
 Draw background. More...
 
virtual void drawFrame (QPainter *p)
 Draw black frame around item. More...
 
virtual void drawSelectionBoxes (QPainter *p)
 Draws additional graphics on selected items. More...
 
QRectF evalItemRect (const QRectF &newRect, const bool resizeOnly=false, const QgsExpressionContext *context=nullptr)
 Evaluates an item's bounding rect to consider data defined position and size of item and reference point. More...
 
QGraphicsLineItem * hAlignSnapItem ()
 Return horizontal align snap item. Creates a new graphics line if 0. More...
 
double horizontalViewScaleFactor () const
 Returns the zoom factor of the graphics view. More...
 
double rectHandlerBorderTolerance () const
 Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the item border for resizing. More...
 
bool shouldDrawItem () const
 Returns whether the item should be drawn in the current context. More...
 
QGraphicsLineItem * vAlignSnapItem ()
 Return vertical align snap item. Creates a new graphics line if 0. More...
 
- Protected Attributes inherited from QgsComposerItem
bool mBackground
 True if item background needs to be painted. More...
 
QColor mBackgroundColor
 Background color. More...
 
QPainter::CompositionMode mBlendMode
 Composition blend mode for item. More...
 
QGraphicsRectItem * mBoundingResizeRectangle = nullptr
 Rectangle used during move and resize actions. More...
 
int mCurrentExportLayer
 The layer that needs to be exported. More...
 
QgsComposerItem::MouseMoveAction mCurrentMouseMoveAction
 
QgsComposerEffectmEffect = nullptr
 
bool mEffectsEnabled
 
bool mEvaluatedExcludeFromExports
 Temporary evaluated item exclusion. More...
 
double mEvaluatedItemRotation
 Temporary evaluated item rotation in degrees, clockwise. More...
 
bool mExcludeFromExports
 Whether item should be excluded in exports. More...
 
bool mFrame
 True if item fram needs to be painted. More...
 
QColor mFrameColor
 Item frame color. More...
 
Qt::PenJoinStyle mFrameJoinStyle = Qt::MiterJoin
 Frame join style. More...
 
double mFrameWidth = 0.3
 Item frame width. More...
 
QGraphicsLineItem * mHAlignSnapItem = nullptr
 
bool mIsGroupMember
 Whether or not this item is part of a group. More...
 
bool mItemPositionLocked
 True if item position and size cannot be changed with mouse move. More...
 
double mItemRotation
 Item rotation in degrees, clockwise. More...
 
QPointF mLastMouseEventPos
 Position of the last mouse move event (in scene coordinates) More...
 
ItemPositionMode mLastUsedPositionMode
 The item's position mode. More...
 
double mLastValidViewScaleFactor
 Backup to restore item appearance if no view scale factor is available. More...
 
QPointF mMouseMoveStartPos
 Start point of the last mouse move action (in scene coordinates) More...
 
double mOpacity = 1.0
 Item opacity, between 0 and 1. More...
 
bool mRemovedFromComposition
 True if item has been removed from the composition. More...
 
QGraphicsLineItem * mVAlignSnapItem = nullptr
 
- Protected Attributes inherited from QgsComposerObject
QgsCompositionmComposition = nullptr
 
QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QgsPropertyCollection mDataDefinedProperties
 

Detailed Description

Object representing map window.

Definition at line 53 of file qgscomposermap.h.

Member Enumeration Documentation

◆ AtlasScalingMode

Scaling modes used for the serial rendering (atlas)

Enumerator
Fixed 

The current scale of the map is used for each feature of the atlas.

Predefined 

A scale is chosen from the predefined scales.

The smallest scale from the list of scales where the atlas feature is fully visible is chosen.

See also
QgsAtlasComposition::setPredefinedScales.
Note
This mode is only valid for polygon or line atlas coverage layers
Auto 

The extent is adjusted so that each feature is fully visible.

A margin is applied around the center

See also
setAtlasMargin
Note
This mode is only valid for polygon or line atlas coverage layers

Definition at line 69 of file qgscomposermap.h.

Constructor & Destructor Documentation

◆ QgsComposerMap() [1/2]

QgsComposerMap::QgsComposerMap ( QgsComposition composition,
int  x,
int  y,
int  width,
int  height 
)

Constructor.

Definition at line 53 of file qgscomposermap.cpp.

◆ QgsComposerMap() [2/2]

QgsComposerMap::QgsComposerMap ( QgsComposition composition)

Constructor. Settings are read from project.

Definition at line 73 of file qgscomposermap.cpp.

◆ ~QgsComposerMap()

QgsComposerMap::~QgsComposerMap ( )
virtual

Definition at line 118 of file qgscomposermap.cpp.

Member Function Documentation

◆ assignFreeId()

void QgsComposerMap::assignFreeId ( )

Sets mId to a number not yet used in the composition.

mId is kept if it is not in use. Usually, this function is called before adding the composer map to the composition

Definition at line 1903 of file qgscomposermap.cpp.

◆ atlasDriven()

bool QgsComposerMap::atlasDriven ( ) const
inline

Returns whether the map extent is set to follow the current atlas feature.

Returns
true if map will follow the current atlas feature.
See also
setAtlasDriven
atlasScalingMode

Definition at line 381 of file qgscomposermap.h.

◆ atlasMargin()

double QgsComposerMap::atlasMargin ( const QgsComposerObject::PropertyValueType  valueType = QgsComposerObject::EvaluatedValue)

Returns the margin size (percentage) used when the map is in atlas mode.

Parameters
valueTypecontrols whether the returned value is the user specified atlas margin, or the current evaluated atlas margin (which may be affected by data driven atlas margin settings).
Returns
margin size in percentage to leave around the atlas feature's extent
Note
this is only used if atlasScalingMode() is Auto.
See also
atlasScalingMode
setAtlasMargin

Definition at line 1942 of file qgscomposermap.cpp.

◆ atlasScalingMode()

AtlasScalingMode QgsComposerMap::atlasScalingMode ( ) const
inline

Returns the current atlas scaling mode.

This controls how the map's extents are calculated for the current atlas feature when an atlas composition is enabled.

Returns
the current scaling mode
Note
this parameter is only used if atlasDriven() is true
See also
setAtlasScalingMode
atlasDriven

Definition at line 398 of file qgscomposermap.h.

◆ boundingRect()

QRectF QgsComposerMap::boundingRect ( ) const
override

In case of annotations, the bounding rectangle can be larger than the map item rectangle.

Definition at line 1569 of file qgscomposermap.cpp.

◆ containsAdvancedEffects()

bool QgsComposerMap::containsAdvancedEffects ( ) const

True if composer map contains layers with blend modes or flattened layers for vectors.

Definition at line 1069 of file qgscomposermap.cpp.

◆ containsWmsLayer()

bool QgsComposerMap::containsWmsLayer ( ) const

True if composer map renders a WMS layer.

Definition at line 1050 of file qgscomposermap.cpp.

◆ createExpressionContext()

QgsExpressionContext QgsComposerMap::createExpressionContext ( ) const
overridevirtual

Creates an expression context relating to the item's current state.

The context includes scopes for global, project, composition, atlas and item properties.

Since
QGIS 2.12

Reimplemented from QgsComposerItem.

Definition at line 1715 of file qgscomposermap.cpp.

◆ crs()

QgsCoordinateReferenceSystem QgsComposerMap::crs ( ) const

Returns coordinate reference system used for rendering the map.

This will match the presetCrs() if that is set, or if a preset CRS is not set then the map's CRS will follow the composition's project's CRS.

Since
QGIS 3.0
See also
presetCrs()
setCrs()

Definition at line 837 of file qgscomposermap.cpp.

◆ currentMapExtent() [1/2]

const QgsRectangle * QgsComposerMap::currentMapExtent ( ) const

Returns a pointer to the current map extent, which is either the original user specified extent or the temporary atlas-driven feature extent depending on the current atlas state of the composition.

Both a const and non-const version are included.

Returns
pointer to current map extent
See also
visibleExtentPolygon

Definition at line 851 of file qgscomposermap.cpp.

◆ currentMapExtent() [2/2]

QgsRectangle * QgsComposerMap::currentMapExtent ( )
Note
not available in Python bindings

Definition at line 821 of file qgscomposermap.cpp.

◆ displayName()

QString QgsComposerMap::displayName ( ) const
overridevirtual

Get item display name.

This is the item's id if set, and if not, a user-friendly string identifying item type.

Returns
display name for item
See also
id
setId
Since
QGIS 2.5

Reimplemented from QgsComposerItem.

Definition at line 1686 of file qgscomposermap.cpp.

◆ draw()

void QgsComposerMap::draw ( QPainter *  painter,
const QgsRectangle extent,
QSizeF  size,
double  dpi,
double *  forceWidthScale = nullptr 
)

Draw to paint device.

Parameters
painterpainter
extentmap extent
sizesize in scene coordinates
dpiscene dpi
forceWidthScaleforce wysiwyg line widths / marker sizes

Definition at line 133 of file qgscomposermap.cpp.

◆ drawAnnotations()

bool QgsComposerMap::drawAnnotations ( ) const
inline

Returns whether annotations are drawn within the composer map.

See also
setDrawAnnotations()

Definition at line 367 of file qgscomposermap.h.

◆ extent()

QgsRectangle QgsComposerMap::extent ( ) const
inline

Definition at line 281 of file qgscomposermap.h.

◆ extentChanged

void QgsComposerMap::extentChanged ( )
signal

◆ followVisibilityPreset()

bool QgsComposerMap::followVisibilityPreset ( ) const
inline

Whether the map should follow a map theme.

If true, the layers and layer styles will be used from given preset name (configured with setFollowVisibilityPresetName() method). This means when preset's settings are changed, the new settings are automatically picked up next time when rendering, without having to explicitly update them. At most one of the flags keepLayerSet() and followVisibilityPreset() should be enabled at any time since they are alternative approaches - if both are enabled, following map theme has higher priority. If neither is enabled (or if preset name is not set), map will use the same configuration as the map canvas uses.

Since
QGIS 2.16

Definition at line 266 of file qgscomposermap.h.

◆ followVisibilityPresetName()

QString QgsComposerMap::followVisibilityPresetName ( ) const
inline

Preset name that decides which layers and layer styles are used for map rendering.

It is only used when followVisibilityPreset() returns true.

Since
QGIS 2.16

Definition at line 275 of file qgscomposermap.h.

◆ grid()

QgsComposerMapGrid * QgsComposerMap::grid ( )

Returns the map item's first grid.

This is a convenience function.

Returns
pointer to first grid for map item
See also
grids()
Since
QGIS 2.5

Definition at line 1539 of file qgscomposermap.cpp.

◆ grids()

QgsComposerMapGridStack* QgsComposerMap::grids ( )
inline

Returns the map item's grid stack, which is used to control how grids are drawn over the map's contents.

Returns
pointer to grid stack
See also
grid()
Since
QGIS 2.5

Definition at line 310 of file qgscomposermap.h.

◆ id()

int QgsComposerMap::id ( ) const
inline

Get identification number.

Definition at line 104 of file qgscomposermap.h.

◆ invalidateCache

void QgsComposerMap::invalidateCache ( )
slot

Forces a deferred update of the cached map image on next paint.

Since
QGIS 3.0

Definition at line 434 of file qgscomposermap.cpp.

◆ isDrawing()

bool QgsComposerMap::isDrawing ( ) const
inline

True if a draw is already in progress.

Definition at line 107 of file qgscomposermap.h.

◆ keepLayerSet()

bool QgsComposerMap::keepLayerSet ( ) const
inline

Getter for flag that determines if a stored layer set should be used or the current layer set of the QGIS map canvas.

This is just a GUI flag, and itself does not change which layers are rendered in the map. Instead, use setLayers() to control which layers are rendered.

See also
setKeepLayerSet()
layers()

Definition at line 217 of file qgscomposermap.h.

◆ keepLayerStyles()

bool QgsComposerMap::keepLayerStyles ( ) const
inline

Getter for flag that determines if current styles of layers should be overridden by previously stored styles.

Since
QGIS 2.8

Definition at line 246 of file qgscomposermap.h.

◆ layers()

QList< QgsMapLayer * > QgsComposerMap::layers ( ) const

Getter for stored layer set.

If empty, the current canvas layers will be used instead.

See also
setLayers()
keepLayerSet()

Definition at line 1492 of file qgscomposermap.cpp.

◆ layerStyleOverrides()

QMap<QString, QString> QgsComposerMap::layerStyleOverrides ( ) const
inline

Getter for stored overrides of styles for layers.

Since
QGIS 2.8

Definition at line 251 of file qgscomposermap.h.

◆ layerStyleOverridesChanged

void QgsComposerMap::layerStyleOverridesChanged ( )
signal

Emitted when layer style overrides are changed...

a means to let associated legend items know they should update

Since
QGIS 2.10

◆ mapRotation()

double QgsComposerMap::mapRotation ( QgsComposerObject::PropertyValueType  valueType = QgsComposerObject::EvaluatedValue) const

Returns the rotation used for drawing the map within the composer item, in degrees clockwise.

Parameters
valueTypecontrols whether the returned value is the user specified rotation, or the current evaluated rotation (which may be affected by data driven rotation settings).
See also
setMapRotation()

Definition at line 914 of file qgscomposermap.cpp.

◆ mapRotationChanged

void QgsComposerMap::mapRotationChanged ( double  newRotation)
signal

Is emitted on rotation change to notify north arrow pictures.

◆ mapSettings()

QgsMapSettings QgsComposerMap::mapSettings ( const QgsRectangle extent,
QSizeF  size,
int  dpi 
) const

Return map settings that would be used for drawing of the map.

Since
QGIS 2.6

Definition at line 155 of file qgscomposermap.cpp.

◆ mapToItemCoords()

QPointF QgsComposerMap::mapToItemCoords ( QPointF  mapCoords) const

Transforms map coordinates to item coordinates (considering rotation and move offset)

Definition at line 1798 of file qgscomposermap.cpp.

◆ mapUnitsToMM()

double QgsComposerMap::mapUnitsToMM ( ) const

Returns the conversion factor map units -> mm.

Definition at line 1749 of file qgscomposermap.cpp.

◆ moveContent()

void QgsComposerMap::moveContent ( double  dx,
double  dy 
)
overridevirtual

Move content of map.

Parameters
dxmove in x-direction (item and canvas coordinates)
dymove in y-direction (item and canvas coordinates)

Reimplemented from QgsComposerItem.

Definition at line 604 of file qgscomposermap.cpp.

◆ numberExportLayers()

int QgsComposerMap::numberExportLayers ( ) const
overridevirtual

Get the number of layers that this item requires for exporting as layers.

Returns
0 if this item is to be placed on the same layer as the previous item, 1 if it should be placed on its own layer, and >1 if it requires multiple export layers
Since
QGIS 2.4

Reimplemented from QgsComposerItem.

Definition at line 440 of file qgscomposermap.cpp.

◆ overview()

QgsComposerMapOverview * QgsComposerMap::overview ( )

Returns the map item's first overview.

This is a convenience function.

Returns
pointer to first overview for map item
See also
overviews()
Since
QGIS 2.5

Definition at line 1554 of file qgscomposermap.cpp.

◆ overviews()

QgsComposerMapOverviewStack* QgsComposerMap::overviews ( )
inline

Returns the map item's overview stack, which is used to control how overviews are drawn over the map's contents.

Returns
pointer to overview stack
See also
overview()
Since
QGIS 2.5

Definition at line 325 of file qgscomposermap.h.

◆ paint()

void QgsComposerMap::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  itemStyle,
QWidget *  pWidget 
)
override

Definition at line 308 of file qgscomposermap.cpp.

◆ preparedForAtlas

void QgsComposerMap::preparedForAtlas ( )
signal

Is emitted when the map has been prepared for atlas rendering, just before actual rendering.

◆ presetCrs()

QgsCoordinateReferenceSystem QgsComposerMap::presetCrs ( ) const
inline

Returns the map's preset coordinate reference system.

If set, this CRS will be used to render the map regardless of any project CRS setting. If the returned CRS is not valid then the project CRS will be used to render the map.

Since
QGIS 3.0
See also
crs()
setCrs()

Definition at line 197 of file qgscomposermap.h.

◆ readXml()

bool QgsComposerMap::readXml ( const QDomElement &  itemElem,
const QDomDocument &  doc 
)
overridevirtual

Sets state from Dom document.

Parameters
itemElemis Dom node corresponding to 'ComposerMap' tag
docis Dom document

Reimplemented from QgsComposerObject.

Definition at line 1236 of file qgscomposermap.cpp.

◆ refreshDataDefinedProperty

void QgsComposerMap::refreshDataDefinedProperty ( const QgsComposerObject::DataDefinedProperty  property = QgsComposerObject::AllProperties,
const QgsExpressionContext context = nullptr 
)
overridevirtualslot

Definition at line 1759 of file qgscomposermap.cpp.

◆ requestedExtent()

void QgsComposerMap::requestedExtent ( QgsRectangle extent) const

Calculates the extent to request and the yShift of the top-left point in case of rotation.

Since
QGIS 2.6

Definition at line 1696 of file qgscomposermap.cpp.

◆ resize()

void QgsComposerMap::resize ( double  dx,
double  dy 
)

Resizes an item in x- and y direction (canvas coordinates)

Definition at line 595 of file qgscomposermap.cpp.

◆ scale()

double QgsComposerMap::scale ( ) const

Returns the map scale.

The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

See also
setNewScale()

Definition at line 587 of file qgscomposermap.cpp.

◆ setAtlasDriven()

void QgsComposerMap::setAtlasDriven ( bool  enabled)

Sets whether the map extent will follow the current atlas feature.

Parameters
enabledset to true if the map extents should be set by the current atlas feature.
See also
atlasDriven
setAtlasScalingMode

Definition at line 1930 of file qgscomposermap.cpp.

◆ setAtlasMargin()

void QgsComposerMap::setAtlasMargin ( double  margin)
inline

Sets the margin size (percentage) used when the map is in atlas mode.

Parameters
marginsize in percentage to leave around the atlas feature's extent
Note
this is only used if atlasScalingMode() is Auto.
See also
atlasScalingMode
atlasMargin

Definition at line 427 of file qgscomposermap.h.

◆ setAtlasScalingMode()

void QgsComposerMap::setAtlasScalingMode ( AtlasScalingMode  mode)
inline

Sets the current atlas scaling mode.

This controls how the map's extents are calculated for the current atlas feature when an atlas composition is enabled.

Parameters
modeatlas scaling mode to set
Note
this parameter is only used if atlasDriven() is true
See also
atlasScalingMode
atlasDriven

Definition at line 408 of file qgscomposermap.h.

◆ setCrs()

void QgsComposerMap::setCrs ( const QgsCoordinateReferenceSystem crs)

Sets the map's preset coordinate reference system.

If a valid CRS is set, this CRS will be used to render the map regardless of any project CRS setting. If the CRS is not valid then the project CRS will be used to render the map.

See also
crs()
presetCrs()
Since
QGIS 3.0

Definition at line 846 of file qgscomposermap.cpp.

◆ setDrawAnnotations()

void QgsComposerMap::setDrawAnnotations ( bool  draw)
inline

Sets whether annotations are drawn within the composer map.

See also
drawAnnotations()

Definition at line 361 of file qgscomposermap.h.

◆ setFollowVisibilityPreset()

void QgsComposerMap::setFollowVisibilityPreset ( bool  follow)
inline

Sets whether the map should follow a map theme.

See followVisibilityPreset() for more details.

Since
QGIS 2.16

Definition at line 270 of file qgscomposermap.h.

◆ setFollowVisibilityPresetName()

void QgsComposerMap::setFollowVisibilityPresetName ( const QString &  name)
inline

Sets preset name for map rendering.

See followVisibilityPresetName() for more details.

Since
QGIS 2.16

Definition at line 279 of file qgscomposermap.h.

◆ setFrameStrokeWidth()

void QgsComposerMap::setFrameStrokeWidth ( const double  strokeWidth)
overridevirtual

Sets frame stroke width.

Parameters
strokeWidthnew width for stroke frame
Since
QGIS 2.2
See also
frameStrokeWidth
setFrameEnabled
setFrameJoinStyle
setFrameStrokeColor

Reimplemented from QgsComposerItem.

Definition at line 1603 of file qgscomposermap.cpp.

◆ setKeepLayerSet()

void QgsComposerMap::setKeepLayerSet ( bool  enabled)
inline

Setter for flag that determines if the stored layer set should be used or the current layer set of the QGIS map canvas.

This is just a GUI flag, and itself does not change which layers are rendered in the map. Instead, use setLayers() to control which layers are rendered.

See also
keepLayerSet()
layers()

Definition at line 227 of file qgscomposermap.h.

◆ setKeepLayerStyles()

void QgsComposerMap::setKeepLayerStyles ( bool  enabled)
inline

Setter for flag that determines if current styles of layers should be overridden by previously stored styles.

Since
QGIS 2.8

Definition at line 248 of file qgscomposermap.h.

◆ setLayers()

void QgsComposerMap::setLayers ( const QList< QgsMapLayer *> &  layers)

Setter for stored layer set.

If empty, the current canvas layers will be used instead.

See also
layers()
keepLayerSet()

Definition at line 1497 of file qgscomposermap.cpp.

◆ setLayerStyleOverrides()

void QgsComposerMap::setLayerStyleOverrides ( const QMap< QString, QString > &  overrides)

Setter for stored overrides of styles for layers.

Since
QGIS 2.8

Definition at line 1503 of file qgscomposermap.cpp.

◆ setMapRotation()

void QgsComposerMap::setMapRotation ( double  rotation)

Sets the rotation for the map - this does not affect the composer item shape, only the way the map is drawn within the item.

Rotation is in degrees, clockwise.

Since
QGIS 2.1
See also
mapRotation()

Definition at line 905 of file qgscomposermap.cpp.

◆ setNewAtlasFeatureExtent()

void QgsComposerMap::setNewAtlasFeatureExtent ( const QgsRectangle extent)

Sets new Extent for the current atlas preview and changes width, height (and implicitly also scale).

Atlas preview extents are only temporary, and are regenerated whenever the atlas feature changes

Definition at line 781 of file qgscomposermap.cpp.

◆ setNewExtent()

void QgsComposerMap::setNewExtent ( const QgsRectangle extent)

Sets new extent for the map.

This method may change the width or height of the map item to ensure that the extent exactly matches the specified extent, with no overlap or margin. This method implicitly alters the map scale.

Parameters
extentnew extent for the map
See also
zoomToExtent

Definition at line 717 of file qgscomposermap.cpp.

◆ setNewScale()

void QgsComposerMap::setNewScale ( double  scaleDenominator,
bool  forceUpdate = true 
)

Sets new map scale and changes only the map extent.

The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

See also
scale()

Definition at line 867 of file qgscomposermap.cpp.

◆ setOffset()

void QgsComposerMap::setOffset ( double  xOffset,
double  yOffset 
)

Sets offset values to shift image (useful for live updates when moving item content)

Definition at line 899 of file qgscomposermap.cpp.

◆ setSceneRect()

void QgsComposerMap::setSceneRect ( const QRectF &  rectangle)
overridevirtual

Sets new scene rectangle bounds and recalculates hight and extent.

Reimplemented from QgsComposerItem.

Definition at line 697 of file qgscomposermap.cpp.

◆ storeCurrentLayerStyles()

void QgsComposerMap::storeCurrentLayerStyles ( )

Stores the current layer styles into style overrides.

Since
QGIS 2.8

Definition at line 1513 of file qgscomposermap.cpp.

◆ transformedMapPolygon()

QPolygonF QgsComposerMap::transformedMapPolygon ( ) const

Returns extent that considers rotation and shift with mOffsetX / mOffsetY.

Definition at line 1617 of file qgscomposermap.cpp.

◆ type()

virtual int QgsComposerMap::type ( ) const
inlineoverridevirtual

Return correct graphics item type.

Reimplemented from QgsComposerItem.

Definition at line 65 of file qgscomposermap.h.

◆ updateBoundingRect

void QgsComposerMap::updateBoundingRect ( )
slot

Updates the bounding rect of this item. Call this function before doing any changes related to annotation out of the map rectangle.

Definition at line 1574 of file qgscomposermap.cpp.

◆ visibleExtentPolygon()

QPolygonF QgsComposerMap::visibleExtentPolygon ( ) const

Returns a polygon representing the current visible map extent, considering map extents and rotation.

If the map rotation is 0, the result is the same as currentMapExtent

Returns
polygon with the four corner points representing the visible map extent. The points are clockwise, starting at the top-left point
See also
currentMapExtent

Definition at line 1679 of file qgscomposermap.cpp.

◆ writeXml()

bool QgsComposerMap::writeXml ( QDomElement &  elem,
QDomDocument &  doc 
) const
overridevirtual

Stores state in Dom node.

Parameters
elemis Dom element corresponding to 'Composer' tag
docDom document

Reimplemented from QgsComposerObject.

Definition at line 1123 of file qgscomposermap.cpp.

◆ zoomContent()

void QgsComposerMap::zoomContent ( const double  factor,
const QPointF  point,
const ZoomMode  mode = QgsComposerItem::Zoom 
)
overridevirtual

Zoom content of item.

Does nothing per default (but implemented in composer map)

Parameters
factorzoom factor, where > 1 results in a zoom in and < 1 results in a zoom out
pointitem point for zoom center
modezoom mode
Since
QGIS 2.5

Reimplemented from QgsComposerItem.

Definition at line 625 of file qgscomposermap.cpp.

◆ zoomToExtent()

void QgsComposerMap::zoomToExtent ( const QgsRectangle extent)

Zooms the map so that the specified extent is fully visible within the map item.

This method will not change the width or height of the map, and may result in an overlap or margin from the specified extent. This method implicitly alters the map scale.

Parameters
extentnew extent for the map
See also
setNewExtent
Since
QGIS 2.5

Definition at line 737 of file qgscomposermap.cpp.

Friends And Related Function Documentation

◆ QgsComposerMapOverview

friend class QgsComposerMapOverview
friend

Definition at line 647 of file qgscomposermap.h.

◆ TestQgsComposerMap

friend class TestQgsComposerMap
friend

Definition at line 648 of file qgscomposermap.h.


The documentation for this class was generated from the following files: