QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Private Slots | Private Member Functions | Private Attributes | List of all members
QgsMapCanvas Class Reference

Map canvas is a class for displaying all GIS data types on a canvas. More...

#include <qgsmapcanvas.h>

Inheritance diagram for QgsMapCanvas:
Inheritance graph
[legend]
Collaboration diagram for QgsMapCanvas:
Collaboration graph
[legend]

Classes

class  CanvasProperties
 

Public Types

enum  WheelAction { WheelZoom, WheelZoomAndRecenter, WheelZoomToMouseCursor, WheelNothing }
 

Public Slots

void refresh ()
 Repaints the canvas map. More...
 
void selectionChangedSlot ()
 Receives signal about selection change, and pass it on with layer info. More...
 
void saveAsImage (QString theFileName, QPixmap *QPixmap=0, QString="PNG")
 Save the convtents of the map canvas to disk as an image. More...
 
void layerStateChange ()
 This slot is connected to the visibility change of one or more layers. More...
 
void setRenderFlag (bool theFlag)
 Whether to suppress rendering or not. More...
 
bool renderFlag ()
 State of render suppression flag. More...
 
bool hasCrsTransformEnabled ()
 A simple helper method to find out if on the fly projections are enabled or not. More...
 
Q_DECL_DEPRECATED void updateMap ()
 
void stopRendering ()
 stop rendering (if there is any right now) More...
 
Q_DECL_DEPRECATED void showError (QgsMapLayer *mapLayer)
 
void readProject (const QDomDocument &)
 called to read map canvas settings from project More...
 
void writeProject (QDomDocument &)
 called to write map canvas settings to project More...
 
void getDatumTransformInfo (const QgsMapLayer *ml, const QString &srcAuthId, const QString &destAuthId)
 ask user about datum transformation More...
 

Signals

Q_DECL_DEPRECATED void setProgress (int, int)
 Let the owner know how far we are with render operations. More...
 
void xyCoordinates (const QgsPoint &p)
 emits current mouse position More...
 
void scaleChanged (double)
 Emitted when the scale of the map changes. More...
 
void extentsChanged ()
 Emitted when the extents of the map change. More...
 
void renderComplete (QPainter *)
 Emitted when the canvas has rendered. More...
 
void mapCanvasRefreshed ()
 Emitted when canvas finished a refresh request. More...
 
void renderStarting ()
 Emitted when the canvas is about to be rendered. More...
 
void layersChanged ()
 Emitted when a new set of layers has been received. More...
 
void keyPressed (QKeyEvent *e)
 Emit key press event. More...
 
void keyReleased (QKeyEvent *e)
 Emit key release event. More...
 
void mapToolSet (QgsMapTool *tool)
 Emit map tool changed event. More...
 
void mapToolSet (QgsMapTool *newTool, QgsMapTool *oldTool)
 Emit map tool changed with the old tool. More...
 
void selectionChanged (QgsMapLayer *layer)
 Emitted when selection in any layer gets changed. More...
 
void zoomLastStatusChanged (bool)
 Emitted when zoom last status changed. More...
 
void zoomNextStatusChanged (bool)
 Emitted when zoom next status changed. More...
 
void hasCrsTransformEnabledChanged (bool flag)
 Emitted when on-the-fly projection has been turned on/off. More...
 
void destinationCrsChanged ()
 Emitted when map CRS has changed. More...
 
void mapUnitsChanged ()
 Emmitted when map units are changed. More...
 

Public Member Functions

 QgsMapCanvas (QWidget *parent=0, const char *name=0)
 Constructor. More...
 
 ~QgsMapCanvas ()
 Destructor. More...
 
void setLayerSet (QList< QgsMapCanvasLayer > &layers)
 
void setCurrentLayer (QgsMapLayer *layer)
 
void updateOverview ()
 
void enableOverviewMode (QgsMapOverviewCanvas *overview)
 
const QgsMapSettingsmapSettings () const
 Get access to properties used for map rendering. More...
 
void setCrsTransformEnabled (bool enabled)
 sets whether to use projections for this layer set More...
 
void setDestinationCrs (const QgsCoordinateReferenceSystem &crs)
 sets destination coordinate reference system More...
 
const QgsLabelingResultslabelingResults () const
 Get access to the labeling results (may be null) More...
 
void setCachingEnabled (bool enabled)
 Set whether to cache images of rendered layers. More...
 
bool isCachingEnabled () const
 Check whether images of rendered layers are curerently being cached. More...
 
void clearCache ()
 Make sure to remove any rendered images from cache (does nothing if cache is not enabled) More...
 
void setParallelRenderingEnabled (bool enabled)
 Set whether the layers are rendered in parallel or sequentially. More...
 
bool isParallelRenderingEnabled () const
 Check whether the layers are rendered in parallel or sequentially. More...
 
void setMapUpdateInterval (int timeMiliseconds)
 Set how often map preview should be updated while it is being rendered (in milliseconds) More...
 
int mapUpdateInterval () const
 Find out how often map preview should be updated while it is being rendered (in milliseconds) More...
 
QgsMapCanvasMapmap ()
 
Q_DECL_DEPRECATED QgsMapRenderermapRenderer ()
 
Q_DECL_DEPRECATED QPaintDevice & canvasPaintDevice ()
 Accessor for the canvas paint device. More...
 
double scale ()
 Get the last reported scale of the canvas. More...
 
Q_DECL_DEPRECATED void clear ()
 Clear the map canvas. More...
 
double mapUnitsPerPixel () const
 Returns the mapUnitsPerPixel (map units per pixel) for the canvas. More...
 
QgsRectangle extent () const
 Returns the current zoom exent of the map canvas. More...
 
QgsRectangle fullExtent () const
 Returns the combined exent for all layers on the map canvas. More...
 
void setExtent (const QgsRectangle &r)
 Set the extent of the map canvas. More...
 
void zoomToFullExtent ()
 Zoom to the full extent of all layers. More...
 
