1
/***************************************************************************
5
copyright : (C) 2005 by Radim Blazek
6
email : radim.blazek@gmail.com
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
***************************************************************************/
17
#ifndef QGSCOMPOSERPICTURE_H
18
#define QGSCOMPOSERPICTURE_H
20
#include "qgscomposeritem.h"
24
/** \ingroup MapComposer
25
* A composer class that displays svg files or raster format (jpg, png, ...)
27
class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
31
QgsComposerPicture( QgsComposition *composition );
32
~QgsComposerPicture();
34
/**Reimplementation of QCanvasItem::paint*/
35
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
37
/**Sets the source file of the image (may be svg or a raster format)*/
38
void setPictureFile( const QString& path );
39
QString pictureFile() const;
41
/**Sets this items bound in scene coordinates such that 1 item size units
42
corresponds to 1 scene size unit and resizes the svg symbol / image*/
43
void setSceneRect( const QRectF& rectangle );
45
/** stores state in Dom node
46
* @param node is Dom node corresponding to 'Composer' tag
47
* @param temp write template file
49
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
51
/** sets state from Dom document
52
* @param itemElem is Dom node corresponding to item tag
54
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
56
/**Sets the map object for rotation (by id). A value of -1 disables the map rotation*/
57
void setRotationMap( int composerMapId );
58
/**Returns the id of the rotation map*/
59
int rotationMap() const;
60
/**True if the rotation is taken from a map item*/
61
bool useRotationMap() const {return mRotationMap;}
64
/**Sets the rotation and adapts the item rect*/
65
virtual void setRotation( double r );
69
enum Mode //SVG or raster graphic format
76
//default constructor is forbidden
78
/**Calculates bounding rect for svg file (mSourcefile) such that aspect ratio is correct*/
79
QRectF boundedSVGRect( double deviceWidth, double deviceHeight );
80
/**Calculates bounding rect for image such that aspect ratio is correct*/
81
QRectF boundedImageRect( double deviceWidth, double deviceHeight );
83
/**Updates content of mImage using svg generator
84
@param out: boundWidth width of mImage that is used by the svg renderer. May different from mImage.width() to preserve aspect ratio
85
@param out: boundHeight height of mImage that is used by the svg renderer*/
86
void updateImageFromSvg();
92
/**False if image needs to be rendered from svg*/
93
bool mSvgCacheUpToDate;
94
int mCachedDpi; //store dpis for which the svg cache is valid
95
double mCachedRotation; //store last rotation value to generate new pixmap from svg on change
96
double mCachedViewScaleFactor;
98
QSize mDefaultSvgSize;
99
/**Map that sets the rotation (or 0 if this picture uses map independent rotation)*/
100
const QgsComposerMap* mRotationMap;
101
/**Width of the picture (in mm)*/
102
double mPictureWidth;
103
/**Height of the picture (in mm)*/
104
double mPictureHeight;
107
/**Tell the configuration widget that the settings need to be updated*/
108
void settingsChanged();