2011-03-15 16:43:23 +00:00
|
|
|
struct QgsDiagramLayerSettings
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsdiagramrendererv2.h>
|
|
|
|
%End
|
2014-05-27 23:22:50 +02:00
|
|
|
public:
|
2012-09-21 21:01:11 +02:00
|
|
|
//avoid inclusion of QgsPalLabeling
|
|
|
|
enum Placement
|
|
|
|
{
|
|
|
|
AroundPoint, // Point / Polygon
|
|
|
|
OverPoint, // Point / Polygon
|
|
|
|
Line, // Line / Polygon
|
|
|
|
Curved, // Line
|
|
|
|
Horizontal, // Polygon
|
|
|
|
Free // Polygon
|
|
|
|
};
|
|
|
|
|
|
|
|
enum LinePlacementFlags
|
|
|
|
{
|
2014-06-02 21:00:51 +02:00
|
|
|
OnLine,
|
|
|
|
AboveLine,
|
|
|
|
BelowLine,
|
|
|
|
MapOrientation,
|
2012-09-21 21:01:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
QgsDiagramLayerSettings();
|
|
|
|
|
2013-12-05 18:27:45 +07:00
|
|
|
~QgsDiagramLayerSettings();
|
|
|
|
|
2012-09-21 21:01:11 +02:00
|
|
|
//pal placement properties
|
|
|
|
Placement placement;
|
2015-04-22 18:03:24 +10:00
|
|
|
unsigned int placementFlags;
|
2012-09-21 21:01:11 +02:00
|
|
|
int priority; // 0 = low, 10 = high
|
|
|
|
bool obstacle; // whether it's an obstacle
|
|
|
|
double dist; // distance from the feature (in mm)
|
2014-05-27 23:22:50 +02:00
|
|
|
QgsDiagramRendererV2* renderer; // if any renderer is assigned, it is owned by this class
|
2016-01-04 22:51:18 +11:00
|
|
|
|
|
|
|
//assigned when layer gets prepared
|
|
|
|
const QgsCoordinateTransform* ct;
|
|
|
|
const QgsMapToPixel* xform;
|
|
|
|
QgsFields fields;
|
|
|
|
|
2012-09-21 21:01:11 +02:00
|
|
|
int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
|
|
|
|
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)
|
2015-04-09 17:50:53 +10:00
|
|
|
bool showAll;
|
2011-03-15 16:43:23 +00:00
|
|
|
|
2013-05-28 12:03:40 +02:00
|
|
|
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
|
|
|
|
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
|
2011-03-15 16:43:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//diagram settings for rendering
|
2012-09-21 21:01:11 +02:00
|
|
|
class QgsDiagramSettings
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsdiagramrendererv2.h>
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
enum SizeType
|
|
|
|
{
|
|
|
|
MM,
|
|
|
|
MapUnits
|
|
|
|
};
|
|
|
|
|
|
|
|
enum LabelPlacementMethod
|
|
|
|
{
|
|
|
|
Height,
|
|
|
|
XHeight
|
|
|
|
};
|
|
|
|
|
|
|
|
//! Orientation of histogram
|
|
|
|
enum DiagramOrientation
|
|
|
|
{
|
|
|
|
Up,
|
|
|
|
Down,
|
|
|
|
Left,
|
|
|
|
Right
|
|
|
|
};
|
|
|
|
|
|
|
|
QgsDiagramSettings();
|
2015-04-09 17:50:29 +10:00
|
|
|
bool enabled;
|
2012-09-21 21:01:11 +02:00
|
|
|
QFont font;
|
|
|
|
QList< QColor > categoryColors;
|
2013-12-05 14:54:09 +01:00
|
|
|
QList< QString > categoryAttributes;
|
2015-05-04 10:44:27 +10:00
|
|
|
//! @note added in 2.10
|
|
|
|
QList< QString > categoryLabels;
|
2012-09-21 21:01:11 +02:00
|
|
|
QSizeF size; //size
|
|
|
|
SizeType sizeType; //mm or map units
|
|
|
|
QColor backgroundColor;
|
|
|
|
QColor penColor;
|
|
|
|
double penWidth;
|
|
|
|
LabelPlacementMethod labelPlacementMethod;
|
|
|
|
DiagramOrientation diagramOrientation;
|
|
|
|
double barWidth;
|
|
|
|
int transparency; // 0 - 100
|
|
|
|
bool scaleByArea;
|
2014-01-26 18:35:21 +01:00
|
|
|
int angleOffset;
|
2012-09-21 21:01:11 +02:00
|
|
|
|
2015-04-22 18:03:32 +10:00
|
|
|
bool scaleBasedVisibility;
|
2012-09-21 21:01:11 +02:00
|
|
|
//scale range (-1 if no lower / upper bound )
|
|
|
|
double minScaleDenominator;
|
|
|
|
double maxScaleDenominator;
|
|
|
|
|
|
|
|
//! Scale diagrams smaller than mMinimumSize to mMinimumSize
|
|
|
|
double minimumSize;
|
|
|
|
|
2013-05-28 12:03:40 +02:00
|
|
|
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
|
|
|
|
void writeXML( QDomElement& rendererElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
|
2015-05-04 10:44:27 +10:00
|
|
|
|
|
|
|
/** Returns list of legend nodes for the diagram
|
|
|
|
* @note caller is responsible for deletion of QgsLayerTreeModelLegendNodes
|
|
|
|
* @note added in 2.10
|
|
|
|
*/
|
|
|
|
QList< QgsLayerTreeModelLegendNode* > legendItems( QgsLayerTreeLayer* nodeLayer ) const /Factory/;
|
2012-09-21 21:01:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//additional diagram settings for interpolated size rendering
|
|
|
|
class QgsDiagramInterpolationSettings
|
2011-03-15 16:43:23 +00:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsdiagramrendererv2.h>
|
|
|
|
%End
|
2012-09-21 21:01:11 +02:00
|
|
|
public:
|
|
|
|
QSizeF lowerSize;
|
|
|
|
QSizeF upperSize;
|
|
|
|
double lowerValue;
|
|
|
|
double upperValue;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Index of the classification attribute*/
|
2012-09-21 21:01:11 +02:00
|
|
|
int classificationAttribute;
|
2014-01-26 18:35:21 +01:00
|
|
|
QString classificationAttributeExpression;
|
|
|
|
bool classificationAttributeIsExpression;
|
2011-03-15 16:43:23 +00:00
|
|
|
};
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns diagram settings for a feature*/
|
2011-03-15 16:43:23 +00:00
|
|
|
class QgsDiagramRendererV2
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsdiagramrendererv2.h>
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
|
|
|
QgsDiagramRendererV2();
|
|
|
|
virtual ~QgsDiagramRendererV2();
|
|
|
|
|
2013-12-05 18:27:45 +07:00
|
|
|
/** Returns new instance that is equivalent to this one
|
2014-02-21 17:33:09 +07:00
|
|
|
* @note added in 2.4 */
|
2015-11-12 19:35:14 +11:00
|
|
|
virtual QgsDiagramRendererV2* clone() const = 0 /Factory/;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns size of the diagram for a feature in map units. Returns an invalid QSizeF in case of error*/
|
2013-12-05 14:54:09 +01:00
|
|
|
virtual QSizeF sizeMapUnits( const QgsFeature& feature, const QgsRenderContext& c );
|
2011-03-15 16:43:23 +00:00
|
|
|
|
|
|
|
virtual QString rendererName() const = 0;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns attribute indices needed for diagram rendering*/
|
2013-12-05 14:54:09 +01:00
|
|
|
virtual QList<QString> diagramAttributes() const = 0;
|
2011-03-15 16:43:23 +00:00
|
|
|
|
2013-12-05 14:54:09 +01:00
|
|
|
void renderDiagram( const QgsFeature& feature, QgsRenderContext& c, const QPointF& pos );
|
2011-03-15 16:43:23 +00:00
|
|
|
|
2013-02-28 09:01:24 +01:00
|
|
|
void setDiagram( QgsDiagram* d /Transfer/ );
|
2014-05-27 23:22:50 +02:00
|
|
|
QgsDiagram* diagram() const;
|
2011-03-15 16:43:23 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns list with all diagram settings in the renderer*/
|
2011-03-15 16:43:23 +00:00
|
|
|
virtual QList<QgsDiagramSettings> diagramSettings() const = 0;
|
|
|
|
|
2013-05-28 12:03:40 +02:00
|
|
|
virtual void readXML( const QDomElement& elem, const QgsVectorLayer* layer ) = 0;
|
|
|
|
virtual void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const = 0;
|
2012-09-21 21:01:11 +02:00
|
|
|
|
2015-05-04 10:44:27 +10:00
|
|
|
/** Returns list of legend nodes for the diagram
|
|
|
|
* @note caller is responsible for deletion of QgsLayerTreeModelLegendNodes
|
|
|
|
* @note added in 2.10
|
|
|
|
*/
|
|
|
|
virtual QList< QgsLayerTreeModelLegendNode* > legendItems( QgsLayerTreeLayer* nodeLayer ) const /Factory/;
|
|
|
|
|
2012-09-21 21:01:11 +02:00
|
|
|
protected:
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns diagram settings for a feature (or false if the diagram for the feature is not to be rendered). Used internally within renderDiagram()
|
2014-01-26 18:35:21 +01:00
|
|
|
* @param feature the feature
|
2012-09-21 21:01:11 +02:00
|
|
|
* @param c render context
|
|
|
|
* @param s out: diagram settings for the feature
|
|
|
|
*/
|
2014-01-26 18:35:21 +01:00
|
|
|
virtual bool diagramSettings( const QgsFeature &feature, const QgsRenderContext& c, QgsDiagramSettings& s ) = 0;
|
2012-09-21 21:01:11 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns size of the diagram (in painter units) or an invalid size in case of error*/
|
2014-01-26 18:35:21 +01:00
|
|
|
virtual QSizeF diagramSize( const QgsFeature& features, const QgsRenderContext& c ) = 0;
|
2012-09-21 21:01:11 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Converts size from mm to map units*/
|
2012-09-21 21:01:11 +02:00
|
|
|
void convertSizeToMapUnits( QSizeF& size, const QgsRenderContext& context ) const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns the paint device dpi (or -1 in case of error*/
|
2012-09-21 21:01:11 +02:00
|
|
|
static int dpiPaintDevice( const QPainter* );
|
|
|
|
|
|
|
|
//read / write diagram
|
2013-05-28 12:03:40 +02:00
|
|
|
void _readXML( const QDomElement& elem, const QgsVectorLayer* layer );
|
|
|
|
void _writeXML( QDomElement& rendererElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
|
2011-03-15 16:43:23 +00:00
|
|
|
};
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Renders the diagrams for all features with the same settings*/
|
2012-09-21 21:01:11 +02:00
|
|
|
class QgsSingleCategoryDiagramRenderer : QgsDiagramRendererV2
|
2011-03-15 16:43:23 +00:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsdiagramrendererv2.h>
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-03-15 16:43:23 +00:00
|
|
|
public:
|
|
|
|
QgsSingleCategoryDiagramRenderer();
|
|
|
|
~QgsSingleCategoryDiagramRenderer();
|
|
|
|
|
2015-11-12 19:35:14 +11:00
|
|
|
virtual QgsSingleCategoryDiagramRenderer* clone() const /Factory/;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2011-03-15 16:43:23 +00:00
|
|
|
QString rendererName() const;
|
|
|
|
|
2013-12-05 14:54:09 +01:00
|
|
|
QList<QString> diagramAttributes() const;
|
2011-03-15 16:43:23 +00:00
|
|
|
|
|
|
|
void setDiagramSettings( const QgsDiagramSettings& s );
|
|
|
|
|
|
|
|
QList<QgsDiagramSettings> diagramSettings() const;
|
|
|
|
|
2013-05-28 12:03:40 +02:00
|
|
|
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
|
|
|
|
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
|
2012-09-21 21:01:11 +02:00
|
|
|
|
2015-05-04 10:44:27 +10:00
|
|
|
virtual QList< QgsLayerTreeModelLegendNode* > legendItems( QgsLayerTreeLayer* nodeLayer ) const /Factory/;
|
|
|
|
|
2012-09-21 21:01:11 +02:00
|
|
|
protected:
|
2014-01-26 18:35:21 +01:00
|
|
|
bool diagramSettings( const QgsFeature &feature, const QgsRenderContext& c, QgsDiagramSettings& s );
|
2012-09-21 21:01:11 +02:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
QSizeF diagramSize( const QgsFeature&, const QgsRenderContext& c );
|
2011-03-15 16:43:23 +00:00
|
|
|
};
|
|
|
|
|
2012-09-21 21:01:11 +02:00
|
|
|
class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRendererV2
|
2011-03-15 16:43:23 +00:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsdiagramrendererv2.h>
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-03-15 16:43:23 +00:00
|
|
|
public:
|
|
|
|
QgsLinearlyInterpolatedDiagramRenderer();
|
|
|
|
~QgsLinearlyInterpolatedDiagramRenderer();
|
|
|
|
|
2015-11-12 19:35:14 +11:00
|
|
|
virtual QgsLinearlyInterpolatedDiagramRenderer* clone() const /Factory/;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns list with all diagram settings in the renderer*/
|
2011-03-15 16:43:23 +00:00
|
|
|
QList<QgsDiagramSettings> diagramSettings() const;
|
|
|
|
|
|
|
|
void setDiagramSettings( const QgsDiagramSettings& s );
|
|
|
|
|
2013-12-05 14:54:09 +01:00
|
|
|
QList<QString> diagramAttributes() const;
|
2011-03-15 16:43:23 +00:00
|
|
|
|
|
|
|
QString rendererName() const;
|
|
|
|
|
|
|
|
void setLowerValue( double val );
|
|
|
|
double lowerValue() const;
|
|
|
|
|
|
|
|
void setUpperValue( double val );
|
|
|
|
double upperValue() const;
|
|
|
|
|
|
|
|
void setLowerSize( QSizeF s );
|
|
|
|
QSizeF lowerSize() const;
|
|
|
|
|
|
|
|
void setUpperSize( QSizeF s );
|
|
|
|
QSizeF upperSize() const;
|
|
|
|
|
|
|
|
int classificationAttribute() const;
|
|
|
|
void setClassificationAttribute( int index );
|
|
|
|
|
2014-01-27 09:22:24 +01:00
|
|
|
QString classificationAttributeExpression() const;
|
2015-10-07 11:55:34 +11:00
|
|
|
void setClassificationAttributeExpression( const QString& expression );
|
2014-01-27 09:22:24 +01:00
|
|
|
|
|
|
|
bool classificationAttributeIsExpression() const;
|
|
|
|
void setClassificationAttributeIsExpression( bool isExpression );
|
|
|
|
|
2013-05-28 12:03:40 +02:00
|
|
|
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
|
|
|
|
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
|
2012-09-21 21:01:11 +02:00
|
|
|
|
2015-05-04 10:44:27 +10:00
|
|
|
virtual QList< QgsLayerTreeModelLegendNode* > legendItems( QgsLayerTreeLayer* nodeLayer ) const /Factory/;
|
|
|
|
|
2012-09-21 21:01:11 +02:00
|
|
|
protected:
|
2014-01-26 18:35:21 +01:00
|
|
|
bool diagramSettings( const QgsFeature &feature, const QgsRenderContext& c, QgsDiagramSettings& s );
|
2012-09-21 21:01:11 +02:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
QSizeF diagramSize( const QgsFeature&, const QgsRenderContext& c );
|
2011-03-15 16:43:23 +00:00
|
|
|
};
|