QGIS API Documentation  2.2.0-Valmiera
 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 : [email protected]
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