Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 }
 
enum  GridAnnotationDirection { Horizontal = 0, Vertical, HorizontalAndVertical, BoundaryDirection }
 
- Public Types inherited from QgsComposerItem
enum  ItemType {
  ComposerItem = UserType + 100, ComposerArrow, ComposerItemGroup, ComposerLabel,
  ComposerLegend, ComposerMap, ComposerPaper, ComposerPicture,
  ComposerScaleBar, ComposerShape, ComposerTable, ComposerAttributeTable,
  ComposerTextTable
}
 
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. More...
 
void renderModeUpdateCachedImage ()
 Call updateCachedImage if item is in render mode. More...
 
- Public Slots inherited from QgsComposerItem
virtual void setRotation (double r)
 
void repaint ()
 

Signals

void extentChanged ()
 
- Signals inherited from QgsComposerItem
void rotationChanged (double newRotation)
 Is emitted on rotation change to notify north arrow pictures. More...
 
void itemChanged ()
 Used e.g. More...
 

Public Member Functions

 QgsComposerMap (QgsComposition *composition, int x, int y, int width, int height)
 Constructor. More...
 
 QgsComposerMap (QgsComposition *composition)
 Constructor. More...
 
 ~QgsComposerMap ()
 
virtual int type () const
 return correct graphics item type. More...
 
void draw (QPainter *painter, const QgsRectangle &extent, const QSize &size, int dpi)
 This function is deprecated. More...
 
void draw (QPainter *painter, const QgsRectangle &extent, const QSizeF &size, double dpi)
 Draw to paint device. More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
 Reimplementation of QCanvasItem::paint - draw on canvas. More...
 
void cache (void)
 Create cache image. More...
 
int id () const
 Get identification number. More...
 
bool isDrawing () const
 True if a draw is already in progress. More...
 
void resize (double dx, double dy)
 resizes an item in x- and y direction (canvas coordinates) More...
 
void moveContent (double dx, double dy)
 Move content of map. More...
 
void zoomContent (int delta, double x, double y)
 Zoom content of map. More...
 
void setSceneRect (const QRectF &rectangle)
 Sets new scene rectangle bounds and recalculates hight and extent. More...
 
double scale (void) const
 Scale. More...
 
void setNewScale (double scaleDenominator)
 Sets new scale and changes only mExtent. More...
 
void setNewExtent (const QgsRectangle &extent)
 Sets new Extent and changes width, height (and implicitely also scale) More...
 
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. More...
 
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. More...
 
QStringList layerSet () const
 Getter for stored layer set that is used if mKeepLayerSet is true. More...
 
void setLayerSet (const QStringList &layerSet)
 Setter for stored layer set that is used if mKeepLayerSet is true. More...
 
void storeCurrentLayerSet ()
 Stores the current layer set of the qgis mapcanvas in mLayerSet. More...
 
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) More...
 
bool containsWMSLayer () const
 True if composer map renders a WMS layer. More...
 
bool writeXML (QDomElement &elem, QDomDocument &doc) const
 stores state in Dom node More...
 
bool readXML (const QDomElement &itemElem, const QDomDocument &doc)
 sets state from Dom document More...
 
void setGridEnabled (bool enabled)
 Enables a coordinate grid that is shown on top of this composermap. More...
 
bool gridEnabled () const
 
void setGridStyle (GridStyle style)
 Sets coordinate grid style to solid or cross. More...
 
GridStyle gridStyle () const
 
void setGridIntervalX (double interval)
 Sets coordinate interval in x-direction for composergrid. More...
 
double gridIntervalX () const
 
void setGridIntervalY (double interval)
 Sets coordinate interval in y-direction for composergrid. More...
 
double gridIntervalY () const
 
void setGridOffsetX (double offset)
 Sets x-coordinate offset for composer grid. More...
 
double gridOffsetX () const
 
void setGridOffsetY (double offset)
 Sets y-coordinate offset for composer grid. More...
 
double gridOffsetY () const
 
