QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsMapSettings Class Reference

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 ()
QColor backgroundColor () const
 Get the background color of the map.
const QgsDatumTransformStoredatumTransformStore () const
QgsDatumTransformStoredatumTransformStore ()
const
QgsCoordinateReferenceSystem
destinationCrs () const
 returns CRS of destination coordinate reference system
QgsRectangle extent () const
 Return geographical coordinates of the rectangle that should be rendered.
Flags flags () const
 Return combination of flags used for rendering.
QgsRectangle fullExtent () const
 returns current extent of layer set
bool hasCrsTransformEnabled () const
 returns true if projections are enabled for this layer set
bool hasValidSettings () const
 Check whether the map settings are valid and can be used for rendering.
QgsRectangle layerExtentToOutputExtent (QgsMapLayer *theLayer, QgsRectangle extent) const
 transform bounding box from layer's CRS to output CRS
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)
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.
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
const QgsCoordinateTransformlayerTransform (QgsMapLayer *layer) const
 Return coordinate transform from layer's CRS to destination 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 QgsMapToPixelmapToPixel () const
QGis::UnitType mapUnits () const
 Get units of map's geographical coordinates - used for scale calculation.
double mapUnitsPerPixel () const
 Return the distance in geographical coordinates that equals to one pixel in the map.
