QGIS API Documentation  2.99.0-Master (8ec3eaf)
Classes | Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | 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]

Classes

class  CanvasProperties
 Deprecated to be deleted, stuff from here should be moved elsewhere. More...
 

Public Slots

void getDatumTransformInfo (const QgsMapLayer *ml, const QString &srcAuthId, const QString &destAuthId)
 ask user about datum transformation More...
 
bool hasCrsTransformEnabled ()
 A simple helper method to find out if on the fly projections are enabled or not. More...
 
void layerCrsChange ()
 This slot is connected to the layer's CRS change. More...
 
void layerStateChange ()
 This slot is connected to the visibility change of one or more layers. More...
 
void readProject (const QDomDocument &)
 called to read map canvas settings from project More...
 
void refresh ()
 Repaints the canvas map. More...
 
bool renderFlag ()
 State of render suppression flag. More...
 
void saveAsImage (const QString &theFileName, QPixmap *QPixmap=nullptr, const QString &="PNG")
 Save the convtents of the map canvas to disk as an image. More...
 
void selectionChangedSlot ()
 Receives signal about selection change, and pass it on with layer info. More...
 
void setMagnificationFactor (double factor)
 Sets the factor of magnification to apply to the map canvas. More...
 
void setRenderFlag (bool theFlag)
 Whether to suppress rendering or not. More...
 
void setScaleLocked (bool isLocked)
 Lock the scale, so zooming can be performed using magnication. More...
 
void stopRendering ()
 stop rendering (if there is any right now) More...
 
void writeProject (QDomDocument &)
 called to write map canvas settings to project More...
 
void zoomIn ()
 Zoom in with fixed factor. More...
 
void zoomOut ()
 Zoom out with fixed factor. More...
 

Signals

void currentLayerChanged (QgsMapLayer *layer)
 Emitted when the current layer is changed. More...
 
void destinationCrsChanged ()
 Emitted when map CRS has changed. More...
 
void extentsChanged ()
 Emitted when the extents of the map change. More...
 
void hasCrsTransformEnabledChanged (bool flag)
 Emitted when on-the-fly projection has been turned on/off. More...
 
void keyPressed (QKeyEvent *e)
 Emit key press event. More...
 
void keyReleased (QKeyEvent *e)
 Emit key release event. More...
 
void layersChanged ()
 Emitted when a new set of layers has been received. More...
 
void layerStyleOverridesChanged ()
 Emitted when the configuration of overridden layer styles changes. More...
 
void magnificationChanged (double)
 Emitted when the scale of the map changes. More...
 
void mapCanvasRefreshed ()
 Emitted when canvas finished a refresh request. 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 mapUnitsChanged ()
 Emitted when map units are changed. More...
 
void messageEmitted (const QString &title, const QString &message, QgsMessageBar::MessageLevel=QgsMessageBar::INFO)
 emit a message (usually to be displayed in a message bar) More...
 
void renderComplete (QPainter *)
 Emitted when the canvas has rendered. More...
 
void renderStarting ()
 Emitted when the canvas is about to be rendered. More...
 
void rotationChanged (double)
 Emitted when the rotation of the map changes. More...
 
void scaleChanged (double)
 Emitted when the scale of the map changes. More...
 
void selectionChanged (QgsMapLayer *layer)
 Emitted when selection in any layer gets changed. More...
 
void xyCoordinates (const QgsPoint &p)
 Emits current mouse position. More...
 
void zoomLastStatusChanged (bool)
 Emitted when zoom last status changed. More...
 
void zoomNextStatusChanged (bool)
 Emitted when zoom next status changed. More...
 

Public Member Functions

 QgsMapCanvas (QWidget *parent=nullptr)
 Constructor. More...
 
 ~QgsMapCanvas ()
 Destructor. More...
 
bool antiAliasingEnabled () const
 true if antialising is enabled More...
 
QColor canvasColor () const
 Read property of QColor bgColor. More...
 
QgsPoint center () const
 Get map center, in geographical coordinates. More...
 
void clearCache ()
 Make sure to remove any rendered images from cache (does nothing if cache is not enabled) More...
 
void clearExtentHistory ()
 
QgsMapLayercurrentLayer ()
 returns current layer (set by legend widget) More...
 
void enableAntiAliasing (bool theFlag)
 used to determine if anti-aliasing is enabled or not More...
 
void enableMapTileRendering (bool theFlag)
 sets map tile rendering flag More...
 
void enableOverviewMode (QgsMapOverviewCanvas *overview)
 
QgsExpressionContextScopeexpressionContextScope ()
 Returns a reference to the expression context scope for the map canvas. More...
 
const QgsExpressionContextScopeexpressionContextScope () const
 Returns a const reference to the expression context scope for the map canvas. More...
 
QgsRectangle extent () const
 Returns the current zoom exent of the map canvas. More...
 
void freeze (bool frz=true)
 Freeze/thaw the map canvas. More...
 