void setGridPen (const QPen &p)
 Sets the pen to draw composer grid. More...
 
QPen gridPen () const
 
void setGridPenWidth (double w)
 Sets with of grid pen. More...
 
void setGridPenColor (const QColor &c)
 Sets the color of the grid pen. More...
 
void setGridAnnotationFont (const QFont &f)
 Sets font for grid annotations. More...
 
QFont gridAnnotationFont () const
 
void setGridAnnotationPrecision (int p)
 Sets coordinate precision for grid annotations. More...
 
int gridAnnotationPrecision () const
 
void setShowGridAnnotation (bool show)
 Sets flag if grid annotation should be shown. More...
 
bool showGridAnnotation () const
 
void setGridAnnotationPosition (GridAnnotationPosition p)
 Sets position of grid annotations. More...
 
GridAnnotationPosition gridAnnotationPosition () const
 
void setAnnotationFrameDistance (double d)
 Sets distance between map frame and annotations. More...
 
double annotationFrameDistance () const
 
void setGridAnnotationDirection (GridAnnotationDirection d)
 Sets grid annotation direction. More...
 
GridAnnotationDirection gridAnnotationDirection () const
 
QRectF boundingRect () const
 In case of annotations, the bounding rectangle can be larger than the map item rectangle. More...
 
void updateBoundingRect ()
 Updates the bounding rect of this item. More...
 
void setCrossLength (double l)
 Sets length of the cros segments (if grid style is cross) More...
 
double crossLength ()
 
void setMapRotation (double r)
 
void setMapCanvas (QGraphicsView *canvas)
 Sets canvas pointer (necessary to query and draw map canvas items) More...
 
void setDrawCanvasItems (bool b)
 
bool drawCanvasItems () const
 
double mapUnitsToMM () const
 Returns the conversion factor map units -> mm. More...
 
- Public Member Functions inherited from QgsComposerItem
 QgsComposerItem (QgsComposition *composition, bool manageZValue=true)
 Constructor. More...
 
 QgsComposerItem (qreal x, qreal y, qreal width, qreal height, QgsComposition *composition, bool manageZValue=true)
 Constructor with box position and composer object. More...
 
virtual ~QgsComposerItem ()
 
virtual void setSelected (bool s)
 Set selected, selected item should be highlighted. More...
 
virtual bool selected (void)
 Is selected. More...
 
virtual bool writeSettings (void)
 stores state in project More...
 
virtual bool readSettings (void)
 read state from project More...
 
virtual bool removeSettings (void)
 delete settings from project file More...
 
void move (double dx, double dy)
 Moves item in canvas coordinates. More...
 
void setItemPosition (double x, double y, ItemPositionMode itemPoint=UpperLeft)
 Moves the item to a new position (in canvas coordinates) More...
 
void setItemPosition (double x, double y, double width, double height, ItemPositionMode itemPoint=UpperLeft)
 Sets item position and width / height in one go. More...
 
bool _writeXML (QDomElement &itemElem, QDomDocument &doc) const
 Writes parameter that are not subclass specific in document. More...
 
bool _readXML (const QDomElement &itemElem, const QDomDocument &doc)
 Reads parameter that are not subclass specific in document. More...
 
bool frame () const
 
void setFrame (bool drawFrame)
 
virtual void addItem (QgsComposerItem *item)
 Composite operations for item groups do nothing per default. More...
 
virtual void removeItems ()
 
const QgsCompositioncomposition () const
 
void beginCommand (const QString &commandText, QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown)
 Starts new composer undo command. More...
 
void endCommand ()
 Finish current command and push it onto the undo stack. More...
 
void cancelCommand ()
 
void drawText (QPainter *p, double x, double y, const QString &text, const QFont &font) const
 Draws Text. More...
 
void drawText (QPainter *p, const QRectF &rect, const QString &text, const QFont &font, Qt::AlignmentFlag halignement=Qt::AlignLeft, Qt::AlignmentFlag valignement=Qt::AlignTop) const
 Like the above, but with a rectangle for multiline text. More...
 