void zoomToPreviousExtent ()
 Zoom to the previous extent (view) More...
 
void zoomToNextExtent ()
 Zoom to the next extent (view) More...
 
void clearExtentHistory ()
 
void zoomToSelected (QgsVectorLayer *layer=NULL)
 Zoom to the extent of the selected features of current (vector) layer. More...
 
void panToSelected (QgsVectorLayer *layer=NULL)
 Pan to the selected features of current (vector) layer keeping same extent. More...
 
void setMapTool (QgsMapTool *mapTool)
 Sets the map tool currently being used on the canvas. More...
 
void unsetMapTool (QgsMapTool *mapTool)
 Unset the current map tool or last non zoom tool. More...
 
QgsMapToolmapTool ()
 Returns the currently active tool. More...
 
virtual void setCanvasColor (const QColor &_newVal)
 Write property of QColor bgColor. More...
 
virtual QColor canvasColor () const
 Read property of QColor bgColor. More...
 
void setSelectionColor (const QColor &color)
 Set color of selected vector features. More...
 
void updateScale ()
 Emits signal scaleChanged to update scale in main window. More...
 
Q_DECL_DEPRECATED void updateFullExtent ()
 Updates the full extent. More...
 
QgsMapLayerlayer (int index)
 return the map layer at position index in the layer stack More...
 
int layerCount () const
 return number of layers on the map More...
 
QList< QgsMapLayer * > layers () const
 return list of layers within map canvas. Added in v1.5 More...
 
void freeze (bool frz=true)
 
bool isFrozen ()
 
Q_DECL_DEPRECATED void setDirty (bool _dirty)
 Flag the canvas as dirty and needed a refresh. More...
 
Q_DECL_DEPRECATED bool isDirty () const
 Return the state of the canvas (dirty or not) More...
 
void setMapUnits (QGis::UnitType mapUnits)
 Set map units (needed by project properties dialog) More...
 
QGis::UnitType mapUnits () const
 Get the current canvas map units. More...
 
const QgsMapToPixelgetCoordinateTransform ()
 Get the current coordinate transform. More...
 
bool isDrawing ()
 Find out whether rendering is in progress. More...
 
QgsMapLayercurrentLayer ()
 returns current layer (set by legend widget) More...
 
void setWheelAction (WheelAction action, double factor=2)
 set wheel action and zoom factor (should be greater than 1) More...
 
void zoomIn ()
 Zoom in with fixed factor. More...
 
void zoomOut ()
 Zoom out with fixed factor. More...
 
void zoomScale (double scale)
 Zoom to a specific scale. More...
 
void zoomByFactor (double scaleFactor)
 Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in. More...
 
void zoomWithCenter (int x, int y, bool zoomIn)
 Zooms in/out with a given center. More...
 
void enableAntiAliasing (bool theFlag)
 used to determine if anti-aliasing is enabled or not More...
 
bool antiAliasingEnabled () const
 true if antialising is enabled More...
 
Q_DECL_DEPRECATED void useImageToRender (bool theFlag)
 Select which Qt class to render with. More...
 
void panActionEnd (QPoint releasePoint)
 Ends pan action and redraws the canvas. More...
 
void panAction (QMouseEvent *event)
 Called when mouse is moving and pan is activated. More...
 
QPoint mouseLastXY ()
 returns last position of mouse cursor More...
 
void setPreviewModeEnabled (bool previewEnabled)
 Enables a preview mode for the map canvas. More...
 
bool previewModeEnabled () const
 Returns whether a preview mode is enabled for the map canvas. More...
 
void setPreviewMode (QgsPreviewEffect::PreviewMode mode)
 Sets a preview mode for the map canvas. More...
 
QgsPreviewEffect::PreviewMode previewMode () const
 Returns the current preview mode for the map canvas. More...
 

Protected Member Functions

void keyPressEvent (QKeyEvent *e)
 Overridden key press event. More...
 
void keyReleaseEvent (QKeyEvent *e)
 Overridden key release event. More...
 
void mouseDoubleClickEvent (QMouseEvent *e)
 Overridden mouse double click event. More...
 
void mouseMoveEvent (QMouseEvent *e)
 Overridden mouse move event. More...
 
void mousePressEvent (QMouseEvent *e)
 Overridden mouse press event. More...
 
void mouseReleaseEvent (QMouseEvent *e)
 Overridden mouse release event. More...
 
void wheelEvent (QWheelEvent *e)
 Overridden mouse wheel event. More...
 
void resizeEvent (QResizeEvent *e)
 Overridden resize event. More...
 
void paintEvent (QPaintEvent *e)
 Overridden paint event. More...
 
void dragEnterEvent (QDragEnterEvent *e)
 Overridden drag enter event. More...
 
void moveCanvasContents (bool reset=false)
 called when panning is in action, reset indicates end of panning More...
 
void updateCanvasItemPositions ()
 called on resize or changed extent to notify canvas items to change their rectangle More...
 
void connectNotify (const char *signal)
 debugging member invoked when a connect() is made to this object More...
 
void updateDatumTransformEntries ()
 Make sure the datum transform store is properly populated. More...
 

Protected Attributes

std::auto_ptr< CanvasPropertiesmCanvasProperties
 Handle pattern for implementation object. More...
 

Private Slots

void mapToolDestroyed ()
 called when current maptool is destroyed More...
 
void rendererJobFinished ()
 called when a renderer job has finished successfully or when it was cancelled More...
 
void mapUpdateTimeout ()
 
void refreshMap ()
 

Private Member Functions

 QgsMapCanvas (QgsMapCanvas const &)
 this class is non-copyable More...
 

Private Attributes

QgsMapSettings mSettings
 encompases all map settings necessary for map rendering More...
 
QgsMapRenderermMapRenderer
 all map rendering is done in this class More...
 
QgsMapCanvasMapmMap
 owns pixmap with rendered map and controls rendering More...
 
QgsMapOverviewCanvasmMapOverview
 map overview widget - it's controlled by QgsMapCanvas More...
 
