QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 ()
 
QgsRectangle extent () const
 Return geographical coordinates of the rectangle that should be rendered. More...
 
void setExtent (const QgsRectangle &rect)
 Set coordinates of the rectangle which should be rendered. More...
 
QSize outputSize () const
 Return the size of the resulting map image. More...
 
void setOutputSize (const QSize &size)
 Set the size of the resulting map image. More...
 
int outputDpi () const
 Return DPI used for conversion between real world units (e.g. More...
 
void setOutputDpi (int dpi)
 Set DPI used for conversion between real world units (e.g. mm) and pixels. 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...
 
void setLayers (const QStringList &layers)
 Set list of layer IDs for map rendering. More...
 
void setCrsTransformEnabled (bool enabled)
 sets whether to use projections for this layer set More...
 
bool hasCrsTransformEnabled () const
 returns true if projections are enabled for this layer set More...
 
void setDestinationCrs (const QgsCoordinateReferenceSystem &crs)
 sets destination coordinate reference system More...
 
const
QgsCoordinateReferenceSystem
destinationCrs () const
 returns CRS of destination coordinate reference system More...
 
QGis::UnitType mapUnits () const
 Get units of map's geographical coordinates - used for scale calculation. More...
 
void setMapUnits (QGis::UnitType u)
 Set units of map's geographical coordinates - used for scale calculation. More...
 
void setBackgroundColor (const QColor &color)
 Set the background color of the map. More...
 
QColor backgroundColor () const
 Get the background color of the map. More...
 
void setSelectionColor (const QColor &color)
 Set color that is used for drawing of selected vector features. More...
 
QColor selectionColor () const
 Get color that is used for drawing of selected vector features. More...
 
void setFlags (Flags flags)
 Set combination of flags that will be used for rendering. More...
 
void setFlag (Flag flag, bool on=true)
 Enable or disable a particular flag (other flags are not affected) More...
 
Flags flags () const
 Return combination of flags used for rendering. More...
 
bool testFlag (Flag flag) const
 Check whether a particular flag is enabled. More...
 
void setOutputImageFormat (QImage::Format format)
 sets format of internal QImage More...
 
QImage::Format outputImageFormat () const
 format of internal QImage, default QImage::Format_ARGB32_Premultiplied More...
 
bool hasValidSettings () const
 Check whether the map settings are valid and can be used for rendering. More...
 
QgsRectangle visibleExtent () const
 Return the actual extent derived from requested extent that takes takes output image size into account. More...
 
double mapUnitsPerPixel () const
 Return the distance in geographical coordinates that equals to one pixel in the map. More...
 
double scale () const
 Return the calculated scale of the map. More...
 
const QgsDatumTransformStoredatumTransformStore () const
 
QgsDatumTransformStoredatumTransformStore ()
 
const QgsMapToPixelmapToPixel () const
 
QgsRectangle layerExtentToOutputExtent (QgsMapLayer *theLayer, QgsRectangle extent) const
 transform bounding box from layer's CRS to output CRS More...
 
QgsRectangle outputExtentToLayerExtent (QgsMapLayer *theLayer, QgsRectangle extent) const
 transform bounding box from output CRS to layer's CRS 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...
 
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 QgsCoordinateTransformlayerTransfrom (QgsMapLayer *layer) const
 Return coordinate transform from layer's CRS to destination CRS. More...
 
QgsRectangle fullExtent () const
 returns current extent of layer set More...
 
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()) More...
 
QgsRectangle mVisibleExtent
 extent with some additional white space that matches the output aspect ratio More...
 
double mMapUnitsPerPixel
 
double mScale
 
QgsScaleCalculator mScaleCalculator
 
QgsMapToPixel mMapToPixel
 

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

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.

Constructor & Destructor Documentation

QgsMapSettings::QgsMapSettings ( )

Member Function Documentation

QColor QgsMapSettings::backgroundColor ( ) const
inline

Get the background color of the map.

const QgsDatumTransformStore& QgsMapSettings::datumTransformStore ( ) const
inline
QgsDatumTransformStore& QgsMapSettings::datumTransformStore ( )
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

See also
layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) if you want to transform a rectangle
Returns
a bounding box (aligned rectangle) containing the transformed extent
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

Returns
the transformed point
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
const QgsCoordinateTransform * QgsMapSettings::layerTransfrom ( 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
QgsPoint QgsMapSettings::mapToLayerCoordinates ( QgsMapLayer theLayer,
QgsPoint  point 
) const

transform point coordinates from output CRS to layer's CRS

Returns
the transformed point
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
const QgsMapToPixel& QgsMapSettings::mapToPixel ( ) const
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

See also
mapToLayerCoordinates( QgsMapLayer* theLayer,QgsRectangle rect ) if you want to transform a rectangle
Returns
a bounding box (aligned rectangle) containing the transformed extent
QImage::Format QgsMapSettings::outputImageFormat ( ) const
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.

QColor QgsMapSettings::selectionColor ( ) const
inline

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

void QgsMapSettings::setBackgroundColor ( const QColor &  color)
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.

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

sets format of internal QImage

void QgsMapSettings::setOutputSize ( const QSize &  size)

Set the size of the resulting map image.

void QgsMapSettings::setSelectionColor ( const QColor &  color)
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.

void QgsMapSettings::updateDerived ( )
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 
)

Member Data Documentation

QColor QgsMapSettings::mBackgroundColor
protected
QgsDatumTransformStore QgsMapSettings::mDatumTransformStore
protected
QgsCoordinateReferenceSystem QgsMapSettings::mDestCRS
protected
int QgsMapSettings::mDpi
protected
QgsRectangle QgsMapSettings::mExtent
protected
Flags QgsMapSettings::mFlags
protected
QImage::Format QgsMapSettings::mImageFormat
protected
QStringList QgsMapSettings::mLayers
protected
QgsMapToPixel QgsMapSettings::mMapToPixel
protected
double QgsMapSettings::mMapUnitsPerPixel
protected
bool QgsMapSettings::mProjectionsEnabled
protected
double QgsMapSettings::mScale
protected
QgsScaleCalculator QgsMapSettings::mScaleCalculator
protected
QColor QgsMapSettings::mSelectionColor
protected
QSize QgsMapSettings::mSize
protected
bool QgsMapSettings::mValid
protected

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

QgsRectangle QgsMapSettings::mVisibleExtent
protected

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


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