QGIS API Documentation  master-3f58142
QgsComposerPicture Class Reference

A composer class that displays svg files or raster format (jpg, png, ...) More...

#include <qgscomposerpicture.h>

+ Inheritance diagram for QgsComposerPicture:
+ Collaboration diagram for QgsComposerPicture:

List of all members.

Public Slots

virtual void setRotation (double r)
 Sets the rotation and adapts the item rect.

Public Member Functions

 QgsComposerPicture (QgsComposition *composition)
 ~QgsComposerPicture ()
void paint (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
 Reimplementation of QCanvasItem::paint.
QString pictureFile () const
bool readXML (const QDomElement &itemElem, const QDomDocument &doc)
 sets state from Dom document
int rotationMap () const
 Returns the id of the rotation map.
void setPictureFile (const QString &path)
 Sets the source file of the image (may be svg or a raster format)
void setRotationMap (int composerMapId)
 Sets the map object for rotation (by id).
void setSceneRect (const QRectF &rectangle)
 Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size unit and resizes the svg symbol / image.
virtual int type () const
 return correct graphics item type.
bool useRotationMap () const
 True if the rotation is taken from a map item.
bool writeXML (QDomElement &elem, QDomDocument &doc) const
 stores state in Dom element

Private Types

enum  Mode { SVG, RASTER, Unknown }

Private Member Functions

 QgsComposerPicture ()
QRectF boundedImageRect (double deviceWidth, double deviceHeight)
 Calculates bounding rect for image such that aspect ratio is correct.
QRectF boundedSVGRect (double deviceWidth, double deviceHeight)
 Calculates bounding rect for svg file (mSourcefile) such that aspect ratio is correct.

Private Attributes

QSize mDefaultSvgSize
QImage mImage
Mode mMode
double mPictureHeight
 Height of the picture (in mm)
double mPictureWidth
 Width of the picture (in mm)
const QgsComposerMapmRotationMap
 Map that sets the rotation (or 0 if this picture uses map independent rotation)
QFile mSourceFile
QSvgRenderer mSVG

Detailed Description

A composer class that displays svg files or raster format (jpg, png, ...)

Definition at line 30 of file qgscomposerpicture.h.


Member Enumeration Documentation

enum QgsComposerPicture::Mode [private]
Enumerator:
SVG 
RASTER 
Unknown 

Definition at line 76 of file qgscomposerpicture.h.


Constructor & Destructor Documentation

Definition at line 30 of file qgscomposerpicture.cpp.

References mPictureWidth.

Definition at line 36 of file qgscomposerpicture.cpp.

References mPictureHeight.


Member Function Documentation

QRectF QgsComposerPicture::boundedImageRect ( double  deviceWidth,
double  deviceHeight 
) [private]

Calculates bounding rect for image such that aspect ratio is correct.

Definition at line 149 of file qgscomposerpicture.cpp.

References mImage.

Referenced by paint().

QRectF QgsComposerPicture::boundedSVGRect ( double  deviceWidth,
double  deviceHeight 
) [private]

Calculates bounding rect for svg file (mSourcefile) such that aspect ratio is correct.

Definition at line 166 of file qgscomposerpicture.cpp.

References mDefaultSvgSize.

Referenced by paint().

void QgsComposerPicture::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  itemStyle,
QWidget *  pWidget 
)

Definition at line 259 of file qgscomposerpicture.cpp.

References mSourceFile.

bool QgsComposerPicture::readXML ( const QDomElement &  itemElem,
const QDomDocument &  doc 
) [virtual]

Returns the id of the rotation map.

Definition at line 331 of file qgscomposerpicture.cpp.

References QgsComposerMap::id(), and mRotationMap.

void QgsComposerPicture::setPictureFile ( const QString &  path)

Sets the source file of the image (may be svg or a raster format)

Definition at line 102 of file qgscomposerpicture.cpp.

References QgsComposerItem::itemChanged(), mDefaultSvgSize, mImage, mMode, mSourceFile, mSVG, RASTER, setSceneRect(), SVG, and Unknown.

Referenced by readXML().

void QgsComposerPicture::setRotation ( double  r) [virtual, slot]

Sets the rotation and adapts the item rect.

Reimplemented from QgsComposerItem.

Definition at line 216 of file qgscomposerpicture.cpp.

References mPictureHeight, mPictureWidth, setSceneRect(), and QgsComposerItem::sizeChangedByRotation().

Referenced by readXML(), and setRotationMap().

void QgsComposerPicture::setRotationMap ( int  composerMapId)

Sets the map object for rotation (by id).

A value of -1 disables the map rotation

Definition at line 231 of file qgscomposerpicture.cpp.

References QgsComposition::getComposerMapById(), QgsComposerItem::mComposition, QgsComposerItem::mRotation, mRotationMap, QgsComposerItem::rotation(), QgsComposerItem::rotationChanged(), and setRotation().

void QgsComposerPicture::setSceneRect ( const QRectF &  rectangle) [virtual]

Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size unit and resizes the svg symbol / image.

Reimplemented from QgsComposerItem.

Definition at line 202 of file qgscomposerpicture.cpp.

References QgsComposerItem::imageSizeConsideringRotation(), QgsComposerItem::itemChanged(), mPictureHeight, and mPictureWidth.

Referenced by QgsComposerView::mousePressEvent(), setPictureFile(), and setRotation().

virtual int QgsComposerPicture::type ( ) const [inline, virtual]

return correct graphics item type.

Added in v1.7

Reimplemented from QgsComposerItem.

Definition at line 38 of file qgscomposerpicture.h.

References QgsComposerItem::ComposerPicture.

bool QgsComposerPicture::useRotationMap ( ) const [inline]

True if the rotation is taken from a map item.

Definition at line 68 of file qgscomposerpicture.h.

bool QgsComposerPicture::writeXML ( QDomElement &  elem,
QDomDocument &  doc 
) const [virtual]

stores state in Dom element

Parameters:
elemis Dom element corresponding to 'Composer' tag
docis Dom document

Implements QgsComposerItem.

Definition at line 264 of file qgscomposerpicture.cpp.

References QgsComposerItem::_writeXML(), QgsComposerMap::id(), QgsProject::instance(), mPictureHeight, mPictureWidth, mRotationMap, and mSourceFile.


Member Data Documentation

Definition at line 96 of file qgscomposerpicture.h.

Referenced by boundedSVGRect(), readXML(), and setPictureFile().

QImage QgsComposerPicture::mImage [private]

Definition at line 91 of file qgscomposerpicture.h.

Referenced by boundedImageRect(), paint(), and setPictureFile().

Definition at line 94 of file qgscomposerpicture.h.

Referenced by paint(), and setPictureFile().

Height of the picture (in mm)

Definition at line 102 of file qgscomposerpicture.h.

Referenced by paint(), QgsComposerPicture(), readXML(), setRotation(), setSceneRect(), and writeXML().

Width of the picture (in mm)

Definition at line 100 of file qgscomposerpicture.h.

Referenced by paint(), QgsComposerPicture(), readXML(), setRotation(), setSceneRect(), and writeXML().

Map that sets the rotation (or 0 if this picture uses map independent rotation)

Definition at line 98 of file qgscomposerpicture.h.

Referenced by readXML(), rotationMap(), setRotationMap(), and writeXML().

Definition at line 93 of file qgscomposerpicture.h.

Referenced by pictureFile(), setPictureFile(), and writeXML().

QSvgRenderer QgsComposerPicture::mSVG [private]

Definition at line 92 of file qgscomposerpicture.h.

Referenced by paint(), and setPictureFile().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines