QGIS API Documentation
2.6.0-Brighton
|
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 } |
Enumeration of flags that adjust the way how map is rendered. More... |
Public Member Functions | |
QgsMapSettings () | |
QgsRectangle | extent () const |
Return geographical coordinates of the rectangle that should be rendered. | |
void | setExtent (const QgsRectangle &rect) |
Set coordinates of the rectangle which should be rendered. | |
QSize | outputSize () const |
Return the size of the resulting map image. | |
void | setOutputSize (const QSize &size) |
Set the size of the resulting map image. | |
int | outputDpi () const |
Return DPI used for conversion between real world units (e.g. | |
void | setOutputDpi (int dpi) |
Set DPI used for conversion between real world units (e.g. mm) and pixels. | |
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) | |
void | setLayers (const QStringList &layers) |
Set list of layer IDs for map rendering. | |
void | setCrsTransformEnabled (bool enabled) |
sets whether to use projections for this layer set | |
bool | hasCrsTransformEnabled () const |
returns true if projections are enabled for this layer set | |
void | setDestinationCrs (const QgsCoordinateReferenceSystem &crs) |
sets destination coordinate reference system | |
const QgsCoordinateReferenceSystem & | destinationCrs () const |
returns CRS of destination coordinate reference system | |
QGis::UnitType | mapUnits () const |
Get units of map's geographical coordinates - used for scale calculation. | |
void | setMapUnits (QGis::UnitType u) |
Set units of map's geographical coordinates - used for scale calculation. | |
void | setBackgroundColor (const QColor &color) |
Set the background color of the map. | |
QColor | backgroundColor () const |
Get the background color of the map. | |
void | setSelectionColor (const QColor &color) |
Set color that is used for drawing of selected vector features. | |
QColor | selectionColor () const |
Get color that is used for drawing of selected vector features. | |
void | setFlags (Flags flags) |
Set combination of flags that will be used for rendering. | |
void | setFlag (Flag flag, bool on=true) |
Enable or disable a particular flag (other flags are not affected) | |
Flags | flags () const |
Return combination of flags used for rendering. | |
bool | testFlag (Flag flag) const |
Check whether a particular flag is enabled. | |
void | setOutputImageFormat (QImage::Format format) |
sets format of internal QImage | |
QImage::Format | outputImageFormat () const |
format of internal QImage, default QImage::Format_ARGB32_Premultiplied | |
bool | hasValidSettings () const |
Check whether the map settings are valid and can be used for rendering. | |
QgsRectangle | visibleExtent () const |
Return the actual extent derived from requested extent that takes takes output image size into account. | |
double | mapUnitsPerPixel () const |
Return the distance in geographical coordinates that equals to one pixel in the map. | |
double | scale () const |
Return the calculated scale of the map. | |
const QgsDatumTransformStore & | datumTransformStore () const |
QgsDatumTransformStore & | datumTransformStore () |
const QgsMapToPixel & | mapToPixel () const |
QgsRectangle | layerExtentToOutputExtent (QgsMapLayer *theLayer, QgsRectangle extent) const |
transform bounding box from layer's CRS to output CRS | |
QgsRectangle | outputExtentToLayerExtent (QgsMapLayer *theLayer, QgsRectangle extent) const |
transform bounding box from output CRS to layer's CRS | |
QgsPoint | layerToMapCoordinates (QgsMapLayer *theLayer, QgsPoint point) const |
transform point coordinates from layer's CRS to output CRS | |
QgsRectangle | layerToMapCoordinates (QgsMapLayer *theLayer, QgsRectangle rect) const |
transform rectangle from layer's CRS to output CRS | |
QgsPoint | mapToLayerCoordinates (QgsMapLayer *theLayer, QgsPoint point) const |
transform point coordinates from output CRS to layer's CRS | |
QgsRectangle | mapToLayerCoordinates (QgsMapLayer *theLayer, QgsRectangle rect) const |
transform rectangle from output CRS to layer's CRS | |
const QgsCoordinateTransform * | layerTransfrom (QgsMapLayer *layer) const |
Return coordinate transform from layer's CRS to destination CRS. | |
QgsRectangle | fullExtent () const |
returns current extent of layer set | |
void | readXML (QDomNode &theNode) |
void | writeXML (QDomNode &theNode, QDomDocument &theDoc) |
Protected Member Functions | |
void | updateDerived () |
Protected Attributes | |
int | mDpi |
QSize | mSize |
QgsRectangle | mExtent |
QStringList | mLayers |
bool | mProjectionsEnabled |
QgsCoordinateReferenceSystem | mDestCRS |
QgsDatumTransformStore | mDatumTransformStore |
QColor | mBackgroundColor |
QColor | mSelectionColor |
Flags | mFlags |
QImage::Format | mImageFormat |
bool | mValid |
whether the actual settings are valid (set in updateDerived()) | |
QgsRectangle | mVisibleExtent |
extent with some additional white space that matches the output aspect ratio | |
double | mMapUnitsPerPixel |
double | mScale |
QgsScaleCalculator | mScaleCalculator |
QgsMapToPixel | mMapToPixel |
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.
enum QgsMapSettings::Flag |
Enumeration of flags that adjust the way how map is rendered.
QgsMapSettings::QgsMapSettings | ( | ) |
|
inline |
Get the background color of the map.
|
inline |
|
inline |
const QgsCoordinateReferenceSystem & QgsMapSettings::destinationCrs | ( | ) | const |
returns CRS of destination coordinate reference system
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.
QgsMapSettings::Flags QgsMapSettings::flags | ( | ) | const |
Return combination of flags used for rendering.
QgsRectangle QgsMapSettings::fullExtent | ( | ) | const |
returns current extent of layer set
bool QgsMapSettings::hasCrsTransformEnabled | ( | ) | const |
returns true if projections are enabled for this layer set
bool QgsMapSettings::hasValidSettings | ( | ) | const |
Check whether the map settings are valid and can be used for rendering.
QgsRectangle QgsMapSettings::layerExtentToOutputExtent | ( | QgsMapLayer * | theLayer, |
QgsRectangle | extent | ||
) | const |
transform bounding box from layer's CRS to output CRS
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)
QgsPoint QgsMapSettings::layerToMapCoordinates | ( | QgsMapLayer * | theLayer, |
QgsPoint | point | ||
) | const |
transform point coordinates from layer's CRS to output CRS
QgsRectangle QgsMapSettings::layerToMapCoordinates | ( | QgsMapLayer * | theLayer, |
QgsRectangle | rect | ||
) | const |
transform rectangle from layer's CRS to output CRS
const QgsCoordinateTransform * QgsMapSettings::layerTransfrom | ( | QgsMapLayer * | layer | ) | const |
Return coordinate transform from layer's CRS to destination CRS.
layer |
QgsPoint QgsMapSettings::mapToLayerCoordinates | ( | QgsMapLayer * | theLayer, |
QgsPoint | point | ||
) | const |
transform point coordinates from output CRS to layer's CRS
QgsRectangle QgsMapSettings::mapToLayerCoordinates | ( | QgsMapLayer * | theLayer, |
QgsRectangle | rect | ||
) | const |
transform rectangle from output CRS to layer's CRS
|
inline |
QGis::UnitType QgsMapSettings::mapUnits | ( | ) | const |
Get units of map's geographical coordinates - used for scale calculation.
double QgsMapSettings::mapUnitsPerPixel | ( | ) | const |
Return the distance in geographical coordinates that equals to one pixel in the map.
int QgsMapSettings::outputDpi | ( | ) | const |
Return DPI used for conversion between real world units (e.g.
mm) and pixels Default value is 96
QgsRectangle QgsMapSettings::outputExtentToLayerExtent | ( | QgsMapLayer * | theLayer, |
QgsRectangle | extent | ||
) | const |
transform bounding box from output CRS to layer's CRS
|
inline |
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
QSize QgsMapSettings::outputSize | ( | ) | const |
Return the size of the resulting map image.
void QgsMapSettings::readXML | ( | QDomNode & | theNode | ) |
double QgsMapSettings::scale | ( | ) | const |
Return the calculated scale of the map.
|
inline |
Get color that is used for drawing of selected vector features.
|
inline |
Set the background color of the map.
void QgsMapSettings::setCrsTransformEnabled | ( | bool | enabled | ) |
sets whether to use projections for this layer set
void QgsMapSettings::setDestinationCrs | ( | const QgsCoordinateReferenceSystem & | crs | ) |
sets destination coordinate reference system
void QgsMapSettings::setExtent | ( | const QgsRectangle & | rect | ) |
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.
void QgsMapSettings::setFlag | ( | QgsMapSettings::Flag | flag, |
bool | on = true |
||
) |
Enable or disable a particular flag (other flags are not affected)
void QgsMapSettings::setFlags | ( | Flags | flags | ) |
Set combination of flags that will be used for rendering.
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)
void QgsMapSettings::setMapUnits | ( | QGis::UnitType | u | ) |
Set units of map's geographical coordinates - used for scale calculation.
void QgsMapSettings::setOutputDpi | ( | int | dpi | ) |
Set DPI used for conversion between real world units (e.g. mm) and pixels.
|
inline |
sets format of internal QImage
void QgsMapSettings::setOutputSize | ( | const QSize & | size | ) |
Set the size of the resulting map image.
|
inline |
Set color that is used for drawing of selected vector features.
bool QgsMapSettings::testFlag | ( | QgsMapSettings::Flag | flag | ) | const |
Check whether a particular flag is enabled.
|
protected |
QgsRectangle QgsMapSettings::visibleExtent | ( | ) | const |
Return the actual extent derived from requested extent that takes takes output image size into account.
void QgsMapSettings::writeXML | ( | QDomNode & | theNode, |
QDomDocument & | theDoc | ||
) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
whether the actual settings are valid (set in updateDerived())
|
protected |
extent with some additional white space that matches the output aspect ratio