QgsRectangle fullExtent () const
 Returns the combined exent for all layers on the map canvas. More...
 
const QgsMapToPixelgetCoordinateTransform ()
 Get the current coordinate transform. More...
 
bool isCachingEnabled () const
 Check whether images of rendered layers are curerently being cached. More...
 
bool isDrawing ()
 Find out whether rendering is in progress. More...
 
bool isFrozen ()
 Accessor for frozen status of canvas. More...
 
bool isParallelRenderingEnabled () const
 Check whether the layers are rendered in parallel or sequentially. More...
 
const QgsLabelingResultslabelingResults () const
 Get access to the labeling results (may be null) 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. More...
 
QMap< QString, QString > layerStyleOverrides () const
 Getter for stored overrides of styles for layers. More...
 
double magnificationFactor () const
 Returns the magnification factor. More...
 
const QgsMapSettingsmapSettings () const
 Get access to properties used for map rendering. More...
 
QgsMapToolmapTool ()
 Returns the currently active tool. More...
 
QgsUnitTypes::DistanceUnit mapUnits () const
 Get the current canvas map units. More...
 
double mapUnitsPerPixel () const
 Returns the mapUnitsPerPixel (map units per pixel) for the canvas. More...
 
int mapUpdateInterval () const
 Find out how often map preview should be updated while it is being rendered (in milliseconds) More...
 
QPoint mouseLastXY ()
 returns last position of mouse cursor More...
 
void panAction (QMouseEvent *event)
 Called when mouse is moving and pan is activated. More...
 
void panActionEnd (QPoint releasePoint)
 Ends pan action and redraws the canvas. More...
 
void panToFeatureIds (QgsVectorLayer *layer, const QgsFeatureIds &ids)
 Centers canvas extent to feature ids. More...
 
void panToSelected (QgsVectorLayer *layer=nullptr)
 Pan to the selected features of current (vector) layer keeping same extent. More...
 
QgsPreviewEffect::PreviewMode previewMode () const
 Returns the current preview mode for the map canvas. More...
 
bool previewModeEnabled () const
 Returns whether a preview mode is enabled for the map canvas. More...
 
void refreshAllLayers ()
 Reload all layers, clear the cache and refresh the canvas. More...
 
double rotation () const
 Get the current map canvas rotation in clockwise degrees. More...
 
double scale ()
 Get the last reported scale of the canvas. More...
 
bool scaleLocked () const
 Returns whether the scale is locked, so zooming can be performed using magnication. More...
 
void setCachingEnabled (bool enabled)
 Set whether to cache images of rendered layers. More...
 
void setCanvasColor (const QColor &_newVal)
 Write property of QColor bgColor. More...
 
void setCenter (const QgsPoint &center)
 Set the center of the map canvas, in geographical coordinates. More...
 
void setCrsTransformEnabled (bool enabled)
 sets whether to use projections for this layer set More...
 
void setCurrentLayer (QgsMapLayer *layer)
 
void setDestinationCrs (const QgsCoordinateReferenceSystem &crs)
 sets destination coordinate reference system More...
 
void setExpressionContextScope (const QgsExpressionContextScope &scope)
 Sets an expression context scope for the map canvas. More...
 
void setExtent (const QgsRectangle &r, bool magnified=false)
 Set the extent of the map canvas. More...
 
void setLayerSet (QList< QgsMapCanvasLayer > &layers)
 
void setLayerStyleOverrides (const QMap< QString, QString > &overrides)
 Setter for stored overrides of styles for layers. More...
 
void setMapTool (QgsMapTool *mapTool)
 Sets the map tool currently being used on the canvas. More...
 
void setMapUnits (QgsUnitTypes::DistanceUnit mapUnits)
 Set map units (needed by project properties dialog) More...
 
void setMapUpdateInterval (int timeMilliseconds)
 Set how often map preview should be updated while it is being rendered (in milliseconds) More...
 
void setParallelRenderingEnabled (bool enabled)
 Set whether the layers are rendered in parallel or sequentially. More...
 
void setPreviewMode (QgsPreviewEffect::PreviewMode mode)
 Sets a preview mode for the map canvas. More...
 
void setPreviewModeEnabled (bool previewEnabled)
 Enables a preview mode for the map canvas. More...
 
void setRotation (double degrees)
 Set the rotation of the map canvas in clockwise degrees. More...
 
void setSegmentationTolerance (double tolerance)
 Sets the segmentation tolerance applied when rendering curved geometries. More...
 
void setSegmentationToleranceType (QgsAbstractGeometry::SegmentationToleranceType type)
 Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation) More...
 
void setSelectionColor (const QColor &color)
 Set color of selected vector features. More...
 
void setSnappingUtils (QgsSnappingUtils *utils)
 Assign an instance of snapping utils to the map canvas. More...
 
void setWheelFactor (double factor)
 set wheel zoom factor (should be greater than 1) More...
 
