Quantum GIS API Documentation  1.7.4
Public Slots | Public Member Functions | Private Types | Private Member Functions | Private Attributes
QgsComposerPicture Class Reference

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

#include <qgscomposerpicture.h>

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

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 ()
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 QgsComposerMapmRotationMap
 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)

Detailed Description

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

Definition at line 28 of file qgscomposerpicture.h.


Member Enumeration Documentation

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

Definition at line 74 of file qgscomposerpicture.h.


Constructor & Destructor Documentation

Definition at line 30 of file qgscomposerpicture.cpp.

References mPictureWidth.

Definition at line 42 of file qgscomposerpicture.cpp.

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 147 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 164 of file qgscomposerpicture.cpp.

References mDefaultSvgSize.

Referenced by paint().

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

Definition at line 257 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 329 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 100 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 214 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 229 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 200 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

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

Implements QgsComposerItem.

Definition at line 262 of file qgscomposerpicture.cpp.

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


Member Data Documentation

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

Definition at line 92 of file qgscomposerpicture.h.

Referenced by paint(), and setPictureFile().

Height of the picture (in mm)

Definition at line 100 of file qgscomposerpicture.h.

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

Width of the picture (in mm)

Definition at line 98 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 96 of file qgscomposerpicture.h.

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

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


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