bool mFrozen
 Flag indicating if the map canvas is frozen. More...
 
bool mRefreshScheduled
 Flag that allows squashing multiple refresh() calls into just one delayed rendering job. More...
 
bool mRenderFlag
 determines whether user has requested to suppress rendering More...
 
QgsMapLayermCurrentLayer
 current layer in legend More...
 
QGraphicsScene * mScene
 graphics scene manages canvas items More...
 
QgsMapToolmMapTool
 pointer to current map tool More...
 
QgsMapToolmLastNonZoomMapTool
 previous tool if current is for zooming/panning More...
 
QList< QgsRectanglemLastExtent
 recently used extent More...
 
int mLastExtentIndex
 
double mWheelZoomFactor
 Scale factor multiple for default zoom in/out. More...
 
WheelAction mWheelAction
 Mouse wheel action. More...
 
QTimer mMapUpdateTimer
 Timer that periodically fires while map rendering is in progress to update the visible map. More...
 
QgsMapRendererQImageJobmJob
 Job that takes care of map rendering in background. More...
 
bool mJobCancelled
 Flag determining whether the active job has been cancelled. More...
 
QgsLabelingResultsmLabelingResults
 Labeling results from the recently rendered map. More...
 
bool mUseParallelRendering
 Whether layers are rendered sequentially or in parallel. More...
 
bool mDrawRenderingStats
 Whether to add rendering stats to the rendered image. More...
 
QgsMapRendererCachemCache
 Optionally use cache with rendered map layers for the current map settings. More...
 
QTimer * mResizeTimer
 
QgsPreviewEffectmPreviewEffect
 

Detailed Description

Map canvas is a class for displaying all GIS data types on a canvas.

Definition at line 104 of file qgsmapcanvas.h.

Member Enumeration Documentation

Enumerator
WheelZoom 
WheelZoomAndRecenter 
WheelZoomToMouseCursor 
WheelNothing 

Definition at line 110 of file qgsmapcanvas.h.

Constructor & Destructor Documentation

QgsMapCanvas::QgsMapCanvas ( QWidget *  parent = 0,
const char *  name = 0 
)
QgsMapCanvas::~QgsMapCanvas ( )
QgsMapCanvas::QgsMapCanvas ( QgsMapCanvas const &  )
private

this class is non-copyable

Note

Otherwise std::auto_ptr would pass the object responsiblity on to the copy like a hot potato leaving the copyer in a weird state.

Member Function Documentation

bool QgsMapCanvas::antiAliasingEnabled ( ) const
inline

true if antialising is enabled

Definition at line 319 of file qgsmapcanvas.h.

References QgsMapSettings::Antialiasing.

Referenced by QgsMapCanvasItem::paint().

QColor QgsMapCanvas::canvasColor ( ) const
virtual

Read property of QColor bgColor.

Definition at line 1457 of file qgsmapcanvas.cpp.

References mScene.

QPaintDevice & QgsMapCanvas::canvasPaintDevice ( )

Accessor for the canvas paint device.

Deprecated:
since 2.4

Definition at line 1507 of file qgsmapcanvas.cpp.

References mMap, QgsMapCanvasMap::paintDevice(), Q_NOWARN_DEPRECATED_POP, and Q_NOWARN_DEPRECATED_PUSH.

void QgsMapCanvas::clear ( )

Clear the map canvas.

Deprecated:
since 2.4 - use refresh() - clear does the same thing

Definition at line 865 of file qgsmapcanvas.cpp.

References refresh().

void QgsMapCanvas::clearCache ( )

Make sure to remove any rendered images from cache (does nothing if cache is not enabled)

Note
added in 2.4

Definition at line 549 of file qgsmapcanvas.cpp.

References QgsMapRendererCache::clear(), and mCache.

void QgsMapCanvas::clearExtentHistory ( )
void QgsMapCanvas::connectNotify ( const char *  signal)
protected

debugging member invoked when a connect() is made to this object

Definition at line 1554 of file qgsmapcanvas.cpp.

References QgsDebugMsg.

QgsMapLayer * QgsMapCanvas::currentLayer ( )

returns current layer (set by legend widget)

Definition at line 586 of file qgsmapcanvas.cpp.

References mCurrentLayer.

Referenced by QgsMapToolIdentify::identify(), setLayerSet(), QgsMapCanvasSnapper::snapToBackgroundLayers(), and QgsMapCanvasSnapper::snapToCurrentLayer().

void QgsMapCanvas::destinationCrsChanged ( )
signal

Emitted when map CRS has changed.

Note
added in 2.4

Referenced by enableOverviewMode(), and setDestinationCrs().

void QgsMapCanvas::dragEnterEvent ( QDragEnterEvent *  e)
protected

Overridden drag enter event.

Definition at line 1830 of file qgsmapcanvas.cpp.

void QgsMapCanvas::enableAntiAliasing ( bool  theFlag)

used to determine if anti-aliasing is enabled or not

Definition at line 293 of file qgsmapcanvas.cpp.

References QgsMapSettings::Antialiasing, QgsMapOverviewCanvas::enableAntiAliasing(), mMapOverview, mSettings, and QgsMapSettings::setFlag().

void QgsMapCanvas::enableOverviewMode ( QgsMapOverviewCanvas overview)
QgsRectangle QgsMapCanvas::extent ( ) const
void QgsMapCanvas::extentsChanged ( )
signal

Emitted when the extents of the map change.

Referenced by resizeEvent(), setExtent(), zoomToNextExtent(), and zoomToPreviousExtent().

void QgsMapCanvas::freeze ( bool  frz = true)

Freeze/thaw the map canvas. This is used to prevent the canvas from responding to events while layers are being added/removed etc.

Parameters
frzBoolean specifying if the canvas should be frozen (true) or thawed (false). Default is true.

Definition at line 1496 of file qgsmapcanvas.cpp.

References mFrozen.

QgsRectangle QgsMapCanvas::fullExtent ( ) const

Returns the combined exent for all layers on the map canvas.

Definition at line 804 of file qgsmapcanvas.cpp.

References QgsMapSettings::fullExtent(), and mapSettings().

Referenced by QgsMapOverviewCanvas::updateFullExtent(), and zoomToFullExtent().

const QgsMapToPixel * QgsMapCanvas::getCoordinateTransform ( )
void QgsMapCanvas::getDatumTransformInfo ( const QgsMapLayer ml,
const QString &  srcAuthId,
const QString &  destAuthId 
)
slot
bool QgsMapCanvas::hasCrsTransformEnabled ( )
slot

A simple helper method to find out if on the fly projections are enabled or not.

Definition at line 934 of file qgsmapcanvas.cpp.

References QgsMapSettings::hasCrsTransformEnabled(), and mapSettings().

Referenced by enableOverviewMode(), QgsMapToolIdentify::featureDerivedAttributes(), and QgsMapToolIdentify::identifyRasterLayer().

void QgsMapCanvas::hasCrsTransformEnabledChanged ( bool  flag)
signal

Emitted when on-the-fly projection has been turned on/off.

Note
added in 2.4

Referenced by enableOverviewMode(), and setCrsTransformEnabled().

bool QgsMapCanvas::isCachingEnabled ( ) const

Check whether images of rendered layers are curerently being cached.

Note
added in 2.4

Definition at line 544 of file qgsmapcanvas.cpp.

References mCache.

Referenced by setCachingEnabled().

bool QgsMapCanvas::isDirty ( ) const

Return the state of the canvas (dirty or not)

Deprecated:
since 2.4 - dirty flag is not kept anymore - always returns false

Definition at line 343 of file qgsmapcanvas.cpp.

bool QgsMapCanvas::isDrawing ( )

Find out whether rendering is in progress.

Definition at line 350 of file qgsmapcanvas.cpp.

References mJob.

bool QgsMapCanvas::isFrozen ( )

Accessor for frozen status of canvas

Definition at line 1501 of file qgsmapcanvas.cpp.

References mFrozen.

bool QgsMapCanvas::isParallelRenderingEnabled ( ) const

Check whether the layers are rendered in parallel or sequentially.

Note
added in 2.4

Definition at line 560 of file qgsmapcanvas.cpp.

References mUseParallelRendering.

void QgsMapCanvas::keyPressed ( QKeyEvent *  e)
signal

Emit key press event.

Referenced by keyPressEvent().

void QgsMapCanvas::keyPressEvent ( QKeyEvent *  e)
protected
void QgsMapCanvas::keyReleased ( QKeyEvent *  e)
signal

Emit key release event.

Referenced by keyReleaseEvent().

void QgsMapCanvas::keyReleaseEvent ( QKeyEvent *  e)
protected

Overridden key release event.

Definition at line 1111 of file qgsmapcanvas.cpp.

References keyReleased(), QgsMapTool::keyReleaseEvent(), mCanvasProperties, mMapTool, panActionEnd(), and QgsDebugMsg.

const QgsLabelingResults * QgsMapCanvas::labelingResults ( ) const

Get access to the labeling results (may be null)

Note
added in 2.4

Definition at line 523 of file qgsmapcanvas.cpp.

References mLabelingResults.

QgsMapLayer * QgsMapCanvas::layer ( int  index)
int QgsMapCanvas::layerCount ( ) const

return number of layers on the map

Definition at line 1467 of file qgsmapcanvas.cpp.

References QgsMapSettings::layers(), and mapSettings().

Referenced by QgsMapToolIdentify::identify(), and setLayerSet().

QList< QgsMapLayer * > QgsMapCanvas::layers ( ) const

return list of layers within map canvas. Added in v1.5

Definition at line 1473 of file qgsmapcanvas.cpp.

References QgsMapLayerRegistry::instance(), layer(), QgsMapLayerRegistry::mapLayer(), and mapSettings().

Referenced by layer(), QgsFormAnnotationItem::updateVisibility(), and QgsHtmlAnnotationItem::updateVisibility().

void QgsMapCanvas::layersChanged ( )
signal

Emitted when a new set of layers has been received.

Referenced by setLayerSet().

void QgsMapCanvas::layerStateChange ( )
slot

This slot is connected to the visibility change of one or more layers.

Definition at line 1486 of file qgsmapcanvas.cpp.

References refresh().

QgsMapCanvasMap * QgsMapCanvas::map ( )
Deprecated:
since 2.4 - there could be more than just one "map" items

Definition at line 306 of file qgsmapcanvas.cpp.

References mMap.

void QgsMapCanvas::mapCanvasRefreshed ( )
signal

Emitted when canvas finished a refresh request.

Note
Added in 2.0

Referenced by rendererJobFinished().

QgsMapRenderer * QgsMapCanvas::mapRenderer ( )
Deprecated:
since 2.4 - use mapSettings() for anything related to current renderer settings / SIP: removed /Transfer/ because it crashes after few calls to iface.mapCanvas().mapRenderer().hasCrsTransformEnabled() / and in fact there is no transfer of ownership from c++ to python! / Actually the problem comes from the fact that "hasCrsTransformEnabled" is both a signal and a normal method / /KeepReference/ is necessary because otherwise mapRenderer().hasCrsTransformEnabled() was crashing

Definition at line 311 of file qgsmapcanvas.cpp.

References mMapRenderer.

const QgsMapSettings & QgsMapCanvas::mapSettings ( ) const
QgsMapTool * QgsMapCanvas::mapTool ( )

Returns the currently active tool.

Definition at line 1585 of file qgsmapcanvas.cpp.

References mMapTool.

void QgsMapCanvas::mapToolDestroyed ( )
privateslot

called when current maptool is destroyed

Definition at line 1838 of file qgsmapcanvas.cpp.

References mMapTool, and QgsDebugMsg.

Referenced by setMapTool().

void QgsMapCanvas::mapToolSet ( QgsMapTool tool)
signal

