QgsMapCanvas Class Reference
[Gui]

#include <qgsmapcanvas.h>

Collaboration diagram for QgsMapCanvas:

Collaboration graph
[legend]
List of all members.

Detailed Description

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

Definition at line 93 of file qgsmapcanvas.h.

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.
void mapUnitsChanged ()
 The map units may have changed, so cope with that.
void updateMap ()
 updates pixmap on render progress
void showError (QgsMapLayer *mapLayer)
 show whatever error is exposed by the QgsMapLayer.
void readProject (const QDomDocument &)
 called to read map canvas settings from project
void writeProject (QDomDocument &)
 called to write map canvas settings to project

Signals

void setProgress (int, int)
 Let the owner know how far we are with render operations.
void xyCoordinates (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 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 selectionChanged (QgsMapLayer *layer)
 Emitted when selection in any layer gets 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)
QgsMapCanvasMapmap ()
QgsMapRenderermapRenderer ()
QPixmap & canvasPixmap ()
 Accessor for the canvas pixmap.
double scale ()
 Get the last reported scale of the canvas.
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 (QgsRectangle const &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 zoomToSelected ()
 Zooms to the extend of the selected features.
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.
QgsMapToolmapTool ()
 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 updateScale ()
 Emits signal scalChanged to update scale in main window.
void updateFullExtent ()
 Updates the full extent.
QgsMapLayerlayer (int index)
 return the map layer at position index in the layer stack
int layerCount () const
 return number of layers on the map
void freeze (bool frz=true)
bool isFrozen ()
void setDirty (bool _dirty)
 Flag the canvas as dirty and needed a refresh.
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 QgsMapToPixelgetCoordinateTransform ()
 Get the current coordinate transform.
bool isDrawing ()
 true if canvas currently drawing
QgsMapLayercurrentLayer ()
 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 zoomByFactor (double scaleFactor)
 Zoom with the factor supplied. Factor > 1 zooms in.
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
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

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

Protected Attributes

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

Private Member Functions

 QgsMapCanvas (QgsMapCanvas const &)
 
Note:

void connectNotify (const char *signal)
 debugging member invoked when a connect() is made to this object

Private Attributes

QgsMapRenderermMapRenderer
 all map rendering is done in this class
QgsMapCanvasMapmMap
 owns pixmap with rendered map and controls rendering
QgsMapOverviewCanvasmMapOverview
 map overview widget - it's controlled by QgsMapCanvas
bool mDrawing
 Flag indicating a map refresh is in progress.
bool mFrozen
 Flag indicating if the map canvas is frozen.
bool mDirty
 Flag to track the state of the Map canvas.
bool mRenderFlag
 determines whether user has requested to suppress rendering
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.
QgsMapLayermCurrentLayer
 current layer in legend
QGraphicsScene * mScene
 graphics scene manages canvas items
QgsMapToolmMapTool
 pointer to current map tool
QgsMapToolmLastNonZoomMapTool
 previous tool if current is for zooming/panning
QgsRectangle mLastExtent
 recently used extent
double mWheelZoomFactor
 Scale factor multiple for default zoom in/out.
WheelAction mWheelAction
 Mouse wheel action.

Classes

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


Member Enumeration Documentation

enum QgsMapCanvas::WheelAction

Enumerator:
WheelZoom 
WheelZoomAndRecenter 
WheelZoomToMouseCursor 
WheelNothing 

Definition at line 99 of file qgsmapcanvas.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 77 of file qgsmapcanvas.cpp.

References QgsProject::instance(), mCurrentLayer, mDirty, mDrawing, mFrozen, mLastNonZoomMapTool, mMap, mMapOverview, mMapRenderer, mMapTool, moveCanvasContents(), mRenderFlag, mScene, readProject(), setWheelAction(), showError(), WheelZoom, and writeProject().

QgsMapCanvas::~QgsMapCanvas (  ) 

Destructor.

Definition at line 124 of file qgsmapcanvas.cpp.

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

QgsMapCanvas::QgsMapCanvas ( QgsMapCanvas const &   )  [private]

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

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

Definition at line 222 of file qgsmapcanvas.cpp.

References currentLayer(), fullExtent(), layer(), layerCount(), layersChanged(), QgsMapOverviewCanvas::layerSet(), QgsMapRenderer::layerSet(), mDrawing, mMapOverview, mMapRenderer, QgsDebugMsg, refresh(), selectionChanged(), selectionChangedSlot(), QgsMapOverviewCanvas::setLayerSet(), QgsMapRenderer::setLayerSet(), QgsMapOverviewCanvas::updateFullExtent(), updateMap(), and updateOverview().

void QgsMapCanvas::setCurrentLayer ( QgsMapLayer layer  ) 

Definition at line 187 of file qgsmapcanvas.cpp.

References layer(), and mCurrentLayer.

void QgsMapCanvas::updateOverview (  ) 

Definition at line 336 of file qgsmapcanvas.cpp.

References mMapOverview, and QgsMapOverviewCanvas::refresh().

Referenced by setLayerSet(), and updateFullExtent().

void QgsMapCanvas::enableOverviewMode ( QgsMapOverviewCanvas overview  ) 

Definition at line 310 of file qgsmapcanvas.cpp.

References hasCrsTransformEnabled(), mMapOverview, and mMapRenderer.

QgsMapCanvasMap * QgsMapCanvas::map (  ) 

Definition at line 166 of file qgsmapcanvas.cpp.

References mMap.

QgsMapRenderer * QgsMapCanvas::mapRenderer (  ) 

Definition at line 171 of file qgsmapcanvas.cpp.

References mMapRenderer.

Referenced by QgsMapOverviewCanvas::destinationSrsChanged(), QgsMapCanvasSnapper::QgsMapCanvasSnapper(), QgsMapCanvasMap::render(), QgsMapCanvasMap::resize(), QgsQuickPrint::setMapCanvas(), QgsMapCanvasSnapper::setMapCanvas(), QgsRubberBand::setToGeometry(), QgsMapTool::toLayerCoordinates(), and QgsMapTool::toMapCoordinates().

QPixmap & QgsMapCanvas::canvasPixmap (  ) 

Accessor for the canvas pixmap.

Definition at line 1055 of file qgsmapcanvas.cpp.

References mMap, and QgsMapCanvasMap::pixmap().

double QgsMapCanvas::scale (  ) 

Get the last reported scale of the canvas.

Definition at line 192 of file qgsmapcanvas.cpp.

References mMapRenderer, and QgsMapRenderer::scale().

Referenced by updateScale().

void QgsMapCanvas::clear (  ) 

Clear the map canvas.

Definition at line 484 of file qgsmapcanvas.cpp.

References setDirty().

Referenced by refresh().

double QgsMapCanvas::mapUnitsPerPixel (  )  const

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

Definition at line 1062 of file qgsmapcanvas.cpp.

References QgsMapRenderer::mapUnitsPerPixel(), and mMapRenderer.

QgsRectangle QgsMapCanvas::extent (  )  const

Returns the current zoom exent of the map canvas.

Definition at line 419 of file qgsmapcanvas.cpp.

References QgsMapRenderer::extent(), and mMapRenderer.

Referenced by QgsMapToolZoom::canvasReleaseEvent(), QgsMapOverviewCanvas::drawExtentRect(), QgsMapTip::fetchFeature(), QgsMapOverviewCanvas::mouseReleaseEvent(), setExtent(), QgsRubberBand::setToGeometry(), wheelEvent(), zoomToFullExtent(), and zoomToPreviousExtent().

QgsRectangle QgsMapCanvas::fullExtent (  )  const

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

Definition at line 424 of file qgsmapcanvas.cpp.

References QgsMapRenderer::fullExtent(), and mMapRenderer.

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

void QgsMapCanvas::setExtent ( QgsRectangle const &  r  ) 

Set the extent of the map canvas.

Definition at line 444 of file qgsmapcanvas.cpp.

References QgsRectangle::center(), QgsMapOverviewCanvas::drawExtentRect(), extent(), extentsChanged(), QgsRectangle::height(), QgsRectangle::isEmpty(), mDrawing, mLastExtent, mMapOverview, mMapRenderer, QgsDebugMsg, QgsMapRenderer::setExtent(), updateCanvasItemPositions(), updateScale(), QgsRectangle::width(), QgsPoint::x(), and QgsPoint::y().

Referenced by QgsMapToolZoom::canvasReleaseEvent(), keyPressEvent(), QgsMapOverviewCanvas::mouseReleaseEvent(), panActionEnd(), wheelEvent(), zoomByFactor(), zoomToFullExtent(), zoomToPreviousExtent(), zoomToSelected(), and zoomWithCenter().

void QgsMapCanvas::zoomToFullExtent (  ) 

Zoom to the full extent of all layers.

Definition at line 493 of file qgsmapcanvas.cpp.

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

void QgsMapCanvas::zoomToPreviousExtent (  ) 

Zoom to the previous extent (view).

Definition at line 514 of file qgsmapcanvas.cpp.

References extent(), mDrawing, mLastExtent, refresh(), and setExtent().

void QgsMapCanvas::zoomToSelected (  ) 

Zooms to the extend of the selected features.

Definition at line 551 of file qgsmapcanvas.cpp.

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

void QgsMapCanvas::setMapTool ( QgsMapTool mapTool  ) 

Sets the map tool currently being used on the canvas.

Definition at line 959 of file qgsmapcanvas.cpp.

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

Referenced by mouseReleaseEvent().

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

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

Referenced by QgsMapTool::~QgsMapTool().

QgsMapTool * QgsMapCanvas::mapTool (  ) 

Returns the currently active tool.

Definition at line 1106 of file qgsmapcanvas.cpp.

References mMapTool.

void QgsMapCanvas::setCanvasColor ( const QColor &  _newVal  )  [virtual]

Write property of QColor bgColor.

Definition at line 1004 of file qgsmapcanvas.cpp.

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

QColor QgsMapCanvas::canvasColor (  )  const [virtual]

Read property of QColor bgColor.

Definition at line 1022 of file qgsmapcanvas.cpp.

References mScene.

Referenced by QgsQuickPrint::setMapCanvas().

void QgsMapCanvas::updateScale (  ) 

Emits signal scalChanged to update scale in main window.

Definition at line 476 of file qgsmapcanvas.cpp.

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

Referenced by mapUnitsChanged(), resizeEvent(), and setExtent().

void QgsMapCanvas::updateFullExtent (  ) 

Updates the full extent.

Definition at line 429 of file qgsmapcanvas.cpp.

References fullExtent(), mMapOverview, mMapRenderer, QgsDebugMsg, refresh(), QgsMapOverviewCanvas::updateFullExtent(), QgsMapRenderer::updateFullExtent(), and updateOverview().

QgsMapLayer * QgsMapCanvas::layer ( int  index  ) 

return the map layer at position index in the layer stack

Definition at line 177 of file qgsmapcanvas.cpp.

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

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

int QgsMapCanvas::layerCount (  )  const

return number of layers on the map

Definition at line 1027 of file qgsmapcanvas.cpp.

References QgsMapRenderer::layerSet(), and mMapRenderer.

Referenced by setLayerSet().

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:
frz Boolean specifying if the canvas should be frozen (true) or thawed (false). Default is true.

Definition at line 1044 of file qgsmapcanvas.cpp.

References mFrozen.

bool QgsMapCanvas::isFrozen (  ) 

Accessor for frozen status of canvas

Definition at line 1049 of file qgsmapcanvas.cpp.

References mFrozen.

void QgsMapCanvas::setDirty ( bool  _dirty  ) 

Flag the canvas as dirty and needed a refresh.

Definition at line 197 of file qgsmapcanvas.cpp.

References mDirty.

Referenced by clear().

bool QgsMapCanvas::isDirty (  )  const

Return the state of the canvas (dirty or not).

Definition at line 202 of file qgsmapcanvas.cpp.

References mDirty.

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

Set map units (needed by project properties dialog).

Definition at line 1068 of file qgsmapcanvas.cpp.

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

QGis::UnitType QgsMapCanvas::mapUnits (  )  const

Get the current canvas map units.

Definition at line 1075 of file qgsmapcanvas.cpp.

References QgsMapRenderer::mapUnits(), and mMapRenderer.

const QgsMapToPixel * QgsMapCanvas::getCoordinateTransform (  ) 

Get the current coordinate transform.

Definition at line 217 of file qgsmapcanvas.cpp.

References QgsMapRenderer::coordinateTransform(), and mMapRenderer.

Referenced by QgsMapToolZoom::canvasReleaseEvent(), mouseMoveEvent(), panActionEnd(), QgsMapTool::toCanvasCoordinates(), QgsMapCanvasItem::toCanvasCoordinates(), QgsMapTool::toMapCoordinates(), QgsMapCanvasItem::toMapCoordinates(), wheelEvent(), and zoomWithCenter().

bool QgsMapCanvas::isDrawing (  ) 

true if canvas currently drawing

Definition at line 209 of file qgsmapcanvas.cpp.

References mDrawing.

QgsMapLayer * QgsMapCanvas::currentLayer (  ) 

returns current layer (set by legend widget)

Definition at line 346 of file qgsmapcanvas.cpp.

References mCurrentLayer.

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

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

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

Definition at line 899 of file qgsmapcanvas.cpp.

References mWheelAction, and mWheelZoomFactor.

Referenced by QgsMapCanvas().

void QgsMapCanvas::zoomIn (  ) 

Zoom in with fixed factor.

Definition at line 905 of file qgsmapcanvas.cpp.

References mWheelZoomFactor, and zoomByFactor().

Referenced by keyPressEvent(), and wheelEvent().

void QgsMapCanvas::zoomOut (  ) 

Zoom out with fixed factor.

Definition at line 910 of file qgsmapcanvas.cpp.

References mWheelZoomFactor, and zoomByFactor().

Referenced by keyPressEvent(), and wheelEvent().

void QgsMapCanvas::zoomByFactor ( double  scaleFactor  ) 

Zoom with the factor supplied. Factor > 1 zooms in.

Definition at line 1272 of file qgsmapcanvas.cpp.

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

Referenced by zoomIn(), and zoomOut().

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

Zooms in/out with a given center.

Definition at line 915 of file qgsmapcanvas.cpp.

References QgsMapRenderer::extent(), getCoordinateTransform(), mDrawing, mMapRenderer, mWheelZoomFactor, refresh(), QgsRectangle::scale(), setExtent(), and QgsMapToPixel::toMapPoint().

Referenced by QgsMapToolZoom::canvasReleaseEvent(), and wheelEvent().

void QgsMapCanvas::enableAntiAliasing ( bool  theFlag  ) 

used to determine if anti-aliasing is enabled or not

Definition at line 153 of file qgsmapcanvas.cpp.

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

void QgsMapCanvas::useImageToRender ( bool  theFlag  ) 

Select which Qt class to render with.

Definition at line 160 of file qgsmapcanvas.cpp.

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

void QgsMapCanvas::panActionEnd ( QPoint  releasePoint  ) 

Ends pan action and redraws the canvas.

Definition at line 1111 of file qgsmapcanvas.cpp.

References QgsMapRenderer::extent(), getCoordinateTransform(), mCanvasProperties, mDrawing, mMapRenderer, moveCanvasContents(), refresh(), setExtent(), QgsRectangle::setXMinimum(), QgsMapToPixel::toMapCoordinates(), QgsPoint::x(), and QgsPoint::y().

Referenced by QgsMapToolPan::canvasReleaseEvent(), and keyReleaseEvent().

void QgsMapCanvas::panAction ( QMouseEvent *  event  ) 

Called when mouse is moving and pan is activated.

Definition at line 1159 of file qgsmapcanvas.cpp.

References mDrawing, moveCanvasContents(), and QgsDebugMsg.

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

QPoint QgsMapCanvas::mouseLastXY (  ) 

returns last position of mouse cursor

Definition at line 1233 of file qgsmapcanvas.cpp.

References mCanvasProperties.

void QgsMapCanvas::refresh (  )  [slot]

Repaints the canvas map.

Definition at line 352 of file qgsmapcanvas.cpp.

References clear(), mDirty, mDrawing, mFrozen, mMap, mMapTool, mRenderFlag, QgsMapCanvasMap::paintDevice(), QgsMapCanvasMap::render(), QgsMapTool::renderComplete(), and renderComplete().

Referenced by QgsMapToolZoom::canvasReleaseEvent(), keyPressEvent(), layerStateChange(), mapUnitsChanged(), QgsMapOverviewCanvas::mouseReleaseEvent(), panActionEnd(), resizeEvent(), selectionChangedSlot(), setLayerSet(), setRenderFlag(), updateFullExtent(), useImageToRender(), wheelEvent(), zoomByFactor(), zoomToFullExtent(), zoomToPreviousExtent(), zoomToSelected(), and zoomWithCenter().

void QgsMapCanvas::selectionChangedSlot (  )  [slot]

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

Definition at line 1285 of file qgsmapcanvas.cpp.

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

Referenced by setLayerSet().

void QgsMapCanvas::saveAsImage ( QString  theFileName,
QPixmap *  QPixmap = 0,
QString  = "PNG" 
) [slot]

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

Definition at line 396 of file qgsmapcanvas.cpp.

References mMap, mMapRenderer, QgsMapCanvasMap::pixmap(), and QgsMapRenderer::render().

void QgsMapCanvas::layerStateChange (  )  [slot]

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

Definition at line 1034 of file qgsmapcanvas.cpp.

References refresh().

void QgsMapCanvas::setRenderFlag ( bool  theFlag  )  [slot]

Whether to suppress rendering or not.

Definition at line 1081 of file qgsmapcanvas.cpp.

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

bool QgsMapCanvas::renderFlag (  )  [inline, slot]

State of render suppression flag.

Definition at line 259 of file qgsmapcanvas.h.

bool QgsMapCanvas::hasCrsTransformEnabled (  )  [slot]

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

Definition at line 528 of file qgsmapcanvas.cpp.

References QgsMapRenderer::hasCrsTransformEnabled(), and mMapRenderer.

Referenced by enableOverviewMode().

void QgsMapCanvas::mapUnitsChanged (  )  [slot]

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

Definition at line 533 of file qgsmapcanvas.cpp.

References refresh(), and updateScale().

void QgsMapCanvas::updateMap (  )  [slot]

updates pixmap on render progress

Definition at line 387 of file qgsmapcanvas.cpp.

References mMap.

Referenced by setLayerSet().

void QgsMapCanvas::showError ( QgsMapLayer mapLayer  )  [slot]

show whatever error is exposed by the QgsMapLayer.

Definition at line 1212 of file qgsmapcanvas.cpp.

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

Referenced by QgsMapCanvas().

void QgsMapCanvas::readProject ( const QDomDocument &   )  [slot]

called to read map canvas settings from project

Definition at line 1238 of file qgsmapcanvas.cpp.

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

Referenced by QgsMapCanvas().

void QgsMapCanvas::writeProject ( QDomDocument &   )  [slot]

called to write map canvas settings to project

Definition at line 1253 of file qgsmapcanvas.cpp.

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

Referenced by QgsMapCanvas().

void QgsMapCanvas::setProgress ( int  ,
int   
) [signal]

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

void QgsMapCanvas::xyCoordinates ( QgsPoint p  )  [signal]

emits current mouse position

Referenced by mouseMoveEvent().

void QgsMapCanvas::scaleChanged ( double   )  [signal]

Emitted when the scale of the map changes.

Referenced by updateScale().

void QgsMapCanvas::extentsChanged (  )  [signal]

Emitted when the extents of the map change.

Referenced by resizeEvent(), and setExtent().

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

void QgsMapCanvas::layersChanged (  )  [signal]

Emitted when a new set of layers has been received.

Referenced by setLayerSet().

void QgsMapCanvas::keyPressed ( QKeyEvent *  e  )  [signal]

Emit key press event.

Referenced by keyPressEvent().

void QgsMapCanvas::keyReleased ( QKeyEvent *  e  )  [signal]

Emit key release event.

Referenced by keyReleaseEvent().

void QgsMapCanvas::mapToolSet ( QgsMapTool tool  )  [signal]

Emit map tool changed event.

Referenced by setMapTool(), and unsetMapTool().

void QgsMapCanvas::selectionChanged ( QgsMapLayer layer  )  [signal]

Emitted when selection in any layer gets changed.

Referenced by selectionChangedSlot(), and setLayerSet().

void QgsMapCanvas::keyPressEvent ( QKeyEvent *  e  )  [protected]

Overridden key press event.

Definition at line 584 of file qgsmapcanvas.cpp.

References QgsMapRenderer::extent(), keyPressed(), QgsMapTool::keyPressEvent(), mCanvasProperties, mDrawing, mMapRenderer, mMapTool, QgsDebugMsg, refresh(), setExtent(), QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), QgsRectangle::setYMinimum(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), QgsRectangle::yMinimum(), zoomIn(), and zoomOut().

void QgsMapCanvas::keyReleaseEvent ( QKeyEvent *  e  )  [protected]

Overridden key release event.

Definition at line 684 of file qgsmapcanvas.cpp.

References keyReleased(), mCanvasProperties, mDrawing, panActionEnd(), and QgsDebugMsg.

void QgsMapCanvas::mouseDoubleClickEvent ( QMouseEvent *  e  )  [protected]

Overridden mouse double click event.

Definition at line 717 of file qgsmapcanvas.cpp.

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

void QgsMapCanvas::mouseMoveEvent ( QMouseEvent *  e  )  [protected]

Overridden mouse move event.

Definition at line 932 of file qgsmapcanvas.cpp.

References QgsMapTool::canvasMoveEvent(), getCoordinateTransform(), mCanvasProperties, mDrawing, mMapTool, panAction(), QgsMapToPixel::toMapCoordinates(), and xyCoordinates().

void QgsMapCanvas::mousePressEvent ( QMouseEvent *  e  )  [protected]

Overridden mouse press event.

Definition at line 730 of file qgsmapcanvas.cpp.

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

void QgsMapCanvas::mouseReleaseEvent ( QMouseEvent *  e  )  [protected]

Overridden mouse release event.

Definition at line 750 of file qgsmapcanvas.cpp.