int outputDpi () const
 Return DPI used for conversion between real world units (e.g.
QgsRectangle outputExtentToLayerExtent (QgsMapLayer *theLayer, QgsRectangle extent) const
 transform bounding box from output CRS to layer's CRS
QImage::Format outputImageFormat () const
 format of internal QImage, default QImage::Format_ARGB32_Premultiplied
QSize outputSize () const
 Return the size of the resulting map image.
void readXML (QDomNode &theNode)
double rotation () const
 Return the rotation of the resulting map image Units are clockwise degrees.
double scale () const
 Return the calculated scale of the map.
QColor selectionColor () const
 Get color that is used for drawing of selected vector features.
void setBackgroundColor (const QColor &color)
 Set the background color of the map.
void setCrsTransformEnabled (bool enabled)
 sets whether to use projections for this layer set
void setDestinationCrs (const QgsCoordinateReferenceSystem &crs)
 sets destination coordinate reference system
void setExtent (const QgsRectangle &rect)
 Set coordinates of the rectangle which should be rendered.
void setFlag (Flag flag, bool on=true)
 Enable or disable a particular flag (other flags are not affected)
void setFlags (Flags flags)
 Set combination of flags that will be used for rendering.
void setLayers (const QStringList &layers)
 Set list of layer IDs for map rendering.
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.
void setMapUnits (QGis::UnitType u)
 Set units of map's geographical coordinates - used for scale calculation.
void setOutputDpi (int dpi)
 Set DPI used for conversion between real world units (e.g. mm) and pixels.
void setOutputImageFormat (QImage::Format format)
 sets format of internal QImage
void setOutputSize (const QSize &size)
 Set the size of the resulting map image.
void setRotation (double degrees)
 Set the rotation of the resulting map image Units are clockwise degrees.
void setSelectionColor (const QColor &color)
 Set color that is used for drawing of selected vector features.
bool testFlag (Flag flag) const
 Check whether a particular flag is enabled.
QgsRectangle visibleExtent () const
 Return the actual extent derived from requested extent that takes takes output image size into account.
QPolygonF visiblePolygon () const
 Return the visible area as a polygon (may be rotated)
void writeXML (QDomNode &theNode, QDomDocument &theDoc)

Protected Member Functions

void updateDerived ()

Protected Attributes

QColor mBackgroundColor
QgsDatumTransformStore mDatumTransformStore
QgsCoordinateReferenceSystem mDestCRS
int mDpi
QgsRectangle mExtent
Flags mFlags
QImage::Format mImageFormat
QStringList mLayers
QMap< QString, QString > mLayerStyleOverrides
QgsMapToPixel mMapToPixel
double mMapUnitsPerPixel
bool mProjectionsEnabled
double mRotation
double mScale
QgsScaleCalculator mScaleCalculator
QColor mSelectionColor
QSize mSize
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

Detailed Description

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.

Note
added in 2.4

Definition at line 52 of file qgsmapsettings.h.

Member Enumeration Documentation

Enumeration of flags that adjust the way how map is rendered.

Enumerator:
Antialiasing 

Enable anti-aliasin for map rendering.

DrawEditingInfo 

Enable drawing of vertex markers for layers in editing mode.

ForceVectorOutput 

Vector graphics should not be cached and drawn as raster images.

UseAdvancedEffects 

Enable layer transparency and blending effects.

DrawLabeling 

Enable drawing of labels on top of the map.

UseRenderingOptimization 

Enable vector simplification and other rendering optimizations.

DrawSelection 

Whether vector selections should be shown in the rendered map.

Definition at line 128 of file qgsmapsettings.h.

Constructor & Destructor Documentation

QgsMapSettings::QgsMapSettings ( )

Definition at line 33 of file qgsmapsettings.cpp.

Member Function Documentation

QColor QgsMapSettings::backgroundColor ( ) const
inline

Get the background color of the map.

Definition at line 120 of file qgsmapsettings.h.

const QgsDatumTransformStore& QgsMapSettings::datumTransformStore ( ) const
inline

Definition at line 170 of file qgsmapsettings.h.

QgsDatumTransformStore& QgsMapSettings::datumTransformStore ( )
inline

Definition at line 171 of file qgsmapsettings.h.

const QgsCoordinateReferenceSystem & QgsMapSettings::destinationCrs ( ) const

returns CRS of destination coordinate reference system

Definition at line 261 of file qgsmapsettings.cpp.

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 57 of file qgsmapsettings.cpp.

QgsMapSettings::Flags QgsMapSettings::flags ( ) const

Return combination of flags used for rendering.

Definition at line 288 of file qgsmapsettings.cpp.

QgsRectangle QgsMapSettings::fullExtent ( ) const

returns current extent of layer set

Definition at line 483 of file qgsmapsettings.cpp.

bool QgsMapSettings::hasCrsTransformEnabled ( ) const

returns true if projections are enabled for this layer set

Definition at line 249 of file qgsmapsettings.cpp.

bool QgsMapSettings::hasValidSettings ( ) const

Check whether the map settings are valid and can be used for rendering.

Definition at line 304 of file qgsmapsettings.cpp.

QgsRectangle QgsMapSettings::layerExtentToOutputExtent ( QgsMapLayer theLayer,
QgsRectangle  extent 
) const

transform bounding box from layer's CRS to output CRS

See Also
layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) if you want to transform a rectangle
Returns
a bounding box (aligned rectangle) containing the transformed extent

Definition at line 346 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 224 of file qgsmapsettings.cpp.

QMap< QString, QString > QgsMapSettings::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.

Note
added in 2.8

Definition at line 234 of file qgsmapsettings.cpp.

QgsPoint QgsMapSettings::layerToMapCoordinates ( QgsMapLayer theLayer,
QgsPoint  point 
) const

transform point coordinates from layer's CRS to output CRS

Returns
the transformed point

Definition at line 398 of file qgsmapsettings.cpp.

QgsRectangle QgsMapSettings::layerToMapCoordinates ( QgsMapLayer theLayer,
QgsRectangle  rect 
) const

transform rectangle from layer's CRS to output CRS

See Also
layerExtentToOutputExtent() if you want to transform a bounding box
Returns
the transformed rectangle

Definition at line 420 of file qgsmapsettings.cpp.

const QgsCoordinateTransform * QgsMapSettings::layerTransform ( QgsMapLayer layer) const

Return coordinate transform from layer's CRS to destination CRS.

