~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/core/composer/qgscomposerpicture.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
24
/** \ingroup MapComposer
 
25
 * A composer class that displays svg files or raster format (jpg, png, ...)
 
26
 * */
 
27
class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
 
28
{
 
29
    Q_OBJECT
 
30
  public:
 
31
    QgsComposerPicture( QgsComposition *composition );
 
32
    ~QgsComposerPicture();
 
33
 
 
34
    /**Reimplementation of QCanvasItem::paint*/
 
35
    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
 
36
 
 
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;
 
40
 
 
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 );
 
44
 
 
45
    /** stores state in Dom node
 
46
       * @param node is Dom node corresponding to 'Composer' tag
 
47
       * @param temp write template file
 
48
       */
 
49
    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
 
50
 
 
51
    /** sets state from Dom document
 
52
      * @param itemElem is Dom node corresponding to item tag
 
53
      */
 
54
    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
 
55
 
 
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;}
 
62
 
 
63
  public slots:
 
64
    /**Sets the rotation and adapts the item rect*/
 
65
    virtual void setRotation( double r );
 
66
 
 
67
  private:
 
68
 
 
69
    enum Mode //SVG or raster graphic format
 
70
    {
 
71
      SVG,
 
72
      RASTER,
 
73
      Unknown
 
74
    };
 
75
 
 
76
    //default constructor is forbidden
 
77
    QgsComposerPicture();
 
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 );
 
82
 
 
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();
 
87
 
 
88
 
 
89
    QImage mImage;
 
90
    QFile mSourceFile;
 
91
    Mode mMode;
 
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;
 
97
 
 
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;
 
105
 
 
106
  signals:
 
107
    /**Tell the configuration widget that the settings need to be updated*/
 
108
    void settingsChanged();
 
109
};
 
110
 
 
111
#endif