@@ -3,70 +3,108 @@ struct QgsDiagramLayerSettings
3
3
%TypeHeaderCode
4
4
#include <qgsdiagramrendererv2.h>
5
5
%End
6
+ //avoid inclusion of QgsPalLabeling
7
+ enum Placement
8
+ {
9
+ AroundPoint, // Point / Polygon
10
+ OverPoint, // Point / Polygon
11
+ Line, // Line / Polygon
12
+ Curved, // Line
13
+ Horizontal, // Polygon
14
+ Free // Polygon
15
+ };
16
+
17
+ enum LinePlacementFlags
18
+ {
19
+ OnLine = 1,
20
+ AboveLine = 2,
21
+ BelowLine = 4,
22
+ MapOrientation = 8
23
+ };
24
+
25
+ QgsDiagramLayerSettings();
26
+
27
+ //pal placement properties
28
+ Placement placement;
29
+ LinePlacementFlags placementFlags;
30
+ int priority; // 0 = low, 10 = high
31
+ bool obstacle; // whether it's an obstacle
32
+ double dist; // distance from the feature (in mm)
33
+ QgsDiagramRendererV2* renderer;
34
+ int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
35
+ int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)
6
36
7
- //avoid inclusion of QgsPalLabeling
8
- enum Placement
9
- {
10
- AroundPoint, // Point / Polygon
11
- OverPoint, // Point / Polygon
12
- Line, // Line / Polygon
13
- Curved, // Line
14
- Horizontal, // Polygon
15
- Free // Polygon
16
- };
17
-
18
- enum LinePlacementFlags
19
- {
20
- OnLine = 1,
21
- AboveLine = 2,
22
- BelowLine = 4,
23
- MapOrientation = 8
24
- };
25
-
26
- QgsDiagramLayerSettings();
27
-
28
- //pal placement properties
29
- Placement placement;
30
- LinePlacementFlags placementFlags;
31
- int priority; // 0 = low, 10 = high
32
- bool obstacle; // whether it's an obstacle
33
- double dist; // distance from the feature (in mm)
34
- QgsDiagramRendererV2* renderer;
35
- int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
36
- int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)
37
-
38
- void readXML( const QDomElement& elem );
39
- void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
37
+ void readXML( const QDomElement& elem );
38
+ void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
40
39
};
41
40
42
41
//diagram settings for rendering
43
- struct QgsDiagramSettings
42
+ class QgsDiagramSettings
43
+ {
44
+ %TypeHeaderCode
45
+ #include <qgsdiagramrendererv2.h>
46
+ %End
47
+ public:
48
+ enum SizeType
49
+ {
50
+ MM,
51
+ MapUnits
52
+ };
53
+
54
+ enum LabelPlacementMethod
55
+ {
56
+ Height,
57
+ XHeight
58
+ };
59
+
60
+ //! Orientation of histogram
61
+ enum DiagramOrientation
62
+ {
63
+ Up,
64
+ Down,
65
+ Left,
66
+ Right
67
+ };
68
+
69
+ QgsDiagramSettings();
70
+ QFont font;
71
+ QList< QColor > categoryColors;
72
+ QList< int > categoryIndices;
73
+ QSizeF size; //size
74
+ SizeType sizeType; //mm or map units
75
+ QColor backgroundColor;
76
+ QColor penColor;
77
+ double penWidth;
78
+ LabelPlacementMethod labelPlacementMethod;
79
+ DiagramOrientation diagramOrientation;
80
+ double barWidth;
81
+ int transparency; // 0 - 100
82
+ bool scaleByArea;
83
+
84
+ //scale range (-1 if no lower / upper bound )
85
+ double minScaleDenominator;
86
+ double maxScaleDenominator;
87
+
88
+ //! Scale diagrams smaller than mMinimumSize to mMinimumSize
89
+ double minimumSize;
90
+
91
+ void readXML( const QDomElement& elem );
92
+ void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
93
+ };
94
+
95
+ //additional diagram settings for interpolated size rendering
96
+ class QgsDiagramInterpolationSettings
44
97
{
45
98
%TypeHeaderCode
46
99
#include <qgsdiagramrendererv2.h>
47
100
%End
48
- enum SizeType
49
- {
50
- MM,
51
- MapUnits
52
- };
53
-
54
- QgsDiagramSettings();
55
- QFont font;
56
- QList< QColor > categoryColors;
57
- QList< int > categoryIndices;
58
- QSizeF size; //size
59
- SizeType sizeType; //mm or map units
60
- QColor backgroundColor;
61
- QColor penColor;
62
- double penWidth;
63
-
64
- //scale range (-1 if no lower / upper bound )
65
- double minScaleDenominator;
66
- double maxScaleDenominator;
67
-
68
- void readXML( const QDomElement& elem );
69
- void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
101
+ public:
102
+ QSizeF lowerSize;
103
+ QSizeF upperSize;
104
+ double lowerValue;
105
+ double upperValue;
106
+ /**Index of the classification attribute*/
107
+ int classificationAttribute;
70
108
};
71
109
72
110
/**Returns diagram settings for a feature*/
@@ -98,10 +136,36 @@ class QgsDiagramRendererV2
98
136
99
137
virtual void readXML( const QDomElement& elem ) = 0;
100
138
virtual void writeXML( QDomElement& layerElem, QDomDocument& doc ) const = 0;
139
+
140
+
141
+ protected:
142
+
143
+ /**Returns diagram settings for a feature (or false if the diagram for the feature is not to be rendered). Used internally within renderDiagram()
144
+ * @param att attribute map
145
+ * @param c render context
146
+ * @param s out: diagram settings for the feature
147
+ */
148
+ virtual bool diagramSettings( const QgsAttributeMap& att, const QgsRenderContext& c, QgsDiagramSettings& s ) = 0;
149
+
150
+ /**Returns size of the diagram (in painter units) or an invalid size in case of error*/
151
+ virtual QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c ) = 0;
152
+
153
+ /**Converts size from mm to map units*/
154
+ void convertSizeToMapUnits( QSizeF& size, const QgsRenderContext& context ) const;
155
+
156
+ /**Returns the paint device dpi (or -1 in case of error*/
157
+ static int dpiPaintDevice( const QPainter* );
158
+
159
+ //read / write diagram
160
+ void _readXML( const QDomElement& elem );
161
+ void _writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
162
+
163
+ /**Reference to the object that does the real diagram rendering*/
164
+ QgsDiagram* mDiagram;
101
165
};
102
166
103
167
/**Renders the diagrams for all features with the same settings*/
104
- class QgsSingleCategoryDiagramRenderer: QgsDiagramRendererV2
168
+ class QgsSingleCategoryDiagramRenderer : QgsDiagramRendererV2
105
169
{
106
170
%TypeHeaderCode
107
171
#include <qgsdiagramrendererv2.h>
@@ -120,9 +184,14 @@ class QgsSingleCategoryDiagramRenderer: QgsDiagramRendererV2
120
184
121
185
void readXML( const QDomElement& elem );
122
186
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
187
+
188
+ protected:
189
+ bool diagramSettings( const QgsAttributeMap&, const QgsRenderContext& c, QgsDiagramSettings& s );
190
+
191
+ QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c );
123
192
};
124
193
125
- class QgsLinearlyInterpolatedDiagramRenderer: QgsDiagramRendererV2
194
+ class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRendererV2
126
195
{
127
196
%TypeHeaderCode
128
197
#include <qgsdiagramrendererv2.h>
@@ -157,4 +226,9 @@ class QgsLinearlyInterpolatedDiagramRenderer: QgsDiagramRendererV2
157
226
158
227
void readXML( const QDomElement& elem );
159
228
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
229
+
230
+ protected:
231
+ bool diagramSettings( const QgsAttributeMap&, const QgsRenderContext& c, QgsDiagramSettings& s );
232
+
233
+ QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c );
160
234
};
0 commit comments