Parameters
layer
Returns
transform - may be null if the transform is not needed

Definition at line 340 of file qgsmapsettings.cpp.

QgsPoint QgsMapSettings::mapToLayerCoordinates ( QgsMapLayer theLayer,
QgsPoint  point 
) const

transform point coordinates from output CRS to layer's CRS

Returns
the transformed point

Definition at line 442 of file qgsmapsettings.cpp.

QgsRectangle QgsMapSettings::mapToLayerCoordinates ( QgsMapLayer theLayer,
QgsRectangle  rect 
) const

transform rectangle from output CRS to layer's CRS

See Also
outputExtentToLayerExtent() if you want to transform a bounding box
Returns
the transformed rectangle

Definition at line 464 of file qgsmapsettings.cpp.

const QgsMapToPixel& QgsMapSettings::mapToPixel ( ) const
inline

Definition at line 173 of file qgsmapsettings.h.

QGis::UnitType QgsMapSettings::mapUnits ( ) const

Get units of map's geographical coordinates - used for scale calculation.

Definition at line 298 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 329 of file qgsmapsettings.cpp.

int QgsMapSettings::outputDpi ( ) const

Return DPI used for conversion between real world units (e.g.

mm) and pixels Default value is 96

Definition at line 211 of file qgsmapsettings.cpp.

QgsRectangle QgsMapSettings::outputExtentToLayerExtent ( QgsMapLayer theLayer,
QgsRectangle  extent 
) const

transform bounding box from output CRS to layer's CRS

See Also
mapToLayerCoordinates( QgsMapLayer* theLayer,QgsRectangle rect ) if you want to transform a rectangle
Returns
a bounding box (aligned rectangle) containing the transformed extent

Definition at line 372 of file qgsmapsettings.cpp.

QImage::Format QgsMapSettings::outputImageFormat ( ) const
inline

format of internal QImage, default QImage::Format_ARGB32_Premultiplied

Definition at line 153 of file qgsmapsettings.h.

QSize QgsMapSettings::outputSize ( ) const

Return the size of the resulting map image.

Definition at line 199 of file qgsmapsettings.cpp.

void QgsMapSettings::readXML ( QDomNode &  theNode)

Definition at line 555 of file qgsmapsettings.cpp.

double QgsMapSettings::rotation ( ) const

Return the rotation of the resulting map image Units are clockwise degrees.

Note
added in 2.8

Definition at line 69 of file qgsmapsettings.cpp.

double QgsMapSettings::scale ( ) const

Return the calculated scale of the map.

Definition at line 334 of file qgsmapsettings.cpp.

QColor QgsMapSettings::selectionColor ( ) const
inline

Get color that is used for drawing of selected vector features.

Definition at line 125 of file qgsmapsettings.h.

void QgsMapSettings::setBackgroundColor ( const QColor &  color)
inline

Set the background color of the map.

Definition at line 118 of file qgsmapsettings.h.

void QgsMapSettings::setCrsTransformEnabled ( bool  enabled)

sets whether to use projections for this layer set

Definition at line 244 of file qgsmapsettings.cpp.

void QgsMapSettings::setDestinationCrs ( const QgsCoordinateReferenceSystem crs)

sets destination coordinate reference system

Definition at line 255 of file qgsmapsettings.cpp.

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.

Definition at line 62 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 280 of file qgsmapsettings.cpp.

void QgsMapSettings::setFlags ( Flags  flags)

Set combination of flags that will be used for rendering.

Definition at line 275 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 229 of file qgsmapsettings.cpp.

void QgsMapSettings::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.

Note
added in 2.8

Definition at line 239 of file qgsmapsettings.cpp.

void QgsMapSettings::setMapUnits ( QGis::UnitType  u)

Set units of map's geographical coordinates - used for scale calculation.

Definition at line 267 of file qgsmapsettings.cpp.

void QgsMapSettings::setOutputDpi ( int  dpi)