double textWidthMillimeters (const QFont &font, const QString &text) const
 Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE. More...
 
double fontHeightCharacterMM (const QFont &font, const QChar &c) const
 Returns the font height of a character in millimeters. More...
 
double fontAscentMillimeters (const QFont &font) const
 Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE. More...
 
double pixelFontSize (double pointSize) const
 Calculates font to from point size to pixel size. More...
 
QFont scaledFontPixelSize (const QFont &font) const
 Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE. More...
 
void setPositionLock (bool lock)
 Locks / unlocks the item position for mouse drags. More...
 
bool positionLock () const
 Returns position lock for mouse drags (true means locked) More...
 
void updateCursor (const QPointF &itemPos)
 Update mouse cursor at (item) position. More...
 
double rotation () const
 

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. More...
 
void syncLayerSet ()
 Removes layer ids from mLayerSet that are no longer present in the qgis main map. More...
 
void drawGrid (QPainter *p)
 Draws the map grid. More...
 
void drawCoordinateAnnotations (QPainter *p, const QList< QPair< double, QLineF > > &hLines, const QList< QPair< double, QLineF > > &vLines)
 Draw coordinates for mGridAnnotationType Coordinate. More...
 
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. More...
 
int xGridLines (QList< QPair< double, QLineF > > &lines) const
 Returns the grid lines with associated coordinate value. More...
 
int yGridLines (QList< QPair< double, QLineF > > &lines) const
 Returns the grid lines for the y-coordinates. More...
 
QgsRectangle transformedExtent () const
 Returns extent that considers mOffsetX / mOffsetY (during content move) More...
 
QPolygonF transformedMapPolygon () const
 Returns extent that considers rotation and shift with mOffsetX / mOffsetY. More...
 
double maxExtension () const
 
void mapPolygon (QPolygonF &poly) const
 Returns the polygon of the map extent. More...
 
void requestedExtent (QgsRectangle &extent) const
 Calculates the extent to request and the yShift of the top-left point in case of rotation. More...
 
void transformShift (double &xShift, double &yShift) const
 Scales a composer map shift (in MM) and rotates it by mRotation. More...
 
QPointF mapToItemCoords (const QPointF &mapCoords) const
 Transforms map coordinates to item coordinates (considering rotation and move offset) More...
 
Border borderForLineCoord (const QPointF &p) const
 Returns the item border of a point (in item coordinates) More...
 
void drawCanvasItems (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle)
 
void drawCanvasItem (QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *itemStyle)
 
QPointF composerMapPosForItem (const QGraphicsItem *item) const
 

Private Attributes

QgsMapRenderermMapRenderer
 
int mId
 Unique identifier. More...
 
QgsRectangle mExtent
 
QImage mCacheImage
 
bool mCacheUpdated
 
PreviewMode mPreviewMode
 Preview style. More...
 
int mNumCachedLayers
 Number of layers when cache was created. More...
 
bool mDrawing
 set to true if in state of drawing. More...
 
double mXOffset
 Offset in x direction for showing map cache image. More...
 
double mYOffset
 Offset in y direction for showing map cache image. More...
 
bool mKeepLayerSet
 Flag if layers to be displayed should be read from qgis canvas (true) or from stored list in mLayerSet (false) More...
 
QStringList mLayerSet
 Stored layer list (used if layer live-link mKeepLayerSet is disabled) More...
 
bool mGridEnabled
 True if coordinate grid has to be displayed. More...
 
GridStyle mGridStyle
 Solid or crosses. More...
 
double mGridIntervalX
 Grid line interval in x-direction (map units) More...
 
double mGridIntervalY
 Grid line interval in y-direction (map units) More...
 
double mGridOffsetX
 Grid line offset in x-direction. More...
 
double mGridOffsetY
 Grid line offset in y-direction. More...
 
QPen mGridPen
 Grid line pen. More...
 
