QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsMapCanvasItem Class Referenceabstract

An abstract class for items that can be placed on the map canvas. More...

#include <qgsmapcanvasitem.h>

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

Public Member Functions

virtual void updatePosition ()
 called on changed extent or resize event to update position of the item More...
 
virtual QRectF boundingRect () const
 default implementation for canvas items More...
 
Q_DECL_DEPRECATED void setPanningOffset (const QPoint &point)
 sets current offset, to be called from QgsMapCanvas More...
 
QgsRectangle rect () const
 returns canvas item rectangle More...
 
void setRect (const QgsRectangle &r)
 sets canvas item rectangle More...
 
QgsPoint toMapCoordinates (const QPoint &point)
 transformation from screen coordinates to map coordinates More...
 
QPointF toCanvasCoordinates (const QgsPoint &point)
 transformation from map coordinates to screen coordinates More...
 

Protected Member Functions

 QgsMapCanvasItem (QgsMapCanvas *mapCanvas)
 protected constructor: cannot be constructed directly More...
 
virtual ~QgsMapCanvasItem ()
 
virtual void paint (QPainter *painter)=0
 function to be implemented by derived classes More...
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
 paint function called by map canvas More...
 
void updateCanvas ()
 schedules map canvas for repaint More...
 
bool setRenderContextVariables (QPainter *p, QgsRenderContext &context) const
 Sets render context parameters. More...
 

Protected Attributes

QgsMapCanvasmMapCanvas
 pointer to map canvas More...
 
QgsRectangle mRect
 canvas item rectangle (in map coordinates) More...
 
QPoint mPanningOffset
 offset from normal position due current panning operation, used when converting map coordinates to move map canvas items More...
 
QSizeF mItemSize
 cached size of the item (to return in boundingRect()) More...
 

Detailed Description

An abstract class for items that can be placed on the map canvas.

Definition at line 30 of file qgsmapcanvasitem.h.

Constructor & Destructor Documentation

QgsMapCanvasItem::QgsMapCanvasItem ( QgsMapCanvas mapCanvas)
protected

protected constructor: cannot be constructed directly

Definition at line 29 of file qgsmapcanvasitem.cpp.

QgsMapCanvasItem::~QgsMapCanvasItem ( )
protectedvirtual

Definition at line 35 of file qgsmapcanvasitem.cpp.

Member Function Documentation

QRectF QgsMapCanvasItem::boundingRect ( ) const
virtual

default implementation for canvas items

Reimplemented in QgsAnnotationItem, and QgsVertexMarker.

Definition at line 96 of file qgsmapcanvasitem.cpp.

References mItemSize.

Referenced by QgsMapCanvasMap::paint().

virtual void QgsMapCanvasItem::paint ( QPainter *  painter)
protectedpure virtual

function to be implemented by derived classes

Implemented in QgsRubberBand, QgsHighlight, QgsVertexMarker, QgsMapCanvasMap, QgsTextAnnotationItem, QgsHtmlAnnotationItem, QgsFormAnnotationItem, and QgsSvgAnnotationItem.

Referenced by paint().

void QgsMapCanvasItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget = 0 
)
protectedvirtual

paint function called by map canvas

Reimplemented in QgsHtmlAnnotationItem, and QgsFormAnnotationItem.

Definition at line 40 of file qgsmapcanvasitem.cpp.

References QgsMapCanvas::antiAliasingEnabled(), mMapCanvas, and paint().

QgsRectangle QgsMapCanvasItem::rect ( ) const

returns canvas item rectangle

Definition at line 67 of file qgsmapcanvasitem.cpp.

References mRect.

Referenced by QgsHighlight::paint(), setRect(), and QgsRubberBand::updateRect().

void QgsMapCanvasItem::setPanningOffset ( const QPoint &  point)

sets current offset, to be called from QgsMapCanvas

Deprecated:
since v2.4 - not called by QgsMapCanvas anymore

Definition at line 133 of file qgsmapcanvasitem.cpp.

References mPanningOffset.

void QgsMapCanvasItem::setRect ( const QgsRectangle r)
bool QgsMapCanvasItem::setRenderContextVariables ( QPainter *  p,
QgsRenderContext context 
) const
protected

Sets render context parameters.

Parameters
ppainter for rendering
contextout: configured context
Returns
true in case of success
Note
added in version 1.5

Definition at line 109 of file qgsmapcanvasitem.cpp.

References QgsMapCanvas::mapSettings(), mMapCanvas, QgsMapSettings::outputDpi(), QgsMapCanvas::scale(), QgsRenderContext::setForceVectorOutput(), QgsRenderContext::setPainter(), QgsRenderContext::setRasterScaleFactor(), QgsRenderContext::setRendererScale(), and QgsRenderContext::setScaleFactor().

Referenced by QgsAnnotationItem::drawMarkerSymbol().

QPointF QgsMapCanvasItem::toCanvasCoordinates ( const QgsPoint point)
QgsPoint QgsMapCanvasItem::toMapCoordinates ( const QPoint &  point)

transformation from screen coordinates to map coordinates

Definition at line 53 of file qgsmapcanvasitem.cpp.

References QgsMapCanvas::getCoordinateTransform(), mMapCanvas, mPanningOffset, and QgsMapToPixel::toMapCoordinates().

Referenced by QgsAnnotationItem::setMapPositionFixed(), and QgsAnnotationItem::updatePosition().

void QgsMapCanvasItem::updateCanvas ( )
protected

schedules map canvas for repaint

Definition at line 102 of file qgsmapcanvasitem.cpp.

void QgsMapCanvasItem::updatePosition ( )
virtual

called on changed extent or resize event to update position of the item

Reimplemented in QgsVertexMarker, and QgsAnnotationItem.

Definition at line 126 of file qgsmapcanvasitem.cpp.

References mRect, and setRect().

Referenced by QgsMapCanvas::updateCanvasItemPositions().

Member Data Documentation

QSizeF QgsMapCanvasItem::mItemSize
protected

cached size of the item (to return in boundingRect())

Definition at line 94 of file qgsmapcanvasitem.h.

Referenced by boundingRect(), and setRect().

QgsMapCanvas* QgsMapCanvasItem::mMapCanvas
protected
QPoint QgsMapCanvasItem::mPanningOffset
protected

offset from normal position due current panning operation, used when converting map coordinates to move map canvas items

Definition at line 91 of file qgsmapcanvasitem.h.

Referenced by setPanningOffset(), toCanvasCoordinates(), and toMapCoordinates().

QgsRectangle QgsMapCanvasItem::mRect
protected

canvas item rectangle (in map coordinates)

Definition at line 87 of file qgsmapcanvasitem.h.

Referenced by rect(), setRect(), and updatePosition().


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