Emit map tool changed event.

Referenced by setMapTool(), and unsetMapTool().

void QgsMapCanvas::mapToolSet ( QgsMapTool newTool,
QgsMapTool oldTool 
)
signal

Emit map tool changed with the old tool.

Note
added in 2.3
QGis::UnitType QgsMapCanvas::mapUnits ( ) const

Get the current canvas map units.

Definition at line 1536 of file qgsmapcanvas.cpp.

References mapSettings(), and QgsMapSettings::mapUnits().

Referenced by QgsMapToolIdentify::convertMeasurement(), and QgsMapToolIdentify::displayUnits().

void QgsMapCanvas::mapUnitsChanged ( )
signal

Emmitted when map units are changed.

Note
added in 2.4

Referenced by setMapUnits().

double QgsMapCanvas::mapUnitsPerPixel ( ) const

Returns the mapUnitsPerPixel (map units per pixel) for the canvas.

Definition at line 1514 of file qgsmapcanvas.cpp.

References mapSettings(), and QgsMapSettings::mapUnitsPerPixel().

Referenced by QgsMapToolIdentify::identify(), saveAsImage(), and QgsRubberBand::updateRect().

int QgsMapCanvas::mapUpdateInterval ( ) const

Find out how often map preview should be updated while it is being rendered (in milliseconds)

Note
added in 2.4

Definition at line 570 of file qgsmapcanvas.cpp.

References mMapUpdateTimer.

void QgsMapCanvas::mapUpdateTimeout ( )
privateslot
void QgsMapCanvas::mouseDoubleClickEvent ( QMouseEvent *  e)
protected

Overridden mouse double click event.

Definition at line 1143 of file qgsmapcanvas.cpp.

References QgsMapTool::canvasDoubleClickEvent(), and mMapTool.

QPoint QgsMapCanvas::mouseLastXY ( )

returns last position of mouse cursor

Definition at line 1658 of file qgsmapcanvas.cpp.

References mCanvasProperties.

void QgsMapCanvas::mouseMoveEvent ( QMouseEvent *  e)
protected
void QgsMapCanvas::mousePressEvent ( QMouseEvent *  e)
protected

Overridden mouse press event.

Definition at line 1151 of file qgsmapcanvas.cpp.

References QgsMapTool::canvasPressEvent(), mCanvasProperties, and mMapTool.

void QgsMapCanvas::mouseReleaseEvent ( QMouseEvent *  e)
protected
void QgsMapCanvas::moveCanvasContents ( bool  reset = false)
protected

called when panning is in action, reset indicates end of panning

Definition at line 1644 of file qgsmapcanvas.cpp.

References mCanvasProperties.

Referenced by panAction(), panActionEnd(), QgsMapCanvas(), and resizeEvent().

void QgsMapCanvas::paintEvent ( QPaintEvent *  e)
protected

Overridden paint event.

Definition at line 1245 of file qgsmapcanvas.cpp.

void QgsMapCanvas::panAction ( QMouseEvent *  event)

Called when mouse is moving and pan is activated.

Definition at line 1636 of file qgsmapcanvas.cpp.

References moveCanvasContents().

Referenced by QgsMapToolPan::canvasMoveEvent(), QgsMapToolTouch::canvasMoveEvent(), and mouseMoveEvent().

void QgsMapCanvas::panActionEnd ( QPoint  releasePoint)
void QgsMapCanvas::panToSelected ( QgsVectorLayer layer = NULL)

Pan to the selected features of current (vector) layer keeping same extent.

Note
added in 2.0

Definition at line 981 of file qgsmapcanvas.cpp.

References QgsVectorLayer::boundingBoxOfSelected(), QgsRectangle::center(), QgsMapSettings::layerExtentToOutputExtent(), mapSettings(), mCurrentLayer, refresh(), QgsVectorLayer::selectedFeatureCount(), and setExtent().

QgsPreviewEffect::PreviewMode QgsMapCanvas::previewMode ( ) const

Returns the current preview mode for the map canvas.

This setting only has an effect if previewModeEnabled is true.

Returns
preview mode for map canvas
See also
setPreviewMode
previewModeEnabled
Note
added in 2.3

Definition at line 1693 of file qgsmapcanvas.cpp.

References QgsPreviewEffect::mode(), mPreviewEffect, and QgsPreviewEffect::PreviewGrayscale.

bool QgsMapCanvas::previewModeEnabled ( ) const

Returns whether a preview mode is enabled for the map canvas.

Returns
true if a preview mode is currently enabled
See also
setPreviewModeEnabled
previewMode
Note
added in 2.3

Definition at line 1673 of file qgsmapcanvas.cpp.

References mPreviewEffect.

void QgsMapCanvas::readProject ( const QDomDocument &  doc)
slot
void QgsMapCanvas::refresh ( )
slot
void QgsMapCanvas::refreshMap ( )
privateslot
void QgsMapCanvas::renderComplete ( QPainter *  )
signal

Emitted when the canvas has rendered.

Passes a pointer to the painter on which the map was drawn. This is useful for plugins that wish to draw on the map after it has been rendered. Passing the painter allows plugins to work when the map is being rendered onto a pixmap other than the mapCanvas own pixmap member.TODO: deprecate when decorations are reimplemented as map canvas items

  • anything related to rendering progress is not visible outside of map canvas
  • additional drawing shall be done directly within the renderer job or independently as a map canvas item

Referenced by rendererJobFinished(), and saveAsImage().

void QgsMapCanvas::rendererJobFinished ( )
privateslot
bool QgsMapCanvas::renderFlag ( )
inlineslot

State of render suppression flag.

Definition at line 383 of file qgsmapcanvas.h.

void QgsMapCanvas::renderStarting ( )
signal

Emitted when the canvas is about to be rendered.

Note
Added in 1.5

Referenced by refreshMap().

