QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
QgsMapRenderer Class Reference

A non GUI class for rendering a map layer set onto a QPainter. More...

#include <qgsmaprenderer.h>

Inheritance diagram for QgsMapRenderer:
Inheritance graph
[legend]

Public Types

enum  BlendMode {
  BlendNormal, BlendLighten, BlendScreen, BlendDodge,
  BlendAddition, BlendDarken, BlendMultiply, BlendBurn,
  BlendOverlay, BlendSoftLight, BlendHardLight, BlendDifference,
  BlendSubtract, BlendSource, BlendDestinationOver, BlendClear,
  BlendDestination, BlendSourceIn, BlendDestinationIn, BlendSourceOut,
  BlendDestinationOut, BlendSourceAtop, BlendDestinationAtop, BlendXor
}
 Blending modes enum defining the available composition modes that can be used when rendering a layer. More...
 
enum  OutputUnits { Millimeters, Pixels }
 Output units for pen width and point marker width/height. More...
 

Public Slots

Q_DECL_DEPRECATED void onDrawingProgress (int current, int total)
 

Signals

void datumTransformInfoRequested (const QgsMapLayer *ml, const QString &srcAuthId, const QString &destAuthId) const
 Notifies higher level components to show the datum transform dialog and add a QgsLayerCoordinateTransformInfo for that layer. More...
 
void destinationSrsChanged ()
 
void drawError (QgsMapLayer *)
 emitted when layer's draw() returned false More...
 
void drawingProgress (int current, int total)
 
void extentsChanged ()
 emitted when the current extent gets changed More...
 
Q_DECL_DEPRECATED void hasCrsTransformEnabled (bool flag)
 This signal is emitted when CRS transformation is enabled/disabled. More...
 
void hasCrsTransformEnabledChanged (bool flag)
 This signal is emitted when CRS transformation is enabled/disabled. More...
 
void mapUnitsChanged ()
 
void updateMap ()
 

Public Member Functions

 QgsMapRenderer ()
 constructor More...
 
 ~QgsMapRenderer ()
 destructor More...
 
void addLayerCoordinateTransform (const QString &layerId, const QString &srcAuthId, const QString &destAuthId, int srcDatumTransform=-1, int destDatumTransform=-1)
 
void clearLayerCoordinateTransforms ()
 
const QgsMapToPixelcoordinateTransform ()
 
const
QgsCoordinateReferenceSystem
destinationCrs () const
 returns CRS of destination coordinate reference system More...
 
void enableOverviewMode (bool isOverview=true)
 sets whether map image will be for overview More...
 
QgsRectangle extent () const
 returns current extent More...
 
QgsRectangle fullExtent ()
 returns current extent of layer set More...
 
bool hasCrsTransformEnabled () const
 returns true if projections are enabled for this layer set More...
 
int height () const
 
