QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Slots | Signals | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
QgsComposerMap Class Reference

Object representing map window. More...

#include <qgscomposermap.h>

Inheritance diagram for QgsComposerMap:
Inheritance graph
[legend]
Collaboration diagram for QgsComposerMap:
Collaboration graph
[legend]

Public Types

enum  PreviewMode { Cache = 0, Render, Rectangle }
 Preview style. More...
enum  GridStyle { Solid = 0, Cross }
enum  GridAnnotationPosition { InsideMapFrame = 0, OutsideMapFrame, Disabled }
enum  GridAnnotationDirection { Horizontal = 0, Vertical, HorizontalAndVertical, BoundaryDirection }
enum  GridAnnotationFormat { Decimal = 0, DegreeMinute, DegreeMinuteSecond }
enum  GridFrameStyle { NoGridFrame = 0, Zebra }
enum  Border { Left, Right, Bottom, Top }
 Enum for different frame borders. More...
- Public Types inherited from QgsComposerItem
enum  ItemType {
  ComposerItem = UserType + 100, ComposerArrow, ComposerItemGroup, ComposerLabel,
  ComposerLegend, ComposerMap, ComposerPaper, ComposerPicture,
  ComposerScaleBar, ComposerShape, ComposerTable, ComposerAttributeTable,
  ComposerTextTable, ComposerFrame
}
enum  MouseMoveAction {
  MoveItem, ResizeUp, ResizeDown, ResizeLeft,
  ResizeRight, ResizeLeftUp, ResizeRightUp, ResizeLeftDown,
  ResizeRightDown, NoAction
}
 Describes the action (move or resize in different directon) to be done during mouse move. More...
enum  ItemPositionMode {
  UpperLeft, UpperMiddle, UpperRight, MiddleLeft,
  Middle, MiddleRight, LowerLeft, LowerMiddle,
  LowerRight
}

Public Slots

void updateCachedImage ()
 Called if map canvas has changed.
void renderModeUpdateCachedImage ()
 Call updateCachedImage if item is in render mode.
void overviewExtentChanged ()
- Public Slots inherited from QgsComposerItem
virtual void setItemRotation (double r, bool adjustPosition=false)
 Sets the item rotation.
void repaint ()

Signals

void extentChanged ()
void mapRotationChanged (double newRotation)
 Is emitted on rotation change to notify north arrow pictures.
- Signals inherited from QgsComposerItem
void itemRotationChanged (double newRotation)
 Is emitted on item rotation change.
void itemChanged ()
 Used e.g.
void sizeChanged ()
 Emitted if the rectangle changes.
void frameChanged ()
 Emitted if the item's frame style changes.

Public Member Functions

 QgsComposerMap (QgsComposition *composition, int x, int y, int width, int height)
 Constructor.
 QgsComposerMap (QgsComposition *composition)
 Constructor.
virtual ~QgsComposerMap ()
virtual int type () const
 return correct graphics item type.
void draw (QPainter *painter, const QgsRectangle &extent, const QSizeF &size, double dpi, double *forceWidthScale=0)
 Draw to paint device.
void paint (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
 Reimplementation of QCanvasItem::paint - draw on canvas.
void cache ()
 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 () 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)
void setNewAtlasFeatureExtent (const QgsRectangle &extent)
 Sets new Extent for the current atlas preview and changes width, height (and implicitely also scale).
void toggleAtlasPreview ()
 Called when atlas preview is toggled, to force map item to update its extent and redraw.
QgsRectanglecurrentMapExtent ()
 Returns a pointer to the current map extent, which is either the original user specified extent or the temporary atlas-driven feature extent depending on the current atlas state of the composition.
const QgsRectanglecurrentMapExtent () const
PreviewMode previewMode () const
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 QgsMapRenderermapRenderer () 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 containsAdvancedEffects () const
 True if composer map contains layers with blend modes or flattened layers for vectors.
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 setAnnotationFontColor (const QColor &c)
 Sets font color for grid annotations.
QColor annotationFontColor () const
 Get font color for grid annotations.
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, QgsComposerMap::Border border)
GridAnnotationPosition gridAnnotationPosition (QgsComposerMap::Border border) const
void setAnnotationFrameDistance (double d)
 Sets distance between map frame and annotations.
double annotationFrameDistance () const
void setGridAnnotationDirection (GridAnnotationDirection d, QgsComposerMap::Border border)
GridAnnotationDirection gridAnnotationDirection (QgsComposerMap::Border border) const
void setGridAnnotationFormat (GridAnnotationFormat f)
GridAnnotationFormat gridAnnotationFormat () const
void setGridFrameStyle (GridFrameStyle style)
 Set grid frame style (NoGridFrame or Zebra)
GridFrameStyle gridFrameStyle () const
void setGridFrameWidth (double w)
 Set grid frame width.
double gridFrameWidth () const
void setGridFramePenSize (double w)
 Set grid frame pen thickness.
double gridFramePenSize () const
void setGridFramePenColor (const QColor &c)
 Sets pen color for grid frame.
QColor gridFramePenColor () const
 Get pen color for grid frame.
void setGridFrameFillColor1 (const QColor &c)
 Sets first fill color for grid zebra frame.
QColor gridFrameFillColor1 () const
 Get first fill color for grid zebra frame.
void setGridFrameFillColor2 (const QColor &c)
 Sets second fill color for grid zebra frame.
QColor gridFrameFillColor2 () const
 Get second fill color for grid zebra frame.
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.
virtual void setFrameOutlineWidth (double outlineWidth)
 Sets frame outline width.
void setCrossLength (double l)
 Sets length of the cros segments (if grid style is cross)
double crossLength ()
void setRotation (double r)
 Sets rotation for the map - this does not affect the composer item shape, only the way the map is drawn within the item.
double rotation () const
 Returns the rotation used for drawing the map within the composer item.
void setMapRotation (double r)
 Sets rotation for the map - this does not affect the composer item shape, only the way the map is drawn within the item.
double mapRotation () const
 Returns the rotation used for drawing the map within the composer item.
void updateItem ()
 Updates item, with the possibility to do custom update for subclasses.
void setMapCanvas (QGraphicsView *canvas)
 Sets canvas pointer (necessary to query and draw map canvas items)
void setDrawCanvasItems (bool b)
bool drawCanvasItems () const
double mapUnitsToMM () const
 Returns the conversion factor map units -> mm.
void setOverviewFrameMap (int mapId)
 Sets overview frame map.
int overviewFrameMapId () const
 Returns id of overview frame (or -1 if no overfiew frame)
void setOverviewFrameMapSymbol (QgsFillSymbolV2 *symbol)
QgsFillSymbolV2overviewFrameMapSymbol ()
QPainter::CompositionMode overviewBlendMode () const
 Returns the overview's blending mode.
void setOverviewBlendMode (QPainter::CompositionMode blendMode)
 Sets the overview's blending mode.
bool overviewInverted () const
 Returns true if the overview frame is inverted.
void setOverviewInverted (bool inverted)
 Sets the overview's inversion mode.
bool overviewCentered () const
 Returns true if the extent is forced to center on the overview.
void setOverviewCentered (bool centered)
 Set the overview's centering mode.
void setGridLineSymbol (QgsLineSymbolV2 *symbol)
QgsLineSymbolV2gridLineSymbol ()
QPainter::CompositionMode gridBlendMode () const
 Returns the grid's blending mode.
void setGridBlendMode (QPainter::CompositionMode blendMode)
 Sets the grid's blending mode.
void assignFreeId ()
 Sets mId to a number not yet used in the composition.
bool imageSizeConsideringRotation (double &width, double &height) const
 Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation.
bool cornerPointOnRotatedAndScaledRect (double &x, double &y, double width, double height) const
 Calculates corner point after rotation and scaling.
void sizeChangedByRotation (double &width, double &height)
 Calculates width / height of the bounding box of a rotated rectangle.
bool atlasDriven () const
 Returns true if the map extent is set to follow the current atlas feature.
void setAtlasDriven (bool enabled)
 Set to true if the map extents should be set by the current atlas feature.
bool atlasFixedScale () const
 Returns true if the map uses a fixed scale when in atlas mode.