QFont mGridAnnotationFont
 Font for grid line annotation. More...
 
int mGridAnnotationPrecision
 Digits after the dot. More...
 
bool mShowGridAnnotation
 True if coordinate values should be drawn. More...
 
GridAnnotationPosition mGridAnnotationPosition
 Annotation position inside or outside of map frame. More...
 
double mAnnotationFrameDistance
 Distance between map frame and annotation. More...
 
GridAnnotationDirection mGridAnnotationDirection
 Annotation can be horizontal / vertical or different for axes. More...
 
QRectF mCurrentRectangle
 Current bounding rectangle. More...
 
double mCrossLength
 The length of the cross sides for mGridStyle Cross. More...
 
QGraphicsView * mMapCanvas
 
bool mDrawCanvasItems
 True if annotation items, rubber band, etc. More...
 

Additional Inherited Members

- Protected Member Functions inherited from QgsComposerItem
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
virtual void hoverMoveEvent (QGraphicsSceneHoverEvent *event)
 
Qt::CursorShape cursorForPosition (const QPointF &itemCoordPos)
 Finds out the appropriate cursor for the current mouse position in the widget (e.g. More...
 
QgsComposerItem::MouseMoveAction mouseMoveActionForPosition (const QPointF &itemCoordPos)
 Finds out which mouse move action to choose depending on the cursor position inside the widget. More...
 
void changeItemRectangle (const QPointF &currentPosition, const QPointF &mouseMoveStartPos, const QGraphicsRectItem *originalItem, double dx, double dy, QGraphicsRectItem *changeItem)
 Changes the rectangle of an item depending on current mouse action (resize or move) More...
 
virtual void drawSelectionBoxes (QPainter *p)
 Draw selection boxes around item. More...
 
virtual void drawFrame (QPainter *p)
 Draw black frame around item. More...
 
virtual void drawBackground (QPainter *p)
 Draw background. More...
 
void drawArrowHead (QPainter *p, double x, double y, double angle, double arrowHeadWidth) const
 Draws arrowhead. More...
 
double angle (const QPointF &p1, const QPointF &p2) const
 Returns angle of the line from p1 to p2 (clockwise, starting at N) More...
 
double rectHandlerBorderTolerance () const
 Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the \ item border for resizing. More...
 
double lockSymbolSize () const
 Returns the size of the lock symbol depending on the composer zoom level and the item size. More...
 
double horizontalViewScaleFactor () const
 Returns the zoom factor of the graphics view. More...
 
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. More...
 
bool cornerPointOnRotatedAndScaledRect (double &x, double &y, double width, double height) const
 Calculates corner point after rotation and scaling. More...
 
QPointF pointOnLineWithDistance (const QPointF &startPoint, const QPointF &directionPoint, double distance) const
 Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point. More...
 
void sizeChangedByRotation (double &width, double &height)
 Calculates width / height of the bounding box of a rotated rectangle (mRotation) More...
 
void rotate (double angle, double &x, double &y) const
 Rotates a point / vector. More...
 
- Protected Attributes inherited from QgsComposerItem
QgsCompositionmComposition
 
QgsComposerItem::MouseMoveAction mCurrentMouseMoveAction
 
QPointF mMouseMoveStartPos
 Start point of the last mouse move action (in scene coordinates) More...
 
QPointF mLastMouseEventPos
 Position of the last mouse move event (in scene coordinates) More...
 
QGraphicsRectItem * mBoundingResizeRectangle
 Rectangle used during move and resize actions. More...
 
bool mFrame
 True if item fram needs to be painted. More...
 
bool mItemPositionLocked
 True if item position and size cannot be changed with mouse move. More...
 
double mLastValidViewScaleFactor
 Backup to restore item appearance if no view scale factor is available. More...
 
double mRotation
 Item rotation in degrees, clockwise. More...
 

Detailed Description

Object representing map window.

Definition at line 38 of file qgscomposermap.h.

Member Enumeration Documentation

enum QgsComposerMap::Border
private

Enum for different frame borders.

Enumerator
Left 
Right 
Bottom 
Top 

Definition at line 279 of file qgscomposermap.h.

Enumerator
Horizontal 
Vertical 
HorizontalAndVertical 
BoundaryDirection 

Definition at line 72 of file qgscomposermap.h.

Enumerator
InsideMapFrame 
OutsideMapFrame 

Definition at line 66 of file qgscomposermap.h.

Enumerator
Solid 
Cross 

Definition at line 60 of file qgscomposermap.h.

Preview style.

Enumerator
Cache 
Render 
Rectangle 

Definition at line 53 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 ( )

Definition at line 109 of file qgscomposermap.cpp.

Member Function Documentation

double QgsComposerMap::annotationFrameDistance ( ) const
inline

Definition at line 236 of file qgscomposermap.h.

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

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

Definition at line 1446 of file qgscomposermap.cpp.

References Bottom, Left, Right, and Top.

Referenced by drawCoordinateAnnotation().

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

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

Referenced by QgsComposerMap().

bool QgsComposerMap::containsWMSLayer ( ) const
double QgsComposerMap::crossLength ( )
inline

Definition at line 253 of file qgscomposermap.h.

void QgsComposerMap::draw ( QPainter *  painter,
const QgsRectangle extent,
const QSize &  size,
int  dpi 
)

This function is deprecated.

Definition at line 113 of file qgscomposermap.cpp.

Referenced by cache(), and paint().

void QgsComposerMap::draw ( QPainter *  painter,
const QgsRectangle extent,
const QSizeF &  size,
double  dpi 
)
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 1101 of file qgscomposermap.cpp.

References QgsComposerItem::drawText(), and mGridAnnotationFont.

Referenced by drawCoordinateAnnotation().

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

Definition at line 261 of file qgscomposermap.h.

Referenced by paint().

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

Definition at line 1466 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 935 of file qgscomposermap.cpp.

References drawCoordinateAnnotation(), and mGridAnnotationPrecision.

Referenced by drawGrid().

void QgsComposerMap::drawGrid ( QPainter *  p)
private
QgsRectangle QgsComposerMap::extent ( ) const
inline
void QgsComposerMap::extentChanged ( )
signal
GridAnnotationDirection QgsComposerMap::gridAnnotationDirection ( ) const
inline

Definition at line 241 of file qgscomposermap.h.

QFont QgsComposerMap::gridAnnotationFont ( ) const
inline

Definition at line 216 of file qgscomposermap.h.

GridAnnotationPosition QgsComposerMap::gridAnnotationPosition ( ) const
inline

Definition at line 231 of file qgscomposermap.h.

int QgsComposerMap::gridAnnotationPrecision ( ) const
inline

Definition at line 221 of file qgscomposermap.h.

bool QgsComposerMap::gridEnabled ( ) const
inline

Definition at line 175 of file qgscomposermap.h.

double QgsComposerMap::gridIntervalX ( ) const
inline

Definition at line 185 of file qgscomposermap.h.

double QgsComposerMap::gridIntervalY ( ) const
inline

Definition at line 190 of file qgscomposermap.h.

double QgsComposerMap::gridOffsetX ( ) const
inline

Definition at line 195 of file qgscomposermap.h.

double QgsComposerMap::gridOffsetY ( ) const
inline

Definition at line 200 of file qgscomposermap.h.

QPen QgsComposerMap::gridPen ( ) const
inline

Definition at line 205 of file qgscomposermap.h.

GridStyle QgsComposerMap::gridStyle ( ) const
inline

Definition at line 180 of file qgscomposermap.h.

int QgsComposerMap::id ( ) const
inline
bool QgsComposerMap::isDrawing ( ) const
inline

True if a draw is already in progress.

Definition at line 100 of file qgscomposermap.h.

Referenced by QgsComposerView::keyPressEvent(), and QgsComposerAttributeTable::paint().

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

Referenced by readXML().

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

const QgsMapRenderer* QgsComposerMap::mapRenderer ( ) const
inline

Definition at line 152 of file qgscomposermap.h.

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

Returns the conversion factor map units -> mm.

Definition at line 1403 of file qgscomposermap.cpp.

References mExtent, 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 400 of file qgscomposermap.cpp.

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

void QgsComposerMap::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  itemStyle,
QWidget *  pWidget 
)
PreviewMode QgsComposerMap::previewMode ( )
inline

