update QgsDiagramRendererV2 sip bindings

This commit is contained in:
Juergen E. Fischer 2012-09-21 21:01:11 +02:00
parent f24862ae16
commit 3e08931e40
2 changed files with 224 additions and 150 deletions

View File

@ -3,70 +3,108 @@ struct QgsDiagramLayerSettings
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
%End
//avoid inclusion of QgsPalLabeling
enum Placement
{
AroundPoint, // Point / Polygon
OverPoint, // Point / Polygon
Line, // Line / Polygon
Curved, // Line
Horizontal, // Polygon
Free // Polygon
};
//avoid inclusion of QgsPalLabeling
enum Placement
{
AroundPoint, // Point / Polygon
OverPoint, // Point / Polygon
Line, // Line / Polygon
Curved, // Line
Horizontal, // Polygon
Free // Polygon
};
enum LinePlacementFlags
{
OnLine = 1,
AboveLine = 2,
BelowLine = 4,
MapOrientation = 8
};
enum LinePlacementFlags
{
OnLine = 1,
AboveLine = 2,
BelowLine = 4,
MapOrientation = 8
};
QgsDiagramLayerSettings();
QgsDiagramLayerSettings();
//pal placement properties
Placement placement;
LinePlacementFlags placementFlags;
int priority; // 0 = low, 10 = high
bool obstacle; // whether it's an obstacle
double dist; // distance from the feature (in mm)
QgsDiagramRendererV2* renderer;
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)
//pal placement properties
Placement placement;
LinePlacementFlags placementFlags;
int priority; // 0 = low, 10 = high
bool obstacle; // whether it's an obstacle
double dist; // distance from the feature (in mm)
QgsDiagramRendererV2* renderer;
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)
void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
};
//diagram settings for rendering
struct QgsDiagramSettings
class QgsDiagramSettings
{
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
%End
enum SizeType
{
MM,
MapUnits
};
public:
enum SizeType
{
MM,
MapUnits
};
QgsDiagramSettings();
QFont font;
QList< QColor > categoryColors;
QList< int > categoryIndices;
QSizeF size; //size
SizeType sizeType; //mm or map units
QColor backgroundColor;
QColor penColor;
double penWidth;
enum LabelPlacementMethod
{
Height,
XHeight
};
//scale range (-1 if no lower / upper bound )
double minScaleDenominator;
double maxScaleDenominator;
//! Orientation of histogram
enum DiagramOrientation
{
Up,
Down,
Left,
Right
};
void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
QgsDiagramSettings();
QFont font;
QList< QColor > categoryColors;
QList< int > categoryIndices;
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;
//scale range (-1 if no lower / upper bound )
double minScaleDenominator;
double maxScaleDenominator;
//! Scale diagrams smaller than mMinimumSize to mMinimumSize
double minimumSize;
void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
};
//additional diagram settings for interpolated size rendering
class QgsDiagramInterpolationSettings
{
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
%End
public:
QSizeF lowerSize;
QSizeF upperSize;
double lowerValue;
double upperValue;
/**Index of the classification attribute*/
int classificationAttribute;
};
/**Returns diagram settings for a feature*/
@ -98,10 +136,36 @@ class QgsDiagramRendererV2
virtual void readXML( const QDomElement& elem ) = 0;
virtual void writeXML( QDomElement& layerElem, QDomDocument& doc ) const = 0;
protected:
/**Returns diagram settings for a feature (or false if the diagram for the feature is not to be rendered). Used internally within renderDiagram()
* @param att attribute map
* @param c render context
* @param s out: diagram settings for the feature
*/
virtual bool diagramSettings( const QgsAttributeMap& att, const QgsRenderContext& c, QgsDiagramSettings& s ) = 0;
/**Returns size of the diagram (in painter units) or an invalid size in case of error*/
virtual QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c ) = 0;
/**Converts size from mm to map units*/
void convertSizeToMapUnits( QSizeF& size, const QgsRenderContext& context ) const;
/**Returns the paint device dpi (or -1 in case of error*/
static int dpiPaintDevice( const QPainter* );
//read / write diagram
void _readXML( const QDomElement& elem );
void _writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
/**Reference to the object that does the real diagram rendering*/
QgsDiagram* mDiagram;
};
/**Renders the diagrams for all features with the same settings*/
class QgsSingleCategoryDiagramRenderer: QgsDiagramRendererV2
class QgsSingleCategoryDiagramRenderer : QgsDiagramRendererV2
{
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
@ -120,9 +184,14 @@ class QgsSingleCategoryDiagramRenderer: QgsDiagramRendererV2
void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
protected:
bool diagramSettings( const QgsAttributeMap&, const QgsRenderContext& c, QgsDiagramSettings& s );
QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c );
};
class QgsLinearlyInterpolatedDiagramRenderer: QgsDiagramRendererV2
class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRendererV2
{
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
@ -157,4 +226,9 @@ class QgsLinearlyInterpolatedDiagramRenderer: QgsDiagramRendererV2
void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
protected:
bool diagramSettings( const QgsAttributeMap&, const QgsRenderContext& c, QgsDiagramSettings& s );
QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c );
};

View File