void setAtlasFixedScale (bool fixed)
 Set to true if the map should use a fixed scale when in atlas mode.
double atlasMargin () const
 Returns the margin size (percentage) used when the map is in atlas mode.
void setAtlasMargin (double margin)
 Sets the margin size (percentage) used when the map is in atlas mode.
- Public Member Functions inherited from QgsComposerItem
 QgsComposerItem (QgsComposition *composition, bool manageZValue=true)
 Constructor.
 QgsComposerItem (qreal x, qreal y, qreal width, qreal height, QgsComposition *composition, bool manageZValue=true)
 Constructor with box position and composer object.
virtual ~QgsComposerItem ()
virtual void setSelected (bool s)
 Set selected, selected item should be highlighted.
virtual bool selected () const
 Is selected.
virtual bool writeSettings ()
 stores state in project
virtual bool readSettings ()
 read state from project
virtual bool removeSettings ()
 delete settings from project file
void move (double dx, double dy)
 Moves item in canvas coordinates.
void setItemPosition (double x, double y, ItemPositionMode itemPoint=UpperLeft)
 Moves the item to a new position (in canvas coordinates)
void setItemPosition (double x, double y, double width, double height, ItemPositionMode itemPoint=UpperLeft, bool posIncludesFrame=false)
 Sets item position and width / height in one go.
ItemPositionMode lastUsedPositionMode ()
 Returns item's last used position mode.
bool _writeXML (QDomElement &itemElem, QDomDocument &doc) const
 Writes parameter that are not subclass specific in document.
bool _readXML (const QDomElement &itemElem, const QDomDocument &doc)
 Reads parameter that are not subclass specific in document.
bool hasFrame () const
 Whether this item has a frame or not.
void setFrameEnabled (bool drawFrame)
 Set whether this item has a frame drawn around it or not.
virtual double estimatedFrameBleed () const
 Returns the estimated amount the item's frame bleeds outside the item's actual rectangle.
virtual QRectF rectWithFrame () const
 Returns the item's rectangular bounds, including any bleed caused by the item's frame.
bool hasBackground () const
 Whether this item has a Background or not.
void setBackgroundEnabled (bool drawBackground)
 Set whether this item has a Background drawn around it or not.
QColor backgroundColor () const
 Gets the background color for this item.
void setBackgroundColor (const QColor &backgroundColor)
 Sets the background color for this item.
QPainter::CompositionMode blendMode () const
 Returns the item's composition blending mode.
void setBlendMode (QPainter::CompositionMode blendMode)
 Sets the item's composition blending mode.
int transparency () const
 Returns the item's transparency.
void setTransparency (int transparency)
 Sets the item's transparency.
bool effectsEnabled () const
 Returns true if effects (eg blend modes) are enabled for the item.
void setEffectsEnabled (bool effectsEnabled)
 Sets whether effects (eg blend modes) are enabled for the item.
virtual void addItem (QgsComposerItem *item)
 Composite operations for item groups do nothing per default.
virtual void removeItems ()
const QgsCompositioncomposition () const
QgsCompositioncomposition ()
virtual void beginItemCommand (const QString &text)
void beginCommand (const QString &commandText, QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown)
 Starts new composer undo command.
virtual void endItemCommand ()
void endCommand ()
 Finish current command and push it onto the undo stack.
void cancelCommand ()
void drawText (QPainter *p, double x, double y, const QString &text, const QFont &font) const
 Draws Text.
void drawText (QPainter *p, const QRectF &rect, const QString &text, const QFont &font, Qt::AlignmentFlag halignment=Qt::AlignLeft, Qt::AlignmentFlag valignment=Qt::AlignTop) const
 Like the above, but with a rectangle for multiline text.
double textWidthMillimeters (const QFont &font, const QString &text) const
 Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE.
double fontHeightCharacterMM (const QFont &font, const QChar &c) const
 Returns the font height of a character in millimeters.
double fontAscentMillimeters (const QFont &font) const
 Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE.
double fontDescentMillimeters (const QFont &font) const
 Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE.
double pixelFontSize (double pointSize) const
 Calculates font to from point size to pixel size.
QFont scaledFontPixelSize (const QFont &font) const
 Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE.
void setPositionLock (bool lock)
 Locks / unlocks the item position for mouse drags.
bool positionLock () const
 Returns position lock for mouse drags (true means locked)
double itemRotation () const
 Returns the rotation for the composer item.
virtual void setId (const QString &id)
 Set item's id (which is not necessarly unique)
QString uuid () const
 Get item identification name.

Private Types

enum  AnnotationCoordinate { Longitude = 0, Latitude }

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 adjustExtentToItemShape (double itemWidth, double itemHeight, QgsRectangle &extent) const
 Adjusts an extent rectangle to match the provided item width and height, so that extent center of extent remains the same.
QStringList layersToRender ()
 Returns a list of the layers to render for this map item.
void drawGrid (QPainter *p)
 Draws the map grid.
void drawGridFrame (QPainter *p, const QList< QPair< double, QLineF > > &hLines, const QList< QPair< double, QLineF > > &vLines)
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.
QString gridAnnotationString (double value, AnnotationCoordinate coord) const
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 mapPolygon (const QgsRectangle &extent, QPolygonF &poly) const
 mapPolygon variant using a given extent
void requestedExtent (QgsRectangle &extent) const
 Calculates the extent to request and the yShift of the top-left point in case of rotation.
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
void sortGridLinesOnBorders (const QList< QPair< double, QLineF > > &hLines, const QList< QPair< double, QLineF > > &vLines, QMap< double, double > &leftFrameEntries, QMap< double, double > &rightFrameEntries, QMap< double, double > &topFrameEntries, QMap< double, double > &bottomFrameEntries) const
void drawGridFrameBorder (QPainter *p, const QMap< double, double > &borderPos, Border border)
void drawGridLine (const QLineF &line, QPainter *p)
void drawOverviewMapExtent (QPainter *p)
void createDefaultOverviewFrameSymbol ()
void createDefaultGridLineSymbol ()
void initGridAnnotationFormatFromProject ()

Private Attributes

QgsMapRenderermMapRenderer
int mId
 Unique identifier.
QgsRectangle mExtent
QgsRectangle mAtlasFeatureExtent
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.
double mMapRotation
 Map rotation.
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)
int mOverviewFrameMapId
 Id of map which displays its extent rectangle into this composer map (overview map functionality).
QgsFillSymbolV2mOverviewFrameMapSymbol
 Drawing style for overview farme.
QgsLineSymbolV2mGridLineSymbol
QPainter::CompositionMode mOverviewBlendMode
 Blend mode for overview.
bool mOverviewInverted
bool mOverviewCentered
 Centering mode for overview.
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.
QFont mGridAnnotationFont
 Font for grid line annotation.
QColor mGridAnnotationFontColor
 Font color for grid line annotation.
int mGridAnnotationPrecision
 Digits after the dot.
bool mShowGridAnnotation
 True if coordinate values should be drawn.
QPainter::CompositionMode mGridBlendMode
 Blend mode for grid.
GridAnnotationPosition mLeftGridAnnotationPosition
 Annotation position for left map side (inside / outside / not shown)
GridAnnotationPosition mRightGridAnnotationPosition
 Annotation position for right map side (inside / outside / not shown)
GridAnnotationPosition mTopGridAnnotationPosition
 Annotation position for top map side (inside / outside / not shown)
GridAnnotationPosition mBottomGridAnnotationPosition
 Annotation position for bottom map side (inside / outside / not shown)
double mAnnotationFrameDistance
 Distance between map frame and annotation.
GridAnnotationDirection mLeftGridAnnotationDirection
 Annotation direction on left side ( horizontal or vertical )
GridAnnotationDirection mRightGridAnnotationDirection
 Annotation direction on right side ( horizontal or vertical )
GridAnnotationDirection mTopGridAnnotationDirection
 Annotation direction on top side ( horizontal or vertical )
GridAnnotationDirection mBottomGridAnnotationDirection
 Annotation direction on bottom side ( horizontal or vertical )