Set DPI used for conversion between real world units (e.g. mm) and pixels.

Definition at line 216 of file qgsmapsettings.cpp.

void QgsMapSettings::setOutputImageFormat ( QImage::Format  format)
inline

sets format of internal QImage

Definition at line 151 of file qgsmapsettings.h.

void QgsMapSettings::setOutputSize ( const QSize &  size)

Set the size of the resulting map image.

Definition at line 204 of file qgsmapsettings.cpp.

void QgsMapSettings::setRotation ( double  degrees)

Set the rotation of the resulting map image Units are clockwise degrees.

Note
added in 2.8

Definition at line 74 of file qgsmapsettings.cpp.

void QgsMapSettings::setSelectionColor ( const QColor &  color)
inline

Set color that is used for drawing of selected vector features.

Definition at line 123 of file qgsmapsettings.h.

bool QgsMapSettings::testFlag ( QgsMapSettings::Flag  flag) const

Check whether a particular flag is enabled.

Definition at line 293 of file qgsmapsettings.cpp.

void QgsMapSettings::updateDerived ( )
protected

Definition at line 85 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 309 of file qgsmapsettings.cpp.

QPolygonF QgsMapSettings::visiblePolygon ( ) const

Return the visible area as a polygon (may be rotated)

Note
added in 2.8

Definition at line 314 of file qgsmapsettings.cpp.

void QgsMapSettings::writeXML ( QDomNode &  theNode,
QDomDocument &  theDoc 
)

Definition at line 591 of file qgsmapsettings.cpp.

Member Data Documentation

QColor QgsMapSettings::mBackgroundColor
protected

Definition at line 248 of file qgsmapsettings.h.

QgsDatumTransformStore QgsMapSettings::mDatumTransformStore
protected

Definition at line 246 of file qgsmapsettings.h.

QgsCoordinateReferenceSystem QgsMapSettings::mDestCRS
protected

Definition at line 245 of file qgsmapsettings.h.

int QgsMapSettings::mDpi
protected

Definition at line 233 of file qgsmapsettings.h.

QgsRectangle QgsMapSettings::mExtent
protected

Definition at line 237 of file qgsmapsettings.h.

Flags QgsMapSettings::mFlags
protected

Definition at line 251 of file qgsmapsettings.h.

QImage::Format QgsMapSettings::mImageFormat
protected

Definition at line 253 of file qgsmapsettings.h.

QStringList QgsMapSettings::mLayers
protected

Definition at line 241 of file qgsmapsettings.h.

QMap<QString, QString> QgsMapSettings::mLayerStyleOverrides
protected

Definition at line 242 of file qgsmapsettings.h.

QgsMapToPixel QgsMapSettings::mMapToPixel
protected

Definition at line 264 of file qgsmapsettings.h.

double QgsMapSettings::mMapUnitsPerPixel
protected

Definition at line 258 of file qgsmapsettings.h.

bool QgsMapSettings::mProjectionsEnabled
protected

Definition at line 244 of file qgsmapsettings.h.

double QgsMapSettings::mRotation
protected

Definition at line 239 of file qgsmapsettings.h.

double QgsMapSettings::mScale
protected

Definition at line 259 of file qgsmapsettings.h.

QgsScaleCalculator QgsMapSettings::mScaleCalculator
protected

Definition at line 263 of file qgsmapsettings.h.

QColor QgsMapSettings::mSelectionColor
protected

Definition at line 249 of file qgsmapsettings.h.

QSize QgsMapSettings::mSize
protected

Definition at line 235 of file qgsmapsettings.h.

bool QgsMapSettings::mValid
protected

whether the actual settings are valid (set in updateDerived())

Definition at line 256 of file qgsmapsettings.h.

QgsRectangle QgsMapSettings::mVisibleExtent
protected

extent with some additional white space that matches the output aspect ratio

Definition at line 257 of file qgsmapsettings.h.


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