QgsSnappingUtilssnappingUtils () const
 Return snapping utility class that is associated with map canvas. More...
 
void unsetMapTool (QgsMapTool *mapTool)
 Unset the current map tool or last non zoom tool. More...
 
void updateOverview ()
 
void updateScale ()
 Emits signal scaleChanged to update scale in main window. More...
 
void zoomByFactor (double scaleFactor, const QgsPoint *center=nullptr)
 Zoom with the factor supplied. More...
 
void zoomScale (double scale)
 Zoom to a specific scale. More...
 
void zoomToFeatureIds (QgsVectorLayer *layer, const QgsFeatureIds &ids)
 Set canvas extent to the bounding box of a set of features. More...
 
void zoomToFullExtent ()
 Zoom to the full extent of all layers. More...
 
void zoomToNextExtent ()
 Zoom to the next extent (view) More...
 
void zoomToPreviousExtent ()
 Zoom to the previous extent (view) More...
 
void zoomToSelected (QgsVectorLayer *layer=nullptr)
 Zoom to the extent of the selected features of current (vector) layer. More...
 
void zoomWithCenter (int x, int y, bool zoomIn)
 Zooms in/out with a given center. More...
 

Protected Member Functions

void dragEnterEvent (QDragEnterEvent *e) override
 Overridden drag enter event. More...
 
void keyPressEvent (QKeyEvent *e) override
 Overridden key press event. More...
 
void keyReleaseEvent (QKeyEvent *e) override
 Overridden key release event. More...
 
void mouseDoubleClickEvent (QMouseEvent *e) override
 Overridden mouse double click event. More...
 
void mouseMoveEvent (QMouseEvent *e) override
 Overridden mouse move event. More...
 
void mousePressEvent (QMouseEvent *e) override
 Overridden mouse press event. More...
 
void mouseReleaseEvent (QMouseEvent *e) override
 Overridden mouse release event. More...
 
void moveCanvasContents (bool reset=false)
 called when panning is in action, reset indicates end of panning More...
 
void paintEvent (QPaintEvent *e) override
 Overridden paint event. More...
 
void resizeEvent (QResizeEvent *e) override
 Overridden resize event. More...
 
void updateCanvasItemPositions ()
 called on resize or changed extent to notify canvas items to change their rectangle More...
 
void updateDatumTransformEntries ()
 Make sure the datum transform store is properly populated. More...
 
void wheelEvent (QWheelEvent *e) override
 Overridden mouse wheel event. More...
 
void zoomToFeatureExtent (QgsRectangle &rect)
 Zooms to feature extent. More...
 

Protected Attributes

QScopedPointer< CanvasPropertiesmCanvasProperties
 Handle pattern for implementation object. More...
 

Friends

class TestQgsMapCanvas
 

Detailed Description

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

Definition at line 106 of file qgsmapcanvas.h.

Constructor & Destructor Documentation

§ QgsMapCanvas()

QgsMapCanvas::QgsMapCanvas ( QWidget *  parent = nullptr)

Constructor.

Definition at line 97 of file qgsmapcanvas.cpp.

§ ~QgsMapCanvas()

QgsMapCanvas::~QgsMapCanvas ( )

Destructor.

Definition at line 187 of file qgsmapcanvas.cpp.

Member Function Documentation

§ antiAliasingEnabled()

bool QgsMapCanvas::antiAliasingEnabled ( ) const
inline

true if antialising is enabled

Definition at line 337 of file qgsmapcanvas.h.

§ canvasColor()

QColor QgsMapCanvas::canvasColor ( ) const

Read property of QColor bgColor.

Definition at line 1626 of file qgsmapcanvas.cpp.

§ center()

QgsPoint QgsMapCanvas::center ( ) const

Get map center, in geographical coordinates.

Note
added in 2.8

Definition at line 878 of file qgsmapcanvas.cpp.

§ clearCache()

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 498 of file qgsmapcanvas.cpp.

§ clearExtentHistory()

void QgsMapCanvas::clearExtentHistory ( )

Definition at line 964 of file qgsmapcanvas.cpp.

§ currentLayer()

QgsMapLayer * QgsMapCanvas::currentLayer ( )

returns current layer (set by legend widget)

Definition at line 535 of file qgsmapcanvas.cpp.

§ currentLayerChanged

void QgsMapCanvas::currentLayerChanged ( QgsMapLayer layer)
signal

Emitted when the current layer is changed.

Note
added in 2.8

§ destinationCrsChanged

void QgsMapCanvas::destinationCrsChanged ( )
signal

Emitted when map CRS has changed.

Note
added in 2.4

§ dragEnterEvent()

void QgsMapCanvas::dragEnterEvent ( QDragEnterEvent *  e)
overrideprotected

Overridden drag enter event.

Definition at line 2006 of file qgsmapcanvas.cpp.

§ enableAntiAliasing()

void QgsMapCanvas::enableAntiAliasing ( bool  theFlag)