GridAnnotationFormat mGridAnnotationFormat
GridFrameStyle mGridFrameStyle
double mGridFrameWidth
double mGridFramePenThickness
QColor mGridFramePenColor
QColor mGridFrameFillColor1
QColor mGridFrameFillColor2
QRectF mCurrentRectangle
 Current bounding rectangle.
double mCrossLength
 The length of the cross sides for mGridStyle Cross.
QGraphicsView * mMapCanvas
bool mDrawCanvasItems
 True if annotation items, rubber band, etc.
bool mAtlasDriven
 True if map is being controlled by an atlas.
bool mAtlasFixedScale
 True if map uses a fixed scale when controlled by an atlas.
double mAtlasMargin
 Margin size for atlas driven extents (percentage of feature size)

Additional Inherited Members

- Protected Member Functions inherited from QgsComposerItem
virtual void drawSelectionBoxes (QPainter *p)
 Draw selection boxes around item.
virtual void drawFrame (QPainter *p)
 Draw black frame around item.
virtual void drawBackground (QPainter *p)
 Draw background.
void drawArrowHead (QPainter *p, double x, double y, double angle, double arrowHeadWidth) const
 Draws arrowhead.
double angle (const QPointF &p1, const QPointF &p2) const
 Returns angle of the line from p1 to p2 (clockwise, starting at N)
double rectHandlerBorderTolerance () const
 Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the item border for resizing.
double lockSymbolSize () const
 Returns the size of the lock symbol depending on the composer zoom level and the item size.
double horizontalViewScaleFactor () const
 Returns the zoom factor of the graphics view.
bool imageSizeConsideringRotation (double &width, double &height, double rotation) const
 Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation.
QRectF largestRotatedRectWithinBounds (QRectF originalRect, QRectF boundsRect, double rotation) const
 Calculates the largest scaled version of originalRect which fits within boundsRect, when it is rotated by a specified amount.
bool cornerPointOnRotatedAndScaledRect (double &x, double &y, double width, double height, double rotation) const
 Calculates corner point after rotation and scaling.
void sizeChangedByRotation (double &width, double &height, double rotation)
 Calculates width / height of the bounding box of a rotated rectangle.
void rotate (double angle, double &x, double &y) const
 Rotates a point / vector.
QGraphicsLineItem * hAlignSnapItem ()
 Return horizontal align snap item.
void deleteHAlignSnapItem ()
QGraphicsLineItem * vAlignSnapItem ()
 Return vertical align snap item.
void deleteVAlignSnapItem ()
void deleteAlignItems ()
- Protected Attributes inherited from QgsComposerItem
QgsCompositionmComposition
QgsComposerItem::MouseMoveAction mCurrentMouseMoveAction
QPointF mMouseMoveStartPos
 Start point of the last mouse move action (in scene coordinates)
QPointF mLastMouseEventPos
 Position of the last mouse move event (in scene coordinates)
QGraphicsRectItem * mBoundingResizeRectangle
 Rectangle used during move and resize actions.
QGraphicsLineItem * mHAlignSnapItem
QGraphicsLineItem * mVAlignSnapItem
bool mFrame
 True if item fram needs to be painted.
bool mBackground
 True if item background needs to be painted.
QColor mBackgroundColor
 Background color.
bool mItemPositionLocked
 True if item position and size cannot be changed with mouse move.
double mLastValidViewScaleFactor
 Backup to restore item appearance if no view scale factor is available.
double mItemRotation
 Item rotation in degrees, clockwise.
QPainter::CompositionMode mBlendMode
 Composition blend mode for item.
bool mEffectsEnabled
QgsComposerEffectmEffect
int mTransparency
 Item transparency.
ItemPositionMode mLastUsedPositionMode
 The item's position mode.

Detailed Description

Object representing map window.

Definition at line 42 of file qgscomposermap.h.

Member Enumeration Documentation

Enumerator:
Longitude 
Latitude 

Definition at line 458 of file qgscomposermap.h.

Enum for different frame borders.

Enumerator:
Left 
Right 
Bottom 
Top 

Definition at line 99 of file qgscomposermap.h.

Enumerator:
Horizontal 
Vertical 
HorizontalAndVertical 
BoundaryDirection 

Definition at line 77 of file qgscomposermap.h.

Enumerator:
Decimal 
DegreeMinute 
DegreeMinuteSecond 

Definition at line 85 of file qgscomposermap.h.

Enumerator:
InsideMapFrame 
OutsideMapFrame 
Disabled 

Definition at line 70 of file qgscomposermap.h.

Enumerator:
NoGridFrame 
Zebra 

Definition at line 92 of file qgscomposermap.h.

Enumerator:
Solid 
Cross 

Definition at line 64 of file qgscomposermap.h.

Preview style.

Enumerator:
Cache 
Render 
Rectangle 

Definition at line 57 of file qgscomposermap.h.

Constructor & Destructor Documentation

QgsComposerMap::QgsComposerMap ( QgsComposition composition,
int  x,
int  y,
int  width,
int  height 
)
QgsComposerMap::QgsComposerMap ( QgsComposition composition)
QgsComposerMap::~QgsComposerMap ( )
virtual

Definition at line 161 of file qgscomposermap.cpp.

References mGridLineSymbol, and mOverviewFrameMapSymbol.

Member Function Documentation

void QgsComposerMap::adjustExtentToItemShape ( double  itemWidth,
double  itemHeight,
QgsRectangle extent 
) const
private

Adjusts an extent rectangle to match the provided item width and height, so that extent center of extent remains the same.

Definition at line 138 of file qgscomposermap.cpp.

References QgsRectangle::height(), QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), QgsRectangle::setYMinimum(), QgsRectangle::width(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().

QColor QgsComposerMap::annotationFontColor ( ) const
inline

Get font color for grid annotations.

Note
: this function was added in version 2.0

Definition at line 268 of file qgscomposermap.h.

double QgsComposerMap::annotationFrameDistance ( ) const
inline

Definition at line 286 of file qgscomposermap.h.

void QgsComposerMap::assignFreeId ( )

Sets mId to a number not yet used in the composition.

mId is kept if it is not in use. Usually, this function is called before adding the composer map to the composition

Definition at line 2558 of file qgscomposermap.cpp.

References QgsComposition::composerMapItems(), QgsComposition::getComposerMapById(), QgsComposerItem::mComposition, and mId.

Referenced by QgsComposition::addItemsFromXML(), and QgsComposerMap().

bool QgsComposerMap::atlasDriven ( ) const
inline

Returns true if the map extent is set to follow the current atlas feature.

Definition at line 427 of file qgscomposermap.h.

Referenced by QgsAtlasComposition::composerMap(), QgsAtlasComposition::prepareForFeature(), QgsAtlasComposition::prepareMap(), QgsComposition::setAtlasMode(), and QgsAtlasComposition::updateAtlasMaps().

bool QgsComposerMap::atlasFixedScale ( ) const
inline

Returns true if the map uses a fixed scale when in atlas mode.

Definition at line 432 of file qgscomposermap.h.

Referenced by QgsAtlasComposition::fixedScale(), and QgsAtlasComposition::prepareMap().

double QgsComposerMap::atlasMargin ( ) const
inline

Returns the margin size (percentage) used when the map is in atlas mode.

Definition at line 437 of file qgscomposermap.h.

Referenced by QgsAtlasComposition::margin(), and QgsAtlasComposition::prepareMap().

QgsComposerMap::Border QgsComposerMap::borderForLineCoord ( const QPointF &  p) const
private

Returns the item border of a point (in item coordinates)

Definition at line 2210 of file qgscomposermap.cpp.

References Bottom, Left, Right, and Top.

Referenced by drawCoordinateAnnotation(), and sortGridLinesOnBorders().

QRectF QgsComposerMap::boundingRect ( ) const

In case of annotations, the bounding rectangle can be larger than the map item rectangle.

Note
this function was added in version 1.4

Definition at line 1927 of file qgscomposermap.cpp.

References mCurrentRectangle.

void QgsComposerMap::cache ( void  )
QPointF QgsComposerMap::composerMapPosForItem ( const QGraphicsItem *  item) const
private
void QgsComposerMap::connectUpdateSlot ( )
private

Establishes signal/slot connection for update in case of layer change.

Definition at line 858 of file qgscomposermap.cpp.

References QgsMapLayerRegistry::instance(), and updateCachedImage().

Referenced by QgsComposerMap().

bool QgsComposerMap::containsAdvancedEffects ( ) const
bool QgsComposerMap::containsWMSLayer ( ) const
bool QgsComposerMap::cornerPointOnRotatedAndScaledRect ( double &  x,
double &  y,
double  width,
double  height 
) const

Calculates corner point after rotation and scaling.

Deprecated:
Use QgsComposerItem::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height, double rotation ) instead

