QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerpicture.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerpicture.h
3  -------------------
4  begin : September 2005
5  copyright : (C) 2005 by Radim Blazek
6  email : radim.blazek@gmail.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
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. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSCOMPOSERPICTURE_H
18 #define QGSCOMPOSERPICTURE_H
19 
20 #include "qgscomposeritem.h"
21 #include <QFile>
22 #include <QImage>
23 #include <QSvgRenderer>
24 
25 class QgsComposerMap;
26 
30 class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
31 {
32  Q_OBJECT
33  public:
34  QgsComposerPicture( QgsComposition *composition );
36 
38  virtual int type() const { return ComposerPicture; }
39 
41  void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
42 
44  void setPictureFile( const QString& path );
45  QString pictureFile() const;
46 
49  void setSceneRect( const QRectF& rectangle );
50 
55  bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
56 
61  bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
62 
66  double rotation() const { return mPictureRotation;};
67 
70  double pictureRotation() const { return mPictureRotation;};
71 
73  void setRotationMap( int composerMapId );
75  int rotationMap() const;
77  bool useRotationMap() const {return mRotationMap;}
78 
83  bool imageSizeConsideringRotation( double& width, double& height ) const;
88  bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const;
93  void sizeChangedByRotation( double& width, double& height );
94 
95  public slots:
100  virtual void setRotation( double r );
101 
105  virtual void setPictureRotation( double r );
106 
107  signals:
109  void pictureRotationChanged( double newRotation );
110 
111  private:
112 
113  enum Mode //SVG or raster graphic format
114  {
118  };
119 
120  //default constructor is forbidden
123  QRectF boundedSVGRect( double deviceWidth, double deviceHeight );
125  QRectF boundedImageRect( double deviceWidth, double deviceHeight );
126 
128  QSizeF pictureSize();
129 
130  QImage mImage;
131  QSvgRenderer mSVG;
132  QFile mSourceFile;
134 
136 
145 };
146 
147 #endif
bool imageSizeConsideringRotation(double &width, double &height, double rotation) const
Calculates width and hight of the picture (in mm) such that it fits into the item frame with the give...
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc)=0
sets state from Dom document
virtual void setRotation(double r)
Sets the item rotation.
A item that forms part of a map composition.
A composer class that displays svg files or raster format (jpg, png, ...)
const QgsComposerMap * mRotationMap
Map that sets the rotation (or 0 if this picture uses map independent rotation)
double mPictureHeight
Height of the picture (in mm)
bool useRotationMap() const
True if the rotation is taken from a map item.
Graphics scene for map printing.
Object representing map window.
bool cornerPointOnRotatedAndScaledRect(double &x, double &y, double width, double height, double rotation) const
Calculates corner point after rotation and scaling.
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
double rotation() const
Returns the rotation used for drawing the picture within the composer item.
double mPictureWidth
Width of the picture (in mm)
double pictureRotation() const
Returns the rotation used for drawing the picture within the item.
double mPictureRotation
Image rotation.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const =0
stores state in Dom element
void sizeChangedByRotation(double &width, double &height, double rotation)
Calculates width / height of the bounding box of a rotated rectangle.
virtual int type() const
return correct graphics item type.