used to determine if anti-aliasing is enabled or not

Definition at line 246 of file qgsmapcanvas.cpp.

§ enableMapTileRendering()

void QgsMapCanvas::enableMapTileRendering ( bool  theFlag)

sets map tile rendering flag

Definition at line 254 of file qgsmapcanvas.cpp.

§ enableOverviewMode()

void QgsMapCanvas::enableOverviewMode ( QgsMapOverviewCanvas overview)

Definition at line 382 of file qgsmapcanvas.cpp.

§ expressionContextScope() [1/2]

QgsExpressionContextScope& QgsMapCanvas::expressionContextScope ( )
inline

Returns a reference to the expression context scope for the map canvas.

This scope is injected into the expression context used for rendering the map, and can be used to apply specific variable overrides for expression evaluation for the map canvas render.

Note
added in QGIS 2.12
See also
setExpressionContextScope()

Definition at line 417 of file qgsmapcanvas.h.

§ expressionContextScope() [2/2]

const QgsExpressionContextScope& QgsMapCanvas::expressionContextScope ( ) const
inline

Returns a const reference to the expression context scope for the map canvas.

Note
added in QGIS 2.12
See also
setExpressionContextScope()
Note
not available in python bindings

Definition at line 424 of file qgsmapcanvas.h.

§ extent()

QgsRectangle QgsMapCanvas::extent ( ) const

Returns the current zoom exent of the map canvas.

Definition at line 799 of file qgsmapcanvas.cpp.

§ extentsChanged

void QgsMapCanvas::extentsChanged ( )
signal

Emitted when the extents of the map change.

§ freeze()

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.

TODO remove in QGIS 3

Definition at line 1674 of file qgsmapcanvas.cpp.

§ fullExtent()

QgsRectangle QgsMapCanvas::fullExtent ( ) const

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

Definition at line 804 of file qgsmapcanvas.cpp.

§ getCoordinateTransform()

const QgsMapToPixel * QgsMapCanvas::getCoordinateTransform ( )

Get the current coordinate transform.

Definition at line 287 of file qgsmapcanvas.cpp.

§ getDatumTransformInfo

void QgsMapCanvas::getDatumTransformInfo ( const QgsMapLayer ml,
const QString &  srcAuthId,
const QString &  destAuthId 
)
slot

ask user about datum transformation

Ask user which datum transform to use.

Definition at line 1918 of file qgsmapcanvas.cpp.

§ hasCrsTransformEnabled

bool QgsMapCanvas::hasCrsTransformEnabled ( )
slot

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

Definition at line 975 of file qgsmapcanvas.cpp.

§ hasCrsTransformEnabledChanged

void QgsMapCanvas::hasCrsTransformEnabledChanged ( bool  flag)
signal

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

Note
added in 2.4

§ isCachingEnabled()

bool QgsMapCanvas::isCachingEnabled ( ) const

Check whether images of rendered layers are curerently being cached.

Note
added in 2.4

Definition at line 493 of file qgsmapcanvas.cpp.

§ isDrawing()

bool QgsMapCanvas::isDrawing ( )

Find out whether rendering is in progress.

Definition at line 280 of file qgsmapcanvas.cpp.

§ isFrozen()

bool QgsMapCanvas::isFrozen ( )

Accessor for frozen status of canvas.

TODO remove in QGIS 3

Definition at line 1679 of file qgsmapcanvas.cpp.

§ isParallelRenderingEnabled()

bool QgsMapCanvas::isParallelRenderingEnabled ( ) const

Check whether the layers are rendered in parallel or sequentially.

Note
added in 2.4

Definition at line 509 of file qgsmapcanvas.cpp.

§ keyPressed

void QgsMapCanvas::keyPressed ( QKeyEvent *  e)
signal

Emit key press event.

§ keyPressEvent()

void QgsMapCanvas::keyPressEvent ( QKeyEvent *  e)
overrideprotected

Overridden key press event.

Definition at line 1119 of file qgsmapcanvas.cpp.

§ keyReleased

void QgsMapCanvas::keyReleased ( QKeyEvent *  e)
signal

Emit key release event.

§ keyReleaseEvent()

void QgsMapCanvas::keyReleaseEvent ( QKeyEvent *  e)
overrideprotected

Overridden key release event.

Definition at line 1213 of file qgsmapcanvas.cpp.

§ labelingResults()

const QgsLabelingResults * QgsMapCanvas::labelingResults ( ) const

Get access to the labeling results (may be null)

Note
added in 2.4

Definition at line 466 of file qgsmapcanvas.cpp.

§ layer()

QgsMapLayer * QgsMapCanvas::layer ( int  index)

return the map layer at position index in the layer stack

Definition at line 259 of file qgsmapcanvas.cpp.

§ layerCount()

int QgsMapCanvas::layerCount ( ) const

return number of layers on the map

Definition at line 1636 of file qgsmapcanvas.cpp.