Reimplemented from QgsComposerItem.

Definition at line 2590 of file qgscomposermap.cpp.

References mMapRotation.

void QgsComposerMap::createDefaultGridLineSymbol ( )
private

Definition at line 2524 of file qgscomposermap.cpp.

References QgsLineSymbolV2::createSimple(), and mGridLineSymbol.

Referenced by QgsComposerMap().

void QgsComposerMap::createDefaultOverviewFrameSymbol ( )
private
double QgsComposerMap::crossLength ( )
inline

Definition at line 343 of file qgscomposermap.h.

QgsRectangle * QgsComposerMap::currentMapExtent ( )

Returns a pointer to the current map extent, which is either the original user specified extent or the temporary atlas-driven feature extent depending on the current atlas state of the composition.

Both a const and non-const version are included.

Definition at line 682 of file qgscomposermap.cpp.

References QgsComposition::atlasMode(), QgsComposition::AtlasOff, mAtlasDriven, mAtlasFeatureExtent, QgsComposerItem::mComposition, and mExtent.

Referenced by cache(), composerMapPosForItem(), QgsComposition::computeWorldFileParameters(), drawCanvasItem(), drawOverviewMapExtent(), QgsComposerAttributeTable::getFeatureAttributes(), mapPolygon(), mapUnitsToMM(), QgsComposerScaleBar::mapWidth(), moveContent(), overviewExtentChanged(), paint(), QgsComposerScaleBar::refreshSegmentMillimeters(), requestedExtent(), scale(), setNewScale(), transformedExtent(), and zoomContent().

const QgsRectangle * QgsComposerMap::currentMapExtent ( ) const
void QgsComposerMap::draw ( QPainter *  painter,
const QgsRectangle extent,
const QSizeF &  size,
double  dpi,
double *  forceWidthScale = 0 
)
void QgsComposerMap::drawAnnotation ( QPainter *  p,
const QPointF &  pos,
int  rotation,
const QString &  annotationText 
)
private

Draws a single annotation.

Parameters
pdrawing painter
positem coordinates where to draw
rotationtext rotation
annotationTextthe text to draw

Definition at line 1706 of file qgscomposermap.cpp.

References QgsComposerItem::drawText(), mGridAnnotationFont, and mGridAnnotationFontColor.

Referenced by drawCoordinateAnnotation().

void QgsComposerMap::drawCanvasItem ( QGraphicsItem *  item,
QPainter *  painter,
const QStyleOptionGraphicsItem *  itemStyle 
)
private
bool QgsComposerMap::drawCanvasItems ( ) const
inline

Definition at line 368 of file qgscomposermap.h.

Referenced by paint().

void QgsComposerMap::drawCanvasItems ( QPainter *  painter,
const QStyleOptionGraphicsItem *  itemStyle 
)
private

Definition at line 2230 of file qgscomposermap.cpp.

References drawCanvasItem(), mDrawCanvasItems, and mMapCanvas.

void QgsComposerMap::drawCoordinateAnnotation ( QPainter *  p,
const QPointF &  pos,
QString  annotationString 
)
private
void QgsComposerMap::drawCoordinateAnnotations ( QPainter *  p,
const QList< QPair< double, QLineF > > &  hLines,
const QList< QPair< double, QLineF > > &  vLines 
)
private

Draw coordinates for mGridAnnotationType Coordinate.

Parameters
pdrawing painter
hLineshorizontal coordinate lines in item coordinates
vLinesvertical coordinate lines in item coordinates

Definition at line 1522 of file qgscomposermap.cpp.

References drawCoordinateAnnotation(), gridAnnotationString(), Latitude, and Longitude.

Referenced by drawGrid().

void QgsComposerMap::drawGrid ( QPainter *  p)
private
void QgsComposerMap::drawGridFrame ( QPainter *  p,
const QList< QPair< double, QLineF > > &  hLines,
const QList< QPair< double, QLineF > > &  vLines 
)
private

Definition at line 1427 of file qgscomposermap.cpp.

References Bottom, drawGridFrameBorder(), Left, Right, sortGridLinesOnBorders(), and Top.

Referenced by drawGrid().

void QgsComposerMap::drawGridFrameBorder ( QPainter *  p,
const QMap< double, double > &  borderPos,
Border  border 
)
private
void QgsComposerMap::drawGridLine ( const QLineF &  line,
QPainter *  p 
)
private
void QgsComposerMap::drawOverviewMapExtent ( QPainter *  p)
private
QgsRectangle QgsComposerMap::extent ( ) const
inline
void QgsComposerMap::extentChanged ( )
signal
QgsComposerMap::GridAnnotationDirection QgsComposerMap::gridAnnotationDirection ( QgsComposerMap::Border  border) const
QFont QgsComposerMap::gridAnnotationFont ( ) const
inline

Definition at line 261 of file qgscomposermap.h.

GridAnnotationFormat QgsComposerMap::gridAnnotationFormat ( ) const
inline

Definition at line 292 of file qgscomposermap.h.

QgsComposerMap::GridAnnotationPosition QgsComposerMap::gridAnnotationPosition ( QgsComposerMap::Border  border) const
int QgsComposerMap::gridAnnotationPrecision ( ) const
inline

Definition at line 273 of file qgscomposermap.h.

QString QgsComposerMap::gridAnnotationString ( double  value,
AnnotationCoordinate  coord 
) const
private
QPainter::CompositionMode QgsComposerMap::gridBlendMode ( ) const
inline

Returns the grid's blending mode.

Definition at line 402 of file qgscomposermap.h.

bool QgsComposerMap::gridEnabled ( ) const
inline

Definition at line 218 of file qgscomposermap.h.

QColor QgsComposerMap::gridFrameFillColor1 ( ) const
inline

Get first fill color for grid zebra frame.

Note
: this function was added in version 2.1

Definition at line 321 of file qgscomposermap.h.

QColor QgsComposerMap::gridFrameFillColor2 ( ) const
inline

Get second fill color for grid zebra frame.

Note
: this function was added in version 2.1

Definition at line 328 of file qgscomposermap.h.

QColor QgsComposerMap::gridFramePenColor ( ) const
inline

Get pen color for grid frame.

Note
: this function was added in version 2.1

Definition at line 314 of file qgscomposermap.h.

double QgsComposerMap::gridFramePenSize ( ) const
inline

Definition at line 307 of file qgscomposermap.h.

GridFrameStyle QgsComposerMap::gridFrameStyle ( ) const
inline

Definition at line 297 of file qgscomposermap.h.

double QgsComposerMap::gridFrameWidth ( ) const
inline

Definition at line 302 of file qgscomposermap.h.

double QgsComposerMap::gridIntervalX ( ) const
inline

Definition at line 228 of file qgscomposermap.h.

double QgsComposerMap::gridIntervalY ( ) const
inline

Definition at line 233 of file qgscomposermap.h.

QgsLineSymbolV2* QgsComposerMap::gridLineSymbol ( )
inline

Definition at line 399 of file qgscomposermap.h.

double QgsComposerMap::gridOffsetX ( ) const
inline

Definition at line 238 of file qgscomposermap.h.

double QgsComposerMap::gridOffsetY ( ) const
inline

Definition at line 243 of file qgscomposermap.h.

QPen QgsComposerMap::gridPen ( ) const
GridStyle QgsComposerMap::gridStyle ( ) const
inline

Definition at line 223 of file qgscomposermap.h.

int QgsComposerMap::id ( ) const
inline
bool QgsComposerMap::imageSizeConsideringRotation ( double &  width,
double &  height 
) const

Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation.

Deprecated:
Use bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& height, double rotation ) instead

Reimplemented from QgsComposerItem.

Definition at line 2584 of file qgscomposermap.cpp.

