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

« back to all changes in this revision

Viewing changes to src/plugins/diagram_overlay/qgsbardiagramfactory.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
                         qgsbardiagramfactory.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 QGSBARDIAGRAMFACTORY_H
 
19
#define QGSBARDIAGRAMFACTORY_H
 
20
 
 
21
#include "qgswkndiagramfactory.h"
 
22
 
 
23
/**A class that creates bar diagrams*/
 
24
class QgsBarDiagramFactory: public QgsWKNDiagramFactory
 
25
{
 
26
  public:
 
27
    QgsBarDiagramFactory();
 
28
    ~QgsBarDiagramFactory();
 
29
 
 
30
    /**Creates a diagram for a feature and a given size (that is usually determined by QgsDiagramRenderer. The calling method takes ownership of the generated image*/
 
31
    QImage* createDiagram( int size, const QgsFeature& f, const QgsRenderContext& renderContext ) const;
 
32
 
 
33
    /**Creates items to show in the legend*/
 
34
    int createLegendContent( int size, const QgsRenderContext& renderContext, QString value, QMap<QString, QImage*>& items ) const {return 1;} //soon
 
35
 
 
36
    /**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.
 
37
    @param size diagram size calculated by diagram renderer (in mm)
 
38
    @param f reference to the feature associated with the diagram
 
39
    @param the render context (contains mm scale factor and raster scale factor)
 
40
    @param width out: the width of the diagram image in pixels
 
41
    @param height out: the height of the diagram image in pixels*/
 
42
    int getDiagramDimensions( int size, const QgsFeature& f, const QgsRenderContext& context, int& width, int& height ) const;
 
43
 
 
44
    /**Returns the property described by the size (e.g. diameter or height). This can be important to
 
45
    know if e.g. size has to be calculated proportional to pie area*/
 
46
    QgsDiagramFactory::SizeType sizeType() const {return QgsDiagramFactory::HEIGHT;}
 
47
 
 
48
    /**Writes bar with into the project file*/
 
49
    bool _writeXML( QDomNode& factory_node, QDomDocument& doc ) const;
 
50
 
 
51
  private:
 
52
 
 
53
    /**width of one bar (default 5 mm)*/
 
54
    int mBarWidth;
 
55
 
 
56
 
 
57
    /**Calculates the maximum height of the bar chart (based on size for the
 
58
     scaling attribute)*/
 
59
    int getMaximumHeight( int size, const QgsAttributeMap& featureAttributes ) const;
 
60
 
 
61
    /**Calculates the value to size unit ratio for the bar chart (based on the size \
 
62
     of the scaling attribute)
 
63
    @return the ratio or -1 in case of error*/
 
64
    double sizeValueRatioBarChart( int size, const QgsAttributeMap& featureAttributes ) const;
 
65
};
 
66
 
 
67
#endif