QgsLabelingEngineInterfacelabelingEngine ()
 Labeling engine (NULL if there's no custom engine) More...
 
QgsRectangle layerExtentToOutputExtent (QgsMapLayer *theLayer, QgsRectangle extent)
 transform bounding box from layer's CRS to output CRS More...
 
QStringList & layerSet ()
 returns current layer set More...
 
QgsPoint layerToMapCoordinates (QgsMapLayer *theLayer, QgsPoint point)
 transform point coordinates from layer's CRS to output CRS More...
 
QgsRectangle layerToMapCoordinates (QgsMapLayer *theLayer, QgsRectangle rect)
 transform rectangle from layer's CRS to output CRS More...
 
const QgsMapSettingsmapSettings ()
 bridge to QgsMapSettings More...
 
QgsPoint mapToLayerCoordinates (QgsMapLayer *theLayer, QgsPoint point)
 transform point coordinates from output CRS to layer's CRS More...
 
QgsRectangle mapToLayerCoordinates (QgsMapLayer *theLayer, QgsRectangle rect)
 transform rectangle from output CRS to layer's CRS More...
 
QGis::UnitType mapUnits () const
 
double mapUnitsPerPixel () const
 
double outputDpi ()
 accessor for output dpi More...
 
QgsRectangle outputExtentToLayerExtent (QgsMapLayer *theLayer, QgsRectangle extent)
 transform bounding box from output CRS to layer's CRS More...
 
QSize outputSize ()
 accessor for output size More...
 
QSizeF outputSizeF ()
 
OutputUnits outputUnits () const
 
bool readXML (QDomNode &theNode)
 read settings More...
 
void render (QPainter *painter, double *forceWidthScale=0)
 starts rendering More...
 
QgsRenderContextrendererContext ()
 Accessor for render context. More...
 
double scale () const
 Scale denominator. More...
 
void setDestinationCrs (const QgsCoordinateReferenceSystem &crs, bool refreshCoordinateTransformInfo=true, bool transformExtent=true)
 sets destination coordinate reference system More...
 
bool setExtent (const QgsRectangle &extent)
 sets extent and checks whether suitable (returns false if not) More...
 
void setLabelingEngine (QgsLabelingEngineInterface *iface)
 Set labeling engine. More...
 
void setLayerSet (const QStringList &layers)
 change current layer set More...
 
void setMapUnits (QGis::UnitType u)
 
void setOutputSize (QSize size, int dpi)
 
void setOutputSize (QSizeF size, double dpi)
 
void setOutputUnits (OutputUnits u)
 
void setProjectionsEnabled (bool enabled)
 sets whether to use projections for this layer set More...
 
void setScale (double scale)
 Sets scale for scale based visibility. More...
 
bool splitLayersExtent (QgsMapLayer *layer, QgsRectangle &extent, QgsRectangle &r2)
 Convenience function to project an extent into the layer source CRS, but also split it into two extents if it crosses the +/- 180 degree line. More...
 
const QgsCoordinateTransformtransformation (const QgsMapLayer *layer) const
 
void updateFullExtent ()
 updates extent of the layer set More...
 
void updateScale ()
 Recalculate the map scale. More...
 
int width () const
 
bool writeXML (QDomNode &theNode, QDomDocument &theDoc)
 write settings More...
 

Static Public Member Functions

static QgsMapRenderer::BlendMode getBlendModeEnum (const QPainter::CompositionMode &blendMode)
 Returns a BlendMode corresponding to a QPainter::CompositionMode. More...
 
static QPainter::CompositionMode getCompositionMode (const QgsMapRenderer::BlendMode &blendMode)
 Returns a QPainter::CompositionMode corresponding to a BlendMode. More...
 

Protected Member Functions

void adjustExtentToSize ()
 adjust extent to fit the pixmap size More...
 

Protected Attributes

QgsCoordinateReferenceSystemmDestCRS
 destination spatial reference system of the projection More...
 
QgsDistanceAreamDistArea
 tool for measuring More...
 
QgsRectangle mExtent
 current extent to be drawn More...
 
QgsRectangle mFullExtent
 full extent of the layer set More...
 
QgsLabelingEngineInterfacemLabelingEngine
 Labeling engine (NULL by default) More...
 
QgsRectangle mLastExtent
 Last extent to we drew so we know if we can used layer render caching or not. More...
 
QHash< QString,
QgsLayerCoordinateTransform
mLayerCoordinateTransformInfo
 
QStringList mLayerSet
 stores array of layers to be rendered (identified by string) More...
 
QgsMapSettings mMapSettings
 map settings - used only for export in mapSettings() for use in classes that deal with QgsMapSettings More...
 
double mMapUnitsPerPixel
 map units per pixel More...
 
OutputUnits mOutputUnits
 Output units. More...
 
bool mOverview
 indicates whether it's map image for overview More...
 
bool mProjectionsEnabled
 detemines whether on the fly projection support is enabled More...
 
QgsRenderContext mRenderContext
 Encapsulates context of rendering. More...
 
QMutex mRenderMutex
 Locks rendering loop for concurrent draws. More...
 
double mScale
 Map scale denominator at its current zoom level. More...
 
QgsScaleCalculatormScaleCalculator
 scale calculator More...
 
QSizeF mSize
 

Static Protected Attributes

static bool mDrawing = false
 indicates drawing in progress More...
 

Detailed Description

A non GUI class for rendering a map layer set onto a QPainter.

Definition at line 125 of file qgsmaprenderer.h.

Constructor & Destructor Documentation

QgsMapRenderer::QgsMapRenderer ( )

constructor

Definition at line 42 of file qgsmaprenderer.cpp.

QgsMapRenderer::~QgsMapRenderer ( )

destructor

Definition at line 64 of file qgsmaprenderer.cpp.

Member Function Documentation

void QgsMapRenderer::addLayerCoordinateTransform ( const QString &  layerId,
const QString &  srcAuthId,
const QString &  destAuthId,
int  srcDatumTransform = -1,
int  destDatumTransform = -1 
)

Definition at line 1241 of file qgsmaprenderer.cpp.

void QgsMapRenderer::adjustExtentToSize ( )
protected

adjust extent to fit the pixmap size

Definition at line 155 of file qgsmaprenderer.cpp.

void QgsMapRenderer::clearLayerCoordinateTransforms ( )

Definition at line 1251 of file qgsmaprenderer.cpp.

const QgsMapToPixel* QgsMapRenderer::coordinateTransform ( )
inline

Definition at line 187 of file qgsmaprenderer.h.

void QgsMapRenderer::datumTransformInfoRequested ( const QgsMapLayer ml,
const QString &  srcAuthId,
const QString &  destAuthId 
) const
signal

Notifies higher level components to show the datum transform dialog and add a QgsLayerCoordinateTransformInfo for that layer.

const QgsCoordinateReferenceSystem & QgsMapRenderer::destinationCrs ( ) const

returns CRS of destination coordinate reference system

Definition at line 691 of file qgsmaprenderer.cpp.

void QgsMapRenderer::destinationSrsChanged ( )
signal
void QgsMapRenderer::drawError ( QgsMapLayer )
signal

emitted when layer's draw() returned false

void QgsMapRenderer::drawingProgress ( int  current,
int  total 
)
signal
Deprecated:
in 2.4 - not emitted anymore
void QgsMapRenderer::enableOverviewMode ( bool  isOverview = true)
inline

sets whether map image will be for overview

Definition at line 206 of file qgsmaprenderer.h.

QgsRectangle QgsMapRenderer::extent ( ) const

returns current extent

Definition at line 72 of file qgsmaprenderer.cpp.

void QgsMapRenderer::extentsChanged ( )
signal

emitted when the current extent gets changed

Note
added in 2.4
QgsRectangle QgsMapRenderer::fullExtent ( )

returns current extent of layer set

Definition at line 976 of file qgsmaprenderer.cpp.

QgsMapRenderer::BlendMode QgsMapRenderer::getBlendModeEnum ( const QPainter::CompositionMode &  blendMode)
static

Returns a BlendMode corresponding to a QPainter::CompositionMode.

Definition at line 1167 of file qgsmaprenderer.cpp.

QPainter::CompositionMode QgsMapRenderer::getCompositionMode ( const QgsMapRenderer::BlendMode blendMode)
static

Returns a QPainter::CompositionMode corresponding to a BlendMode.

Returns a QPainter::CompositionMode corresponding to a QgsMapRenderer::BlendMode.

Definition at line 1108 of file qgsmaprenderer.cpp.

bool QgsMapRenderer::hasCrsTransformEnabled ( ) const

returns true if projections are enabled for this layer set

Definition at line 655 of file qgsmaprenderer.cpp.

Q_DECL_DEPRECATED void QgsMapRenderer::hasCrsTransformEnabled ( bool  flag)
signal

This signal is emitted when CRS transformation is enabled/disabled.

Parameters
flagtrue if transformation is enabled.
Deprecated:
Use hasCrsTransformEnabledChanged( bool flag ) to avoid conflict with method of the same name).
void QgsMapRenderer::hasCrsTransformEnabledChanged ( bool  flag)
signal