void QgsMapCanvas::resizeEvent ( QResizeEvent *  e)
protected
void QgsMapCanvas::saveAsImage ( QString  theFileName,
QPixmap *  QPixmap = 0,
QString  theFormat = "PNG" 
)
slot
double QgsMapCanvas::scale ( )

Get the last reported scale of the canvas.

Definition at line 332 of file qgsmapcanvas.cpp.

References mapSettings(), and QgsMapSettings::scale().

Referenced by QgsMapCanvasItem::setRenderContextVariables(), updateScale(), and zoomScale().

void QgsMapCanvas::scaleChanged ( double  )
signal

Emitted when the scale of the map changes.

Referenced by updateScale().

void QgsMapCanvas::selectionChanged ( QgsMapLayer layer)
signal

Emitted when selection in any layer gets changed.

Referenced by selectionChangedSlot(), and setLayerSet().

void QgsMapCanvas::selectionChangedSlot ( )
slot

Receives signal about selection change, and pass it on with layer info.

Definition at line 1822 of file qgsmapcanvas.cpp.

References layer(), refresh(), and selectionChanged().

Referenced by setLayerSet().

void QgsMapCanvas::setCachingEnabled ( bool  enabled)

Set whether to cache images of rendered layers.

Note
added in 2.4

Definition at line 528 of file qgsmapcanvas.cpp.

References isCachingEnabled(), and mCache.

void QgsMapCanvas::setCanvasColor ( const QColor &  theColor)
virtual

Write property of QColor bgColor.

Definition at line 1439 of file qgsmapcanvas.cpp.

References mScene, mSettings, and QgsMapSettings::setBackgroundColor().

void QgsMapCanvas::setCrsTransformEnabled ( bool  enabled)
void QgsMapCanvas::setCurrentLayer ( QgsMapLayer layer)

Definition at line 327 of file qgsmapcanvas.cpp.

References layer(), and mCurrentLayer.

void QgsMapCanvas::setDestinationCrs ( const QgsCoordinateReferenceSystem crs)
void QgsMapCanvas::setDirty ( bool  _dirty)

Flag the canvas as dirty and needed a refresh.

Deprecated:
since 2.4 - use refresh() to trigger a refresh (clients should not decide explicitly whether canvas is dirty or not)

Definition at line 337 of file qgsmapcanvas.cpp.

References refresh().

void QgsMapCanvas::setExtent ( const QgsRectangle r)
void QgsMapCanvas::setLayerSet ( QList< QgsMapCanvasLayer > &  layers)
void QgsMapCanvas::setMapTool ( QgsMapTool mapTool)

Sets the map tool currently being used on the canvas.

Definition at line 1384 of file qgsmapcanvas.cpp.

References QgsMapTool::activate(), QgsMapTool::deactivate(), QgsMapTool::isTransient(), mapToolDestroyed(), mapToolSet(), mLastNonZoomMapTool, and mMapTool.

Referenced by mouseReleaseEvent().

void QgsMapCanvas::setMapUnits ( QGis::UnitType  mapUnits)

Set map units (needed by project properties dialog)

Definition at line 1520 of file qgsmapcanvas.cpp.

References QgsMapSettings::mapUnits(), mapUnitsChanged(), mSettings, QgsDebugMsg, refresh(), QgsMapSettings::setMapUnits(), and updateScale().

Referenced by QgsMapCanvasRendererSync::onMapUnitsR2C(), and readProject().

void QgsMapCanvas::setMapUpdateInterval ( int  timeMiliseconds)

Set how often map preview should be updated while it is being rendered (in milliseconds)

Note
added in 2.4

Definition at line 565 of file qgsmapcanvas.cpp.

References mMapUpdateTimer.

void QgsMapCanvas::setParallelRenderingEnabled ( bool  enabled)

Set whether the layers are rendered in parallel or sequentially.

Note
added in 2.4

Definition at line 555 of file qgsmapcanvas.cpp.

References mUseParallelRendering.

void QgsMapCanvas::setPreviewMode ( QgsPreviewEffect::PreviewMode  mode)

Sets a preview mode for the map canvas.

This setting only has an effect if previewModeEnabled is true.

Parameters
modepreview mode for the canvas
See also
previewMode
setPreviewModeEnabled
previewModeEnabled
Note
added in 2.3

Definition at line 1683 of file qgsmapcanvas.cpp.

References mPreviewEffect, and QgsPreviewEffect::setMode().

void QgsMapCanvas::setPreviewModeEnabled ( bool  previewEnabled)

Enables a preview mode for the map canvas.

Parameters
previewEnabledset to true to enable a preview mode
See also
setPreviewMode
Note
added in 2.3

Definition at line 1663 of file qgsmapcanvas.cpp.

References mPreviewEffect.

Q_DECL_DEPRECATED void QgsMapCanvas::setProgress ( int  ,
int   
)
signal

Let the owner know how far we are with render operations.

Deprecated:
since 2.4 - already unused in 2.0 anyway
void QgsMapCanvas::setRenderFlag ( bool  theFlag)
slot

Whether to suppress rendering or not.

Definition at line 1542 of file qgsmapcanvas.cpp.

References mRenderFlag, refresh(), and stopRendering().

void QgsMapCanvas::setSelectionColor ( const QColor &  color)

Set color of selected vector features.

Note
added in 2.4

Definition at line 1462 of file qgsmapcanvas.cpp.

References mSettings, and QgsMapSettings::setSelectionColor().

void QgsMapCanvas::setWheelAction ( WheelAction  action,
double  factor = 2 
)

set wheel action and zoom factor (should be greater than 1)

Definition at line 1327 of file qgsmapcanvas.cpp.

References mWheelAction, and mWheelZoomFactor.

Referenced by QgsMapCanvas().

void QgsMapCanvas::showError ( QgsMapLayer mapLayer)
slot
Deprecated:
since 2.4 - does nothing - errors are reported by different means

Definition at line 1653 of file qgsmapcanvas.cpp.

void QgsMapCanvas::stopRendering ( )
slot

stop rendering (if there is any right now)

