Subversion Repositories public

Rev

Rev 274 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
273 andreas 1
//
2
// C++ Interface: render
3
//
4
// Description: This defines the class for render.
5
//
6
//
7
// Author: Andreas Theofilu <andreas@theosys.at>, (C) 2009
8
//
9
// Copyright: See COPYING file that comes with this distribution
10
//
11
//
12
#ifndef _RENDER_H
13
#define _RENDER_H
14
 
15
#include <QLabel>
16
#include <QString>
17
#include <QPainter>
18
#include <QXmlReader>
19
#include <KStandardDirs>
20
 
21
typedef struct LINESYMBOLIZER
22
{
23
	Color     stroke;
24
	double    stroke_width;
25
	short int stroke_linejoin;
26
	short int stroke_linecap;
27
	double    stroke_dasharray[10];
28
	double    stroke_opacity;
29
	LINESYMBOLIZER *next;
30
}LINESYMBOLIZER;
31
 
32
typedef struct POLYGONSYMBOLIZER
33
{
34
	Color     fill;
35
	double    fill_opacity;
36
	POLYGONSYMBOLIZER *next;
37
}POLYGONSYMBOLIZER;
38
 
39
typedef struct TEXTSYMBOLIZER
40
{
41
	QString   name;
42
	QString   face_name;
43
	double    size;
44
	Color     fill;
45
	double    halo_radius;
46
	double    wrap_width;
47
	double    dy;
48
	double    mindistance;
49
	double    maxdistance;
50
	TEXTSYMBOLIZER *next;
51
}TEXTSYMBOLIZER;
52
 
53
typedef struct POINTSYMBOLIZER
54
{
55
	QString   file;
56
	int       type;		// enum TYPES
57
	double    width;
58
	double    height;
59
	bool      allow_overlap;
60
	POINTSYMBOLIZER *next;
61
}POINTSYMBOLIZER;
62
 
63
typedef struct POLYGONPATTERNSYMBOLIZER
64
{
65
	QString   file;
66
	int       type;		// enum TYPES
67
	double    width;
68
	double    height;
69
	bool      allow_overlap;
70
	POLYGONPATTERNSYMBOLIZER *next;
71
}POLYGONPATTERNSYMBOLIZER;
72
 
73
typedef struct SHIELDSYMBOLIZER
74
{
75
	QString   name;
76
	QString   face_name;
77
	double    size;
78
	Color     fill;
79
	QString   placement;
80
	QString   file;
81
	int       type;
82
	double    width;
83
	double    height;
84
	double    mindistance;
85
	double    maxdistance;
86
	SHIELDSYMBOLIZER *next;
87
}SHIELDSYMBOLIZER;
88
 
89
typedef struct LINEPATTERNSYMBOLIZER
90
{
91
	QString   file;
92
	int       type;
93
	double    width;
94
	double    height;
95
	LINEPATTERNSYMBOLIZER *next;
96
}LINEPATTERNSYMBOLIZER;
97
 
98
typedef struct RULE
99
{
100
	double    maxscale;
101
	double    minscale;
102
	QString   filter;
103
	LINESYMBOLIZER		 *LineSymbolizer;
104
	POLYGONSYMBOLIZER	 *PolygonSymbolizer;
105
	TEXTSYMBOLIZER		 *TextSymbolizer;
106
	POINTSYMBOLIZER		 *PointSymbolizer;
107
	POLYGONPATTERNSYMBOLIZER *PolygonPatternSymbolizer;
108
	SHIELDSYMBOLIZER	 *ShieldSymbolizer;
109
	LINEPATTERNSYMBOLIZER    *LinePatternSymbolizer;
110
	RULE *next;		// Pointer to next rule
111
}RULE;
112
 
113
typedef struct STYLE
114
{
115
	QString  name;
116
	RULE     *rule;		// Pointer to first rule node of the chain
117
	STYLE    *next;		// Pointer to next style
118
}STYLE;
119
 
