QGIS API Documentation
2.6.0-Brighton
|
Map canvas is a class for displaying all GIS data types on a canvas. More...
#include <qgsmapcanvas.h>
Classes | |
class | CanvasProperties |
Public Types | |
enum | WheelAction { WheelZoom, WheelZoomAndRecenter, WheelZoomToMouseCursor, WheelNothing } |
Public Slots | |
void | refresh () |
Repaints the canvas map. | |
void | selectionChangedSlot () |
Receives signal about selection change, and pass it on with layer info. | |
void | saveAsImage (QString theFileName, QPixmap *QPixmap=0, QString="PNG") |
Save the convtents of the map canvas to disk as an image. | |
void | layerStateChange () |
This slot is connected to the visibility change of one or more layers. | |
void | setRenderFlag (bool theFlag) |
Whether to suppress rendering or not. | |
bool | renderFlag () |
State of render suppression flag. | |
bool | hasCrsTransformEnabled () |
A simple helper method to find out if on the fly projections are enabled or not. | |
Q_DECL_DEPRECATED void | updateMap () |
void | stopRendering () |
stop rendering (if there is any right now) | |
Q_DECL_DEPRECATED void | showError (QgsMapLayer *mapLayer) |
void | readProject (const QDomDocument &) |
called to read map canvas settings from project | |
void | writeProject (QDomDocument &) |
called to write map canvas settings to project | |
void | getDatumTransformInfo (const QgsMapLayer *ml, const QString &srcAuthId, const QString &destAuthId) |
ask user about datum transformation |
Signals | |
Q_DECL_DEPRECATED void | setProgress (int, int) |
Let the owner know how far we are with render operations. | |
void | xyCoordinates (const QgsPoint &p) |
emits current mouse position | |
void | scaleChanged (double) |
Emitted when the scale of the map changes. | |
void | extentsChanged () |
Emitted when the extents of the map change. | |
void | renderComplete (QPainter *) |
Emitted when the canvas has rendered. | |
void | mapCanvasRefreshed () |
Emitted when canvas finished a refresh request. | |
void | renderStarting () |
Emitted when the canvas is about to be rendered. | |
void | layersChanged () |
Emitted when a new set of layers has been received. | |
void | keyPressed (QKeyEvent *e) |
Emit key press event. | |
void | keyReleased (QKeyEvent *e) |
Emit key release event. | |
void | mapToolSet (QgsMapTool *tool) |
Emit map tool changed event. | |
void | mapToolSet (QgsMapTool *newTool, QgsMapTool *oldTool) |
Emit map tool changed with the old tool. | |
void | selectionChanged (QgsMapLayer *layer) |
Emitted when selection in any layer gets changed. | |
void | zoomLastStatusChanged (bool) |
Emitted when zoom last status changed. | |
void | zoomNextStatusChanged (bool) |
Emitted when zoom next status changed. | |
void | hasCrsTransformEnabledChanged (bool flag) |
Emitted when on-the-fly projection has been turned on/off. | |
void | destinationCrsChanged () |
Emitted when map CRS has changed. | |
void | mapUnitsChanged () |
Emmitted when map units are changed. |
Public Member Functions | |
QgsMapCanvas (QWidget *parent=0, const char *name=0) | |
Constructor. | |
~QgsMapCanvas () | |
Destructor. | |
void | setLayerSet (QList< QgsMapCanvasLayer > &layers) |
void | setCurrentLayer (QgsMapLayer *layer) |
void | updateOverview () |
void | enableOverviewMode (QgsMapOverviewCanvas *overview) |
const QgsMapSettings & | mapSettings () const |
Get access to properties used for map rendering. | |
void | setCrsTransformEnabled (bool enabled) |
sets whether to use projections for this layer set | |
void | setDestinationCrs (const QgsCoordinateReferenceSystem &crs) |
sets destination coordinate reference system | |
const QgsLabelingResults * | labelingResults () const |
Get access to the labeling results (may be null) | |
void | setCachingEnabled (bool enabled) |
Set whether to cache images of rendered layers. | |
bool | isCachingEnabled () const |
Check whether images of rendered layers are curerently being cached. | |
void | clearCache () |
Make sure to remove any rendered images from cache (does nothing if cache is not enabled) | |
void | setParallelRenderingEnabled (bool enabled) |
Set whether the layers are rendered in parallel or sequentially. | |
bool | isParallelRenderingEnabled () const |
Check whether the layers are rendered in parallel or sequentially. | |
void | setMapUpdateInterval (int timeMiliseconds) |
Set how often map preview should be updated while it is being rendered (in milliseconds) | |
int | mapUpdateInterval () const |
Find out how often map preview should be updated while it is being rendered (in milliseconds) | |
QgsMapCanvasMap * | map () |
Q_DECL_DEPRECATED QgsMapRenderer * | mapRenderer () |
Q_DECL_DEPRECATED QPaintDevice & | canvasPaintDevice () |
Accessor for the canvas paint device. | |
double | scale () |
Get the last reported scale of the canvas. | |
Q_DECL_DEPRECATED void | clear () |
Clear the map canvas. | |
double | mapUnitsPerPixel () const |
Returns the mapUnitsPerPixel (map units per pixel) for the canvas. | |
QgsRectangle | extent () const |
Returns the current zoom exent of the map canvas. | |
QgsRectangle | fullExtent () const |
Returns the combined exent for all layers on the map canvas. | |
void | setExtent (const QgsRectangle &r) |
Set the extent of the map canvas. | |
void | zoomToFullExtent () |
Zoom to the full extent of all layers. | |
void | zoomToPreviousExtent () |
Zoom to the previous extent (view) | |
void | zoomToNextExtent () |
Zoom to the next extent (view) | |
void | clearExtentHistory () |
void | zoomToSelected (QgsVectorLayer *layer=NULL) |
Zoom to the extent of the selected features of current (vector) layer. | |
void | panToSelected (QgsVectorLayer *layer=NULL) |
Pan to the selected features of current (vector) layer keeping same extent. | |
void | setMapTool (QgsMapTool *mapTool) |
Sets the map tool currently being used on the canvas. | |
void | unsetMapTool (QgsMapTool *mapTool) |
Unset the current map tool or last non zoom tool. | |
QgsMapTool * | mapTool () |
Returns the currently active tool. | |
virtual void | setCanvasColor (const QColor &_newVal) |
Write property of QColor bgColor. | |
virtual QColor | canvasColor () const |
Read property of QColor bgColor. | |
void | setSelectionColor (const QColor &color) |
Set color of selected vector features. | |
void | updateScale () |
Emits signal scaleChanged to update scale in main window. | |
Q_DECL_DEPRECATED void | updateFullExtent () |
Updates the full extent. | |
QgsMapLayer * | layer (int index) |
return the map layer at position index in the layer stack | |
int | layerCount () const |
return number of layers on the map | |
QList< QgsMapLayer * > | layers () const |
return list of layers within map canvas. | |
void | freeze (bool frz=true) |
bool | isFrozen () |
Q_DECL_DEPRECATED void | setDirty (bool _dirty) |
Flag the canvas as dirty and needed a refresh. | |
Q_DECL_DEPRECATED bool | isDirty () const |
Return the state of the canvas (dirty or not) | |
void | setMapUnits (QGis::UnitType mapUnits) |
Set map units (needed by project properties dialog) | |
QGis::UnitType | mapUnits () const |
Get the current canvas map units. | |
const QgsMapToPixel * | getCoordinateTransform () |
Get the current coordinate transform. | |
bool | isDrawing () |
Find out whether rendering is in progress. | |
QgsMapLayer * | currentLayer () |
returns current layer (set by legend widget) | |
void | setWheelAction (WheelAction action, double factor=2) |
set wheel action and zoom factor (should be greater than 1) | |
void | zoomIn () |
Zoom in with fixed factor. | |
void | zoomOut () |
Zoom out with fixed factor. | |
void | zoomScale (double scale) |
Zoom to a specific scale. | |
void | zoomByFactor (double scaleFactor, const QgsPoint *center=0) |
Zoom with the factor supplied. | |
void | zoomWithCenter (int x, int y, bool zoomIn) |
Zooms in/out with a given center. | |
void | enableAntiAliasing (bool theFlag) |
used to determine if anti-aliasing is enabled or not | |
bool | antiAliasingEnabled () const |
true if antialising is enabled | |
Q_DECL_DEPRECATED void | useImageToRender (bool theFlag) |
Select which Qt class to render with. | |
void | panActionEnd (QPoint releasePoint) |
Ends pan action and redraws the canvas. | |
void | panAction (QMouseEvent *event) |
Called when mouse is moving and pan is activated. | |
QPoint | mouseLastXY () |
returns last position of mouse cursor | |
void | setPreviewModeEnabled (bool previewEnabled) |
Enables a preview mode for the map canvas. | |
bool | previewModeEnabled () const |
Returns whether a preview mode is enabled for the map canvas. | |
void | setPreviewMode (QgsPreviewEffect::PreviewMode mode) |
Sets a preview mode for the map canvas. | |
QgsPreviewEffect::PreviewMode | previewMode () const |
Returns the current preview mode for the map canvas. |
Protected Member Functions | |
void | keyPressEvent (QKeyEvent *e) |
Overridden key press event. | |
void | keyReleaseEvent (QKeyEvent *e) |
Overridden key release event. | |
void | mouseDoubleClickEvent (QMouseEvent *e) |
Overridden mouse double click event. | |
void | mouseMoveEvent (QMouseEvent *e) |
Overridden mouse move event. | |
void | mousePressEvent (QMouseEvent *e) |
Overridden mouse press event. | |
void | mouseReleaseEvent (QMouseEvent *e) |
Overridden mouse release event. | |
void | wheelEvent (QWheelEvent *e) |
Overridden mouse wheel event. | |
void | resizeEvent (QResizeEvent *e) |
Overridden resize event. | |
void | paintEvent (QPaintEvent *e) |
Overridden paint event. | |
void | dragEnterEvent (QDragEnterEvent *e) |
Overridden drag enter event. | |
void | moveCanvasContents (bool reset=false) |
called when panning is in action, reset indicates end of panning | |
void | updateCanvasItemPositions () |
called on resize or changed extent to notify canvas items to change their rectangle | |
void | connectNotify (const char *signal) |
debugging member invoked when a connect() is made to this object | |
void | updateDatumTransformEntries () |
Make sure the datum transform store is properly populated. |
Protected Attributes | |
std::auto_ptr< CanvasProperties > | mCanvasProperties |
Handle pattern for implementation object. |
Map canvas is a class for displaying all GIS data types on a canvas.
QgsMapCanvas::QgsMapCanvas | ( | QWidget * | parent = 0 , |
const char * | name = 0 |
||
) |
Constructor.
QgsMapCanvas::~QgsMapCanvas | ( | ) |
Destructor.
|
inline |
true if antialising is enabled
|
virtual |
Read property of QColor bgColor.
QPaintDevice & QgsMapCanvas::canvasPaintDevice | ( | ) |
Accessor for the canvas paint device.
void QgsMapCanvas::clear | ( | ) |
Clear the map canvas.
void QgsMapCanvas::clearCache | ( | ) |
Make sure to remove any rendered images from cache (does nothing if cache is not enabled)
void QgsMapCanvas::clearExtentHistory | ( | ) |
|
protected |
debugging member invoked when a connect() is made to this object
QgsMapLayer * QgsMapCanvas::currentLayer | ( | ) |
returns current layer (set by legend widget)
|
signal |
Emitted when map CRS has changed.
|
protected |
Overridden drag enter event.
void QgsMapCanvas::enableAntiAliasing | ( | bool | theFlag | ) |
used to determine if anti-aliasing is enabled or not
void QgsMapCanvas::enableOverviewMode | ( | QgsMapOverviewCanvas * | overview | ) |
QgsRectangle QgsMapCanvas::extent | ( | ) | const |
Returns the current zoom exent of the map canvas.
|
signal |
Emitted when the extents of the map change.
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.
frz | Boolean specifying if the canvas should be frozen (true) or thawed (false). Default is true. |
QgsRectangle QgsMapCanvas::fullExtent | ( | ) | const |
Returns the combined exent for all layers on the map canvas.
const QgsMapToPixel * QgsMapCanvas::getCoordinateTransform | ( | ) |
Get the current coordinate transform.
|
slot |
ask user about datum transformation
Ask user which datum transform to use.
|
slot |
A simple helper method to find out if on the fly projections are enabled or not.
|
signal |
Emitted when on-the-fly projection has been turned on/off.
bool QgsMapCanvas::isCachingEnabled | ( | ) | const |
Check whether images of rendered layers are curerently being cached.
bool QgsMapCanvas::isDirty | ( | ) | const |
Return the state of the canvas (dirty or not)
bool QgsMapCanvas::isDrawing | ( | ) |
Find out whether rendering is in progress.
bool QgsMapCanvas::isFrozen | ( | ) |
Accessor for frozen status of canvas
bool QgsMapCanvas::isParallelRenderingEnabled | ( | ) | const |
Check whether the layers are rendered in parallel or sequentially.
|
signal |
Emit key press event.
|
protected |
Overridden key press event.
|
signal |
Emit key release event.
|
protected |
Overridden key release event.
const QgsLabelingResults * QgsMapCanvas::labelingResults | ( | ) | const |
Get access to the labeling results (may be null)
QgsMapLayer * QgsMapCanvas::layer | ( | int | index | ) |
return the map layer at position index in the layer stack
int QgsMapCanvas::layerCount | ( | ) | const |
return number of layers on the map
QList< QgsMapLayer * > QgsMapCanvas::layers | ( | ) | const |
return list of layers within map canvas.
|
signal |
Emitted when a new set of layers has been received.
|
slot |
This slot is connected to the visibility change of one or more layers.
QgsMapCanvasMap * QgsMapCanvas::map | ( | ) |
|
signal |
Emitted when canvas finished a refresh request.
QgsMapRenderer * QgsMapCanvas::mapRenderer | ( | ) |
const QgsMapSettings & QgsMapCanvas::mapSettings | ( | ) | const |
Get access to properties used for map rendering.
QgsMapTool * QgsMapCanvas::mapTool | ( | ) |
Returns the currently active tool.
|
signal |
Emit map tool changed event.
|
signal |
Emit map tool changed with the old tool.
QGis::UnitType QgsMapCanvas::mapUnits | ( | ) | const |
Get the current canvas map units.
|
signal |
Emmitted when map units are changed.
double QgsMapCanvas::mapUnitsPerPixel | ( | ) | const |
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
int QgsMapCanvas::mapUpdateInterval | ( | ) | const |
Find out how often map preview should be updated while it is being rendered (in milliseconds)
|
protected |
Overridden mouse double click event.
QPoint QgsMapCanvas::mouseLastXY | ( | ) |
returns last position of mouse cursor
|
protected |
Overridden mouse move event.
|
protected |
Overridden mouse press event.
|
protected |
Overridden mouse release event.
|
protected |
called when panning is in action, reset indicates end of panning
|
protected |
Overridden paint event.
void QgsMapCanvas::panAction | ( | QMouseEvent * | event | ) |
Called when mouse is moving and pan is activated.
void QgsMapCanvas::panActionEnd | ( | QPoint | releasePoint | ) |
Ends pan action and redraws the canvas.
void QgsMapCanvas::panToSelected | ( | QgsVectorLayer * | layer = NULL | ) |
Pan to the selected features of current (vector) layer keeping same extent.
QgsPreviewEffect::PreviewMode QgsMapCanvas::previewMode | ( | ) | const |
Returns the current preview mode for the map canvas.
This setting only has an effect if previewModeEnabled is true.
bool QgsMapCanvas::previewModeEnabled | ( | ) | const |
Returns whether a preview mode is enabled for the map canvas.
|
slot |
called to read map canvas settings from project
|
slot |
Repaints the canvas map.
|
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
|
inlineslot |
State of render suppression flag.
|
signal |
Emitted when the canvas is about to be rendered.
|
protected |
Overridden resize event.
|
slot |
Save the convtents of the map canvas to disk as an image.
double QgsMapCanvas::scale | ( | ) |
Get the last reported scale of the canvas.
|
signal |
Emitted when the scale of the map changes.
|
signal |
Emitted when selection in any layer gets changed.
|
slot |
Receives signal about selection change, and pass it on with layer info.
void QgsMapCanvas::setCachingEnabled | ( | bool | enabled | ) |
Set whether to cache images of rendered layers.
|
virtual |
Write property of QColor bgColor.
void QgsMapCanvas::setCrsTransformEnabled | ( | bool | enabled | ) |
sets whether to use projections for this layer set
void QgsMapCanvas::setCurrentLayer | ( | QgsMapLayer * | layer | ) |
void QgsMapCanvas::setDestinationCrs | ( | const QgsCoordinateReferenceSystem & | crs | ) |
sets destination coordinate reference system
void QgsMapCanvas::setDirty | ( | bool | _dirty | ) |
Flag the canvas as dirty and needed a refresh.
void QgsMapCanvas::setExtent | ( | const QgsRectangle & | r | ) |
Set the extent of the map canvas.
void QgsMapCanvas::setLayerSet | ( | QList< QgsMapCanvasLayer > & | layers | ) |
void QgsMapCanvas::setMapTool | ( | QgsMapTool * | mapTool | ) |
Sets the map tool currently being used on the canvas.
void QgsMapCanvas::setMapUnits | ( | QGis::UnitType | mapUnits | ) |
Set map units (needed by project properties dialog)
void QgsMapCanvas::setMapUpdateInterval | ( | int | timeMiliseconds | ) |
Set how often map preview should be updated while it is being rendered (in milliseconds)
void QgsMapCanvas::setParallelRenderingEnabled | ( | bool | enabled | ) |
Set whether the layers are rendered in parallel or sequentially.
void QgsMapCanvas::setPreviewMode | ( | QgsPreviewEffect::PreviewMode | mode | ) |
Sets a preview mode for the map canvas.
This setting only has an effect if previewModeEnabled is true.
mode | preview mode for the canvas |
void QgsMapCanvas::setPreviewModeEnabled | ( | bool | previewEnabled | ) |
Enables a preview mode for the map canvas.
previewEnabled | set to true to enable a preview mode |
|
signal |
Let the owner know how far we are with render operations.
|
slot |
Whether to suppress rendering or not.
void QgsMapCanvas::setSelectionColor | ( | const QColor & | color | ) |
Set color of selected vector features.
void QgsMapCanvas::setWheelAction | ( | WheelAction | action, |
double | factor = 2 |
||
) |
set wheel action and zoom factor (should be greater than 1)
|
slot |
|
slot |
stop rendering (if there is any right now)
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.
|
protected |
called on resize or changed extent to notify canvas items to change their rectangle
|
protected |
Make sure the datum transform store is properly populated.
|
inline |
Updates the full extent.
|
slot |
void QgsMapCanvas::updateOverview | ( | ) |
void QgsMapCanvas::updateScale | ( | ) |
Emits signal scaleChanged to update scale in main window.
void QgsMapCanvas::useImageToRender | ( | bool | theFlag | ) |
Select which Qt class to render with.
|
protected |
Overridden mouse wheel event.
|
slot |
called to write map canvas settings to project
|
signal |
emits current mouse position
void QgsMapCanvas::zoomByFactor | ( | double | scaleFactor, |
const QgsPoint * | center = 0 |
||
) |
Zoom with the factor supplied.
Factor > 1 zooms out, interval (0,1) zooms in If point is given, re-center on it
void QgsMapCanvas::zoomIn | ( | ) |
Zoom in with fixed factor.
|
signal |
Emitted when zoom last status changed.
|
signal |
Emitted when zoom next status changed.
void QgsMapCanvas::zoomOut | ( | ) |
Zoom out with fixed factor.
void QgsMapCanvas::zoomScale | ( | double | scale | ) |
Zoom to a specific scale.
void QgsMapCanvas::zoomToFullExtent | ( | ) |
Zoom to the full extent of all layers.
void QgsMapCanvas::zoomToNextExtent | ( | ) |
Zoom to the next extent (view)
void QgsMapCanvas::zoomToPreviousExtent | ( | ) |
Zoom to the previous extent (view)
void QgsMapCanvas::zoomToSelected | ( | QgsVectorLayer * | layer = NULL | ) |
Zoom to the extent of the selected features of current (vector) layer.
layer | optionally specify different than current layer |
void QgsMapCanvas::zoomWithCenter | ( | int | x, |
int | y, | ||
bool | zoomIn | ||
) |
Zooms in/out with a given center.
|
protected |
Handle pattern for implementation object.