Quantum GIS API Documentation
1.8
|
A composer class that displays svg files or raster format (jpg, png, ...) More...
#include <qgscomposerpicture.h>
Public Slots | |
virtual void | setRotation (double r) |
Sets the rotation and adapts the item rect. | |
Public Member Functions | |
QgsComposerPicture (QgsComposition *composition) | |
~QgsComposerPicture () | |
virtual int | type () const |
return correct graphics item type. | |
void | paint (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) |
Reimplementation of QCanvasItem::paint. | |
void | setPictureFile (const QString &path) |
Sets the source file of the image (may be svg or a raster format) | |
QString | pictureFile () const |
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. | |
bool | writeXML (QDomElement &elem, QDomDocument &doc) const |
stores state in Dom element | |
bool | readXML (const QDomElement &itemElem, const QDomDocument &doc) |
sets state from Dom document | |
void | setRotationMap (int composerMapId) |
Sets the map object for rotation (by id). | |
int | rotationMap () const |
Returns the id of the rotation map. | |
bool | useRotationMap () const |
True if the rotation is taken from a map item. | |
Private Types | |
enum | Mode { SVG, RASTER, Unknown } |
Private Member Functions | |
QgsComposerPicture () | |
QRectF | boundedSVGRect (double deviceWidth, double deviceHeight) |
Calculates bounding rect for svg file (mSourcefile) such that aspect ratio is correct. | |
QRectF | boundedImageRect (double deviceWidth, double deviceHeight) |
Calculates bounding rect for image such that aspect ratio is correct. | |
Private Attributes | |
QImage | mImage |
QSvgRenderer | mSVG |
QFile | mSourceFile |
Mode | mMode |
QSize | mDefaultSvgSize |
const QgsComposerMap * | mRotationMap |
Map that sets the rotation (or 0 if this picture uses map independent rotation) | |
double | mPictureWidth |
Width of the picture (in mm) | |
double | mPictureHeight |
Height of the picture (in mm) |
A composer class that displays svg files or raster format (jpg, png, ...)
Definition at line 28 of file qgscomposerpicture.h.
enum QgsComposerPicture::Mode [private] |
Definition at line 74 of file qgscomposerpicture.h.
QgsComposerPicture::QgsComposerPicture | ( | QgsComposition * | composition | ) |
Definition at line 29 of file qgscomposerpicture.cpp.
References mPictureWidth.
Definition at line 41 of file qgscomposerpicture.cpp.
QgsComposerPicture::QgsComposerPicture | ( | ) | [private] |
Definition at line 35 of file qgscomposerpicture.cpp.
References mPictureHeight.
QRectF QgsComposerPicture::boundedImageRect | ( | double | deviceWidth, |
double | deviceHeight | ||
) | [private] |
Calculates bounding rect for image such that aspect ratio is correct.
Definition at line 148 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 165 of file qgscomposerpicture.cpp.
References mDefaultSvgSize.
Referenced by paint().
void QgsComposerPicture::paint | ( | QPainter * | painter, |
const QStyleOptionGraphicsItem * | itemStyle, | ||
QWidget * | pWidget | ||
) |
Reimplementation of QCanvasItem::paint.
Definition at line 46 of file qgscomposerpicture.cpp.
References boundedImageRect(), boundedSVGRect(), QgsComposerItem::drawBackground(), QgsComposerItem::drawFrame(), QgsComposerItem::drawSelectionBoxes(), mImage, mMode, mPictureHeight, mPictureWidth, QgsComposerItem::mRotation, mSVG, RASTER, SVG, and Unknown.
QString QgsComposerPicture::pictureFile | ( | ) | const |
Definition at line 258 of file qgscomposerpicture.cpp.
References mSourceFile.
bool QgsComposerPicture::readXML | ( | const QDomElement & | itemElem, |
const QDomDocument & | doc | ||
) | [virtual] |
sets state from Dom document
itemElem | is Dom node corresponding to item tag |
doc | is Dom document |
Implements QgsComposerItem.
Definition at line 287 of file qgscomposerpicture.cpp.
References QgsComposerItem::_readXML(), QgsComposition::getComposerMapById(), QgsProject::instance(), QgsComposerItem::itemChanged(), QgsComposerItem::mComposition, mDefaultSvgSize, mPictureHeight, mPictureWidth, mRotationMap, QgsProject::readPath(), QgsComposerItem::rotationChanged(), setPictureFile(), and setRotation().
Referenced by QgsComposition::addItemsFromXML().
int QgsComposerPicture::rotationMap | ( | ) | const |
Returns the id of the rotation map.
Definition at line 330 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 101 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 215 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 230 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 201 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 36 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 66 of file qgscomposerpicture.h.
bool QgsComposerPicture::writeXML | ( | QDomElement & | elem, |
QDomDocument & | doc | ||
) | const [virtual] |
stores state in Dom element
elem | is Dom element corresponding to 'Composer' tag |
doc | is Dom document |
Implements QgsComposerItem.
Definition at line 263 of file qgscomposerpicture.cpp.
References QgsComposerItem::_writeXML(), QgsComposerMap::id(), QgsProject::instance(), mPictureHeight, mPictureWidth, mRotationMap, and mSourceFile.
QSize QgsComposerPicture::mDefaultSvgSize [private] |
Definition at line 94 of file qgscomposerpicture.h.
Referenced by boundedSVGRect(), readXML(), and setPictureFile().
QImage QgsComposerPicture::mImage [private] |
Definition at line 89 of file qgscomposerpicture.h.
Referenced by boundedImageRect(), paint(), and setPictureFile().
Mode QgsComposerPicture::mMode [private] |
Definition at line 92 of file qgscomposerpicture.h.
Referenced by paint(), and setPictureFile().
double QgsComposerPicture::mPictureHeight [private] |
Height of the picture (in mm)
Definition at line 100 of file qgscomposerpicture.h.
Referenced by paint(), QgsComposerPicture(), readXML(), setRotation(), setSceneRect(), and writeXML().
double QgsComposerPicture::mPictureWidth [private] |
Width of the picture (in mm)
Definition at line 98 of file qgscomposerpicture.h.
Referenced by paint(), QgsComposerPicture(), readXML(), setRotation(), setSceneRect(), and writeXML().
const QgsComposerMap* QgsComposerPicture::mRotationMap [private] |
Map that sets the rotation (or 0 if this picture uses map independent rotation)
Definition at line 96 of file qgscomposerpicture.h.
Referenced by readXML(), rotationMap(), setRotationMap(), and writeXML().
QFile QgsComposerPicture::mSourceFile [private] |
Definition at line 91 of file qgscomposerpicture.h.
Referenced by pictureFile(), setPictureFile(), and writeXML().
QSvgRenderer QgsComposerPicture::mSVG [private] |
Definition at line 90 of file qgscomposerpicture.h.
Referenced by paint(), and setPictureFile().