References QgsMapTool::canvasReleaseEvent(), QgsMapTool::isTransient(), mCanvasProperties, mDrawing, mLastNonZoomMapTool, mMapTool, QgsDebugMsg, and setMapTool().

void QgsMapCanvas::wheelEvent ( QWheelEvent *  e  )  [protected]

Overridden mouse wheel event.

Definition at line 848 of file qgsmapcanvas.cpp.

References QgsRectangle::center(), extent(), QgsMapRenderer::extent(), getCoordinateTransform(), mDrawing, mMapRenderer, mWheelAction, mWheelZoomFactor, QgsDebugMsg, refresh(), QgsRectangle::scale(), setExtent(), WheelNothing, WheelZoom, WheelZoomAndRecenter, WheelZoomToMouseCursor, zoomIn(), zoomOut(), and zoomWithCenter().

void QgsMapCanvas::resizeEvent ( QResizeEvent *  e  )  [protected]

Overridden resize event.

Definition at line 786 of file qgsmapcanvas.cpp.

References extentsChanged(), mDrawing, mMap, mMapRenderer, mScene, refresh(), QgsMapCanvasMap::resize(), QgsRenderContext::setRenderingStopped(), updateCanvasItemPositions(), and updateScale().

void QgsMapCanvas::moveCanvasContents ( bool  reset = FALSE  )  [protected]

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