References mMapRotation.

void QgsComposerMap::initGridAnnotationFormatFromProject ( )
private
bool QgsComposerMap::isDrawing ( ) const
inline

True if a draw is already in progress.

Definition at line 126 of file qgscomposermap.h.

Referenced by QgsComposerAttributeTable::paint(), and QgsComposition::removeComposerItem().

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.

Note
this function was added in version 1.2

Definition at line 173 of file qgscomposermap.h.

QStringList QgsComposerMap::layerSet ( ) const
inline

Getter for stored layer set that is used if mKeepLayerSet is true.

Note
this function was added in version 1.2

Definition at line 180 of file qgscomposermap.h.

Referenced by readXML().

QStringList QgsComposerMap::layersToRender ( )
private
void QgsComposerMap::mapPolygon ( QPolygonF &  poly) const
private

Returns the polygon of the map extent.

If rotation == 0, the result is the same as mExtent

Parameters
polyout: the result polygon with the four corner points. The points are clockwise, starting at the top-left point
Returns
true in case of success

Definition at line 2064 of file qgscomposermap.cpp.

References currentMapExtent().

Referenced by requestedExtent(), transformedMapPolygon(), xGridLines(), and yGridLines().

void QgsComposerMap::mapPolygon ( const QgsRectangle extent,
QPolygonF &  poly 
) const
private
const QgsMapRenderer* QgsComposerMap::mapRenderer ( ) const
inline
double QgsComposerMap::mapRotation ( ) const
inline

Returns the rotation used for drawing the map within the composer item.

Definition at line 360 of file qgscomposermap.h.

Referenced by QgsComposition::computeWorldFileParameters(), and QgsComposerPicture::setRotationMap().

void QgsComposerMap::mapRotationChanged ( double  newRotation)
signal

Is emitted on rotation change to notify north arrow pictures.

Referenced by setMapRotation().

QPointF QgsComposerMap::mapToItemCoords ( const QPointF &  mapCoords) const
private
double QgsComposerMap::mapUnitsToMM ( ) const

Returns the conversion factor map units -> mm.

Definition at line 2088 of file qgscomposermap.cpp.

References currentMapExtent(), and QgsRectangle::width().

Referenced by cache(), QgsComposerLegend::drawSymbolV2(), paint(), and transformShift().

double QgsComposerMap::maxExtension ( ) const
private
void QgsComposerMap::moveContent ( double  dx,
double  dy 
)
virtual

Move content of map.

Parameters
dxmove in x-direction (item and canvas coordinates)
dymove in y-direction (item and canvas coordinates)

Reimplemented from QgsComposerItem.

Definition at line 515 of file qgscomposermap.cpp.

References cache(), currentMapExtent(), extentChanged(), QgsComposerItem::itemChanged(), mDrawing, QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), QgsRectangle::setYMinimum(), and transformShift().

QPainter::CompositionMode QgsComposerMap::overviewBlendMode ( ) const
inline

Returns the overview's blending mode.

Definition at line 384 of file qgscomposermap.h.

bool QgsComposerMap::overviewCentered ( ) const
inline

Returns true if the extent is forced to center on the overview.

Definition at line 394 of file qgscomposermap.h.

void QgsComposerMap::overviewExtentChanged ( )
slot
int QgsComposerMap::overviewFrameMapId ( ) const
inline

Returns id of overview frame (or -1 if no overfiew frame)

Note
: this function was added in version 1.9

Definition at line 378 of file qgscomposermap.h.

QgsFillSymbolV2* QgsComposerMap::overviewFrameMapSymbol ( )
inline

Definition at line 381 of file qgscomposermap.h.

bool QgsComposerMap::overviewInverted ( ) const
inline

Returns true if the overview frame is inverted.

Definition at line 389 of file qgscomposermap.h.

void QgsComposerMap::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  itemStyle,
QWidget *  pWidget 
)
PreviewMode QgsComposerMap::previewMode ( ) const
inline
bool QgsComposerMap::readXML ( const QDomElement &  itemElem,
const QDomDocument &  doc 
)
virtual
void QgsComposerMap::renderModeUpdateCachedImage ( )
slot

Call updateCachedImage if item is in render mode.

Definition at line 454 of file qgscomposermap.cpp.

References mPreviewMode, Render, and updateCachedImage().

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 2069 of file qgscomposermap.cpp.

References currentMapExtent(), mapPolygon(), mMapRotation, QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), and QgsRectangle::setYMinimum().

Referenced by cache(), and paint().

void QgsComposerMap::resize ( double  dx,
double  dy 
)

resizes an item in x- and y direction (canvas coordinates)

Definition at line 506 of file qgscomposermap.cpp.

References setSceneRect(), and updateItem().

double QgsComposerMap::rotation ( ) const
inline

Returns the rotation used for drawing the map within the composer item.

Deprecated:
Use mapRotation() instead

Reimplemented from QgsComposerItem.

Definition at line 353 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation().

double QgsComposerMap::scale ( ) const
void QgsComposerMap::setAnnotationFontColor ( const QColor &  c)
inline

Sets font color for grid annotations.

Note
this function was added in version 2.0

Definition at line 265 of file qgscomposermap.h.

void QgsComposerMap::setAnnotationFrameDistance ( double  d)
inline

Sets distance between map frame and annotations.

Note
this function was added in version 1.4

Definition at line 285 of file qgscomposermap.h.

void QgsComposerMap::setAtlasDriven ( bool  enabled)
inline

Set to true if the map extents should be set by the current atlas feature.

Definition at line 429 of file qgscomposermap.h.

Referenced by QgsAtlasComposition::readXML(), and QgsAtlasComposition::setComposerMap().

void QgsComposerMap::setAtlasFixedScale ( bool  fixed)
inline

Set to true if the map should use a fixed scale when in atlas mode.

Definition at line 434 of file qgscomposermap.h.

Referenced by QgsAtlasComposition::readXML(), and QgsAtlasComposition::setFixedScale().

void QgsComposerMap::setAtlasMargin ( double  margin)
inline

Sets the margin size (percentage) used when the map is in atlas mode.

Definition at line 439 of file qgscomposermap.h.

Referenced by QgsAtlasComposition::readXML(), and QgsAtlasComposition::setMargin().

void QgsComposerMap::setCacheUpdated ( bool  u = false)

Definition at line 462 of file qgscomposermap.cpp.

References mCacheUpdated.

void QgsComposerMap::setCrossLength ( double  l)
inline

Sets length of the cros segments (if grid style is cross)

Note
this function was added in version 1.4

Definition at line 342 of file qgscomposermap.h.

void QgsComposerMap::setDrawCanvasItems ( bool  b)
inline

Definition at line 367 of file qgscomposermap.h.

void QgsComposerMap::setFrameOutlineWidth ( double  outlineWidth)
virtual

Sets frame outline width.

Parameters
outlineWidthnew width for outline frame
Returns
nothing
Note
introduced in 2.2
See Also
setFrameEnabled

Reimplemented from QgsComposerItem.

Definition at line 1947 of file qgscomposermap.cpp.

References updateBoundingRect().

void QgsComposerMap::setGridAnnotationDirection ( GridAnnotationDirection  d,
QgsComposerMap::Border  border 
)
void QgsComposerMap::setGridAnnotationFont ( const QFont &  f)
inline

Sets font for grid annotations.

Note
this function was added in version 1.4

Definition at line 260 of file qgscomposermap.h.

void QgsComposerMap::setGridAnnotationFormat ( GridAnnotationFormat  f)
inline

Definition at line 291 of file qgscomposermap.h.

void QgsComposerMap::setGridAnnotationPosition ( GridAnnotationPosition  p,
QgsComposerMap::Border  border 
)
void QgsComposerMap::setGridAnnotationPrecision ( int  p)
inline

Sets coordinate precision for grid annotations.

Note
this function was added in version 1.4

Definition at line 272 of file qgscomposermap.h.

void QgsComposerMap::setGridBlendMode ( QPainter::CompositionMode  blendMode)

Sets the grid's blending mode.

Definition at line 1921 of file qgscomposermap.cpp.

References QgsComposerItem::blendMode(), and mGridBlendMode.

Referenced by readXML().

