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

« back to all changes in this revision

Viewing changes to src/plugins/diagram_overlay/qgspiediagramfactory.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
                         qgspiediagramfactory.h  -  description
 
3
                         ----------------------
 
4
    begin                : December 2007
 
5
    copyright            : (C) 2007 by Marco Hugentobler
 
6
    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
 
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
 
 
18
#ifndef QGSPIEDIAGRAMFACTORY_H
 
19
#define QGSPIEDIAGRAMFACTORY_H
 
20
 
 
21
#include "qgswkndiagramfactory.h"
 
22
#include <QPainter>
 
23
#include <cmath>
 
24
 
 
25
/**A class that creates pie charts*/
 
26
 
 
27
class QgsPieDiagramFactory: public QgsWKNDiagramFactory
 
28
{
 
29
  public:
 
30
    QgsPieDiagramFactory();
 
31
    ~QgsPieDiagramFactory();
 
32
 
 
33
    /**Creates a diagram for a feature and a given size. The size is usually determined by QgsDiagramRenderer. The calling method takes ownership of the generated image*/
 
34
    QImage* createDiagram( int size, const QgsFeature& f, const QgsRenderContext& renderContext ) const;
 
35
 
 
36
    /**Creates items to show in the legend*/
 
37
    int createLegendContent( int size, const QgsRenderContext& renderContext, QString value, QMap<QString, QImage*>& items ) const {return 1;} //soon
 
38
 
 
39
    /**Gets the width and height (in pixels) of the diagram image. Considers different width, height values, the maximum width of the drawing pen and the conversion from mm size to pixels according to render context.
 
40
    @param size diagram size calculated by diagram renderer (in mm)
 
41
    @param f reference to the feature associated with the diagram
 
42
    @param the render context (contains mm scale factor and raster scale factor)
 
43
    @param width out: the width of the diagram image in pixels
 
44
    @param height out: the height of the diagram image in pixels*/
 
45
    int getDiagramDimensions( int size, const QgsFeature& f, const QgsRenderContext& context, int& width, int& height ) const;
 
46
 
 
47
    /**Returns the property described by the size (e.g. diameter or height). This can be important to
 
48
     know if e.g. size has to be calculated proportional to pie area*/
 
49
    QgsDiagramFactory::SizeType sizeType() const {return QgsDiagramFactory::DIAMETER;}
 
50
 
 
51
  private:
 
52
    /**Calculates the x- and y-offsets for pie gaps
 
53
       @param gap the gap (in pixels)
 
54
       @param angle azimut of pie slice (mean azimut of both pie angles), 0 - 5760 (degrees * 16) with 0 in 3 o'clock position and counterclockwise direction
 
55
       @param xOffset out offset (in pixel) for x-direction
 
56
       @param yOffset out offset (in pixel) for y-direction
 
57
    @return 0 in case of success*/
 
58
    int gapOffsetsForPieSlice( int gap, int angle, int& xOffset, int& yOffset ) const;
 
59
};
 
60
 
 
61
#endif