Definition at line 1175 of file qgsmapcanvas.cpp.

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

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

void QgsMapCanvas::updateCanvasItemPositions (  )  [protected]

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

Definition at line 830 of file qgsmapcanvas.cpp.

References mScene.

Referenced by moveCanvasContents(), resizeEvent(), and setExtent().

void QgsMapCanvas::connectNotify ( const char *  signal  )  [private]

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

Definition at line 1099 of file qgsmapcanvas.cpp.

References QgsDebugMsg.


Member Data Documentation

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

Handle pattern for implementation object.

Definition at line 348 of file qgsmapcanvas.h.

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

QgsMapRenderer* QgsMapCanvas::mMapRenderer [private]

all map rendering is done in this class

Definition at line 364 of file qgsmapcanvas.h.

Referenced by enableOverviewMode(), extent(), fullExtent(), getCoordinateTransform(), hasCrsTransformEnabled(), keyPressEvent(), layer(), layerCount(), mapRenderer(), mapUnits(), mapUnitsPerPixel(), panActionEnd(), QgsMapCanvas(), readProject(), resizeEvent(), saveAsImage(), scale(), setExtent(), setLayerSet(), setMapUnits(), setRenderFlag(), updateFullExtent(), updateScale(), wheelEvent(), writeProject(), zoomByFactor(), zoomToSelected(), zoomWithCenter(), and ~QgsMapCanvas().