Note
added in 2.4

Definition at line 730 of file qgsmapcanvas.cpp.

References QgsMapRendererJob::cancel(), mJob, mJobCancelled, and QgsDebugMsg.

Referenced by refreshMap(), and setRenderFlag().

void QgsMapCanvas::unsetMapTool ( QgsMapTool mapTool)

Unset the current map tool or last non zoom tool.

This is called from destructor of map tools to make sure that this map tool won't be used any more. You don't have to call it manualy, QgsMapTool takes care of it.

Definition at line 1421 of file qgsmapcanvas.cpp.

References QgsMapTool::deactivate(), mapToolSet(), mLastNonZoomMapTool, and mMapTool.

Referenced by QgsMapTool::~QgsMapTool().

void QgsMapCanvas::updateCanvasItemPositions ( )
protected

called on resize or changed extent to notify canvas items to change their rectangle

Definition at line 1252 of file qgsmapcanvas.cpp.

References mScene, and QgsMapCanvasItem::updatePosition().

Referenced by resizeEvent(), setExtent(), zoomToNextExtent(), and zoomToPreviousExtent().

void QgsMapCanvas::updateDatumTransformEntries ( )
protected
Q_DECL_DEPRECATED void QgsMapCanvas::updateFullExtent ( )
inline

Updates the full extent.

Deprecated:
since v2.4 - does nothing

Definition at line 252 of file qgsmapcanvas.h.

void QgsMapCanvas::updateMap ( )
slot
Deprecated:
in 2.4 - does nothing - kept for API compatibility

Definition at line 741 of file qgsmapcanvas.cpp.

void QgsMapCanvas::updateOverview ( )

Definition at line 576 of file qgsmapcanvas.cpp.

References mMapOverview, and QgsMapOverviewCanvas::refresh().

Referenced by setLayerSet().

void QgsMapCanvas::updateScale ( )

Emits signal scaleChanged to update scale in main window.

Definition at line 859 of file qgsmapcanvas.cpp.

References mapSettings(), scale(), and scaleChanged().

Referenced by resizeEvent(), setExtent(), setMapUnits(), zoomToNextExtent(), and zoomToPreviousExtent().

void QgsMapCanvas::useImageToRender ( bool  theFlag)

Select which Qt class to render with.

Deprecated:
since 2.4 - does nothing because now we always render to QImage

Definition at line 301 of file qgsmapcanvas.cpp.

void QgsMapCanvas::wheelEvent ( QWheelEvent *  e)
protected
void QgsMapCanvas::writeProject ( QDomDocument &  doc)
slot

called to write map canvas settings to project

Definition at line 1726 of file qgsmapcanvas.cpp.

References mSettings, QgsDebugMsg, and QgsMapSettings::writeXML().

Referenced by QgsMapCanvas().

void QgsMapCanvas::xyCoordinates ( const QgsPoint p)
signal

emits current mouse position

Note
changed in 1.3

Referenced by mouseMoveEvent().

void QgsMapCanvas::zoomByFactor ( double  scaleFactor)

Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in.

Definition at line 1814 of file qgsmapcanvas.cpp.

References mapSettings(), refresh(), QgsRectangle::scale(), setExtent(), and QgsMapSettings::visibleExtent().

Referenced by zoomIn(), zoomOut(), and zoomScale().

void QgsMapCanvas::zoomIn ( )

Zoom in with fixed factor.

Definition at line 1333 of file qgsmapcanvas.cpp.

References mWheelZoomFactor, and zoomByFactor().

Referenced by keyPressEvent(), and wheelEvent().

void QgsMapCanvas::zoomLastStatusChanged ( bool  )
signal

Emitted when zoom last status changed.

Note
: this signal was added in version 1.4

Referenced by clearExtentHistory(), setExtent(), zoomToNextExtent(), and zoomToPreviousExtent().

void QgsMapCanvas::zoomNextStatusChanged ( bool  )
signal

Emitted when zoom next status changed.

Note
: this signal was added in version 1.4

Referenced by clearExtentHistory(), setExtent(), zoomToNextExtent(), and zoomToPreviousExtent().

void QgsMapCanvas::zoomOut ( )

Zoom out with fixed factor.

Definition at line 1338 of file qgsmapcanvas.cpp.

References mWheelZoomFactor, and zoomByFactor().

Referenced by keyPressEvent(), QgsMapToolTouch::pinchTriggered(), and wheelEvent().

void QgsMapCanvas::zoomScale ( double  scale)

Zoom to a specific scale.

Definition at line 1343 of file qgsmapcanvas.cpp.

References scale(), and zoomByFactor().

void QgsMapCanvas::zoomToFullExtent ( )

Zoom to the full extent of all layers.

Definition at line 872 of file qgsmapcanvas.cpp.

References extent(), fullExtent(), QgsRectangle::isEmpty(), refresh(), QgsRectangle::scale(), and setExtent().

void QgsMapCanvas::zoomToNextExtent ( )
void QgsMapCanvas::zoomToPreviousExtent ( )
void QgsMapCanvas::zoomToSelected ( QgsVectorLayer layer = NULL)

Zoom to the extent of the selected features of current (vector) layer.

Added in version 1.2: optionally specify different than current layer

Definition at line 939 of file qgsmapcanvas.cpp.

References QgsVectorLayer::boundingBoxOfSelected(), QgsRectangle::center(), extent(), QgsRectangle::isEmpty(), QgsMapSettings::layerExtentToOutputExtent(), mapSettings(), mCurrentLayer, refresh(), QgsRectangle::scale(), QgsVectorLayer::selectedFeatureCount(), and setExtent().

void QgsMapCanvas::zoomWithCenter ( int  x,
int  y,
bool  zoomIn 
)

Member Data Documentation

QgsMapRendererCache* QgsMapCanvas::mCache
private

Optionally use cache with rendered map layers for the current map settings.

Definition at line 625 of file qgsmapcanvas.h.

