Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | 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...
 
void mapUnitsChanged ()
 The map units may have changed, so cope with that. More...
 
void updateMap ()
 updates pixmap on render progress More...
 
void showError (QgsMapLayer *mapLayer)
 show whatever error is exposed by the QgsMapLayer. More...
 
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...
 

Signals

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 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 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...
 

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)
 
QgsMapCanvasMapmap ()
 
QgsMapRenderermapRenderer ()
 
Q_DECL_DEPRECATED QPixmap & canvasPixmap ()
 Accessor for the canvas pixmap. More...
 
QPaintDevice & canvasPaintDevice ()
 Accessor for the canvas paint device. More...
 
double scale ()
 Get the last reported scale of the canvas. More...
 
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 (QgsRectangle const &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 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 updateScale ()
 Emits signal scalChanged to update scale in main window. More...
 
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 ()
 
void setDirty (bool _dirty)
 Flag the canvas as dirty and needed a refresh. More...
 
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 ()
 true if canvas currently drawing 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...
 
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...
 

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 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...
 

Protected Attributes

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

Private Member Functions

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

Private Attributes

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 mDrawing
 Flag indicating a map refresh is in progress. More...
 
bool mFrozen
 Flag indicating if the map canvas is frozen. More...
 
bool mDirty
 Flag to track the state of the Map canvas. More...
 
bool mRenderFlag
 determines whether user has requested to suppress rendering More...
 
QList< QPair< int, int > > mResizeQueue
 Resize events that have been ignored because the canvas is busy with rendering may put their sizes into this list. 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...
 
QSize mNewSize
 resize canvas size More...
 
bool mPainting
 currently in paint event More...
 
bool mAntiAliasing
 indicates whether antialiasing will be used for rendering More...
 

Detailed Description

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

Definition at line 94 of file qgsmapcanvas.h.

Member Enumeration Documentation

Enumerator
WheelZoom 
WheelZoomAndRecenter 
WheelZoomToMouseCursor 
WheelNothing 

Definition at line 100 of file qgsmapcanvas.h.

Constructor & Destructor Documentation

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

Destructor.

Definition at line 136 of file qgsmapcanvas.cpp.

References QgsMapTool::deactivate(), mLastNonZoomMapTool, mMapRenderer, mMapTool, and mScene.

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 248 of file qgsmapcanvas.h.

Referenced by QgsMapCanvasItem::paint().

QColor QgsMapCanvas::canvasColor ( ) const
virtual

Read property of QColor bgColor.

Definition at line 1197 of file qgsmapcanvas.cpp.

References mScene.

Referenced by QgsQuickPrint::setMapCanvas().

QPaintDevice & QgsMapCanvas::canvasPaintDevice ( )

Accessor for the canvas paint device.

Definition at line 1267 of file qgsmapcanvas.cpp.

References mMap, and QgsMapCanvasMap::paintDevice().

Referenced by canvasPixmap().

QPixmap & QgsMapCanvas::canvasPixmap ( )

Accessor for the canvas pixmap.

Deprecated:
use canvasPaintDevice()

Definition at line 1242 of file qgsmapcanvas.cpp.

References canvasPaintDevice(), mMap, and QgsMapCanvasMap::paintDevice().

void QgsMapCanvas::clear ( )

Clear the map canvas.

Definition at line 557 of file qgsmapcanvas.cpp.

References setDirty().

Referenced by refresh().

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

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

Definition at line 1309 of file qgsmapcanvas.cpp.

References QgsDebugMsg.

QgsMapLayer * QgsMapCanvas::currentLayer ( )

returns current layer (set by legend widget)

Definition at line 364 of file qgsmapcanvas.cpp.

References mCurrentLayer.

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

void QgsMapCanvas::enableAntiAliasing ( bool  theFlag)

used to determine if anti-aliasing is enabled or not

Definition at line 165 of file qgsmapcanvas.cpp.

References QgsMapCanvasMap::enableAntiAliasing(), QgsMapOverviewCanvas::enableAntiAliasing(), mAntiAliasing, mMap, and mMapOverview.

void QgsMapCanvas::enableOverviewMode ( QgsMapOverviewCanvas overview)

Definition at line 328 of file qgsmapcanvas.cpp.

References hasCrsTransformEnabled(), mMapOverview, and mMapRenderer.

QgsRectangle QgsMapCanvas::extent ( ) const
void QgsMapCanvas::extentsChanged ( )
signal

Emitted when the extents of the map change.

Referenced by paintEvent(), 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 1231 of file qgsmapcanvas.cpp.

References mFrozen.

QgsRectangle QgsMapCanvas::fullExtent ( ) const

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

Definition at line 477 of file qgsmapcanvas.cpp.

References QgsMapRenderer::fullExtent(), and mMapRenderer.

Referenced by setLayerSet(), updateFullExtent(), and zoomToFullExtent().

const QgsMapToPixel * QgsMapCanvas::getCoordinateTransform ( )
bool QgsMapCanvas::hasCrsTransformEnabled ( )
slot

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

Definition at line 646 of file qgsmapcanvas.cpp.

References QgsMapRenderer::hasCrsTransformEnabled(), and mMapRenderer.

Referenced by enableOverviewMode().

bool QgsMapCanvas::isDirty ( ) const

Return the state of the canvas (dirty or not)

Definition at line 215 of file qgsmapcanvas.cpp.

References mDirty.

bool QgsMapCanvas::isDrawing ( )

true if canvas currently drawing

Definition at line 222 of file qgsmapcanvas.cpp.

References mDrawing.

bool QgsMapCanvas::isFrozen ( )

Accessor for frozen status of canvas

Definition at line 1236 of file qgsmapcanvas.cpp.

References mFrozen.

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

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

QgsMapLayer * QgsMapCanvas::layer ( int  index)

return the map layer at position index in the layer stack

Definition at line 190 of file qgsmapcanvas.cpp.

References QgsMapLayerRegistry::instance(), layers(), QgsMapRenderer::layerSet(), QgsMapLayerRegistry::mapLayer(), and mMapRenderer.

Referenced by layers(), selectionChangedSlot(), setCurrentLayer(), and setLayerSet().

int QgsMapCanvas::layerCount ( ) const

return number of layers on the map

Definition at line 1202 of file qgsmapcanvas.cpp.

References QgsMapRenderer::layerSet(), and mMapRenderer.

Referenced by setLayerSet().

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

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

Definition at line 1208 of file qgsmapcanvas.cpp.

References QgsMapLayerRegistry::instance(), layer(), QgsMapRenderer::layerSet(), QgsMapLayerRegistry::mapLayer(), and mMapRenderer.

Referenced by layer(), and QgsFormAnnotationItem::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 1221 of file qgsmapcanvas.cpp.

References refresh().

QgsMapCanvasMap * QgsMapCanvas::map ( )

Definition at line 179 of file qgsmapcanvas.cpp.

References mMap.

QgsMapRenderer * QgsMapCanvas::mapRenderer ( )
QgsMapTool * QgsMapCanvas::mapTool ( )

Returns the currently active tool.

Definition at line 1316 of file qgsmapcanvas.cpp.

References mMapTool.

void QgsMapCanvas::mapToolSet ( QgsMapTool tool)
signal

Emit map tool changed event.

Referenced by setMapTool(), and unsetMapTool().

QGis::UnitType QgsMapCanvas::mapUnits ( ) const

Get the current canvas map units.

Definition at line 1285 of file qgsmapcanvas.cpp.

References QgsMapRenderer::mapUnits(), and mMapRenderer.

void QgsMapCanvas::mapUnitsChanged ( )
slot

The map units may have changed, so cope with that.

Definition at line 651 of file qgsmapcanvas.cpp.

References refresh(), and updateScale().

double QgsMapCanvas::mapUnitsPerPixel ( ) const

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

Definition at line 1272 of file qgsmapcanvas.cpp.

References QgsMapRenderer::mapUnitsPerPixel(), and mMapRenderer.

Referenced by saveAsImage().

void QgsMapCanvas::mouseDoubleClickEvent ( QMouseEvent *  e)
protected

Overridden mouse double click event.

Definition at line 854 of file qgsmapcanvas.cpp.

References QgsMapTool::canvasDoubleClickEvent(), mDrawing, and mMapTool.

QPoint QgsMapCanvas::mouseLastXY ( )

returns last position of mouse cursor

Definition at line 1438 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 867 of file qgsmapcanvas.cpp.

References QgsMapTool::canvasPressEvent(), mCanvasProperties, mDrawing, 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 1383 of file qgsmapcanvas.cpp.

References mCanvasProperties, mDrawing, mMap, mScene, QgsMapCanvasMap::setPanningOffset(), QgsMapCanvasItem::setPanningOffset(), and updateCanvasItemPositions().

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

void QgsMapCanvas::paintEvent ( QPaintEvent *  e)
protected
void QgsMapCanvas::panAction ( QMouseEvent *  event)

Called when mouse is moving and pan is activated.

Definition at line 1369 of file qgsmapcanvas.cpp.

References mDrawing, and moveCanvasContents().

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

void QgsMapCanvas::panActionEnd ( QPoint  releasePoint)
void QgsMapCanvas::readProject ( const QDomDocument &  doc)
slot

called to read map canvas settings from project

Definition at line 1443 of file qgsmapcanvas.cpp.

References clearExtentHistory(), mMapRenderer, QgsDebugMsg, and QgsMapRenderer::readXML().

Referenced by QgsMapCanvas().

void QgsMapCanvas::refresh ( )
slot
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.

Referenced by refresh(), and saveAsImage().

bool QgsMapCanvas::renderFlag ( )
inlineslot

State of render suppression flag.

Definition at line 281 of file qgsmapcanvas.h.

void QgsMapCanvas::renderStarting ( )
signal

Emitted when the canvas is about to be rendered.

Note
Added in 1.5

Referenced by refresh().

void QgsMapCanvas::resizeEvent ( QResizeEvent *  e)
protected

Overridden resize event.

Definition at line 947 of file qgsmapcanvas.cpp.

References mNewSize.

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

Get the last reported scale of the canvas.

Definition at line 205 of file qgsmapcanvas.cpp.

References mMapRenderer, and QgsMapRenderer::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 1491 of file qgsmapcanvas.cpp.

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

Referenced by setLayerSet().

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

Write property of QColor bgColor.

Definition at line 1179 of file qgsmapcanvas.cpp.

References mMap, mScene, and QgsMapCanvasMap::setBackgroundColor().

void QgsMapCanvas::setCurrentLayer ( QgsMapLayer layer)

Definition at line 200 of file qgsmapcanvas.cpp.

References layer(), and mCurrentLayer.

void QgsMapCanvas::setDirty ( bool  _dirty)

Flag the canvas as dirty and needed a refresh.

Definition at line 210 of file qgsmapcanvas.cpp.

References mDirty.

Referenced by clear().

void QgsMapCanvas::setExtent ( QgsRectangle const &  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 1134 of file qgsmapcanvas.cpp.

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

Referenced by mouseReleaseEvent().

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

Set map units (needed by project properties dialog)

Definition at line 1278 of file qgsmapcanvas.cpp.

References mMapRenderer, QgsDebugMsg, and QgsMapRenderer::setMapUnits().

void QgsMapCanvas::setProgress ( int  ,
int   
)
signal

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

void QgsMapCanvas::setRenderFlag ( bool  theFlag)
slot

Whether to suppress rendering or not.

Definition at line 1291 of file qgsmapcanvas.cpp.

References mMapRenderer, mRenderFlag, refresh(), QgsMapRenderer::rendererContext(), and QgsRenderContext::setRenderingStopped().

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

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

Definition at line 1067 of file qgsmapcanvas.cpp.

References mWheelAction, and mWheelZoomFactor.

Referenced by QgsMapCanvas().

void QgsMapCanvas::showError ( QgsMapLayer mapLayer)
slot

show whatever error is exposed by the QgsMapLayer.

Definition at line 1418 of file qgsmapcanvas.cpp.

References QgsMapLayer::lastError(), QgsMapLayer::lastErrorTitle(), QgsMapLayer::name(), and QgsMessageViewer::setMessageAsPlainText().

Referenced by QgsMapCanvas().

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

References mScene, and QgsMapCanvasItem::updatePosition().

Referenced by moveCanvasContents(), paintEvent(), setExtent(), zoomToNextExtent(), and zoomToPreviousExtent().

void QgsMapCanvas::updateFullExtent ( )
void QgsMapCanvas::updateMap ( )
slot

updates pixmap on render progress

Definition at line 408 of file qgsmapcanvas.cpp.

References mMap, and QgsMapCanvasMap::updateContents().

Referenced by setLayerSet().

void QgsMapCanvas::updateOverview ( )

Definition at line 354 of file qgsmapcanvas.cpp.

References mMapOverview, and QgsMapOverviewCanvas::refresh().

Referenced by setLayerSet(), and updateFullExtent().

void QgsMapCanvas::updateScale ( )

Emits signal scalChanged to update scale in main window.

Definition at line 549 of file qgsmapcanvas.cpp.

References mMapRenderer, scale(), QgsMapRenderer::scale(), and scaleChanged().

Referenced by mapUnitsChanged(), paintEvent(), setExtent(), zoomToNextExtent(), and zoomToPreviousExtent().

void QgsMapCanvas::useImageToRender ( bool  theFlag)

Select which Qt class to render with.

Definition at line 173 of file qgsmapcanvas.cpp.

References mMap, refresh(), and QgsMapCanvasMap::useImageToRender().

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

called to write map canvas settings to project

Definition at line 1459 of file qgsmapcanvas.cpp.

References mMapRenderer, QgsDebugMsg, and QgsMapRenderer::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 1478 of file qgsmapcanvas.cpp.

References QgsMapRenderer::extent(), mDrawing, mMapRenderer, refresh(), QgsRectangle::scale(), and setExtent().

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

void QgsMapCanvas::zoomIn ( )

Zoom in with fixed factor.

Definition at line 1073 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 1078 of file qgsmapcanvas.cpp.

References mWheelZoomFactor, and zoomByFactor().

Referenced by keyPressEvent(), and wheelEvent().

void QgsMapCanvas::zoomScale ( double  scale)

Zoom to a specific scale.

Definition at line 1083 of file qgsmapcanvas.cpp.

References scale(), and zoomByFactor().

void QgsMapCanvas::zoomToFullExtent ( )

Zoom to the full extent of all layers.

Definition at line 566 of file qgsmapcanvas.cpp.

References extent(), fullExtent(), QgsRectangle::isEmpty(), mDrawing, 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 669 of file qgsmapcanvas.cpp.

References QgsVectorLayer::boundingBoxOfSelected(), QgsRectangle::center(), QgsRectangle::expand(), extent(), QgsRectangle::isEmpty(), QgsMapRenderer::layerExtentToOutputExtent(), mCurrentLayer, mDrawing, mMapRenderer, refresh(), QgsRectangle::scale(), QgsVectorLayer::selectedFeatureCount(), and setExtent().

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

Member Data Documentation

bool QgsMapCanvas::mAntiAliasing
private

indicates whether antialiasing will be used for rendering

Definition at line 470 of file qgsmapcanvas.h.

Referenced by enableAntiAliasing().

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

Handle pattern for implementation object.

Definition at line 387 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 442 of file qgsmapcanvas.h.

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

bool QgsMapCanvas::mDirty
private

Flag to track the state of the Map canvas.

The canvas is flagged as dirty by any operation that changes the state of the layers or the view extent. If the canvas is not dirty, paint events are handled by bit-blitting the stored canvas bitmap to the canvas. This improves performance by not reading the data source when no real change has occurred

Definition at line 431 of file qgsmapcanvas.h.

Referenced by isDirty(), QgsMapCanvas(), refresh(), and setDirty().

bool QgsMapCanvas::mDrawing
private
bool QgsMapCanvas::mFrozen
private

Flag indicating if the map canvas is frozen.

Definition at line 420 of file qgsmapcanvas.h.

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

QList<QgsRectangle> QgsMapCanvas::mLastExtent
private

recently used extent

Definition at line 454 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 451 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 411 of file qgsmapcanvas.h.

Referenced by canvasPaintDevice(), canvasPixmap(), enableAntiAliasing(), map(), moveCanvasContents(), paintEvent(), QgsMapCanvas(), refresh(), saveAsImage(), setCanvasColor(), updateMap(), and useImageToRender().

QgsMapOverviewCanvas* QgsMapCanvas::mMapOverview
private
QgsMapRenderer* QgsMapCanvas::mMapRenderer
private
QgsMapTool* QgsMapCanvas::mMapTool
private
QSize QgsMapCanvas::mNewSize
private

resize canvas size

Definition at line 464 of file qgsmapcanvas.h.

Referenced by paintEvent(), and resizeEvent().

bool QgsMapCanvas::mPainting
private

currently in paint event

Definition at line 467 of file qgsmapcanvas.h.

Referenced by paintEvent().

bool QgsMapCanvas::mRenderFlag
private

determines whether user has requested to suppress rendering

Definition at line 434 of file qgsmapcanvas.h.

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

QList< QPair<int, int> > QgsMapCanvas::mResizeQueue
private

Resize events that have been ignored because the canvas is busy with rendering may put their sizes into this list.

The canvas then picks up the last entry in case a lot of resize events arrive in short time

Definition at line 439 of file qgsmapcanvas.h.

QGraphicsScene* QgsMapCanvas::mScene
private

graphics scene manages canvas items

Definition at line 445 of file qgsmapcanvas.h.

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

WheelAction QgsMapCanvas::mWheelAction
private

Mouse wheel action.

Definition at line 461 of file qgsmapcanvas.h.

Referenced by setWheelAction(), and wheelEvent().

double QgsMapCanvas::mWheelZoomFactor
private

Scale factor multiple for default zoom in/out.

Definition at line 458 of file qgsmapcanvas.h.

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


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