QgsMapCanvasMap* QgsMapCanvas::mMap [private]

owns pixmap with rendered map and controls rendering

Definition at line 367 of file qgsmapcanvas.h.

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

QgsMapOverviewCanvas* QgsMapCanvas::mMapOverview [private]

map overview widget - it's controlled by QgsMapCanvas

Definition at line 370 of file qgsmapcanvas.h.

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

bool QgsMapCanvas::mDrawing [private]

Flag indicating a map refresh is in progress.

Definition at line 373 of file qgsmapcanvas.h.

Referenced by isDrawing(), keyPressEvent(), keyReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveCanvasContents(), panAction(), panActionEnd(), QgsMapCanvas(), refresh(), resizeEvent(), setExtent(), setLayerSet(), wheelEvent(), zoomByFactor(), zoomToFullExtent(), zoomToPreviousExtent(), zoomToSelected(), and zoomWithCenter().

bool QgsMapCanvas::mFrozen [private]

Flag indicating if the map canvas is frozen.

Definition at line 376 of file qgsmapcanvas.h.

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

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

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

bool QgsMapCanvas::mRenderFlag [private]

determines whether user has requested to suppress rendering

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

QgsMapLayer* QgsMapCanvas::mCurrentLayer [private]

current layer in legend

Definition at line 403 of file qgsmapcanvas.h.

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

