#include <qgscomposerpicture.h>
Public Slots | |
virtual void | setRotation (double r) |
Sets the rotation and adapts the item rect. | |
Signals | |
void | settingsChanged () |
Tell the configuration widget that the settings need to be updated. | |
Public Member Functions | |
QgsComposerPicture (QgsComposition *composition) | |
~QgsComposerPicture () | |
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. | |
void | updateImageFromSvg () |
Updates content of mImage using svg generator. | |
Private Attributes | |
QImage | mImage |
QFile | mSourceFile |
Mode | mMode |
bool | mSvgCacheUpToDate |
False if image needs to be rendered from svg. | |
int | mCachedDpi |
double | mCachedRotation |
double | mCachedViewScaleFactor |
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). |
..)
Definition at line 27 of file qgscomposerpicture.h.
enum QgsComposerPicture::Mode [private] |
QgsComposerPicture::QgsComposerPicture | ( | QgsComposition * | composition | ) |
QgsComposerPicture::~QgsComposerPicture | ( | ) |
Definition at line 41 of file qgscomposerpicture.cpp.
QgsComposerPicture::QgsComposerPicture | ( | ) | [private] |
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(), QgsComposerItem::horizontalViewScaleFactor(), mCachedDpi, mCachedRotation, mCachedViewScaleFactor, QgsComposerItem::mComposition, mImage, MathUtils::min(), mMode, mPictureHeight, mPictureWidth, QgsComposerItem::mRotation, mSvgCacheUpToDate, QgsComposition::plotStyle(), QgsComposition::Preview, RASTER, SVG, Unknown, and updateImageFromSvg().
void QgsComposerPicture::setPictureFile | ( | const QString & | path | ) |
Sets the source file of the image (may be svg or a raster format).
Definition at line 119 of file qgscomposerpicture.cpp.
References mDefaultSvgSize, mImage, mMode, mSourceFile, mSvgCacheUpToDate, RASTER, setSceneRect(), settingsChanged(), SVG, and Unknown.
Referenced by readXML().
QString QgsComposerPicture::pictureFile | ( | ) | const |
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 232 of file qgscomposerpicture.cpp.
References QgsComposerItem::imageSizeConsideringRotation(), mPictureHeight, mPictureWidth, mSvgCacheUpToDate, QgsComposerItem::setSceneRect(), and settingsChanged().
Referenced by QgsComposerView::mousePressEvent(), and setPictureFile().
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 295 of file qgscomposerpicture.cpp.
References QgsComposerItem::_writeXML(), QgsComposerMap::id(), QgsProject::instance(), mPictureHeight, mPictureWidth, mRotationMap, and 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 319 of file qgscomposerpicture.cpp.
References QgsComposerItem::_readXML(), QgsComposition::getComposerMapById(), QgsProject::instance(), mCachedDpi, QgsComposerItem::mComposition, mDefaultSvgSize, mPictureHeight, mPictureWidth, mRotationMap, mSvgCacheUpToDate, QgsProject::readPath(), QgsComposerItem::rotationChanged(), setPictureFile(), and setRotation().
void QgsComposerPicture::setRotationMap | ( | int | composerMapId | ) |
Sets the map object for rotation (by id).
A value of -1 disables the map rotation
Definition at line 262 of file qgscomposerpicture.cpp.
References QgsComposition::getComposerMapById(), QgsComposerItem::mComposition, QgsComposerItem::mRotation, mRotationMap, QgsComposerItem::rotation(), QgsComposerItem::rotationChanged(), and setRotation().
int QgsComposerPicture::rotationMap | ( | ) | const |
Returns the id of the rotation map.
Definition at line 363 of file qgscomposerpicture.cpp.
References QgsComposerMap::id(), and mRotationMap.
bool QgsComposerPicture::useRotationMap | ( | ) | const [inline] |
void QgsComposerPicture::setRotation | ( | double | r | ) | [virtual, slot] |
Sets the rotation and adapts the item rect.
Reimplemented from QgsComposerItem.
Definition at line 247 of file qgscomposerpicture.cpp.
References mPictureHeight, mPictureWidth, QgsComposerItem::setRotation(), QgsComposerItem::setSceneRect(), and QgsComposerItem::sizeChangedByRotation().
Referenced by readXML(), and setRotationMap().
QRectF QgsComposerPicture::boundedSVGRect | ( | double | deviceWidth, | |
double | deviceHeight | |||
) | [private] |
Calculates bounding rect for svg file (mSourcefile) such that aspect ratio is correct.
Definition at line 184 of file qgscomposerpicture.cpp.
References mDefaultSvgSize.
Referenced by paint().
QRectF QgsComposerPicture::boundedImageRect | ( | double | deviceWidth, | |
double | deviceHeight | |||
) | [private] |
Calculates bounding rect for image such that aspect ratio is correct.
Definition at line 167 of file qgscomposerpicture.cpp.
References mImage.
Referenced by paint().
void QgsComposerPicture::updateImageFromSvg | ( | ) | [private] |
Updates content of mImage using svg generator.
Definition at line 220 of file qgscomposerpicture.cpp.
References mImage, mSourceFile, and mSvgCacheUpToDate.
Referenced by paint().
void QgsComposerPicture::settingsChanged | ( | ) | [signal] |
Tell the configuration widget that the settings need to be updated.
Referenced by setPictureFile(), and setSceneRect().
QImage QgsComposerPicture::mImage [private] |
Definition at line 88 of file qgscomposerpicture.h.
Referenced by boundedImageRect(), paint(), setPictureFile(), and updateImageFromSvg().
QFile QgsComposerPicture::mSourceFile [private] |
Definition at line 89 of file qgscomposerpicture.h.
Referenced by pictureFile(), setPictureFile(), updateImageFromSvg(), and writeXML().
Mode QgsComposerPicture::mMode [private] |
bool QgsComposerPicture::mSvgCacheUpToDate [private] |
False if image needs to be rendered from svg.
Definition at line 92 of file qgscomposerpicture.h.
Referenced by paint(), readXML(), setPictureFile(), setSceneRect(), and updateImageFromSvg().
int QgsComposerPicture::mCachedDpi [private] |
double QgsComposerPicture::mCachedRotation [private] |
double QgsComposerPicture::mCachedViewScaleFactor [private] |
QSize QgsComposerPicture::mDefaultSvgSize [private] |
Definition at line 97 of file qgscomposerpicture.h.
Referenced by boundedSVGRect(), readXML(), and setPictureFile().
const QgsComposerMap* QgsComposerPicture::mRotationMap [private] |
Map that sets the rotation (or 0 if this picture uses map independent rotation).
Definition at line 99 of file qgscomposerpicture.h.
Referenced by readXML(), rotationMap(), setRotationMap(), and writeXML().
double QgsComposerPicture::mPictureWidth [private] |
Width of the picture (in mm).
Definition at line 101 of file qgscomposerpicture.h.
Referenced by paint(), QgsComposerPicture(), readXML(), setRotation(), setSceneRect(), and writeXML().
double QgsComposerPicture::mPictureHeight [private] |
Height of the picture (in mm).
Definition at line 103 of file qgscomposerpicture.h.
Referenced by paint(), QgsComposerPicture(), readXML(), setRotation(), setSceneRect(), and writeXML().