@ -32,124 +32,124 @@ namespace pal { class Layer; }
class CORE_EXPORT QgsDiagramLayerSettings
{
public:
//avoid inclusion of QgsPalLabeling
enum Placement
{
AroundPoint = 0, // Point / Polygon
OverPoint, // Point / Polygon
Line, // Line / Polygon
Curved, // Line
Horizontal, // Polygon
Free // Polygon
};
public:
//avoid inclusion of QgsPalLabeling
enum Placement
{
AroundPoint = 0, // Point / Polygon
OverPoint, // Point / Polygon
Line, // Line / Polygon
Curved, // Line
Horizontal, // Polygon
Free // Polygon
};
enum LinePlacementFlags
{
OnLine = 1,
AboveLine = 2,
BelowLine = 4,
MapOrientation = 8
};
enum LinePlacementFlags
{
OnLine = 1,
AboveLine = 2,
BelowLine = 4,
MapOrientation = 8
};
QgsDiagramLayerSettings()
: placement( AroundPoint )
, placementFlags( OnLine )
, priority( 5 )
, obstacle( false )
, dist( 0.0 )
, renderer( 0 )
, palLayer( 0 )
, ct( 0 )
, xform( 0 )
, xPosColumn( -1 )
, yPosColumn( -1 )
{
}
QgsDiagramLayerSettings()
: placement( AroundPoint )
, placementFlags( OnLine )
, priority( 5 )
, obstacle( false )
, dist( 0.0 )
, renderer( 0 )
, palLayer( 0 )
, ct( 0 )
, xform( 0 )
, xPosColumn( -1 )
, yPosColumn( -1 )
{
}
//pal placement properties
Placement placement;
LinePlacementFlags placementFlags;
int priority; // 0 = low, 10 = high
bool obstacle; // whether it's an obstacle
double dist; // distance from the feature (in mm)
QgsDiagramRendererV2* renderer;
//pal placement properties
Placement placement;
LinePlacementFlags placementFlags;
int priority; // 0 = low, 10 = high
bool obstacle; // whether it's an obstacle
double dist; // distance from the feature (in mm)
QgsDiagramRendererV2* renderer;
//assigned when layer gets prepared
pal::Layer* palLayer;
const QgsCoordinateTransform* ct;
const QgsMapToPixel* xform;
QList<QgsPalGeometry*> geometries;
//assigned when layer gets prepared
pal::Layer* palLayer;
const QgsCoordinateTransform* ct;
const QgsMapToPixel* xform;
QList<QgsPalGeometry*> geometries;
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)
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)
void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
};
//diagram settings for rendering
class CORE_EXPORT QgsDiagramSettings
{
public:
enum SizeType
{
MM,
MapUnits
};
public:
enum SizeType
{
MM,
MapUnits
};
enum LabelPlacementMethod
{
Height,
XHeight
};
enum LabelPlacementMethod
{
Height,
XHeight
};
//! Orientation of histogram
enum DiagramOrientation
{
Up,
Down,
Left,
Right
};
//! Orientation of histogram
enum DiagramOrientation
{
Up,
Down,
Left,
Right
};
QgsDiagramSettings(): sizeType( MM ), minScaleDenominator( -1 ), maxScaleDenominator( -1 )
{}
QFont font;
QList< QColor > categoryColors;
QList< int > categoryIndices;
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;
QgsDiagramSettings(): sizeType( MM ), minScaleDenominator( -1 ), maxScaleDenominator( -1 )
{}
QFont font;
QList< QColor > categoryColors;
QList< int > categoryIndices;
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;
//scale range (-1 if no lower / upper bound )
double minScaleDenominator;
double maxScaleDenominator;
//scale range (-1 if no lower / upper bound )
double minScaleDenominator;
double maxScaleDenominator;
//! Scale diagrams smaller than mMinimumSize to mMinimumSize
double minimumSize;
//! Scale diagrams smaller than mMinimumSize to mMinimumSize
double minimumSize;
void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
};
//additional diagram settings for interpolated size rendering
class CORE_EXPORT QgsDiagramInterpolationSettings
{
public:
QSizeF lowerSize;
QSizeF upperSize;
double lowerValue;
double upperValue;
/**Index of the classification attribute*/
int classificationAttribute;
public:
QSizeF lowerSize;
QSizeF upperSize;
double lowerValue;
double upperValue;
/**Index of the classification attribute*/
int classificationAttribute;
};
/**Returns diagram settings for a feature*/
@ -206,7 +206,7 @@ class CORE_EXPORT QgsDiagramRendererV2
};
/**Renders the diagrams for all features with the same settings*/
class CORE_EXPORT QgsSingleCategoryDiagramRenderer: public QgsDiagramRendererV2
class CORE_EXPORT QgsSingleCategoryDiagramRenderer : public QgsDiagramRendererV2
{
public:
QgsSingleCategoryDiagramRenderer();
@ -232,7 +232,7 @@ class CORE_EXPORT QgsSingleCategoryDiagramRenderer: public QgsDiagramRendererV2
QgsDiagramSettings mSettings;
};
class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer: public QgsDiagramRendererV2
class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer : public QgsDiagramRendererV2
{
public:
QgsLinearlyInterpolatedDiagramRenderer();