Referenced by clearCache(), isCachingEnabled(), refreshMap(), setCachingEnabled(), and ~QgsMapCanvas().

std::auto_ptr<CanvasProperties> QgsMapCanvas::mCanvasProperties
protected

Handle pattern for implementation object.

Definition at line 540 of file qgsmapcanvas.h.

Referenced by keyPressEvent(), keyReleaseEvent(), mouseLastXY(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveCanvasContents(), and panActionEnd().

QgsMapLayer* QgsMapCanvas::mCurrentLayer
private

current layer in legend

Definition at line 585 of file qgsmapcanvas.h.

Referenced by currentLayer(), mouseReleaseEvent(), panToSelected(), QgsMapCanvas(), setCurrentLayer(), and zoomToSelected().

bool QgsMapCanvas::mDrawRenderingStats
private

Whether to add rendering stats to the rendered image.

Definition at line 622 of file qgsmapcanvas.h.

Referenced by keyPressEvent(), and rendererJobFinished().

bool QgsMapCanvas::mFrozen
private

Flag indicating if the map canvas is frozen.

Definition at line 576 of file qgsmapcanvas.h.

Referenced by freeze(), isFrozen(), QgsMapCanvas(), and refresh().

QgsMapRendererQImageJob* QgsMapCanvas::mJob
private

Job that takes care of map rendering in background.

Definition at line 610 of file qgsmapcanvas.h.

Referenced by isDrawing(), mapUpdateTimeout(), refreshMap(), rendererJobFinished(), stopRendering(), and ~QgsMapCanvas().

bool QgsMapCanvas::mJobCancelled
private

Flag determining whether the active job has been cancelled.

Definition at line 613 of file qgsmapcanvas.h.

Referenced by refreshMap(), rendererJobFinished(), and stopRendering().

QgsLabelingResults* QgsMapCanvas::mLabelingResults
private

Labeling results from the recently rendered map.

Definition at line 616 of file qgsmapcanvas.h.

Referenced by labelingResults(), rendererJobFinished(), and ~QgsMapCanvas().

QList<QgsRectangle> QgsMapCanvas::mLastExtent
private

recently used extent

Definition at line 597 of file qgsmapcanvas.h.

Referenced by clearExtentHistory(), setExtent(), zoomToNextExtent(), and zoomToPreviousExtent().

int QgsMapCanvas::mLastExtentIndex
private
QgsMapTool* QgsMapCanvas::mLastNonZoomMapTool
private

previous tool if current is for zooming/panning

Definition at line 594 of file qgsmapcanvas.h.

Referenced by mouseReleaseEvent(), QgsMapCanvas(), setMapTool(), unsetMapTool(), and ~QgsMapCanvas().

QgsMapCanvasMap* QgsMapCanvas::mMap
private

owns pixmap with rendered map and controls rendering

Definition at line 570 of file qgsmapcanvas.h.

Referenced by canvasPaintDevice(), map(), mapUpdateTimeout(), QgsMapCanvas(), rendererJobFinished(), and saveAsImage().

QgsMapOverviewCanvas* QgsMapCanvas::mMapOverview
private

map overview widget - it's controlled by QgsMapCanvas

Definition at line 573 of file qgsmapcanvas.h.

Referenced by enableAntiAliasing(), enableOverviewMode(), QgsMapCanvas(), setLayerSet(), and updateOverview().

QgsMapRenderer* QgsMapCanvas::mMapRenderer
private

all map rendering is done in this class

Definition at line 567 of file qgsmapcanvas.h.

Referenced by getDatumTransformInfo(), mapRenderer(), QgsMapCanvas(), resizeEvent(), and ~QgsMapCanvas().

QgsMapTool* QgsMapCanvas::mMapTool
private
QTimer QgsMapCanvas::mMapUpdateTimer
private

Timer that periodically fires while map rendering is in progress to update the visible map.

Definition at line 607 of file qgsmapcanvas.h.

Referenced by mapUpdateInterval(), QgsMapCanvas(), refreshMap(), rendererJobFinished(), and setMapUpdateInterval().

QgsPreviewEffect* QgsMapCanvas::mPreviewEffect
private
bool QgsMapCanvas::mRefreshScheduled
private

Flag that allows squashing multiple refresh() calls into just one delayed rendering job.

Definition at line 579 of file qgsmapcanvas.h.

Referenced by QgsMapCanvas(), refresh(), and refreshMap().

bool QgsMapCanvas::mRenderFlag
private

determines whether user has requested to suppress rendering

Definition at line 582 of file qgsmapcanvas.h.

Referenced by QgsMapCanvas(), refresh(), and setRenderFlag().

QTimer* QgsMapCanvas::mResizeTimer
private

Definition at line 627 of file qgsmapcanvas.h.

Referenced by QgsMapCanvas(), and resizeEvent().

QGraphicsScene* QgsMapCanvas::mScene
private

graphics scene manages canvas items

Definition at line 588 of file qgsmapcanvas.h.

Referenced by canvasColor(), QgsMapCanvas(), resizeEvent(), setCanvasColor(), updateCanvasItemPositions(), and ~QgsMapCanvas().

QgsMapSettings QgsMapCanvas::mSettings
private
bool QgsMapCanvas::mUseParallelRendering
private

Whether layers are rendered sequentially or in parallel.

Definition at line 619 of file qgsmapcanvas.h.

Referenced by isParallelRenderingEnabled(), keyPressEvent(), refreshMap(), rendererJobFinished(), and setParallelRenderingEnabled().

WheelAction QgsMapCanvas::mWheelAction
private

Mouse wheel action.

Definition at line 604 of file qgsmapcanvas.h.

Referenced by setWheelAction(), and wheelEvent().

double QgsMapCanvas::mWheelZoomFactor
private

Scale factor multiple for default zoom in/out.

Definition at line 601 of file qgsmapcanvas.h.

Referenced by setWheelAction(), wheelEvent(), zoomIn(), zoomOut(), and zoomWithCenter().


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