§ layerCrsChange

void QgsMapCanvas::layerCrsChange ( )
slot

This slot is connected to the layer's CRS change.

Definition at line 1663 of file qgsmapcanvas.cpp.

§ layers()

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

return list of layers within map canvas.

Definition at line 1642 of file qgsmapcanvas.cpp.

§ layersChanged

void QgsMapCanvas::layersChanged ( )
signal

Emitted when a new set of layers has been received.

§ layerStateChange

void QgsMapCanvas::layerStateChange ( )
slot

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

Definition at line 1655 of file qgsmapcanvas.cpp.

§ layerStyleOverrides()

QMap< QString, QString > QgsMapCanvas::layerStyleOverrides ( ) const

Getter for stored overrides of styles for layers.

Note
added in 2.12

Definition at line 1712 of file qgsmapcanvas.cpp.

§ layerStyleOverridesChanged

void QgsMapCanvas::layerStyleOverridesChanged ( )
signal

Emitted when the configuration of overridden layer styles changes.

Note
added in 2.12

§ magnificationChanged

void QgsMapCanvas::magnificationChanged ( double  )
signal

Emitted when the scale of the map changes.

Note
added in 2.16

§ magnificationFactor()

double QgsMapCanvas::magnificationFactor ( ) const

Returns the magnification factor.

Note
added in 2.16

Definition at line 241 of file qgsmapcanvas.cpp.

§ mapCanvasRefreshed

void QgsMapCanvas::mapCanvasRefreshed ( )
signal

Emitted when canvas finished a refresh request.

§ mapSettings()

const QgsMapSettings & QgsMapCanvas::mapSettings ( ) const

Get access to properties used for map rendering.

Note
added in 2.4

Definition at line 407 of file qgsmapcanvas.cpp.

§ mapTool()

QgsMapTool * QgsMapCanvas::mapTool ( )

Returns the currently active tool.

Definition at line 1771 of file qgsmapcanvas.cpp.

§ mapToolSet [1/2]

void QgsMapCanvas::mapToolSet ( QgsMapTool tool)
signal

Emit map tool changed event.

§ mapToolSet [2/2]

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

Emit map tool changed with the old tool.

Note
added in 2.3

§ mapUnits()

QgsUnitTypes::DistanceUnit QgsMapCanvas::mapUnits ( ) const

Get the current canvas map units.

Definition at line 1707 of file qgsmapcanvas.cpp.

§ mapUnitsChanged

void QgsMapCanvas::mapUnitsChanged ( )
signal

Emitted when map units are changed.

Note
added in 2.4

§ mapUnitsPerPixel()

double QgsMapCanvas::mapUnitsPerPixel ( ) const

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

Definition at line 1685 of file qgsmapcanvas.cpp.

§ mapUpdateInterval()

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 519 of file qgsmapcanvas.cpp.

§ messageEmitted

void QgsMapCanvas::messageEmitted ( const QString &  title,
const QString &  message,
QgsMessageBar::MessageLevel  = QgsMessageBar::INFO 
)
signal

emit a message (usually to be displayed in a message bar)

§ mouseDoubleClickEvent()

void QgsMapCanvas::mouseDoubleClickEvent ( QMouseEvent *  e)
overrideprotected

Overridden mouse double click event.

Definition at line 1245 of file qgsmapcanvas.cpp.

§ mouseLastXY()

QPoint QgsMapCanvas::mouseLastXY ( )

returns last position of mouse cursor

Definition at line 1812 of file qgsmapcanvas.cpp.

§ mouseMoveEvent()

void QgsMapCanvas::mouseMoveEvent ( QMouseEvent *  e)
overrideprotected

Overridden mouse move event.

Definition at line 1519 of file qgsmapcanvas.cpp.

§ mousePressEvent()

void QgsMapCanvas::mousePressEvent ( QMouseEvent *  e)
overrideprotected

Overridden mouse press event.

Definition at line 1300 of file qgsmapcanvas.cpp.

§ mouseReleaseEvent()

void QgsMapCanvas::mouseReleaseEvent ( QMouseEvent *  e)
overrideprotected

Overridden mouse release event.

Definition at line 1338 of file qgsmapcanvas.cpp.

§ moveCanvasContents()

void QgsMapCanvas::moveCanvasContents ( bool  reset = false)
protected

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

Definition at line 1803 of file qgsmapcanvas.cpp.

§ paintEvent()

void QgsMapCanvas::paintEvent ( QPaintEvent *  e)
overrideprotected

Overridden paint event.

Definition at line 1412 of file qgsmapcanvas.cpp.

§ panAction()

void QgsMapCanvas::panAction ( QMouseEvent *  event)

Called when mouse is moving and pan is activated.

Definition at line 1795 of file qgsmapcanvas.cpp.

§ panActionEnd()

void QgsMapCanvas::panActionEnd ( QPoint  releasePoint)

Ends pan action and redraws the canvas.

