1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
/* -*- Mode: C++ -*-
KDChart - a multi-platform charting engine
*/
/****************************************************************************
** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB. All rights reserved.
**
** This file is part of the KDChart library.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid commercial KDChart licenses may use this file in
** accordance with the KDChart Commercial License Agreement provided with
** the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.klaralvdalens-datakonsult.se/?page=products for
** information about KDChart Commercial License Agreements.
**
** Contact [email protected] if any conditions of this
** licensing are not clear to you.
**
**********************************************************************/
#ifndef __KDCHARTENUMS_H__
#define __KDCHARTENUMS_H__
#include <qrect.h>
#include <qpointarray.h>
#include "KDChartGlobal.h"
#include <qobject.h>
/** \file KDChartEnums.h
\brief Definition of global enums.
*/
/**
Project global class providing some enums needed both by KDChartParams
and by KDChartCustomBox.
*/
class KDCHART_EXPORT KDChartEnums :public QObject
{
Q_OBJECT
Q_ENUMS( TextLayoutPolicy )
Q_ENUMS( AreaName )
Q_ENUMS( PositionFlag )
public:
/**
Text layout policy: what to do if text that is to be drawn would
cover neighboring text or neighboring areas.
\li \c LayoutJustOverwrite Just ignore the layout collision and write the text nevertheless.
\li \c LayoutPolicyRotate Try counter-clockwise rotation to make the text fit into the space.
\li \c LayoutPolicyShiftVertically Shift the text baseline upwards (or downwards, resp.) and draw a connector line between the text and its anchor.
\li \c LayoutPolicyShiftHorizontally Shift the text baseline to the left (or to the right, resp.) and draw a connector line between the text and its anchor.
\li \c LayoutPolicyShrinkFontSize Reduce the text font size.
\sa KDChartParams::setPrintDataValues
*/
enum TextLayoutPolicy { LayoutJustOverwrite,
LayoutPolicyRotate,
LayoutPolicyShiftVertically,
LayoutPolicyShiftHorizontally,
LayoutPolicyShrinkFontSize };
/**
Converts the specified text layout policy enum to a
string representation.
\param type the text layout policy to convert
\return the string representation of the text layout policy enum
*/
static QString layoutPolicyToString( TextLayoutPolicy type ) {
switch( type ) {
case LayoutJustOverwrite:
return "JustOverwrite";
case LayoutPolicyRotate:
return "Rotate";
case LayoutPolicyShiftVertically:
return "ShiftVertically";
case LayoutPolicyShiftHorizontally:
return "ShiftHorizontally";
case LayoutPolicyShrinkFontSize:
return "ShrinkFontSize";
default: // should not happen
qDebug( "Unknown text layout policy" );
return "JustOverwrite";
}
}
/**
Number notation specifies the general way, how a number is to be shown.
\li \c NumberNotationDecimal Traditional way of writing a decimal number.
\li \c NumberNotationScientific Exponential notation, with exactly one non-zero digit to the left of the decimal.
\li \c NumberNotationScientificBig Same as \c NumberNotationScientific, but using 'E' instead of 'e'.
\sa KDChartAxisParams::setAxisLabelsNotation
*/
enum NumberNotation { NumberNotationDecimal,
NumberNotationScientific,
NumberNotationScientificBig };
/**
Converts the specified number notation enum to a
string representation.
\param notation the number notation to convert
\return the string representation of the number notation enum
*/
static QString numberNotationToString( NumberNotation notation ) {
switch( notation ) {
case NumberNotationDecimal:
return "NumberNotationDecimal";
case NumberNotationScientific:
return "NumberNotationScientific";
case NumberNotationScientificBig:
return "NumberNotationScientificBig";
default: // should not happen
qDebug( "Unknown text number notation" );
return "NumberNotationDecimal";
}
}
/**
Converts the specified string to a number notation enum value.
\param string the string to convert
\return the number notation enum value
*/
static NumberNotation stringToNumberNotation( const QString& notation ) {
if( notation == "NumberNotationDecimal" )
return NumberNotationDecimal;
else if( notation == "NumberNotationScientific" )
return NumberNotationScientific;
else if( notation == "NumberNotationScientificBig" )
return NumberNotationScientificBig;
else // default, should not happen
return NumberNotationDecimal;
}
/**
Converts the specified string to a text layout policy enum value.
\param string the string to convert
\return the text layout policy enum value
*/
static TextLayoutPolicy stringToLayoutPolicy( const QString& string ) {
if( string == "JustOverwrite" )
return LayoutJustOverwrite;
else if( string == "Rotate" )
return LayoutPolicyRotate;
else if( string == "ShiftVertically" )
return LayoutPolicyShiftVertically;
else if( string == "ShiftHorizontally" )
return LayoutPolicyShiftHorizontally;
else if( string == "ShrinkFontSize" )
return LayoutPolicyShrinkFontSize;
else // default, should not happen
return LayoutJustOverwrite;
}
/**
Areas of the chart that may have their own backgrounds
and/or may be surrounded by a simple or complex border.
\li \c AreaData surrounding the data area
\li \c AreaAxes surrounding the axes but leaving out the data area
\li \c AreaDataAxes surrounding the data+axes area
\li \c AreaLegend surrounding the legend area
\li \c AreaDataAxesLegend surrounding the data+axes+legend area
\li \c AreaHeaders surrounding the headers area
\li \c AreaFooters surrounding the footers area
\li \c AreaDataAxesLegendHeadersFooters surrounding the data+axes+legend+headers+footers area
\li \c AreaInnermost covering the complete drawing area but <b>not</b> covering the global left/top/right/bottom leading
\li \c AreaOutermost covering the complete drawing area including the global left/top/right/bottom leading
\li \c AreaChartDataRegion covering the area used to display one data entry (i.e. one point, bar, line, pie slice,...).
The respective data coordinates are specified by additional parameters, this is used by
KDChartCustomBox where you have the parameters \c dataRow, \c dataCol, \c data3rd.
In addition there is a special value specifying a <b>list</b> of regions:
\li \c AreasCustomBoxes specifies many small areas surrounding all the custom boxes that you might have added to the chart,
this is useful in case you want to specify some default frame settings to be used for all custom boxes
not having frame settings of their own.
Finally there are three special values that you may use to specify
a single axis area (or a header/footer area, or a custom box area resp.).
Just add the number of the axis (or header/footer, or custom box resp.)
to the respective base value:
\li \c AreaAxisBASE value to be added to the axis number in case you want to specify a single axis area,
e.g. for specifying the area of the left ordinate axis just type <b>AreaAxisBASE + AxisPosLeft</b>.
\li \c AreaHdFtBASE value to be added to the header/footer number in case you want to specify a single header (or footer, resp.) area,
e.g. for specifying the area of the main header just type <b>AreaHdFtBASE + HdFtPosHeader</b>.
\li \c AreaCustomBoxBASE value to be added to the number of a custom box that you might have added to your chart,
e.g. for specifying the area a custom box you have added to the chart
(let us assume the index of that box is in \c boxIdx1) just type <b>AreaCustBoxBASE + boxIdx1</b>.
\sa KDChartParams::setSimpleFrame, KDChartParams::setFrame
\sa KDChartParams::insertCustomBox, KDChartCustomBox
*/
enum AreaName { AreaUNKNOWN = 0x0000,
AreaData = 0x0001,
AreaAxes = 0x0002,
AreaDataAxes = 0x0003,
AreaLegend = 0x0004,
AreaDataAxesLegend = 0x0005,
AreaHeaders = 0x0006,
AreaFooters = 0x0007,
AreaDataAxesLegendHeadersFooters = 0x0008,
AreaInnermost = 0x0009,
AreaOutermost = 0x000a,
AreaChartDataRegion = 0x000b,
AreasCustomBoxes = 0x000d,
AreaAxisBASE = 0x1000,
AreaHdFtBASE = 0x2000,
AreaCustomBoxesBASE = 0x4000,
AreaBASEMask = 0xF000 };
/**
The general position flag to specify a point of
an area, for example this could be the anchor point
which an annotation box should be aligned to.
The following picture shows the different positions:
\image html "../refman_images/positions.png"
\image latex "../refman_images/positions.png" "the PositionFlag enum" width=4in
\note The position and alignment of content to be printed at (or
inside of, resp.) an area or a point -- like for printing data value texts next
to their graphical representations (which might be a bar, line, pie slice,...) --
is specified by two parameters: a \c PositionFlag and a uint holding a combination of \c Qt::AlignmentFlags.
Remember that Qt::AlignmentFlags are used to specify <b>with which edge</b> something
is to be aligned to its anchor, e.g. \c AlignLeft means align with the left edge.
The position of content and the way it is aligned to this
position is shown in the following drawing, note that annotation #2 and annotation #3
share the same PositionFlag but have different alignment flags set:
\image html "../refman_images/alignment.png"
\image latex "../refman_images/alignment.png" "positioning and aligning" width=4in
\sa KDChartParams::setPrintDataValues
*/
enum PositionFlag { PosTopLeft =0, PosTopCenter =1, PosTopRight =2,
PosCenterLeft=3, PosCenter =4, PosCenterRight=5,
PosBottomLeft=6, PosBottomCenter=7, PosBottomRight=8 };
/**
Returns the point representing a position of a rectangle.
*/
static QPoint positionFlagToPoint( const QRect& rect,
PositionFlag pos );
/**
Returns the point representing a position of a corresponding
QPointArray.
\note The array \c points <b>must</b> have at least nine elements.
*/
static QPoint positionFlagToPoint( const QPointArray& points,
PositionFlag pos )
{
QPoint pt;
if( 9 <= points.size() )
pt = points[ pos ];
return pt;
}
/**
Converts the specified content position enum to a
string representation.
\param type the content position to convert
\return the string representation of the type enum
*/
static QString positionFlagToString( PositionFlag type );
/**
Converts the specified string to a content position enum value.
\param string the string to convert
\return the content position enum value
*/
static PositionFlag stringToPositionFlag( const QString& string );
};
#endif
|