#include <qgscomposermap.h>
Public Types | |
enum | PreviewMode { Cache = 0, Render, Rectangle } |
Preview style. More... | |
enum | GridStyle { Solid = 0, Cross } |
enum | GridAnnotationPosition { InsideMapFrame = 0, OutsideMapFrame } |
enum | GridAnnotationDirection { Horizontal = 0, Vertical, HorizontalAndVertical, BoundaryDirection } |
Public Slots | |
void | updateCachedImage () |
Called if map canvas has changed. | |
void | renderModeUpdateCachedImage () |
Call updateCachedImage if item is in render mode. | |
Signals | |
void | extentChanged () |
Is emitted when width/height is changed as a result of user interaction. | |
Public Member Functions | |
QgsComposerMap (QgsComposition *composition, int x, int y, int width, int height) | |
Constructor. | |
QgsComposerMap (QgsComposition *composition) | |
Constructor. | |
~QgsComposerMap () | |
void | draw (QPainter *painter, const QgsRectangle &extent, const QSize &size, int dpi) |
This function is deprecated. | |
void | draw (QPainter *painter, const QgsRectangle &extent, const QSizeF &size, double dpi) |
Draw to paint device. | |
void | paint (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) |
Reimplementation of QCanvasItem::paint - draw on canvas. | |
void | cache (void) |
Create cache image. | |
int | id () const |
Get identification number. | |
bool | isDrawing () const |
True if a draw is already in progress. | |
void | resize (double dx, double dy) |
resizes an item in x- and y direction (canvas coordinates) | |
void | moveContent (double dx, double dy) |
Move content of map. | |
void | zoomContent (int delta, double x, double y) |
Zoom content of map. | |
void | setSceneRect (const QRectF &rectangle) |
Sets new scene rectangle bounds and recalculates hight and extent. | |
double | scale (void) const |
Scale. | |
void | setNewScale (double scaleDenominator) |
Sets new scale and changes only mExtent. | |
void | setNewExtent (const QgsRectangle &extent) |
Sets new Extent and changes width, height (and implicitely also scale). | |
PreviewMode | previewMode () |
void | setPreviewMode (PreviewMode m) |
bool | keepLayerSet () const |
Getter for flag that determines if the stored layer set should be used or the current layer set of the qgis mapcanvas. | |
void | setKeepLayerSet (bool enabled) |
Setter for flag that determines if the stored layer set should be used or the current layer set of the qgis mapcanvas. | |
QStringList | layerSet () const |
Getter for stored layer set that is used if mKeepLayerSet is true. | |
void | setLayerSet (const QStringList &layerSet) |
Setter for stored layer set that is used if mKeepLayerSet is true. | |
void | storeCurrentLayerSet () |
Stores the current layer set of the qgis mapcanvas in mLayerSet. | |
void | setCacheUpdated (bool u=false) |
QgsRectangle | extent () const |
const QgsMapRenderer * | mapRenderer () const |
void | setOffset (double xOffset, double yOffset) |
Sets offset values to shift image (useful for live updates when moving item content). | |
bool | containsWMSLayer () const |
True if composer map renders a WMS layer. | |
bool | writeXML (QDomElement &elem, QDomDocument &doc) const |
stores state in Dom node | |
bool | readXML (const QDomElement &itemElem, const QDomDocument &doc) |
sets state from Dom document | |
void | setGridEnabled (bool enabled) |
Enables a coordinate grid that is shown on top of this composermap. | |
bool | gridEnabled () const |
void | setGridStyle (GridStyle style) |
Sets coordinate grid style to solid or cross. | |
GridStyle | gridStyle () const |
void | setGridIntervalX (double interval) |
Sets coordinate interval in x-direction for composergrid. | |
double | gridIntervalX () const |
void | setGridIntervalY (double interval) |
Sets coordinate interval in y-direction for composergrid. | |
double | gridIntervalY () const |
void | setGridOffsetX (double offset) |
Sets x-coordinate offset for composer grid. | |
double | gridOffsetX () const |
void | setGridOffsetY (double offset) |
Sets y-coordinate offset for composer grid. | |
double | gridOffsetY () const |
void | setGridPen (const QPen &p) |
Sets the pen to draw composer grid. | |
QPen | gridPen () const |
void | setGridPenWidth (double w) |
Sets with of grid pen. | |
void | setGridPenColor (const QColor &c) |
Sets the color of the grid pen. | |
void | setGridAnnotationFont (const QFont &f) |
Sets font for grid annotations. | |
QFont | gridAnnotationFont () const |
void | setGridAnnotationPrecision (int p) |
Sets coordinate precision for grid annotations. | |
int | gridAnnotationPrecision () const |
void | setShowGridAnnotation (bool show) |
Sets flag if grid annotation should be shown. | |
bool | showGridAnnotation () const |
void | setGridAnnotationPosition (GridAnnotationPosition p) |
Sets position of grid annotations. | |
GridAnnotationPosition | gridAnnotationPosition () const |
void | setAnnotationFrameDistance (double d) |
Sets distance between map frame and annotations. | |
double | annotationFrameDistance () const |
void | setGridAnnotationDirection (GridAnnotationDirection d) |
Sets grid annotation direction. | |
GridAnnotationDirection | gridAnnotationDirection () const |
QRectF | boundingRect () const |
In case of annotations, the bounding rectangle can be larger than the map item rectangle. | |
void | updateBoundingRect () |
Updates the bounding rect of this item. | |
void | setCrossLength (double l) |
Sets length of the cros segments (if grid style is cross). | |
double | crossLength () |
void | setMapRotation (double r) |
void | setMapCanvas (QGraphicsView *canvas) |
Sets canvas pointer (necessary to query and draw map canvas items). | |
Private Types | |
enum | Border { Left, Right, Bottom, Top } |
Enum for different frame borders. More... | |
Private Member Functions | |
void | connectUpdateSlot () |
Establishes signal/slot connection for update in case of layer change. | |
void | syncLayerSet () |
Removes layer ids from mLayerSet that are no longer present in the qgis main map. | |
void | drawGrid (QPainter *p) |
Draws the map grid. | |
void | drawCoordinateAnnotations (QPainter *p, const QList< QPair< double, QLineF > > &hLines, const QList< QPair< double, QLineF > > &vLines) |
Draw coordinates for mGridAnnotationType Coordinate. | |
void | drawCoordinateAnnotation (QPainter *p, const QPointF &pos, QString annotationString) |
void | drawAnnotation (QPainter *p, const QPointF &pos, int rotation, const QString &annotationText) |
Draws a single annotation. | |
int | xGridLines (QList< QPair< double, QLineF > > &lines) const |
Returns the grid lines with associated coordinate value. | |
int | yGridLines (QList< QPair< double, QLineF > > &lines) const |
Returns the grid lines for the y-coordinates. | |
QgsRectangle | transformedExtent () const |
Returns extent that considers mOffsetX / mOffsetY (during content move). | |
QPolygonF | transformedMapPolygon () const |
Returns extent that considers rotation and shift with mOffsetX / mOffsetY. | |
double | maxExtension () const |
void | mapPolygon (QPolygonF &poly) const |
Returns the polygon of the map extent. | |
void | requestedExtent (QgsRectangle &extent) const |
Calculates the extent to request and the yShift of the top-left point in case of rotation. | |
double | mapUnitsToMM () const |
Returns the conversion factor map units -> mm. | |
void | transformShift (double &xShift, double &yShift) const |
Scales a composer map shift (in MM) and rotates it by mRotation. | |
QPointF | mapToItemCoords (const QPointF &mapCoords) const |
Transforms map coordinates to item coordinates (considering rotation and move offset). | |
Border | borderForLineCoord (const QPointF &p) const |
Returns the item border of a point (in item coordinates). | |
void | drawCanvasItems (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle) |
void | drawCanvasItem (QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *itemStyle) |
QPointF | composerMapPosForItem (const QGraphicsItem *item) const |
Private Attributes | |
QgsMapRenderer * | mMapRenderer |
int | mId |
Unique identifier. | |
QgsRectangle | mExtent |
QImage | mCacheImage |
bool | mCacheUpdated |
PreviewMode | mPreviewMode |
Preview style. | |
int | mNumCachedLayers |
Number of layers when cache was created. | |
bool | mDrawing |
set to true if in state of drawing. | |
double | mXOffset |
Offset in x direction for showing map cache image. | |
double | mYOffset |
Offset in y direction for showing map cache image. | |
bool | mKeepLayerSet |
Flag if layers to be displayed should be read from qgis canvas (true) or from stored list in mLayerSet (false). | |
QStringList | mLayerSet |
Stored layer list (used if layer live-link mKeepLayerSet is disabled). | |
bool | mGridEnabled |
True if coordinate grid has to be displayed. | |
GridStyle | mGridStyle |
Solid or crosses. | |
double | mGridIntervalX |
Grid line interval in x-direction (map units). | |
double | mGridIntervalY |
Grid line interval in y-direction (map units). | |
double | mGridOffsetX |
Grid line offset in x-direction. | |
double | mGridOffsetY |
Grid line offset in y-direction. | |
QPen | mGridPen |
Grid line pen. | |
QFont | mGridAnnotationFont |
Font for grid line annotation. | |
int | mGridAnnotationPrecision |
Digits after the dot. | |
bool | mShowGridAnnotation |
True if coordinate values should be drawn. | |
GridAnnotationPosition | mGridAnnotationPosition |
Annotation position inside or outside of map frame. | |
double | mAnnotationFrameDistance |
Distance between map frame and annotation. | |
GridAnnotationDirection | mGridAnnotationDirection |
Annotation can be horizontal / vertical or different for axes. | |
QRectF | mCurrentRectangle |
Current bounding rectangle. | |
double | mCrossLength |
The length of the cross sides for mGridStyle Cross. | |
QGraphicsView * | mMapCanvas |
Definition at line 38 of file qgscomposermap.h.
Definition at line 69 of file qgscomposermap.h.
enum QgsComposerMap::Border [private] |
QgsComposerMap::QgsComposerMap | ( | QgsComposition * | composition, | |
int | x, | |||
int | y, | |||
int | width, | |||
int | height | |||
) |
Constructor.
Definition at line 43 of file qgscomposermap.cpp.
References QgsComposition::composerMapItems(), connectUpdateSlot(), QgsMapRenderer::extent(), QgsComposition::mapRenderer(), mCacheUpdated, QgsComposerItem::mComposition, mCurrentRectangle, mDrawing, mExtent, mGridPen, mId, mMapRenderer, mPreviewMode, mXOffset, mYOffset, Rectangle, and setSceneRect().
QgsComposerMap::QgsComposerMap | ( | QgsComposition * | composition | ) |
Constructor.
Settings are read from project.
Definition at line 74 of file qgscomposermap.cpp.
References QgsComposition::composerMapItems(), connectUpdateSlot(), QgsComposition::mapRenderer(), QgsComposerItem::mComposition, mCurrentRectangle, mGridPen, mId, mMapRenderer, mPreviewMode, mXOffset, mYOffset, and Rectangle.
QgsComposerMap::~QgsComposerMap | ( | ) |
Definition at line 95 of file qgscomposermap.cpp.
void QgsComposerMap::draw | ( | QPainter * | painter, | |
const QgsRectangle & | extent, | |||
const QSize & | size, | |||
int | dpi | |||
) |
void QgsComposerMap::draw | ( | QPainter * | painter, | |
const QgsRectangle & | extent, | |||
const QSizeF & | size, | |||
double | dpi | |||
) |
Draw to paint device.
painter | painter | |
extent | map extent | |
size | size in scene coordinates | |
dpi | scene dpi |
Definition at line 106 of file qgscomposermap.cpp.
References QgsLabelingEngineInterface::clone(), QgsMapRenderer::destinationSrs(), QgsMapRenderer::hasCrsTransformEnabled(), QgsMapRenderer::labelingEngine(), QgsMapRenderer::layerSet(), mKeepLayerSet, mLayerSet, mMapRenderer, QgsMapRenderer::render(), QgsMapRenderer::rendererContext(), scale(), QgsMapRenderer::scale(), QgsMapRenderer::setDestinationSrs(), QgsRenderContext::setDrawEditingInformation(), QgsMapRenderer::setExtent(), QgsRenderContext::setForceVectorOutput(), QgsMapRenderer::setLabelingEngine(), QgsMapRenderer::setLayerSet(), QgsMapRenderer::setOutputSize(), QgsMapRenderer::setProjectionsEnabled(), QgsRenderContext::setRenderingStopped(), and QgsMapRenderer::setScale().
void QgsComposerMap::paint | ( | QPainter * | painter, | |
const QStyleOptionGraphicsItem * | itemStyle, | |||
QWidget * | pWidget | |||
) |
Reimplementation of QCanvasItem::paint - draw on canvas.
Definition at line 221 of file qgscomposermap.cpp.
References draw(), QgsComposerItem::drawBackground(), drawCanvasItems(), QgsComposerItem::drawFrame(), drawGrid(), QgsComposerItem::drawSelectionBoxes(), QgsRectangle::height(), QgsComposerItem::horizontalViewScaleFactor(), mapUnitsToMM(), mCacheImage, QgsComposerItem::mComposition, mDrawing, mExtent, mGridEnabled, QgsComposerItem::mLastValidViewScaleFactor, mPreviewMode, QgsComposerItem::mRotation, mXOffset, mYOffset, QgsComposition::plotStyle(), QgsComposition::Postscript, QgsComposition::Preview, QgsComposition::Print, Rectangle, requestedExtent(), scale(), QgsRectangle::width(), QgsPoint::x(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsPoint::y(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
void QgsComposerMap::cache | ( | void | ) |
Create cache image.
Definition at line 168 of file qgscomposermap.cpp.
References draw(), QgsRectangle::height(), QgsComposerItem::horizontalViewScaleFactor(), mapUnitsToMM(), mCacheImage, mCacheUpdated, mDrawing, mExtent, QgsComposerItem::mLastValidViewScaleFactor, mPreviewMode, Rectangle, requestedExtent(), QgsRectangle::width(), QgsRectangle::xMinimum(), and QgsRectangle::yMinimum().
Referenced by QgsComposerView::addComposerMap(), moveContent(), setNewScale(), setSceneRect(), updateCachedImage(), and zoomContent().
int QgsComposerMap::id | ( | ) | const [inline] |
Get identification number.
Definition at line 94 of file qgscomposermap.h.
Referenced by QgsComposition::getComposerMapById(), QgsComposerPicture::rotationMap(), QgsComposerScaleBar::writeXML(), QgsComposerPicture::writeXML(), and QgsComposerAttributeTable::writeXML().
bool QgsComposerMap::isDrawing | ( | ) | const [inline] |
True if a draw is already in progress.
Definition at line 97 of file qgscomposermap.h.
Referenced by QgsComposerView::keyPressEvent(), and QgsComposerAttributeTable::paint().
void QgsComposerMap::resize | ( | double | dx, | |
double | dy | |||
) |
resizes an item in x- and y direction (canvas coordinates)
Definition at line 372 of file qgscomposermap.cpp.
References setSceneRect().
void QgsComposerMap::moveContent | ( | double | dx, | |
double | dy | |||
) | [virtual] |
Move content of map.
dx | move in x-direction (item and canvas coordinates) | |
dy | move in y-direction (item and canvas coordinates) |
Reimplemented from QgsComposerItem.
Definition at line 380 of file qgscomposermap.cpp.
References cache(), extentChanged(), mDrawing, mExtent, QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), QgsRectangle::setYMinimum(), transformShift(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
void QgsComposerMap::zoomContent | ( | int | delta, | |
double | x, | |||
double | y | |||
) | [virtual] |
Zoom content of map.
delta | value from wheel event that describes magnitude and direction (positive /negative number) | |
x | x-coordinate of mouse position in item coordinates | |
y | y-coordinate of mouse position in item coordinates |
Reimplemented from QgsComposerItem.
Definition at line 395 of file qgscomposermap.cpp.
References cache(), extentChanged(), mDrawing, mExtent, QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), QgsRectangle::setYMinimum(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
void QgsComposerMap::setSceneRect | ( | const QRectF & | rectangle | ) | [virtual] |
Sets new scene rectangle bounds and recalculates hight and extent.
Reimplemented from QgsComposerItem.
Definition at line 462 of file qgscomposermap.cpp.
References cache(), extentChanged(), mCacheUpdated, mExtent, mPreviewMode, Rectangle, QgsComposerItem::setSceneRect(), updateBoundingRect(), QgsRectangle::width(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), and QgsRectangle::yMinimum().
Referenced by QgsComposerMap(), resize(), and setNewExtent().
double QgsComposerMap::scale | ( | void | ) | const |
Scale.
Definition at line 364 of file qgscomposermap.cpp.
References QgsScaleCalculator::calculate(), QgsMapRenderer::mapUnits(), mExtent, mMapRenderer, QgsScaleCalculator::setDpi(), and QgsScaleCalculator::setMapUnits().
Referenced by draw(), paint(), QgsNumericScaleBarStyle::scaleText(), and setNewScale().
void QgsComposerMap::setNewScale | ( | double | scaleDenominator | ) |
Sets new scale and changes only mExtent.
Definition at line 500 of file qgscomposermap.cpp.
References cache(), extentChanged(), mCacheUpdated, mExtent, QgsRectangle::scale(), and scale().
void QgsComposerMap::setNewExtent | ( | const QgsRectangle & | extent | ) |
Sets new Extent and changes width, height (and implicitely also scale).
Definition at line 484 of file qgscomposermap.cpp.
References QgsRectangle::height(), mExtent, setSceneRect(), and QgsRectangle::width().
PreviewMode QgsComposerMap::previewMode | ( | ) | [inline] |
void QgsComposerMap::setPreviewMode | ( | PreviewMode | m | ) | [inline] |
bool QgsComposerMap::keepLayerSet | ( | ) | const [inline] |
Getter for flag that determines if the stored layer set should be used or the current layer set of the qgis mapcanvas.
Definition at line 130 of file qgscomposermap.h.
void QgsComposerMap::setKeepLayerSet | ( | bool | enabled | ) | [inline] |
Setter for flag that determines if the stored layer set should be used or the current layer set of the qgis mapcanvas.
Definition at line 133 of file qgscomposermap.h.
QStringList QgsComposerMap::layerSet | ( | ) | const [inline] |
Getter for stored layer set that is used if mKeepLayerSet is true.
Definition at line 137 of file qgscomposermap.h.
Referenced by readXML().
void QgsComposerMap::setLayerSet | ( | const QStringList & | layerSet | ) | [inline] |
Setter for stored layer set that is used if mKeepLayerSet is true.
Definition at line 140 of file qgscomposermap.h.
void QgsComposerMap::storeCurrentLayerSet | ( | ) |
Stores the current layer set of the qgis mapcanvas in mLayerSet.
Definition at line 771 of file qgscomposermap.cpp.
References QgsMapRenderer::layerSet(), mLayerSet, and mMapRenderer.
void QgsComposerMap::setCacheUpdated | ( | bool | u = false |
) |
QgsRectangle QgsComposerMap::extent | ( | ) | const [inline] |
Definition at line 147 of file qgscomposermap.h.
Referenced by QgsComposerScaleBar::applyDefaultSettings(), QgsComposerAttributeTable::getFeatureAttributes(), and QgsComposerScaleBar::refreshSegmentMillimeters().
const QgsMapRenderer* QgsComposerMap::mapRenderer | ( | ) | const [inline] |
Definition at line 149 of file qgscomposermap.h.
void QgsComposerMap::setOffset | ( | double | xOffset, | |
double | yOffset | |||
) |
Sets offset values to shift image (useful for live updates when moving item content).
Definition at line 517 of file qgscomposermap.cpp.
References mXOffset, and mYOffset.
Referenced by QgsComposerView::mouseMoveEvent(), and QgsComposerView::mouseReleaseEvent().
bool QgsComposerMap::containsWMSLayer | ( | ) | const |
True if composer map renders a WMS layer.
Definition at line 529 of file qgscomposermap.cpp.
References QgsRasterLayer::dataProvider(), QgsMapLayerRegistry::instance(), QgsMapRenderer::layerSet(), QgsMapLayerRegistry::mapLayer(), mMapRenderer, and QgsDataProvider::name().
bool QgsComposerMap::writeXML | ( | QDomElement & | elem, | |
QDomDocument & | doc | |||
) | const [virtual] |
stores state in Dom node
elem | is Dom element corresponding to 'Composer' tag | |
doc | Dom document |
Implements QgsComposerItem.
Definition at line 574 of file qgscomposermap.cpp.
References QgsComposerItem::_writeXML(), Cache, mAnnotationFrameDistance, mCrossLength, mExtent, mGridAnnotationDirection, mGridAnnotationFont, mGridAnnotationPosition, mGridAnnotationPrecision, mGridEnabled, mGridIntervalX, mGridIntervalY, mGridOffsetX, mGridOffsetY, mGridPen, mGridStyle, mId, mKeepLayerSet, mLayerSet, mPreviewMode, mShowGridAnnotation, Render, QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
bool QgsComposerMap::readXML | ( | const QDomElement & | itemElem, | |
const QDomDocument & | doc | |||
) | [virtual] |
sets state from Dom document
itemElem | is Dom node corresponding to 'ComposerMap' tag | |
doc | is Dom document |
Implements QgsComposerItem.
Definition at line 657 of file qgscomposermap.cpp.
References QgsComposerItem::_readXML(), Cache, layerSet(), mAnnotationFrameDistance, mCacheUpdated, mCrossLength, mDrawing, mExtent, mGridAnnotationDirection, mGridAnnotationFont, mGridAnnotationPosition, mGridAnnotationPrecision, mGridEnabled, mGridIntervalX, mGridIntervalY, mGridOffsetX, mGridOffsetY, mGridPen, mGridStyle, mId, mKeepLayerSet, mLayerSet, mNumCachedLayers, mPreviewMode, mShowGridAnnotation, previewMode(), Rectangle, Render, and updateBoundingRect().
void QgsComposerMap::setGridEnabled | ( | bool | enabled | ) | [inline] |
Enables a coordinate grid that is shown on top of this composermap.
Definition at line 171 of file qgscomposermap.h.
bool QgsComposerMap::gridEnabled | ( | ) | const [inline] |
Definition at line 172 of file qgscomposermap.h.
void QgsComposerMap::setGridStyle | ( | GridStyle | style | ) | [inline] |
Sets coordinate grid style to solid or cross.
Definition at line 176 of file qgscomposermap.h.
GridStyle QgsComposerMap::gridStyle | ( | ) | const [inline] |
Definition at line 177 of file qgscomposermap.h.
void QgsComposerMap::setGridIntervalX | ( | double | interval | ) | [inline] |
Sets coordinate interval in x-direction for composergrid.
Definition at line 181 of file qgscomposermap.h.
double QgsComposerMap::gridIntervalX | ( | ) | const [inline] |
Definition at line 182 of file qgscomposermap.h.
void QgsComposerMap::setGridIntervalY | ( | double | interval | ) | [inline] |
Sets coordinate interval in y-direction for composergrid.
Definition at line 186 of file qgscomposermap.h.
double QgsComposerMap::gridIntervalY | ( | ) | const [inline] |
Definition at line 187 of file qgscomposermap.h.
void QgsComposerMap::setGridOffsetX | ( | double | offset | ) | [inline] |
Sets x-coordinate offset for composer grid.
Definition at line 191 of file qgscomposermap.h.
double QgsComposerMap::gridOffsetX | ( | ) | const [inline] |
Definition at line 192 of file qgscomposermap.h.
void QgsComposerMap::setGridOffsetY | ( | double | offset | ) | [inline] |
Sets y-coordinate offset for composer grid.
Definition at line 196 of file qgscomposermap.h.
double QgsComposerMap::gridOffsetY | ( | ) | const [inline] |
Definition at line 197 of file qgscomposermap.h.
void QgsComposerMap::setGridPen | ( | const QPen & | p | ) | [inline] |
Sets the pen to draw composer grid.
Definition at line 201 of file qgscomposermap.h.
QPen QgsComposerMap::gridPen | ( | ) | const [inline] |
Definition at line 202 of file qgscomposermap.h.
void QgsComposerMap::setGridPenWidth | ( | double | w | ) |
Sets with of grid pen.
Definition at line 1191 of file qgscomposermap.cpp.
References mGridPen.
void QgsComposerMap::setGridPenColor | ( | const QColor & | c | ) |
Sets the color of the grid pen.
Definition at line 1196 of file qgscomposermap.cpp.
References mGridPen.
void QgsComposerMap::setGridAnnotationFont | ( | const QFont & | f | ) | [inline] |
Sets font for grid annotations.
Definition at line 212 of file qgscomposermap.h.
QFont QgsComposerMap::gridAnnotationFont | ( | ) | const [inline] |
Definition at line 213 of file qgscomposermap.h.
void QgsComposerMap::setGridAnnotationPrecision | ( | int | p | ) | [inline] |
Sets coordinate precision for grid annotations.
Definition at line 217 of file qgscomposermap.h.
int QgsComposerMap::gridAnnotationPrecision | ( | ) | const [inline] |
Definition at line 218 of file qgscomposermap.h.
void QgsComposerMap::setShowGridAnnotation | ( | bool | show | ) | [inline] |
Sets flag if grid annotation should be shown.
Definition at line 222 of file qgscomposermap.h.
bool QgsComposerMap::showGridAnnotation | ( | ) | const [inline] |
Definition at line 223 of file qgscomposermap.h.
void QgsComposerMap::setGridAnnotationPosition | ( | GridAnnotationPosition | p | ) | [inline] |
Sets position of grid annotations.
Possibilities are inside or outside of the map frame
Definition at line 227 of file qgscomposermap.h.
GridAnnotationPosition QgsComposerMap::gridAnnotationPosition | ( | ) | const [inline] |
Definition at line 228 of file qgscomposermap.h.
void QgsComposerMap::setAnnotationFrameDistance | ( | double | d | ) | [inline] |
Sets distance between map frame and annotations.
Definition at line 232 of file qgscomposermap.h.
double QgsComposerMap::annotationFrameDistance | ( | ) | const [inline] |
Definition at line 233 of file qgscomposermap.h.
void QgsComposerMap::setGridAnnotationDirection | ( | GridAnnotationDirection | d | ) | [inline] |
Sets grid annotation direction.
Can be horizontal, vertical, direction of axis and horizontal and vertical
Definition at line 237 of file qgscomposermap.h.
GridAnnotationDirection QgsComposerMap::gridAnnotationDirection | ( | ) | const [inline] |
Definition at line 238 of file qgscomposermap.h.
QRectF QgsComposerMap::boundingRect | ( | ) | const |
In case of annotations, the bounding rectangle can be larger than the map item rectangle.
Definition at line 1201 of file qgscomposermap.cpp.
References mCurrentRectangle.
void QgsComposerMap::updateBoundingRect | ( | ) |
Updates the bounding rect of this item.
Call this function before doing any changes related to annotation out of the map rectangle
Definition at line 1206 of file qgscomposermap.cpp.
References maxExtension(), and mCurrentRectangle.
Referenced by readXML(), and setSceneRect().
void QgsComposerMap::setCrossLength | ( | double | l | ) | [inline] |
Sets length of the cros segments (if grid style is cross).
Definition at line 249 of file qgscomposermap.h.
double QgsComposerMap::crossLength | ( | ) | [inline] |
Definition at line 250 of file qgscomposermap.h.
void QgsComposerMap::setMapRotation | ( | double | r | ) |
Definition at line 523 of file qgscomposermap.cpp.
References QgsComposerItem::rotationChanged(), and QgsComposerItem::setRotation().
void QgsComposerMap::setMapCanvas | ( | QGraphicsView * | canvas | ) | [inline] |
Sets canvas pointer (necessary to query and draw map canvas items).
Definition at line 255 of file qgscomposermap.h.
void QgsComposerMap::updateCachedImage | ( | void | ) | [slot] |
Called if map canvas has changed.
Definition at line 343 of file qgscomposermap.cpp.
References cache(), mCacheUpdated, and syncLayerSet().
Referenced by connectUpdateSlot(), and renderModeUpdateCachedImage().
void QgsComposerMap::renderModeUpdateCachedImage | ( | ) | [slot] |
Call updateCachedImage if item is in render mode.
Definition at line 351 of file qgscomposermap.cpp.
References mPreviewMode, Render, and updateCachedImage().
void QgsComposerMap::extentChanged | ( | ) | [signal] |
Is emitted when width/height is changed as a result of user interaction.
Referenced by moveContent(), setNewScale(), setSceneRect(), and zoomContent().
void QgsComposerMap::connectUpdateSlot | ( | ) | [private] |
Establishes signal/slot connection for update in case of layer change.
Definition at line 563 of file qgscomposermap.cpp.
References QgsMapLayerRegistry::instance(), and updateCachedImage().
Referenced by QgsComposerMap().
void QgsComposerMap::syncLayerSet | ( | ) | [private] |
Removes layer ids from mLayerSet that are no longer present in the qgis main map.
Definition at line 779 of file qgscomposermap.cpp.
References QgsMapRenderer::layerSet(), mLayerSet, and mMapRenderer.
Referenced by updateCachedImage().
void QgsComposerMap::drawGrid | ( | QPainter * | p | ) | [private] |
Draws the map grid.
Definition at line 796 of file qgscomposermap.cpp.
References drawCoordinateAnnotations(), mCrossLength, mGridPen, mGridStyle, mShowGridAnnotation, QgsComposerItem::pointOnLineWithDistance(), Solid, xGridLines(), and yGridLines().
Referenced by paint().
void QgsComposerMap::drawCoordinateAnnotations | ( | QPainter * | p, | |
const QList< QPair< double, QLineF > > & | hLines, | |||
const QList< QPair< double, QLineF > > & | vLines | |||
) | [private] |
Draw coordinates for mGridAnnotationType Coordinate.
p | drawing painter | |
hLines | horizontal coordinate lines in item coordinates | |
vLines | vertical coordinate lines in item coordinates |
Definition at line 881 of file qgscomposermap.cpp.
References drawCoordinateAnnotation(), and mGridAnnotationPrecision.
Referenced by drawGrid().
void QgsComposerMap::drawCoordinateAnnotation | ( | QPainter * | p, | |
const QPointF & | pos, | |||
QString | annotationString | |||
) | [private] |
Definition at line 907 of file qgscomposermap.cpp.
References borderForLineCoord(), Bottom, BoundaryDirection, drawAnnotation(), QgsComposerItem::fontAscentMillimeters(), Horizontal, InsideMapFrame, Left, mAnnotationFrameDistance, mGridAnnotationDirection, mGridAnnotationFont, mGridAnnotationPosition, Right, QgsComposerItem::rotation(), QgsComposerItem::textWidthMillimeters(), and Vertical.
Referenced by drawCoordinateAnnotations().
void QgsComposerMap::drawAnnotation | ( | QPainter * | p, | |
const QPointF & | pos, | |||
int | rotation, | |||
const QString & | annotationText | |||
) | [private] |
Draws a single annotation.
p | drawing painter | |
pos | item coordinates where to draw | |
rotation | text rotation | |
annotationText | the text to draw |
Definition at line 1046 of file qgscomposermap.cpp.
References QgsComposerItem::drawText(), and mGridAnnotationFont.
Referenced by drawCoordinateAnnotation().
int QgsComposerMap::xGridLines | ( | QList< QPair< double, QLineF > > & | lines | ) | const [private] |
Returns the grid lines with associated coordinate value.
Definition at line 1056 of file qgscomposermap.cpp.
References mapPolygon(), mapToItemCoords(), mGridIntervalY, mGridOffsetY, QgsComposerItem::mRotation, and transformedMapPolygon().
Referenced by drawGrid(), and maxExtension().
int QgsComposerMap::yGridLines | ( | QList< QPair< double, QLineF > > & | lines | ) | const [private] |
Returns the grid lines for the y-coordinates.
Not vertical in case of rotation
Definition at line 1125 of file qgscomposermap.cpp.
References mapPolygon(), mapToItemCoords(), mGridIntervalX, mGridOffsetX, QgsComposerItem::mRotation, and transformedMapPolygon().
Referenced by drawGrid(), and maxExtension().
QgsRectangle QgsComposerMap::transformedExtent | ( | ) | const [private] |
Returns extent that considers mOffsetX / mOffsetY (during content move).
Definition at line 1221 of file qgscomposermap.cpp.
References mExtent, mXOffset, mYOffset, transformShift(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
Referenced by mapToItemCoords().
QPolygonF QgsComposerMap::transformedMapPolygon | ( | ) | const [private] |
Returns extent that considers rotation and shift with mOffsetX / mOffsetY.
Definition at line 1229 of file qgscomposermap.cpp.
References mapPolygon(), mXOffset, mYOffset, and transformShift().
Referenced by mapToItemCoords(), xGridLines(), and yGridLines().
double QgsComposerMap::maxExtension | ( | ) | const [private] |
Definition at line 1246 of file qgscomposermap.cpp.
References QgsComposerItem::fontAscentMillimeters(), mAnnotationFrameDistance, MathUtils::max(), mGridAnnotationFont, mGridAnnotationPosition, mGridAnnotationPrecision, mGridEnabled, mShowGridAnnotation, OutsideMapFrame, QgsComposerItem::textWidthMillimeters(), xGridLines(), and yGridLines().
Referenced by updateBoundingRect().
void QgsComposerMap::mapPolygon | ( | QPolygonF & | poly | ) | const [private] |
Returns the polygon of the map extent.
If rotation == 0, the result is the same as mExtent
poly | out: the result polygon with the four corner points. The points are clockwise, starting at the top-left point |
Definition at line 1289 of file qgscomposermap.cpp.
References mExtent, QgsComposerItem::mRotation, QgsComposerItem::rotate(), QgsPoint::x(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsPoint::y(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
Referenced by requestedExtent(), transformedMapPolygon(), xGridLines(), and yGridLines().
void QgsComposerMap::requestedExtent | ( | QgsRectangle & | extent | ) | const [private] |
Calculates the extent to request and the yShift of the top-left point in case of rotation.
Definition at line 1330 of file qgscomposermap.cpp.
References mapPolygon(), mExtent, QgsComposerItem::mRotation, QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), and QgsRectangle::setYMinimum().
double QgsComposerMap::mapUnitsToMM | ( | ) | const [private] |
Returns the conversion factor map units -> mm.
Definition at line 1348 of file qgscomposermap.cpp.
References mExtent, and QgsRectangle::width().
Referenced by cache(), paint(), and transformShift().
void QgsComposerMap::transformShift | ( | double & | xShift, | |
double & | yShift | |||
) | const [private] |
Scales a composer map shift (in MM) and rotates it by mRotation.
xShift | in: shift in x direction (in item units), out: xShift in map units | |
yShift | in: shift in y direction (in item units), out: yShift in map units |
Definition at line 1358 of file qgscomposermap.cpp.
References mapUnitsToMM(), QgsComposerItem::mRotation, and QgsComposerItem::rotate().
Referenced by moveContent(), transformedExtent(), and transformedMapPolygon().
QPointF QgsComposerMap::mapToItemCoords | ( | const QPointF & | mapCoords | ) | const [private] |
Transforms map coordinates to item coordinates (considering rotation and move offset).
Definition at line 1370 of file qgscomposermap.cpp.
References QgsComposerItem::mRotation, QgsComposerItem::rotate(), transformedExtent(), transformedMapPolygon(), QgsPoint::x(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsPoint::y(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
Referenced by xGridLines(), and yGridLines().
QgsComposerMap::Border QgsComposerMap::borderForLineCoord | ( | const QPointF & | p | ) | const [private] |
Returns the item border of a point (in item coordinates).
Definition at line 1391 of file qgscomposermap.cpp.
References Bottom, Left, Right, and Top.
Referenced by drawCoordinateAnnotation().
void QgsComposerMap::drawCanvasItems | ( | QPainter * | painter, | |
const QStyleOptionGraphicsItem * | itemStyle | |||
) | [private] |
Definition at line 1411 of file qgscomposermap.cpp.
References drawCanvasItem(), and mMapCanvas.
Referenced by paint().
void QgsComposerMap::drawCanvasItem | ( | QGraphicsItem * | item, | |
QPainter * | painter, | |||
const QStyleOptionGraphicsItem * | itemStyle | |||
) | [private] |
Definition at line 1474 of file qgscomposermap.cpp.
References composerMapPosForItem(), QgsMapRenderer::extent(), mExtent, mMapCanvas, and mMapRenderer.
Referenced by drawCanvasItems().
QPointF QgsComposerMap::composerMapPosForItem | ( | const QGraphicsItem * | item | ) | const [private] |
Definition at line 1519 of file qgscomposermap.cpp.
References QgsMapRenderer::extent(), QgsRectangle::height(), mExtent, mMapCanvas, mMapRenderer, mXOffset, mYOffset, QgsRectangle::width(), QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
Referenced by drawCanvasItem().
QgsMapRenderer* QgsComposerMap::mMapRenderer [private] |
Definition at line 281 of file qgscomposermap.h.
Referenced by composerMapPosForItem(), containsWMSLayer(), draw(), drawCanvasItem(), QgsComposerMap(), scale(), storeCurrentLayerSet(), and syncLayerSet().
int QgsComposerMap::mId [private] |
Unique identifier.
Definition at line 284 of file qgscomposermap.h.
Referenced by QgsComposerMap(), readXML(), and writeXML().
QgsRectangle QgsComposerMap::mExtent [private] |
Definition at line 289 of file qgscomposermap.h.
Referenced by cache(), composerMapPosForItem(), drawCanvasItem(), mapPolygon(), mapUnitsToMM(), moveContent(), paint(), QgsComposerMap(), readXML(), requestedExtent(), scale(), setNewExtent(), setNewScale(), setSceneRect(), transformedExtent(), writeXML(), and zoomContent().
QImage QgsComposerMap::mCacheImage [private] |
bool QgsComposerMap::mCacheUpdated [private] |
Definition at line 295 of file qgscomposermap.h.
Referenced by cache(), QgsComposerMap(), readXML(), setCacheUpdated(), setNewScale(), setSceneRect(), and updateCachedImage().
PreviewMode QgsComposerMap::mPreviewMode [private] |
Preview style.
Definition at line 298 of file qgscomposermap.h.
Referenced by cache(), paint(), QgsComposerMap(), readXML(), renderModeUpdateCachedImage(), setSceneRect(), and writeXML().
int QgsComposerMap::mNumCachedLayers [private] |
Number of layers when cache was created.
Definition at line 301 of file qgscomposermap.h.
Referenced by readXML().
bool QgsComposerMap::mDrawing [private] |
set to true if in state of drawing.
Concurrent requests to draw method are returned if set to true
Definition at line 304 of file qgscomposermap.h.
Referenced by cache(), moveContent(), paint(), QgsComposerMap(), readXML(), and zoomContent().
double QgsComposerMap::mXOffset [private] |
Offset in x direction for showing map cache image.
Definition at line 307 of file qgscomposermap.h.
Referenced by composerMapPosForItem(), paint(), QgsComposerMap(), setOffset(), transformedExtent(), and transformedMapPolygon().
double QgsComposerMap::mYOffset [private] |
Offset in y direction for showing map cache image.
Definition at line 309 of file qgscomposermap.h.
Referenced by composerMapPosForItem(), paint(), QgsComposerMap(), setOffset(), transformedExtent(), and transformedMapPolygon().
bool QgsComposerMap::mKeepLayerSet [private] |
Flag if layers to be displayed should be read from qgis canvas (true) or from stored list in mLayerSet (false).
Definition at line 312 of file qgscomposermap.h.
Referenced by draw(), readXML(), and writeXML().
QStringList QgsComposerMap::mLayerSet [private] |
Stored layer list (used if layer live-link mKeepLayerSet is disabled).
Definition at line 315 of file qgscomposermap.h.
Referenced by draw(), readXML(), storeCurrentLayerSet(), syncLayerSet(), and writeXML().
bool QgsComposerMap::mGridEnabled [private] |
True if coordinate grid has to be displayed.
Definition at line 324 of file qgscomposermap.h.
Referenced by maxExtension(), paint(), readXML(), and writeXML().
GridStyle QgsComposerMap::mGridStyle [private] |
Solid or crosses.
Definition at line 326 of file qgscomposermap.h.
Referenced by drawGrid(), readXML(), and writeXML().
double QgsComposerMap::mGridIntervalX [private] |
Grid line interval in x-direction (map units).
Definition at line 328 of file qgscomposermap.h.
Referenced by readXML(), writeXML(), and yGridLines().
double QgsComposerMap::mGridIntervalY [private] |
Grid line interval in y-direction (map units).
Definition at line 330 of file qgscomposermap.h.
Referenced by readXML(), writeXML(), and xGridLines().
double QgsComposerMap::mGridOffsetX [private] |
Grid line offset in x-direction.
Definition at line 332 of file qgscomposermap.h.
Referenced by readXML(), writeXML(), and yGridLines().
double QgsComposerMap::mGridOffsetY [private] |
Grid line offset in y-direction.
Definition at line 334 of file qgscomposermap.h.
Referenced by readXML(), writeXML(), and xGridLines().
QPen QgsComposerMap::mGridPen [private] |
Grid line pen.
Definition at line 336 of file qgscomposermap.h.
Referenced by drawGrid(), QgsComposerMap(), readXML(), setGridPenColor(), setGridPenWidth(), and writeXML().
QFont QgsComposerMap::mGridAnnotationFont [private] |
Font for grid line annotation.
Definition at line 338 of file qgscomposermap.h.
Referenced by drawAnnotation(), drawCoordinateAnnotation(), maxExtension(), readXML(), and writeXML().
int QgsComposerMap::mGridAnnotationPrecision [private] |
Digits after the dot.
Definition at line 340 of file qgscomposermap.h.
Referenced by drawCoordinateAnnotations(), maxExtension(), readXML(), and writeXML().
bool QgsComposerMap::mShowGridAnnotation [private] |
True if coordinate values should be drawn.
Definition at line 342 of file qgscomposermap.h.
Referenced by drawGrid(), maxExtension(), readXML(), and writeXML().
Annotation position inside or outside of map frame.
Definition at line 344 of file qgscomposermap.h.
Referenced by drawCoordinateAnnotation(), maxExtension(), readXML(), and writeXML().
double QgsComposerMap::mAnnotationFrameDistance [private] |
Distance between map frame and annotation.
Definition at line 346 of file qgscomposermap.h.
Referenced by drawCoordinateAnnotation(), maxExtension(), readXML(), and writeXML().
Annotation can be horizontal / vertical or different for axes.
Definition at line 348 of file qgscomposermap.h.
Referenced by drawCoordinateAnnotation(), readXML(), and writeXML().
QRectF QgsComposerMap::mCurrentRectangle [private] |
Current bounding rectangle.
This is used to check if notification to the graphics scene is necessary
Definition at line 350 of file qgscomposermap.h.
Referenced by boundingRect(), QgsComposerMap(), and updateBoundingRect().
double QgsComposerMap::mCrossLength [private] |
The length of the cross sides for mGridStyle Cross.
Definition at line 352 of file qgscomposermap.h.
Referenced by drawGrid(), readXML(), and writeXML().
QGraphicsView* QgsComposerMap::mMapCanvas [private] |
Definition at line 353 of file qgscomposermap.h.
Referenced by composerMapPosForItem(), drawCanvasItem(), and drawCanvasItems().