void QgsComposerMap::setGridEnabled ( bool  enabled)
inline

Enables a coordinate grid that is shown on top of this composermap.

Note
this function was added in version 1.4

Definition at line 217 of file qgscomposermap.h.

void QgsComposerMap::setGridFrameFillColor1 ( const QColor &  c)
inline

Sets first fill color for grid zebra frame.

Note
: this function was added in version 2.1

Definition at line 318 of file qgscomposermap.h.

void QgsComposerMap::setGridFrameFillColor2 ( const QColor &  c)
inline

Sets second fill color for grid zebra frame.

Note
: this function was added in version 2.1

Definition at line 325 of file qgscomposermap.h.

void QgsComposerMap::setGridFramePenColor ( const QColor &  c)
inline

Sets pen color for grid frame.

Note
: this function was added in version 2.1

Definition at line 311 of file qgscomposermap.h.

void QgsComposerMap::setGridFramePenSize ( double  w)
inline

Set grid frame pen thickness.

Note
: this function was added in version 2.1

Definition at line 306 of file qgscomposermap.h.

void QgsComposerMap::setGridFrameStyle ( GridFrameStyle  style)
inline

Set grid frame style (NoGridFrame or Zebra)

Note
: this function was added in version 1.9

Definition at line 296 of file qgscomposermap.h.

void QgsComposerMap::setGridFrameWidth ( double  w)
inline

Set grid frame width.

Note
: this function was added in version 1.9

Definition at line 301 of file qgscomposermap.h.

void QgsComposerMap::setGridIntervalX ( double  interval)
inline

Sets coordinate interval in x-direction for composergrid.

Note
this function was added in version 1.4

Definition at line 227 of file qgscomposermap.h.

void QgsComposerMap::setGridIntervalY ( double  interval)
inline

Sets coordinate interval in y-direction for composergrid.

Note
this function was added in version 1.4

Definition at line 232 of file qgscomposermap.h.

void QgsComposerMap::setGridLineSymbol ( QgsLineSymbolV2 symbol)

Definition at line 2171 of file qgscomposermap.cpp.

References mGridLineSymbol.

void QgsComposerMap::setGridOffsetX ( double  offset)
inline

Sets x-coordinate offset for composer grid.

Note
this function was added in version 1.4

Definition at line 237 of file qgscomposermap.h.

void QgsComposerMap::setGridOffsetY ( double  offset)
inline

Sets y-coordinate offset for composer grid.

Note
this function was added in version 1.4

Definition at line 242 of file qgscomposermap.h.

void QgsComposerMap::setGridPen ( const QPen &  p)

Sets the pen to draw composer grid.

Note
this function was added in version 1.4

Definition at line 1903 of file qgscomposermap.cpp.

References setGridPenColor(), and setGridPenWidth().

void QgsComposerMap::setGridPenColor ( const QColor &  c)

Sets the color of the grid pen.

Note
this function was added in version 1.4

Definition at line 1895 of file qgscomposermap.cpp.

References mGridLineSymbol, and QgsSymbolV2::setColor().

Referenced by setGridPen().

void QgsComposerMap::setGridPenWidth ( double  w)

Sets with of grid pen.

Note
this function was added in version 1.4

Definition at line 1887 of file qgscomposermap.cpp.

References mGridLineSymbol, and QgsLineSymbolV2::setWidth().

Referenced by setGridPen().

void QgsComposerMap::setGridStyle ( GridStyle  style)
inline

Sets coordinate grid style to solid or cross.

Note
this function was added in version 1.4

Definition at line 222 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.

Note
this function was added in version 1.2

Definition at line 176 of file qgscomposermap.h.

void QgsComposerMap::setLayerSet ( const QStringList &  layerSet)
inline

Setter for stored layer set that is used if mKeepLayerSet is true.

Note
this function was added in version 1.2

Definition at line 183 of file qgscomposermap.h.

void QgsComposerMap::setMapCanvas ( QGraphicsView *  canvas)
inline

Sets canvas pointer (necessary to query and draw map canvas items)

Definition at line 365 of file qgscomposermap.h.

void QgsComposerMap::setMapRotation ( double  r)

Sets rotation for the map - this does not affect the composer item shape, only the way the map is drawn within the item.

Note
this function was added in version 2.1

Definition at line 750 of file qgscomposermap.cpp.

References QgsComposerItem::itemChanged(), mapRotationChanged(), and mMapRotation.

Referenced by setRotation().

void QgsComposerMap::setNewAtlasFeatureExtent ( const QgsRectangle extent)

Sets new Extent for the current atlas preview and changes width, height (and implicitely also scale).

Atlas preview extents are only temporary, and are regenerated whenever the atlas feature changes

Definition at line 635 of file qgscomposermap.cpp.

