QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
The QgsMapSettings class contains configuration for rendering of the map. More...
#include <qgsmapsettings.h>
Public Types | |
enum | Flag { Antialiasing = 0x01, DrawEditingInfo = 0x02, ForceVectorOutput = 0x04, UseAdvancedEffects = 0x08, DrawLabeling = 0x10, UseRenderingOptimization = 0x20, DrawSelection = 0x40, DrawSymbolBounds = 0x80, RenderMapTile = 0x100, RenderPartialOutput = 0x200 } |
Enumeration of flags that adjust the way the map is rendered. More... | |
Public Member Functions | |
QgsMapSettings () | |
QColor | backgroundColor () const |
Get the background color of the map. More... | |
QString | customRenderFlags () const |
Get custom rendering flags. More... | |
const QgsDatumTransformStore & | datumTransformStore () const |
QgsDatumTransformStore & | datumTransformStore () |
const QgsCoordinateReferenceSystem & | destinationCrs () const |
returns CRS of destination coordinate reference system More... | |
const QgsExpressionContext & | expressionContext () const |
Gets the expression context. More... | |
QgsRectangle | extent () const |
Return geographical coordinates of the rectangle that should be rendered. More... | |
Flags | flags () const |
Return combination of flags used for rendering. More... | |
QgsRectangle | fullExtent () const |
returns current extent of layer set More... | |
bool | hasCrsTransformEnabled () const |
returns true if projections are enabled for this layer set More... | |
bool | hasValidSettings () const |
Check whether the map settings are valid and can be used for rendering. More... | |
QgsRectangle | layerExtentToOutputExtent (QgsMapLayer *theLayer, QgsRectangle extent) const |
transform bounding box from layer's CRS to output CRS More... | |
QStringList | layers () const |
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top) More... | |
QMap< QString, QString > | layerStyleOverrides () const |
Get map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one. More... | |
QgsPoint | layerToMapCoordinates (QgsMapLayer *theLayer, QgsPoint point) const |
transform point coordinates from layer's CRS to output CRS More... | |
QgsRectangle | layerToMapCoordinates (QgsMapLayer *theLayer, QgsRectangle rect) const |
transform rectangle from layer's CRS to output CRS More... | |
double | layerToMapUnits (QgsMapLayer *theLayer, const QgsRectangle &referenceExtent=QgsRectangle()) const |
Computes an estimated conversion factor between layer and map units: layerUnits * layerToMapUnits = mapUnits. More... | |
const QgsCoordinateTransform * | layerTransform (QgsMapLayer *layer) const |
Return coordinate transform from layer's CRS to destination CRS. More... | |
double | magnificationFactor () const |
Return the magnification factor. More... | |
QgsPoint | mapToLayerCoordinates (QgsMapLayer *theLayer, QgsPoint point) const |
transform point coordinates from output CRS to layer's CRS More... | |
QgsRectangle | mapToLayerCoordinates (QgsMapLayer *theLayer, QgsRectangle rect) const |
transform rectangle from output CRS to layer's CRS More... | |
const QgsMapToPixel & | mapToPixel () const |
QGis::UnitType | mapUnits () const |
Get units of map's geographical coordinates - used for scale calculation. More... | |
double | mapUnitsPerPixel () const |
Return the distance in geographical coordinates that equals to one pixel in the map. More... | |
double | outputDpi () const |
Return DPI used for conversion between real world units (e.g. More... | |
QgsRectangle | outputExtentToLayerExtent (QgsMapLayer *theLayer, QgsRectangle extent) const |
transform bounding box from output CRS to layer's CRS More... | |
QImage::Format | outputImageFormat () const |
format of internal QImage, default QImage::Format_ARGB32_Premultiplied More... | |
QSize | outputSize () const |
Return the size of the resulting map image. More... | |
void | readXML (QDomNode &theNode) |
double | rotation () const |
Return the rotation of the resulting map image Units are clockwise degrees. More... | |
double | scale () const |
Return the calculated scale of the map. More... | |
double | segmentationTolerance () const |
Gets the segmentation tolerance applied when rendering curved geometries. More... | |
QgsAbstractGeometryV2::SegmentationToleranceType | segmentationToleranceType () const |
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation) More... | |
QColor | selectionColor () const |
Get color that is used for drawing of selected vector features. More... | |
void | setBackgroundColor (const QColor &color) |
Set the background color of the map. More... | |
void | setCrsTransformEnabled (bool enabled) |
sets whether to use projections for this layer set More... | |
void | setCustomRenderFlags (const QString &customRenderFlags) |
Sets the custom rendering flags. More... | |
void | setDestinationCrs (const QgsCoordinateReferenceSystem &crs) |
sets destination coordinate reference system More... | |
void | setExpressionContext (const QgsExpressionContext &context) |
Sets the expression context. More... | |
void | setExtent (const QgsRectangle &rect, bool magnified=true) |
Set coordinates of the rectangle which should be rendered. More... | |
void | setFlag (Flag flag, bool on=true) |
Enable or disable a particular flag (other flags are not affected) More... | |
void | setFlags (const QgsMapSettings::Flags &flags) |
Set combination of flags that will be used for rendering. More... | |
void | setLayers (const QStringList &layers) |
Set list of layer IDs for map rendering. More... | |
void | setLayerStyleOverrides (const QMap< QString, QString > &overrides) |
Set map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one. More... | |
void | setMagnificationFactor (double factor) |
Set the magnification factor. More... | |
void | setMapUnits (QGis::UnitType u) |
Set units of map's geographical coordinates - used for scale calculation. More... | |
void | setOutputDpi (double dpi) |
Set DPI used for conversion between real world units (e.g. mm) and pixels. More... | |
void | setOutputImageFormat (QImage::Format format) |
sets format of internal QImage More... | |
void | setOutputSize (QSize size) |
Set the size of the resulting map image. More... | |
void | setRotation (double degrees) |
Set the rotation of the resulting map image Units are clockwise degrees. More... | |
void | setSegmentationTolerance (double tolerance) |
Sets the segmentation tolerance applied when rendering curved geometries. More... | |
void | setSegmentationToleranceType (QgsAbstractGeometryV2::SegmentationToleranceType type) |
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation) More... | |
void | setSelectionColor (const QColor &color) |
Set color that is used for drawing of selected vector features. More... | |
bool | testFlag (Flag flag) const |
Check whether a particular flag is enabled. More... | |
QgsRectangle | visibleExtent () const |
Return the actual extent derived from requested extent that takes takes output image size into account. More... | |
QPolygonF | visiblePolygon () const |
Return the visible area as a polygon (may be rotated) More... | |
void | writeXML (QDomNode &theNode, QDomDocument &theDoc) |
Protected Member Functions | |
void | updateDerived () |
Protected Attributes | |
QColor | mBackgroundColor |
QString | mCustomRenderFlags |
QgsDatumTransformStore | mDatumTransformStore |
QgsCoordinateReferenceSystem | mDestCRS |
double | mDpi |
QgsExpressionContext | mExpressionContext |
QgsRectangle | mExtent |
Flags | mFlags |
QImage::Format | mImageFormat |
QStringList | mLayers |
QMap< QString, QString > | mLayerStyleOverrides |
double | mMagnificationFactor |
QgsMapToPixel | mMapToPixel |
double | mMapUnitsPerPixel |
bool | mProjectionsEnabled |
double | mRotation |
double | mScale |
QgsScaleCalculator | mScaleCalculator |
double | mSegmentationTolerance |
QgsAbstractGeometryV2::SegmentationToleranceType | mSegmentationToleranceType |
QColor | mSelectionColor |
QSize | mSize |
bool | mValid |
whether the actual settings are valid (set in updateDerived()) More... | |
QgsRectangle | mVisibleExtent |
extent with some additional white space that matches the output aspect ratio More... | |
The QgsMapSettings class contains configuration for rendering of the map.
The rendering itself is done by QgsMapRendererJob subclasses.
In order to set up QgsMapSettings instance, it is necessary to set at least few members: extent, output size and layers.
QgsMapSettings and QgsMapRendererJob (+subclasses) are intended to replace QgsMapRenderer class that existed before QGIS 2.4. The advantage of the new classes is that they separate the settings from the rendering and provide asynchronous API for map rendering.
Definition at line 54 of file qgsmapsettings.h.
enum QgsMapSettings::Flag |
Enumeration of flags that adjust the way the map is rendered.
Definition at line 157 of file qgsmapsettings.h.
QgsMapSettings::QgsMapSettings | ( | ) |
Definition at line 33 of file qgsmapsettings.cpp.
|
inline |
Get the background color of the map.
Definition at line 149 of file qgsmapsettings.h.
|
inline |
Get custom rendering flags.
Layers might honour these to alter their rendering.
Definition at line 122 of file qgsmapsettings.h.
|
inline |
Definition at line 216 of file qgsmapsettings.h.
|
inline |
Definition at line 217 of file qgsmapsettings.h.
const QgsCoordinateReferenceSystem & QgsMapSettings::destinationCrs | ( | ) | const |
returns CRS of destination coordinate reference system
Definition at line 294 of file qgsmapsettings.cpp.
|
inline |
Gets the expression context.
This context should be used for all expression evaluation associated with this map settings.
Definition at line 211 of file qgsmapsettings.h.
QgsRectangle QgsMapSettings::extent | ( | ) | const |
Return geographical coordinates of the rectangle that should be rendered.
The actual visible extent used for rendering could be slightly different since the given extent may be expanded in order to fit the aspect ratio of output size. Use visibleExtent() to get the resulting extent.
Definition at line 85 of file qgsmapsettings.cpp.
QgsMapSettings::Flags QgsMapSettings::flags | ( | ) | const |
Return combination of flags used for rendering.
Definition at line 321 of file qgsmapsettings.cpp.
QgsRectangle QgsMapSettings::fullExtent | ( | ) | const |
returns current extent of layer set
Definition at line 529 of file qgsmapsettings.cpp.
bool QgsMapSettings::hasCrsTransformEnabled | ( | ) | const |
returns true if projections are enabled for this layer set
Definition at line 282 of file qgsmapsettings.cpp.
bool QgsMapSettings::hasValidSettings | ( | ) | const |
Check whether the map settings are valid and can be used for rendering.
Definition at line 337 of file qgsmapsettings.cpp.
QgsRectangle QgsMapSettings::layerExtentToOutputExtent | ( | QgsMapLayer * | theLayer, |
QgsRectangle | extent | ||
) | const |
transform bounding box from layer's CRS to output CRS
Definition at line 392 of file qgsmapsettings.cpp.
QStringList QgsMapSettings::layers | ( | ) | const |
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
Definition at line 257 of file qgsmapsettings.cpp.
Get map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one.
Definition at line 267 of file qgsmapsettings.cpp.
QgsPoint QgsMapSettings::layerToMapCoordinates | ( | QgsMapLayer * | theLayer, |
QgsPoint | point | ||
) | const |
transform point coordinates from layer's CRS to output CRS
Definition at line 444 of file qgsmapsettings.cpp.
QgsRectangle QgsMapSettings::layerToMapCoordinates | ( | QgsMapLayer * | theLayer, |
QgsRectangle | rect | ||
) | const |
transform rectangle from layer's CRS to output CRS
Definition at line 466 of file qgsmapsettings.cpp.
double QgsMapSettings::layerToMapUnits | ( | QgsMapLayer * | theLayer, |
const QgsRectangle & | referenceExtent = QgsRectangle() |
||
) | const |
Computes an estimated conversion factor between layer and map units: layerUnits * layerToMapUnits = mapUnits.
theLayer | The layer |
referenceExtent | A reference extent based on which to perform the computation. If not specified, the layer extent is used |
Definition at line 379 of file qgsmapsettings.cpp.
const QgsCoordinateTransform * QgsMapSettings::layerTransform | ( | QgsMapLayer * | layer | ) | const |
Return coordinate transform from layer's CRS to destination CRS.
layer |
Definition at line 373 of file qgsmapsettings.cpp.
double QgsMapSettings::magnificationFactor | ( | ) | const |
Return the magnification factor.
Definition at line 80 of file qgsmapsettings.cpp.
QgsPoint QgsMapSettings::mapToLayerCoordinates | ( | QgsMapLayer * | theLayer, |
QgsPoint | point | ||
) | const |
transform point coordinates from output CRS to layer's CRS
Definition at line 488 of file qgsmapsettings.cpp.
QgsRectangle QgsMapSettings::mapToLayerCoordinates | ( | QgsMapLayer * | theLayer, |
QgsRectangle | rect | ||
) | const |
transform rectangle from output CRS to layer's CRS
Definition at line 510 of file qgsmapsettings.cpp.
|
inline |
Definition at line 219 of file qgsmapsettings.h.
QGis::UnitType QgsMapSettings::mapUnits | ( | ) | const |
Get units of map's geographical coordinates - used for scale calculation.
Definition at line 331 of file qgsmapsettings.cpp.
double QgsMapSettings::mapUnitsPerPixel | ( | ) | const |
Return the distance in geographical coordinates that equals to one pixel in the map.
Definition at line 362 of file qgsmapsettings.cpp.
double QgsMapSettings::outputDpi | ( | ) | const |
Return DPI used for conversion between real world units (e.g.
mm) and pixels Default value is 96
Definition at line 244 of file qgsmapsettings.cpp.
QgsRectangle QgsMapSettings::outputExtentToLayerExtent | ( | QgsMapLayer * | theLayer, |
QgsRectangle | extent | ||
) | const |
transform bounding box from output CRS to layer's CRS
Definition at line 418 of file qgsmapsettings.cpp.
|
inline |
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
Definition at line 185 of file qgsmapsettings.h.
QSize QgsMapSettings::outputSize | ( | ) | const |
Return the size of the resulting map image.
Definition at line 232 of file qgsmapsettings.cpp.
void QgsMapSettings::readXML | ( | QDomNode & | theNode | ) |
Definition at line 601 of file qgsmapsettings.cpp.
double QgsMapSettings::rotation | ( | ) | const |
Return the rotation of the resulting map image Units are clockwise degrees.
Definition at line 102 of file qgsmapsettings.cpp.
double QgsMapSettings::scale | ( | ) | const |
Return the calculated scale of the map.
Definition at line 367 of file qgsmapsettings.cpp.
|
inline |
Gets the segmentation tolerance applied when rendering curved geometries.
Definition at line 288 of file qgsmapsettings.h.
|
inline |
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)
Definition at line 293 of file qgsmapsettings.h.
|
inline |
Get color that is used for drawing of selected vector features.
Definition at line 154 of file qgsmapsettings.h.
|
inline |
Set the background color of the map.
Definition at line 147 of file qgsmapsettings.h.
void QgsMapSettings::setCrsTransformEnabled | ( | bool | enabled | ) |
sets whether to use projections for this layer set
Definition at line 277 of file qgsmapsettings.cpp.
|
inline |
Sets the custom rendering flags.
Layers might honour these to alter their rendering.
customRenderFlags | custom flags strings, separated by ';' |
Definition at line 129 of file qgsmapsettings.h.
void QgsMapSettings::setDestinationCrs | ( | const QgsCoordinateReferenceSystem & | crs | ) |
sets destination coordinate reference system
Definition at line 288 of file qgsmapsettings.cpp.
|
inline |
Sets the expression context.
This context is used for all expression evaluation associated with this map settings.
Definition at line 204 of file qgsmapsettings.h.
void QgsMapSettings::setExtent | ( | const QgsRectangle & | rect, |
bool | magnified = true |
||
) |
Set coordinates of the rectangle which should be rendered.
The actual visible extent used for rendering could be slightly different since the given extent may be expanded in order to fit the aspect ratio of output size. Use visibleExtent() to get the resulting extent.
Definition at line 90 of file qgsmapsettings.cpp.
void QgsMapSettings::setFlag | ( | QgsMapSettings::Flag | flag, |
bool | on = true |
||
) |
Enable or disable a particular flag (other flags are not affected)
Definition at line 313 of file qgsmapsettings.cpp.
void QgsMapSettings::setFlags | ( | const QgsMapSettings::Flags & | flags | ) |
Set combination of flags that will be used for rendering.
Definition at line 308 of file qgsmapsettings.cpp.
void QgsMapSettings::setLayers | ( | const QStringList & | layers | ) |
Set list of layer IDs for map rendering.
The layers must be registered in QgsMapLayerRegistry. The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
Definition at line 262 of file qgsmapsettings.cpp.
Set map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one.
Definition at line 272 of file qgsmapsettings.cpp.
void QgsMapSettings::setMagnificationFactor | ( | double | factor | ) |
Set the magnification factor.
factor | the factor of magnification |
Definition at line 59 of file qgsmapsettings.cpp.
void QgsMapSettings::setMapUnits | ( | QGis::UnitType | u | ) |
Set units of map's geographical coordinates - used for scale calculation.
Definition at line 300 of file qgsmapsettings.cpp.
void QgsMapSettings::setOutputDpi | ( | double | dpi | ) |
Set DPI used for conversion between real world units (e.g. mm) and pixels.
Definition at line 249 of file qgsmapsettings.cpp.
|
inline |
sets format of internal QImage
Definition at line 183 of file qgsmapsettings.h.
void QgsMapSettings::setOutputSize | ( | QSize | size | ) |
Set the size of the resulting map image.
Definition at line 237 of file qgsmapsettings.cpp.
void QgsMapSettings::setRotation | ( | double | degrees | ) |
Set the rotation of the resulting map image Units are clockwise degrees.
Definition at line 107 of file qgsmapsettings.cpp.
|
inline |
Sets the segmentation tolerance applied when rendering curved geometries.
tolerance | the segmentation tolerance |
Definition at line 286 of file qgsmapsettings.h.
|
inline |
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)
type | the segmentation tolerance typename |
Definition at line 291 of file qgsmapsettings.h.
|
inline |
Set color that is used for drawing of selected vector features.
Definition at line 152 of file qgsmapsettings.h.
bool QgsMapSettings::testFlag | ( | QgsMapSettings::Flag | flag | ) | const |
Check whether a particular flag is enabled.
Definition at line 326 of file qgsmapsettings.cpp.
|
protected |
Definition at line 118 of file qgsmapsettings.cpp.
QgsRectangle QgsMapSettings::visibleExtent | ( | ) | const |
Return the actual extent derived from requested extent that takes takes output image size into account.
Definition at line 342 of file qgsmapsettings.cpp.
QPolygonF QgsMapSettings::visiblePolygon | ( | ) | const |
Return the visible area as a polygon (may be rotated)
Definition at line 347 of file qgsmapsettings.cpp.
void QgsMapSettings::writeXML | ( | QDomNode & | theNode, |
QDomDocument & | theDoc | ||
) |
Definition at line 644 of file qgsmapsettings.cpp.
|
protected |
Definition at line 315 of file qgsmapsettings.h.
|
protected |
Definition at line 308 of file qgsmapsettings.h.
|
protected |
Definition at line 313 of file qgsmapsettings.h.
|
protected |
Definition at line 312 of file qgsmapsettings.h.
|
protected |
Definition at line 297 of file qgsmapsettings.h.
|
protected |
Definition at line 309 of file qgsmapsettings.h.
|
protected |
Definition at line 301 of file qgsmapsettings.h.
|
protected |
Definition at line 318 of file qgsmapsettings.h.
|
protected |
Definition at line 320 of file qgsmapsettings.h.
|
protected |
Definition at line 306 of file qgsmapsettings.h.
Definition at line 307 of file qgsmapsettings.h.
|
protected |
Definition at line 304 of file qgsmapsettings.h.
|
protected |
Definition at line 334 of file qgsmapsettings.h.
|
protected |
Definition at line 329 of file qgsmapsettings.h.
|
protected |
Definition at line 311 of file qgsmapsettings.h.
|
protected |
Definition at line 303 of file qgsmapsettings.h.
|
protected |
Definition at line 330 of file qgsmapsettings.h.
|
protected |
Definition at line 333 of file qgsmapsettings.h.
|
protected |
Definition at line 322 of file qgsmapsettings.h.
|
protected |
Definition at line 323 of file qgsmapsettings.h.
|
protected |
Definition at line 316 of file qgsmapsettings.h.
|
protected |
Definition at line 299 of file qgsmapsettings.h.
|
protected |
whether the actual settings are valid (set in updateDerived())
Definition at line 327 of file qgsmapsettings.h.
|
protected |
extent with some additional white space that matches the output aspect ratio
Definition at line 328 of file qgsmapsettings.h.