Definition at line 128 of file qgscomposermap.h.

Referenced by readXML().

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

References mapPolygon(), mExtent, QgsComposerItem::mRotation, 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 392 of file qgscomposermap.cpp.

References setSceneRect().

double QgsComposerMap::scale ( void  ) const
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 235 of file qgscomposermap.h.

void QgsComposerMap::setCacheUpdated ( bool  u = false)

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

void QgsComposerMap::setDrawCanvasItems ( bool  b)
inline

Definition at line 260 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

Note
this function was added in version 1.4

Definition at line 240 of file qgscomposermap.h.

void QgsComposerMap::setGridAnnotationFont ( const QFont &  f)
inline

Sets font for grid annotations.

Note
this function was added in version 1.4

Definition at line 215 of file qgscomposermap.h.

void QgsComposerMap::setGridAnnotationPosition ( GridAnnotationPosition  p)
inline

Sets position of grid annotations.

Possibilities are inside or outside of the map frame

Note
this function was added in version 1.4

Definition at line 230 of file qgscomposermap.h.

void QgsComposerMap::setGridAnnotationPrecision ( int  p)
inline

Sets coordinate precision for grid annotations.

Note
this function was added in version 1.4

Definition at line 220 of file qgscomposermap.h.

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 174 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 184 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 189 of file qgscomposermap.h.

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