This signal is emitted when CRS transformation is enabled/disabled.

Parameters
flagtrue if transformation is enabled.
Note
Added in 2.4
int QgsMapRenderer::height ( ) const
inline

Definition at line 197 of file qgsmaprenderer.h.

QgsLabelingEngineInterface* QgsMapRenderer::labelingEngine ( )
inline

Labeling engine (NULL if there's no custom engine)

Definition at line 295 of file qgsmaprenderer.h.

QgsRectangle QgsMapRenderer::layerExtentToOutputExtent ( QgsMapLayer theLayer,
QgsRectangle  extent 
)

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 763 of file qgsmaprenderer.cpp.

QStringList & QgsMapRenderer::layerSet ( )

returns current layer set

Definition at line 989 of file qgsmaprenderer.cpp.

QgsPoint QgsMapRenderer::layerToMapCoordinates ( QgsMapLayer theLayer,
QgsPoint  point 
)

transform point coordinates from layer's CRS to output CRS

Returns
the transformed point

Definition at line 818 of file qgsmaprenderer.cpp.

QgsRectangle QgsMapRenderer::layerToMapCoordinates ( QgsMapLayer theLayer,
QgsRectangle  rect 
)

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 842 of file qgsmaprenderer.cpp.

const QgsMapSettings & QgsMapRenderer::mapSettings ( )

bridge to QgsMapSettings

Note
added in 2.4

Definition at line 1228 of file qgsmaprenderer.cpp.

QgsPoint QgsMapRenderer::mapToLayerCoordinates ( QgsMapLayer theLayer,
QgsPoint  point 
)

transform point coordinates from output CRS to layer's CRS

Returns
the transformed point

Definition at line 866 of file qgsmaprenderer.cpp.

QgsRectangle QgsMapRenderer::mapToLayerCoordinates ( QgsMapLayer theLayer,
QgsRectangle  rect 
)

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 888 of file qgsmaprenderer.cpp.

QGis::UnitType QgsMapRenderer::mapUnits ( ) const

Definition at line 626 of file qgsmaprenderer.cpp.

void QgsMapRenderer::mapUnitsChanged ( )
signal
double QgsMapRenderer::mapUnitsPerPixel ( ) const
inline

Definition at line 194 of file qgsmaprenderer.h.

void QgsMapRenderer::onDrawingProgress ( int  current,
int  total 
)
slot
Deprecated:
in 2.4 - does nothing

Definition at line 631 of file qgsmaprenderer.cpp.

double QgsMapRenderer::outputDpi ( )

accessor for output dpi

Definition at line 140 of file qgsmaprenderer.cpp.

QgsRectangle QgsMapRenderer::outputExtentToLayerExtent ( QgsMapLayer theLayer,
QgsRectangle  extent 
)

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 789 of file qgsmaprenderer.cpp.

QSize QgsMapRenderer::outputSize ( )

accessor for output size

Definition at line 145 of file qgsmaprenderer.cpp.

QSizeF QgsMapRenderer::outputSizeF ( )

Definition at line 150 of file qgsmaprenderer.cpp.

OutputUnits QgsMapRenderer::outputUnits ( ) const
inline

Definition at line 271 of file qgsmaprenderer.h.

bool QgsMapRenderer::readXML ( QDomNode &  theNode)

read settings

Definition at line 995 of file qgsmaprenderer.cpp.

void QgsMapRenderer::render ( QPainter *  painter,
double *  forceWidthScale = 0 
)

starts rendering

Parameters
painterpainter to render to
forceWidthScaleForce a specific scale factor for line widths and marker sizes. Automatically calculated from output device DPI if 0

Definition at line 221 of file qgsmaprenderer.cpp.

QgsRenderContext* QgsMapRenderer::rendererContext ( )
inline

Accessor for render context.

Definition at line 292 of file qgsmaprenderer.h.

double QgsMapRenderer::scale ( ) const
inline

Scale denominator.

Definition at line 190 of file qgsmaprenderer.h.

void QgsMapRenderer::setDestinationCrs ( const QgsCoordinateReferenceSystem crs,
bool  refreshCoordinateTransformInfo = true,
bool  transformExtent = true 
)

sets destination coordinate reference system

Definition at line 660 of file qgsmaprenderer.cpp.

bool QgsMapRenderer::setExtent ( const QgsRectangle extent)

sets extent and checks whether suitable (returns false if not)

Definition at line 82 of file qgsmaprenderer.cpp.

void QgsMapRenderer::setLabelingEngine ( QgsLabelingEngineInterface iface)

Set labeling engine.

Previous engine (if any) is deleted. Takes ownership of the engine.

Definition at line 1062 of file qgsmaprenderer.cpp.

void QgsMapRenderer::setLayerSet ( const QStringList &  layers)

change current layer set

Definition at line 982 of file qgsmaprenderer.cpp.

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

Definition at line 616 of file qgsmaprenderer.cpp.

void QgsMapRenderer::setOutputSize ( QSize  size,
int  dpi 
)

Definition at line 126 of file qgsmaprenderer.cpp.

void QgsMapRenderer::setOutputSize ( QSizeF  size,
double  dpi 
)

Definition at line 133 of file qgsmaprenderer.cpp.

void QgsMapRenderer::setOutputUnits ( OutputUnits  u)
inline

Definition at line 269 of file qgsmaprenderer.h.

void QgsMapRenderer::setProjectionsEnabled ( bool  enabled)

sets whether to use projections for this layer set

Definition at line 637 of file qgsmaprenderer.cpp.

void QgsMapRenderer::setScale ( double  scale)
inline

Sets scale for scale based visibility.

Normally, the scale is calculated automatically. This function is only used to force a preview scale (e.g. for print composer)

Definition at line 193 of file qgsmaprenderer.h.

bool QgsMapRenderer::splitLayersExtent ( QgsMapLayer layer,
QgsRectangle extent,
QgsRectangle r2 
)

Convenience function to project an extent into the layer source CRS, but also split it into two extents if it crosses the +/- 180 degree line.

Modifies the given extent to be in the source CRS coordinates, and if it was split, returns true, and also sets the contents of the r2 parameter

Definition at line 700 of file qgsmaprenderer.cpp.

const QgsCoordinateTransform * QgsMapRenderer::transformation ( const QgsMapLayer layer) const

Definition at line 1070 of file qgsmaprenderer.cpp.

void QgsMapRenderer::updateFullExtent ( )

updates extent of the layer set

Definition at line 907 of file qgsmaprenderer.cpp.

void QgsMapRenderer::updateMap ( )
signal
Deprecated:
in 2.4 - not emitted anymore
void QgsMapRenderer::updateScale ( )

Recalculate the map scale.

Definition at line 77 of file qgsmaprenderer.cpp.

int QgsMapRenderer::width ( ) const
inline

Definition at line 196 of file qgsmaprenderer.h.

bool QgsMapRenderer::writeXML ( QDomNode &  theNode,
QDomDocument &  theDoc 
)

write settings

Definition at line 1034 of file qgsmaprenderer.cpp.

Member Data Documentation

QgsCoordinateReferenceSystem* QgsMapRenderer::mDestCRS
protected

destination spatial reference system of the projection

Definition at line 400 of file qgsmaprenderer.h.

QgsDistanceArea* QgsMapRenderer::mDistArea
protected

tool for measuring

Definition at line 409 of file qgsmaprenderer.h.

bool QgsMapRenderer::mDrawing = false
staticprotected

indicates drawing in progress

Definition at line 371 of file qgsmaprenderer.h.

QgsRectangle QgsMapRenderer::mExtent
protected

current extent to be drawn

Definition at line 383 of file qgsmaprenderer.h.

QgsRectangle QgsMapRenderer::mFullExtent
protected

full extent of the layer set

Definition at line 406 of file qgsmaprenderer.h.

QgsLabelingEngineInterface* QgsMapRenderer::mLabelingEngine
protected

Labeling engine (NULL by default)

Definition at line 418 of file qgsmaprenderer.h.

QgsRectangle QgsMapRenderer::mLastExtent
protected

Last extent to we drew so we know if we can used layer render caching or not.

Note there are no accessors for this as it is intended to internal use only.

Definition at line 389 of file qgsmaprenderer.h.

QHash< QString, QgsLayerCoordinateTransform > QgsMapRenderer::mLayerCoordinateTransformInfo
protected

Definition at line 426 of file qgsmaprenderer.h.

QStringList QgsMapRenderer::mLayerSet
protected

stores array of layers to be rendered (identified by string)

Definition at line 403 of file qgsmaprenderer.h.

QgsMapSettings QgsMapRenderer::mMapSettings
protected

map settings - used only for export in mapSettings() for use in classes that deal with QgsMapSettings

Definition at line 424 of file qgsmaprenderer.h.

double QgsMapRenderer::mMapUnitsPerPixel
protected

map units per pixel

Definition at line 374 of file qgsmaprenderer.h.

OutputUnits QgsMapRenderer::mOutputUnits
protected

Output units.

Definition at line 415 of file qgsmaprenderer.h.

bool QgsMapRenderer::mOverview
protected

indicates whether it's map image for overview

Definition at line 392 of file qgsmaprenderer.h.

bool QgsMapRenderer::mProjectionsEnabled
protected

detemines whether on the fly projection support is enabled

Definition at line 397 of file qgsmaprenderer.h.

QgsRenderContext QgsMapRenderer::mRenderContext
protected

Encapsulates context of rendering.

Definition at line 412 of file qgsmaprenderer.h.

QMutex QgsMapRenderer::mRenderMutex
protected

Locks rendering loop for concurrent draws.

Definition at line 421 of file qgsmaprenderer.h.

double QgsMapRenderer::mScale
protected

Map scale denominator at its current zoom level.

Definition at line 377 of file qgsmaprenderer.h.

QgsScaleCalculator* QgsMapRenderer::mScaleCalculator
protected

scale calculator

Definition at line 380 of file qgsmaprenderer.h.

QSizeF QgsMapRenderer::mSize
protected

Definition at line 394 of file qgsmaprenderer.h.


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