QGraphicsScene* QgsMapCanvas::mScene [private]

graphics scene manages canvas items

Definition at line 406 of file qgsmapcanvas.h.

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

QgsMapTool* QgsMapCanvas::mMapTool [private]

pointer to current map tool

Definition at line 409 of file qgsmapcanvas.h.

Referenced by keyPressEvent(), mapTool(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), QgsMapCanvas(), refresh(), setMapTool(), unsetMapTool(), and ~QgsMapCanvas().

QgsMapTool* QgsMapCanvas::mLastNonZoomMapTool [private]

previous tool if current is for zooming/panning

Definition at line 412 of file qgsmapcanvas.h.

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

QgsRectangle QgsMapCanvas::mLastExtent [private]

recently used extent

Definition at line 415 of file qgsmapcanvas.h.

Referenced by setExtent(), and zoomToPreviousExtent().

double QgsMapCanvas::mWheelZoomFactor [private]

Scale factor multiple for default zoom in/out.

Definition at line 418 of file qgsmapcanvas.h.

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

WheelAction QgsMapCanvas::mWheelAction [private]

Mouse wheel action.

Definition at line 421 of file qgsmapcanvas.h.

Referenced by setWheelAction(), and wheelEvent().


The documentation for this class was generated from the following files:
Generated on Sat Feb 7 12:56:47 2009 for Quantum GIS API Documentation by  doxygen 1.5.1