References extent(), extentChanged(), QgsRectangle::height(), QgsComposerItem::itemChanged(), mAtlasFeatureExtent, mCacheUpdated, QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), QgsRectangle::setYMinimum(), updateItem(), QgsRectangle::width(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().

Referenced by QgsAtlasComposition::prepareMap().

void QgsComposerMap::setNewExtent ( const QgsRectangle extent)

Sets new Extent and changes width, height (and implicitely also scale)

Definition at line 618 of file qgscomposermap.cpp.

References extent(), QgsRectangle::height(), mExtent, setSceneRect(), updateItem(), and QgsRectangle::width().

void QgsComposerMap::setNewScale ( double  scaleDenominator)

Sets new scale and changes only mExtent.

Definition at line 714 of file qgscomposermap.cpp.

References cache(), currentMapExtent(), extentChanged(), QgsComposerItem::itemChanged(), mCacheUpdated, QgsRectangle::scale(), and scale().

void QgsComposerMap::setOffset ( double  xOffset,
double  yOffset 
)

Sets offset values to shift image (useful for live updates when moving item content)

Definition at line 738 of file qgscomposermap.cpp.

References mXOffset, and mYOffset.

Referenced by QgsComposerView::mouseMoveEvent(), and QgsComposerView::mouseReleaseEvent().

void QgsComposerMap::setOverviewBlendMode ( QPainter::CompositionMode  blendMode)

Sets the overview's blending mode.

Definition at line 2153 of file qgscomposermap.cpp.

References QgsComposerItem::blendMode(), and mOverviewBlendMode.

Referenced by readXML().

void QgsComposerMap::setOverviewCentered ( bool  centered)

Set the overview's centering mode.

Definition at line 2165 of file qgscomposermap.cpp.

References mOverviewCentered, and overviewExtentChanged().

void QgsComposerMap::setOverviewFrameMap ( int  mapId)

Sets overview frame map.

-1 disables the overview frame

Note
: this function was added in version 1.9

Definition at line 2098 of file qgscomposermap.cpp.

References extentChanged(), QgsComposition::getComposerMapById(), QgsComposerItem::mComposition, mOverviewFrameMapId, and overviewExtentChanged().

Referenced by readXML().

void QgsComposerMap::setOverviewFrameMapSymbol ( QgsFillSymbolV2 symbol)

Definition at line 2147 of file qgscomposermap.cpp.

References mOverviewFrameMapSymbol.

void QgsComposerMap::setOverviewInverted ( bool  inverted)

Sets the overview's inversion mode.

Definition at line 2159 of file qgscomposermap.cpp.

References mOverviewInverted.

Referenced by readXML().

void QgsComposerMap::setPreviewMode ( PreviewMode  m)
void QgsComposerMap::setRotation ( double  r)
virtual

Sets rotation for the map - this does not affect the composer item shape, only the way the map is drawn within the item.

Deprecated:
Use setMapRotation( double rotation ) instead

Reimplemented from QgsComposerItem.

Definition at line 744 of file qgscomposermap.cpp.

References setMapRotation().

void QgsComposerMap::setSceneRect ( const QRectF &  rectangle)
virtual

Sets new scene rectangle bounds and recalculates hight and extent.

Reimplemented from QgsComposerItem.

Definition at line 599 of file qgscomposermap.cpp.

References extentChanged(), QgsComposerItem::itemChanged(), mCacheUpdated, mExtent, updateBoundingRect(), QgsRectangle::width(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), and QgsRectangle::yMinimum().

Referenced by QgsComposerMap(), resize(), and setNewExtent().

void QgsComposerMap::setShowGridAnnotation ( bool  show)
inline

Sets flag if grid annotation should be shown.

Note
this function was added in version 1.4

Definition at line 277 of file qgscomposermap.h.

bool QgsComposerMap::showGridAnnotation ( ) const
inline

Definition at line 278 of file qgscomposermap.h.

void QgsComposerMap::sizeChangedByRotation ( double &  width,
double &  height 
)

Calculates width / height of the bounding box of a rotated rectangle.

Deprecated:
Use QgsComposerItem::sizeChangedByRotation( double& width, double& height, double rotation ) instead

Reimplemented from QgsComposerItem.

Definition at line 2596 of file qgscomposermap.cpp.

References mMapRotation.

void QgsComposerMap::sortGridLinesOnBorders ( const QList< QPair< double, QLineF > > &  hLines,
const QList< QPair< double, QLineF > > &  vLines,
QMap< double, double > &  leftFrameEntries,
QMap< double, double > &  rightFrameEntries,
QMap< double, double > &  topFrameEntries,
QMap< double, double > &  bottomFrameEntries 
) const
private

Definition at line 2409 of file qgscomposermap.cpp.

References borderForLineCoord(), Left, Right, and Top.

Referenced by drawGridFrame().

void QgsComposerMap::storeCurrentLayerSet ( )

Stores the current layer set of the qgis mapcanvas in mLayerSet.

Definition at line 1299 of file qgscomposermap.cpp.

References QgsMapRenderer::layerSet(), mLayerSet, and mMapRenderer.

void QgsComposerMap::syncLayerSet ( )
private

Removes layer ids from mLayerSet that are no longer present in the qgis main map.

Definition at line 1307 of file qgscomposermap.cpp.

References QgsMapLayerRegistry::instance(), QgsMapRenderer::layerSet(), QgsMapLayerRegistry::mapLayers(), mKeepLayerSet, mLayerSet, and mMapRenderer.

Referenced by updateCachedImage().

void QgsComposerMap::toggleAtlasPreview ( )

Called when atlas preview is toggled, to force map item to update its extent and redraw.

Definition at line 673 of file qgscomposermap.cpp.

References extentChanged(), QgsComposerItem::itemChanged(), mCacheUpdated, and updateItem().

Referenced by QgsComposition::setAtlasMode().

QgsRectangle QgsComposerMap::transformedExtent ( ) const
private

Returns extent that considers mOffsetX / mOffsetY (during content move)

Definition at line 1953 of file qgscomposermap.cpp.

References currentMapExtent(), mXOffset, mYOffset, and transformShift().

Referenced by mapToItemCoords().

QPolygonF QgsComposerMap::transformedMapPolygon ( ) const
private

Returns extent that considers rotation and shift with mOffsetX / mOffsetY.

Definition at line 1961 of file qgscomposermap.cpp.

References mapPolygon(), mXOffset, mYOffset, and transformShift().

Referenced by mapToItemCoords(), xGridLines(), and yGridLines().

void QgsComposerMap::transformShift ( double &  xShift,
double &  yShift 
) const
private

Scales a composer map shift (in MM) and rotates it by mRotation.

Parameters
xShiftin: shift in x direction (in item units), out: xShift in map units
yShiftin: shift in y direction (in item units), out: yShift in map units

Definition at line 2177 of file qgscomposermap.cpp.

References mapUnitsToMM(), mMapRotation, and QgsComposerItem::rotate().

Referenced by moveContent(), transformedExtent(), and transformedMapPolygon().

virtual int QgsComposerMap::type ( ) const
inlinevirtual

return correct graphics item type.

Added in v1.7

Reimplemented from QgsComposerItem.

Definition at line 54 of file qgscomposermap.h.

References QgsComposerItem::ComposerMap.

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

Note
this function was added in version 1.4

Definition at line 1932 of file qgscomposermap.cpp.

References maxExtension(), and mCurrentRectangle.

Referenced by readXML(), setFrameOutlineWidth(), setGridAnnotationDirection(), setGridAnnotationPosition(), and setSceneRect().

void QgsComposerMap::updateCachedImage ( void  )
slot

Called if map canvas has changed.

Definition at line 446 of file qgscomposermap.cpp.

References cache(), mCacheUpdated, and syncLayerSet().

Referenced by connectUpdateSlot(), renderModeUpdateCachedImage(), and QgsComposerView::wheelZoom().

void QgsComposerMap::updateItem ( )
virtual

Updates item, with the possibility to do custom update for subclasses.

Reimplemented from QgsComposerItem.

Definition at line 758 of file qgscomposermap.cpp.

References cache(), mCacheUpdated, mPreviewMode, and Rectangle.

Referenced by resize(), setNewAtlasFeatureExtent(), setNewExtent(), and toggleAtlasPreview().

bool QgsComposerMap::writeXML ( QDomElement &  elem,
QDomDocument &  doc 
) const
virtual
int QgsComposerMap::xGridLines ( QList< QPair< double, QLineF > > &  lines) const
private

Returns the grid lines with associated coordinate value.

Returns
0 in case of success

Definition at line 1752 of file qgscomposermap.cpp.

References mapPolygon(), mapToItemCoords(), mGridIntervalY, mGridOffsetY, mMapRotation, qgsDoubleNear(), 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

Returns
0 in case of success

Definition at line 1821 of file qgscomposermap.cpp.

References mapPolygon(), mapToItemCoords(), mGridIntervalX, mGridOffsetX, mMapRotation, qgsDoubleNear(), and transformedMapPolygon().

Referenced by drawGrid(), and maxExtension().

void QgsComposerMap::zoomContent ( int  delta,
double  x,
double  y 
)
virtual

Zoom content of map.

Parameters
deltavalue from wheel event that describes magnitude and direction (positive /negative number)
xx-coordinate of mouse position in item coordinates
yy-coordinate of mouse position in item coordinates

Reimplemented from QgsComposerItem.

Definition at line 531 of file qgscomposermap.cpp.

References cache(), currentMapExtent(), extentChanged(), QgsComposerItem::itemChanged(), mDrawing, QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), QgsRectangle::setYMinimum(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().

Member Data Documentation

double QgsComposerMap::mAnnotationFrameDistance
private

Distance between map frame and annotation.

Definition at line 560 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), maxExtension(), readXML(), and writeXML().

bool QgsComposerMap::mAtlasDriven
private

True if map is being controlled by an atlas.

Definition at line 593 of file qgscomposermap.h.

Referenced by currentMapExtent(), readXML(), and writeXML().

QgsRectangle QgsComposerMap::mAtlasFeatureExtent
private

Definition at line 479 of file qgscomposermap.h.

Referenced by currentMapExtent(), and setNewAtlasFeatureExtent().

bool QgsComposerMap::mAtlasFixedScale
private

True if map uses a fixed scale when controlled by an atlas.

Definition at line 595 of file qgscomposermap.h.

Referenced by readXML(), and writeXML().

double QgsComposerMap::mAtlasMargin
private

Margin size for atlas driven extents (percentage of feature size)

Definition at line 597 of file qgscomposermap.h.

Referenced by readXML(), and writeXML().

GridAnnotationDirection QgsComposerMap::mBottomGridAnnotationDirection
private

Annotation direction on bottom side ( horizontal or vertical )

Definition at line 569 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), gridAnnotationDirection(), readXML(), setGridAnnotationDirection(), and writeXML().

GridAnnotationPosition QgsComposerMap::mBottomGridAnnotationPosition
private

Annotation position for bottom map side (inside / outside / not shown)

Definition at line 557 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), gridAnnotationPosition(), maxExtension(), readXML(), setGridAnnotationPosition(), and writeXML().

QImage QgsComposerMap::mCacheImage
private

Definition at line 482 of file qgscomposermap.h.

Referenced by cache(), and paint().

bool QgsComposerMap::mCacheUpdated
private
double QgsComposerMap::mCrossLength
private

The length of the cross sides for mGridStyle Cross.

Definition at line 583 of file qgscomposermap.h.

Referenced by drawGrid(), 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 581 of file qgscomposermap.h.