void QgsComposerMap::setGridPen ( const QPen &  p)
inline

Sets the pen to draw composer grid.

Note
this function was added in version 1.4

Definition at line 204 of file qgscomposermap.h.

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

References mGridPen.

void QgsComposerMap::setGridPenWidth ( double  w)

Sets with of grid pen.

Note
this function was added in version 1.4

Definition at line 1246 of file qgscomposermap.cpp.

References mGridPen.

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 179 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 136 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 143 of file qgscomposermap.h.

void QgsComposerMap::setMapCanvas ( QGraphicsView *  canvas)
inline

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

Definition at line 258 of file qgscomposermap.h.

void QgsComposerMap::setMapRotation ( double  r)
void QgsComposerMap::setNewExtent ( const QgsRectangle extent)

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

Definition at line 507 of file qgscomposermap.cpp.

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

void QgsComposerMap::setNewScale ( double  scaleDenominator)

Sets new scale and changes only mExtent.

Definition at line 523 of file qgscomposermap.cpp.

References cache(), extentChanged(), QgsComposerItem::itemChanged(), mCacheUpdated, mExtent, 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 541 of file qgscomposermap.cpp.

References mXOffset, and mYOffset.

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

void QgsComposerMap::setPreviewMode ( PreviewMode  m)
inline

Definition at line 129 of file qgscomposermap.h.

Referenced by QgsComposerView::addComposerMap().

void QgsComposerMap::setSceneRect ( const QRectF &  rectangle)
virtual
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 225 of file qgscomposermap.h.

bool QgsComposerMap::showGridAnnotation ( ) const
inline

Definition at line 226 of file qgscomposermap.h.

void QgsComposerMap::storeCurrentLayerSet ( )

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

Definition at line 815 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 823 of file qgscomposermap.cpp.

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

Referenced by updateCachedImage().

QgsRectangle QgsComposerMap::transformedExtent ( ) const
private

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

Definition at line 1276 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 1284 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 1413 of file qgscomposermap.cpp.

References mapUnitsToMM(), QgsComposerItem::mRotation, 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 50 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 1261 of file qgscomposermap.cpp.