Definition at line 1776 of file qgsmapcanvas.cpp.

§ panToFeatureIds()

void QgsMapCanvas::panToFeatureIds ( QgsVectorLayer layer,
const QgsFeatureIds ids 
)

Centers canvas extent to feature ids.

Parameters
layerthe vector layer
idsthe feature ids

Definition at line 1039 of file qgsmapcanvas.cpp.

§ panToSelected()

void QgsMapCanvas::panToSelected ( QgsVectorLayer layer = nullptr)

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

Definition at line 1096 of file qgsmapcanvas.cpp.

§ previewMode()

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 1847 of file qgsmapcanvas.cpp.

§ previewModeEnabled()

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 1827 of file qgsmapcanvas.cpp.

§ readProject

void QgsMapCanvas::readProject ( const QDomDocument &  doc)
slot

called to read map canvas settings from project

Definition at line 1873 of file qgsmapcanvas.cpp.

§ refresh

void QgsMapCanvas::refresh ( )
slot

Repaints the canvas map.

Definition at line 541 of file qgsmapcanvas.cpp.

§ refreshAllLayers()

void QgsMapCanvas::refreshAllLayers ( )

Reload all layers, clear the cache and refresh the canvas.

Note
added in 2.9

Definition at line 2041 of file qgsmapcanvas.cpp.

§ renderComplete

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

§ renderFlag

bool QgsMapCanvas::renderFlag ( )
inlineslot

State of render suppression flag.

Definition at line 454 of file qgsmapcanvas.h.

§ renderStarting

void QgsMapCanvas::renderStarting ( )
signal

Emitted when the canvas is about to be rendered.

§ resizeEvent()

void QgsMapCanvas::resizeEvent ( QResizeEvent *  e)
overrideprotected

Overridden resize event.

Definition at line 1389 of file qgsmapcanvas.cpp.

§ rotation()

double QgsMapCanvas::rotation ( ) const

Get the current map canvas rotation in clockwise degrees.

Note
added in 2.8

Definition at line 885 of file qgsmapcanvas.cpp.

§ rotationChanged

void QgsMapCanvas::rotationChanged ( double  )
signal

Emitted when the rotation of the map changes.

Note
added in 2.8

§ saveAsImage

void QgsMapCanvas::saveAsImage ( const QString &  theFileName,
QPixmap *  QPixmap = nullptr,
const QString &  theFormat = "PNG" 
)
slot

Save the convtents of the map canvas to disk as an image.

Definition at line 713 of file qgsmapcanvas.cpp.

§ scale()

double QgsMapCanvas::scale ( )

Get the last reported scale of the canvas.

Definition at line 275 of file qgsmapcanvas.cpp.

§ scaleChanged

void QgsMapCanvas::scaleChanged ( double  )
signal

Emitted when the scale of the map changes.

§ scaleLocked()

bool QgsMapCanvas::scaleLocked ( ) const
inline

Returns whether the scale is locked, so zooming can be performed using magnication.

Note
added in 2.16
See also
setScaleLocked()

Definition at line 331 of file qgsmapcanvas.h.

§ selectionChanged

void QgsMapCanvas::selectionChanged ( QgsMapLayer layer)
signal

Emitted when selection in any layer gets changed.

§ selectionChangedSlot

void QgsMapCanvas::selectionChangedSlot ( )
slot

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

Definition at line 1998 of file qgsmapcanvas.cpp.

§ setCachingEnabled()

void QgsMapCanvas::setCachingEnabled ( bool  enabled)

Set whether to cache images of rendered layers.

Note
added in 2.4

Definition at line 471 of file qgsmapcanvas.cpp.

§ setCanvasColor()

void QgsMapCanvas::setCanvasColor ( const QColor &  _newVal)

Write property of QColor bgColor.

Definition at line 1608 of file qgsmapcanvas.cpp.

§ setCenter()

void QgsMapCanvas::setCenter ( const QgsPoint center)

Set the center of the map canvas, in geographical coordinates.

Note
added in 2.8

Definition at line 864 of file qgsmapcanvas.cpp.

§ setCrsTransformEnabled()

void QgsMapCanvas::setCrsTransformEnabled ( bool  enabled)

sets whether to use projections for this layer set

Note
added in 2.4

Definition at line 412 of file qgsmapcanvas.cpp.

§ setCurrentLayer()

void QgsMapCanvas::setCurrentLayer ( QgsMapLayer layer)

Definition at line 269 of file qgsmapcanvas.cpp.

§ setDestinationCrs()

void QgsMapCanvas::setDestinationCrs ( const QgsCoordinateReferenceSystem crs)

sets destination coordinate reference system

Note
added in 2.4

Definition at line 426 of file qgsmapcanvas.cpp.

§ setExpressionContextScope()

void QgsMapCanvas::setExpressionContextScope ( const QgsExpressionContextScope scope)
inline

Sets an expression context scope for the map canvas.