Referenced by boundingRect(), QgsComposerMap(), and updateBoundingRect().

bool QgsComposerMap::mDrawCanvasItems
private

True if annotation items, rubber band, etc.

from the main canvas should be displayed

Definition at line 586 of file qgscomposermap.h.

Referenced by drawCanvasItems(), readXML(), and writeXML().

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 494 of file qgscomposermap.h.

Referenced by cache(), moveContent(), paint(), QgsComposerMap(), readXML(), and zoomContent().

QgsRectangle QgsComposerMap::mExtent
private
QFont QgsComposerMap::mGridAnnotationFont
private

Font for grid line annotation.

Definition at line 540 of file qgscomposermap.h.

Referenced by drawAnnotation(), drawCoordinateAnnotation(), maxExtension(), QgsComposerMap(), readXML(), and writeXML().

QColor QgsComposerMap::mGridAnnotationFontColor
private

Font color for grid line annotation.

Definition at line 542 of file qgscomposermap.h.

Referenced by drawAnnotation(), readXML(), and writeXML().

GridAnnotationFormat QgsComposerMap::mGridAnnotationFormat
private
int QgsComposerMap::mGridAnnotationPrecision
private

Digits after the dot.

Definition at line 544 of file qgscomposermap.h.

Referenced by gridAnnotationString(), readXML(), and writeXML().

QPainter::CompositionMode QgsComposerMap::mGridBlendMode
private

Blend mode for grid.

Definition at line 548 of file qgscomposermap.h.

Referenced by drawGrid(), setGridBlendMode(), and writeXML().

bool QgsComposerMap::mGridEnabled
private

True if coordinate grid has to be displayed.

Definition at line 528 of file qgscomposermap.h.

Referenced by maxExtension(), paint(), readXML(), and writeXML().

QColor QgsComposerMap::mGridFrameFillColor1
private

Definition at line 577 of file qgscomposermap.h.

Referenced by drawGridFrameBorder(), readXML(), and writeXML().

QColor QgsComposerMap::mGridFrameFillColor2
private

Definition at line 578 of file qgscomposermap.h.

Referenced by drawGridFrameBorder(), readXML(), and writeXML().

QColor QgsComposerMap::mGridFramePenColor
private

Definition at line 576 of file qgscomposermap.h.

Referenced by drawGridFrameBorder(), readXML(), and writeXML().

double QgsComposerMap::mGridFramePenThickness
private
GridFrameStyle QgsComposerMap::mGridFrameStyle
private

Definition at line 573 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), drawGrid(), maxExtension(), readXML(), and writeXML().

double QgsComposerMap::mGridFrameWidth
private
double QgsComposerMap::mGridIntervalX
private

Grid line interval in x-direction (map units)

Definition at line 532 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 534 of file qgscomposermap.h.

Referenced by readXML(), writeXML(), and xGridLines().

QgsLineSymbolV2* QgsComposerMap::mGridLineSymbol
private
double QgsComposerMap::mGridOffsetX
private

Grid line offset in x-direction.

Definition at line 536 of file qgscomposermap.h.

Referenced by readXML(), writeXML(), and yGridLines().

double QgsComposerMap::mGridOffsetY
private

Grid line offset in y-direction.

Definition at line 538 of file qgscomposermap.h.

Referenced by readXML(), writeXML(), and xGridLines().

GridStyle QgsComposerMap::mGridStyle
private

Solid or crosses.

Definition at line 530 of file qgscomposermap.h.

Referenced by drawGrid(), readXML(), and writeXML().

int QgsComposerMap::mId
private

Unique identifier.

Definition at line 469 of file qgscomposermap.h.

Referenced by assignFreeId(), QgsComposerMap(), readXML(), and writeXML().

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 505 of file qgscomposermap.h.

Referenced by layersToRender(), readXML(), syncLayerSet(), and writeXML().

QStringList QgsComposerMap::mLayerSet
private

Stored layer list (used if layer live-link mKeepLayerSet is disabled)

Definition at line 508 of file qgscomposermap.h.

Referenced by layersToRender(), readXML(), storeCurrentLayerSet(), syncLayerSet(), and writeXML().

GridAnnotationDirection QgsComposerMap::mLeftGridAnnotationDirection
private

Annotation direction on left side ( horizontal or vertical )

Definition at line 563 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), gridAnnotationDirection(), readXML(), setGridAnnotationDirection(), and writeXML().

GridAnnotationPosition QgsComposerMap::mLeftGridAnnotationPosition
private

Annotation position for left map side (inside / outside / not shown)

Definition at line 551 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), gridAnnotationPosition(), maxExtension(), readXML(), setGridAnnotationPosition(), and writeXML().

QGraphicsView* QgsComposerMap::mMapCanvas
private

Definition at line 584 of file qgscomposermap.h.

Referenced by composerMapPosForItem(), drawCanvasItem(), and drawCanvasItems().

QgsMapRenderer* QgsComposerMap::mMapRenderer
private
double QgsComposerMap::mMapRotation
private
int QgsComposerMap::mNumCachedLayers
private

Number of layers when cache was created.

Definition at line 491 of file qgscomposermap.h.

Referenced by readXML().

QPainter::CompositionMode QgsComposerMap::mOverviewBlendMode
private

Blend mode for overview.

Definition at line 516 of file qgscomposermap.h.

Referenced by drawOverviewMapExtent(), setOverviewBlendMode(), and writeXML().

bool QgsComposerMap::mOverviewCentered
private

Centering mode for overview.

Definition at line 519 of file qgscomposermap.h.

Referenced by overviewExtentChanged(), readXML(), setOverviewCentered(), and writeXML().

int QgsComposerMap::mOverviewFrameMapId
private

Id of map which displays its extent rectangle into this composer map (overview map functionality).

-1 if not present

Definition at line 511 of file qgscomposermap.h.

Referenced by drawOverviewMapExtent(), overviewExtentChanged(), paint(), setOverviewFrameMap(), and writeXML().

QgsFillSymbolV2* QgsComposerMap::mOverviewFrameMapSymbol
private
bool QgsComposerMap::mOverviewInverted
private

Definition at line 517 of file qgscomposermap.h.

Referenced by drawOverviewMapExtent(), setOverviewInverted(), and writeXML().

PreviewMode QgsComposerMap::mPreviewMode
private
GridAnnotationDirection QgsComposerMap::mRightGridAnnotationDirection
private

Annotation direction on right side ( horizontal or vertical )

Definition at line 565 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), gridAnnotationDirection(), readXML(), setGridAnnotationDirection(), and writeXML().

GridAnnotationPosition QgsComposerMap::mRightGridAnnotationPosition
private

Annotation position for right map side (inside / outside / not shown)

Definition at line 553 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), gridAnnotationPosition(), maxExtension(), readXML(), setGridAnnotationPosition(), and writeXML().

bool QgsComposerMap::mShowGridAnnotation
private

True if coordinate values should be drawn.

Definition at line 546 of file qgscomposermap.h.

Referenced by drawGrid(), maxExtension(), readXML(), and writeXML().

GridAnnotationDirection QgsComposerMap::mTopGridAnnotationDirection
private

Annotation direction on top side ( horizontal or vertical )

Definition at line 567 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), gridAnnotationDirection(), readXML(), setGridAnnotationDirection(), and writeXML().

GridAnnotationPosition QgsComposerMap::mTopGridAnnotationPosition
private

Annotation position for top map side (inside / outside / not shown)

Definition at line 555 of file qgscomposermap.h.

Referenced by drawCoordinateAnnotation(), gridAnnotationPosition(), maxExtension(), readXML(), setGridAnnotationPosition(), and writeXML().

double QgsComposerMap::mXOffset
private

Offset in x direction for showing map cache image.

Definition at line 497 of file qgscomposermap.h.

Referenced by drawOverviewMapExtent(), paint(), QgsComposerMap(), setOffset(), transformedExtent(), and transformedMapPolygon().

double QgsComposerMap::mYOffset
private

Offset in y direction for showing map cache image.

Definition at line 499 of file qgscomposermap.h.

Referenced by drawOverviewMapExtent(), paint(), QgsComposerMap(), setOffset(), transformedExtent(), and transformedMapPolygon().


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