References maxExtension(), and mCurrentRectangle.

Referenced by readXML(), and setSceneRect().

void QgsComposerMap::updateCachedImage ( void  )
slot

Called if map canvas has changed.

Definition at line 358 of file qgscomposermap.cpp.

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

Referenced by connectUpdateSlot(), and renderModeUpdateCachedImage().

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

References doubleNear(), 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

Returns
0 in case of success

Definition at line 1180 of file qgscomposermap.cpp.

References doubleNear(), mapPolygon(), mapToItemCoords(), mGridIntervalX, mGridOffsetX, QgsComposerItem::mRotation, 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 416 of file qgscomposermap.cpp.

References cache(), extentChanged(), QgsComposerItem::itemChanged(), mDrawing, mExtent, 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 354 of file qgscomposermap.h.

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

QImage QgsComposerMap::mCacheImage
private

Definition at line 300 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 360 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 358 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 363 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 312 of file qgscomposermap.h.

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

QgsRectangle QgsComposerMap::mExtent
private
GridAnnotationDirection QgsComposerMap::mGridAnnotationDirection
private

Annotation can be horizontal / vertical or different for axes.

Definition at line 356 of file qgscomposermap.h.

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

QFont QgsComposerMap::mGridAnnotationFont
private

Font for grid line annotation.

Definition at line 346 of file qgscomposermap.h.

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

GridAnnotationPosition QgsComposerMap::mGridAnnotationPosition
private

Annotation position inside or outside of map frame.

Definition at line 352 of file qgscomposermap.h.

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

int QgsComposerMap::mGridAnnotationPrecision
private

Digits after the dot.

Definition at line 348 of file qgscomposermap.h.

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

bool QgsComposerMap::mGridEnabled
private

True if coordinate grid has to be displayed.

Definition at line 332 of file qgscomposermap.h.

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

double QgsComposerMap::mGridIntervalX
private

Grid line interval in x-direction (map units)

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

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

double QgsComposerMap::mGridOffsetX
private

Grid line offset in x-direction.

Definition at line 340 of file qgscomposermap.h.

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

double QgsComposerMap::mGridOffsetY
private

Grid line offset in y-direction.

Definition at line 342 of file qgscomposermap.h.

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

QPen QgsComposerMap::mGridPen
private

Grid line pen.

Definition at line 344 of file qgscomposermap.h.

Referenced by drawGrid(), QgsComposerMap(), readXML(), setGridPenColor(), setGridPenWidth(), and writeXML().

GridStyle QgsComposerMap::mGridStyle
private

Solid or crosses.

Definition at line 334 of file qgscomposermap.h.

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

int QgsComposerMap::mId
private

Unique identifier.

Definition at line 292 of file qgscomposermap.h.

Referenced by 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 320 of file qgscomposermap.h.

Referenced by draw(), readXML(), syncLayerSet(), updateCachedImage(), and writeXML().

QStringList QgsComposerMap::mLayerSet
private

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

Definition at line 323 of file qgscomposermap.h.

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

QGraphicsView* QgsComposerMap::mMapCanvas
private

Definition at line 361 of file qgscomposermap.h.

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

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

Number of layers when cache was created.

Definition at line 309 of file qgscomposermap.h.

Referenced by readXML().

PreviewMode QgsComposerMap::mPreviewMode
private

Preview style.

Definition at line 306 of file qgscomposermap.h.

Referenced by cache(), paint(), QgsComposerMap(), readXML(), renderModeUpdateCachedImage(), setSceneRect(), and writeXML().

bool QgsComposerMap::mShowGridAnnotation
private

True if coordinate values should be drawn.

Definition at line 350 of file qgscomposermap.h.

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

double QgsComposerMap::mXOffset
private

Offset in x direction for showing map cache image.

Definition at line 315 of file qgscomposermap.h.

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

double QgsComposerMap::mYOffset
private

Offset in y direction for showing map cache image.

Definition at line 317 of file qgscomposermap.h.

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


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