120
typedef struct
121
{
122
	QString   type;
123
	QString   file;
124
	QString   host;
125
	QString   user;
126
	QString   dbname;
127
	QString   table;
128
	bool      estimate_extend;
129
	double    ext_lx;
130
	double    ext_ly;
131
	double    ext_rx;
132
	double    ext_ry;
133
}DATASOURCE;
134
 
135
typedef struct LAYER
136
{
137
	QString    name;
138
	bool       status;
139
	QString    srs;		// Projection
140
	STYLE      *Style;	// Pointer to first style
141
	DATASOURCE Datasource;
142
	LAYER      *next;	// Pointer to next layer
143
}LAYER;
144
 
145
typedef struct
146
{
147
	Color      bgcolor;
148
	int        buffer_size;
149
	QString    srs;
150
}MAP;
151
 
152
typedef enum {
153
	stroke		 = 100,
154
	stroke_width	 = 101,
155
	stroke_linejoin  = 102,
156
	stroke_linecap   = 103,
157
	stroke_opacity   = 104,
158
	stroke_dasharray = 105
159
}NAMES;
160
 
161
typedef enum {
162
	type_png	= 150,
163
	type_gif	= 151,
164
	type_jpg	= 152,
165
	type_xpm	= 153,
166
	type_tif	= 154,
167
	type_bmp	= 155
168
}TYPES;
169
 
170
typedef enum {
171
	in_map			= 100,
172
	in_style		= 101,
173
	in_rule			= 102,
174
	in_linesymbolizer	= 103,
175
	in_pointsymbolizer	= 104,
176
	in_polygonsymbolizer	= 105,
177
	in_textsymbolizer	= 106,
178
	in_polygonpatternsymbolizer = 107,
179
	in_layer		= 108,
180
	in_datasource		= 109
181
}CONTAINER;
182
 
183
extern KEYS keys[];		// defined at >import.h<
184
 
185
class render
186
{
187
	public:
188
	   render();
189
 
190
	   bool setDrawArea(QLabel *lb) { if (!lb) return false; label = *lb; return true; };
191
	   bool setShapePath(QString *str) { if (!str) return false; shapePath = *str; return true; };
192
	   bool getMap(double lx, double ly, double rx, double ry);
193
 
194
	   bool startDocument ();
195
	   bool startElement (const QString&, const QString&, const QString& , const QXmlAttributes&);
196
	   bool endElement (const QString&, const QString&, const QString&);
197
	   bool characters (const QString&);
198
 
199
	protected:
200
	   void addRule (feature_type_style &fts, char *filter, double minscale, double maxscale, Color &polcol, Color &symcol, double symwidth, QString &pattern, int pw, int ph);
201
	   void addRulePoint (feature_type_style &fts, char *filter, double minscale, double maxscale, Color &polcol, Color &symcol, double symwidth, QString &pattern, int pw, int ph);
202
	   void addTextSymbolizer (char *name, char *font, int size, Color &col, int radius, int wrap, double dy);
203
 
204
	private:
205
	   QString getKey (int pos);
206
	   RULE *getLastRule(RULE *first);
207
	   POINTSYMBOLIZER *getLastPointSymbolizer(POINTSYMBOLIZER *first);
208
 
209
	private:
210
	   QLabel label;
211
	   QString shapePath;
212
	   QString XmlPath;
213
	   int indent;
214
	   CONTAINER Container;
215
	   TYPES Types;
216
	   NAMES Names;
217
	   MAP MapPars;
218
	   LAYER *Layer;
219
	   STYLE *Style, *firstStyle, *lastStyle;
220
	   RULE *Rule;
221
	   LINESYMBOLIZER		*LineSymbolizer;
222
	   POLYGONSYMBOLIZER	 	*PolygonSymbolizer;
223
	   TEXTSYMBOLIZER		*TextSymbolizer;
224
	   POINTSYMBOLIZER		*PointSymbolizer;
225
	   POLYGONPATTERNSYMBOLIZER 	*PolygonPatternSymbolizer;
226
	   SHIELDSYMBOLIZER	 	*ShieldSymbolizer;
227
	   LINEPATTERNSYMBOLIZER    	*LinePatternSymbolizer;
228
};
229
 
230
#endif // _RENDER_H