1
/***************************************************************************
2
qgsbardiagramfactory.h - description
5
copyright : (C) 2007 by Marco Hugentobler
6
email : marco dot hugentobler at karto dot baug dot ethz dot ch
7
***************************************************************************/
9
/***************************************************************************
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. *
16
***************************************************************************/
18
#ifndef QGSBARDIAGRAMFACTORY_H
19
#define QGSBARDIAGRAMFACTORY_H
21
#include "qgswkndiagramfactory.h"
23
/**A class that creates bar diagrams*/
24
class QgsBarDiagramFactory: public QgsWKNDiagramFactory
27
QgsBarDiagramFactory();
28
~QgsBarDiagramFactory();
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;
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
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;
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;}
48
/**Writes bar with into the project file*/
49
bool _writeXML( QDomNode& factory_node, QDomDocument& doc ) const;
53
/**width of one bar (default 5 mm)*/
57
/**Calculates the maximum height of the bar chart (based on size for the
59
int getMaximumHeight( int size, const QgsAttributeMap& featureAttributes ) const;
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;