This scope is injected into the expression context used for rendering the map, and can be used to apply specific variable overrides for expression evaluation for the map canvas render. This method will overwrite the existing expression context scope for the canvas.

Parameters
scopenew expression context scope
Note
added in QGIS 2.12
See also
expressionContextScope()

Definition at line 409 of file qgsmapcanvas.h.

§ setExtent()

void QgsMapCanvas::setExtent ( const QgsRectangle r,
bool  magnified = false 
)

Set the extent of the map canvas.

Definition at line 810 of file qgsmapcanvas.cpp.

§ setLayerSet()

void QgsMapCanvas::setLayerSet ( QList< QgsMapCanvasLayer > &  layers)

Definition at line 292 of file qgsmapcanvas.cpp.

§ setLayerStyleOverrides()

void QgsMapCanvas::setLayerStyleOverrides ( const QMap< QString, QString > &  overrides)

Setter for stored overrides of styles for layers.

Note
added in 2.12

Definition at line 1717 of file qgsmapcanvas.cpp.

§ setMagnificationFactor

void QgsMapCanvas::setMagnificationFactor ( double  factor)
slot

Sets the factor of magnification to apply to the map canvas.

Indeed, we increase/decrease the DPI of the map settings according to this factor in order to render marker point, labels, ... bigger.

Note
added in 2.16

Definition at line 225 of file qgsmapcanvas.cpp.

§ setMapTool()

void QgsMapCanvas::setMapTool ( QgsMapTool mapTool)

Sets the map tool currently being used on the canvas.

Definition at line 1552 of file qgsmapcanvas.cpp.

§ setMapUnits()

void QgsMapCanvas::setMapUnits ( QgsUnitTypes::DistanceUnit  mapUnits)

Set map units (needed by project properties dialog)

Definition at line 1691 of file qgsmapcanvas.cpp.

§ setMapUpdateInterval()

void QgsMapCanvas::setMapUpdateInterval ( int  timeMilliseconds)

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

Note
added in 2.4

Definition at line 514 of file qgsmapcanvas.cpp.

§ setParallelRenderingEnabled()

void QgsMapCanvas::setParallelRenderingEnabled ( bool  enabled)

Set whether the layers are rendered in parallel or sequentially.

Note
added in 2.4

Definition at line 504 of file qgsmapcanvas.cpp.

§ setPreviewMode()

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 1837 of file qgsmapcanvas.cpp.

§ setPreviewModeEnabled()

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 1817 of file qgsmapcanvas.cpp.

§ setRenderFlag

void QgsMapCanvas::setRenderFlag ( bool  theFlag)
slot

Whether to suppress rendering or not.

Definition at line 1727 of file qgsmapcanvas.cpp.

§ setRotation()

void QgsMapCanvas::setRotation ( double  degrees)

Set the rotation of the map canvas in clockwise degrees.

Note
added in 2.8

Definition at line 890 of file qgsmapcanvas.cpp.

§ setScaleLocked

void QgsMapCanvas::setScaleLocked ( bool  isLocked)
slot

Lock the scale, so zooming can be performed using magnication.

Note
added in 2.16
See also
scaleLocked()

Definition at line 1514 of file qgsmapcanvas.cpp.

§ setSegmentationTolerance()

void QgsMapCanvas::setSegmentationTolerance ( double  tolerance)

Sets the segmentation tolerance applied when rendering curved geometries.

Parameters
tolerancethe segmentation tolerance

Definition at line 2058 of file qgsmapcanvas.cpp.

§ setSegmentationToleranceType()

void QgsMapCanvas::setSegmentationToleranceType ( QgsAbstractGeometry::SegmentationToleranceType  type)

Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)

Parameters
typethe segmentation tolerance typename

Definition at line 2063 of file qgsmapcanvas.cpp.

§ setSelectionColor()

void QgsMapCanvas::setSelectionColor ( const QColor &  color)

Set color of selected vector features.

Note
added in 2.4

Definition at line 1631 of file qgsmapcanvas.cpp.

§ setSnappingUtils()

void QgsMapCanvas::setSnappingUtils ( QgsSnappingUtils utils)

Assign an instance of snapping utils to the map canvas.

The instance is not owned by the canvas, so it is possible to use one instance in multiple canvases.

For main canvas in QGIS, do not associate a different instance from the existing one (it is updated from the project's snapping configuration).

Note
added in 2.8

Definition at line 1868 of file qgsmapcanvas.cpp.

§ setWheelFactor()

void QgsMapCanvas::setWheelFactor ( double  factor)

set wheel zoom factor (should be greater than 1)

Definition at line 1473 of file qgsmapcanvas.cpp.

§ snappingUtils()

QgsSnappingUtils * QgsMapCanvas::snappingUtils ( ) const

Return snapping utility class that is associated with map canvas.

If no snapping utils instance has been associated previously, an internal will be created for convenience (so map tools do not need to test for existence of the instance).

Main canvas in QGIS returns an instance which is always up-to-date with the project's snapping configuration.

Note
added in 2.8

Definition at line 1857 of file qgsmapcanvas.cpp.

§ stopRendering

void QgsMapCanvas::stopRendering ( )
slot

stop rendering (if there is any right now)

Note
added in 2.4

Definition at line 701 of file qgsmapcanvas.cpp.

§ unsetMapTool()

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 1590 of file qgsmapcanvas.cpp.

§ updateCanvasItemPositions()

void QgsMapCanvas::updateCanvasItemPositions ( )
protected

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

Definition at line 1419 of file qgsmapcanvas.cpp.

§ updateDatumTransformEntries()

void QgsMapCanvas::updateDatumTransformEntries ( )
protected

Make sure the datum transform store is properly populated.

Definition at line 1747 of file qgsmapcanvas.cpp.

§ updateOverview()

void QgsMapCanvas::updateOverview ( )

Definition at line 525 of file qgsmapcanvas.cpp.

§ updateScale()

void QgsMapCanvas::updateScale ( )

Emits signal scaleChanged to update scale in main window.

Definition at line 907 of file qgsmapcanvas.cpp.

§ wheelEvent()

void QgsMapCanvas::wheelEvent ( QWheelEvent *  e)
overrideprotected

Overridden mouse wheel event.

Definition at line 1437 of file qgsmapcanvas.cpp.

§ writeProject

void QgsMapCanvas::writeProject ( QDomDocument &  doc)
slot

called to write map canvas settings to project

Definition at line 1898 of file qgsmapcanvas.cpp.

§ xyCoordinates

void QgsMapCanvas::xyCoordinates ( const QgsPoint p)
signal

Emits current mouse position.

Note
changed in 1.3

§ zoomByFactor()

void QgsMapCanvas::zoomByFactor ( double  scaleFactor,
const QgsPoint center = nullptr 
)

Zoom with the factor supplied.

Factor > 1 zooms out, interval (0,1) zooms in If point is given, re-center on it

Definition at line 1982 of file qgsmapcanvas.cpp.

§ zoomIn

void QgsMapCanvas::zoomIn ( )
slot

Zoom in with fixed factor.

Definition at line 1478 of file qgsmapcanvas.cpp.

§ zoomLastStatusChanged

void QgsMapCanvas::zoomLastStatusChanged ( bool  )
signal

Emitted when zoom last status changed.

§ zoomNextStatusChanged

void QgsMapCanvas::zoomNextStatusChanged ( bool  )
signal

Emitted when zoom next status changed.

§ zoomOut

void QgsMapCanvas::zoomOut ( )
slot

Zoom out with fixed factor.

Definition at line 1484 of file qgsmapcanvas.cpp.

§ zoomScale()

void QgsMapCanvas::zoomScale ( double  scale)

Zoom to a specific scale.

Definition at line 1490 of file qgsmapcanvas.cpp.

§ zoomToFeatureExtent()

void QgsMapCanvas::zoomToFeatureExtent ( QgsRectangle rect)
protected

Zooms to feature extent.

Adds a small margin around the extent and does a pan if rect is empty (point extent)

Definition at line 995 of file qgsmapcanvas.cpp.

§ zoomToFeatureIds()

void QgsMapCanvas::zoomToFeatureIds ( QgsVectorLayer layer,
const QgsFeatureIds ids 
)

Set canvas extent to the bounding box of a set of features.

Parameters
layerthe vector layer
idsthe feature ids

Definition at line 1019 of file qgsmapcanvas.cpp.

§ zoomToFullExtent()

void QgsMapCanvas::zoomToFullExtent ( )

Zoom to the full extent of all layers.

Definition at line 913 of file qgsmapcanvas.cpp.

§ zoomToNextExtent()

void QgsMapCanvas::zoomToNextExtent ( )

Zoom to the next extent (view)

Definition at line 947 of file qgsmapcanvas.cpp.

§ zoomToPreviousExtent()

void QgsMapCanvas::zoomToPreviousExtent ( )

Zoom to the previous extent (view)

Definition at line 929 of file qgsmapcanvas.cpp.

§ zoomToSelected()

void QgsMapCanvas::zoomToSelected ( QgsVectorLayer layer = nullptr)

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

Parameters
layeroptionally specify different than current layer

Definition at line 980 of file qgsmapcanvas.cpp.

§ zoomWithCenter()

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

Zooms in/out with a given center.

Definition at line 1495 of file qgsmapcanvas.cpp.

Friends And Related Function Documentation

§ TestQgsMapCanvas

friend class TestQgsMapCanvas
friend

Definition at line 769 of file qgsmapcanvas.h.

Member Data Documentation

§ mCanvasProperties

QScopedPointer<CanvasProperties> QgsMapCanvas::mCanvasProperties
protected

Handle pattern for implementation object.

Definition at line 637 of file qgsmapcanvas.h.


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