/src/gdal/ogr/ogr_featurestyle.h
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: OpenGIS Simple Features Reference Implementation |
4 | | * Purpose: Define of Feature Representation |
5 | | * Author: Stephane Villeneuve, stephane.v@videtron.ca |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 1999, Frank Warmerdam |
9 | | * |
10 | | * SPDX-License-Identifier: MIT |
11 | | ****************************************************************************/ |
12 | | |
13 | | #ifndef OGR_FEATURESTYLE_INCLUDE |
14 | | #define OGR_FEATURESTYLE_INCLUDE |
15 | | |
16 | | #include "cpl_conv.h" |
17 | | #include "cpl_string.h" |
18 | | #include "ogr_core.h" |
19 | | |
20 | | class OGRFeature; |
21 | | |
22 | | /** |
23 | | * \file ogr_featurestyle.h |
24 | | * |
25 | | * Simple feature style classes. |
26 | | */ |
27 | | |
28 | | /* |
29 | | * All OGRStyleTool param lists are defined in ogr_core.h. |
30 | | */ |
31 | | |
32 | | /** OGR Style type */ |
33 | | typedef enum ogr_style_type |
34 | | { |
35 | | OGRSTypeUnused = -1, |
36 | | OGRSTypeString, |
37 | | OGRSTypeDouble, |
38 | | OGRSTypeInteger, |
39 | | OGRSTypeBoolean |
40 | | } OGRSType; |
41 | | |
42 | | //! @cond Doxygen_Suppress |
43 | | typedef struct ogr_style_param |
44 | | { |
45 | | int eParam; |
46 | | const char *pszToken; |
47 | | GBool bGeoref; |
48 | | OGRSType eType; |
49 | | } OGRStyleParamId; |
50 | | |
51 | | typedef struct ogr_style_value |
52 | | { |
53 | | char *pszValue; |
54 | | double dfValue; |
55 | | int nValue; // Used for both integer and boolean types |
56 | | GBool bValid; |
57 | | OGRSTUnitId eUnit; |
58 | | } OGRStyleValue; |
59 | | |
60 | | //! @endcond |
61 | | |
62 | | // Every time a pszStyleString given in parameter is NULL, |
63 | | // the StyleString defined in the Mgr will be use. |
64 | | |
65 | | /** |
66 | | * This class represents a style table |
67 | | */ |
68 | | class CPL_DLL OGRStyleTable |
69 | | { |
70 | | private: |
71 | | char **m_papszStyleTable = nullptr; |
72 | | |
73 | | CPLString osLastRequestedStyleName{}; |
74 | | int iNextStyle = 0; |
75 | | |
76 | | CPL_DISALLOW_COPY_ASSIGN(OGRStyleTable) |
77 | | |
78 | | public: |
79 | | OGRStyleTable(); |
80 | | ~OGRStyleTable(); |
81 | | GBool AddStyle(const char *pszName, const char *pszStyleString); |
82 | | GBool RemoveStyle(const char *pszName); |
83 | | GBool ModifyStyle(const char *pszName, const char *pszStyleString); |
84 | | |
85 | | GBool SaveStyleTable(const char *pszFilename); |
86 | | GBool LoadStyleTable(const char *pszFilename); |
87 | | const char *Find(const char *pszStyleString); |
88 | | GBool IsExist(const char *pszName); |
89 | | const char *GetStyleName(const char *pszName); |
90 | | void Print(FILE *fpOut); |
91 | | void Clear(); |
92 | | OGRStyleTable *Clone(); |
93 | | void ResetStyleStringReading(); |
94 | | const char *GetNextStyle(); |
95 | | const char *GetLastStyleName(); |
96 | | }; |
97 | | |
98 | | class OGRStyleTool; |
99 | | |
100 | | /** |
101 | | * This class represents a style manager |
102 | | */ |
103 | | class CPL_DLL OGRStyleMgr |
104 | | { |
105 | | private: |
106 | | OGRStyleTable *m_poDataSetStyleTable = nullptr; |
107 | | char *m_pszStyleString = nullptr; |
108 | | |
109 | | CPL_DISALLOW_COPY_ASSIGN(OGRStyleMgr) |
110 | | |
111 | | public: |
112 | | explicit OGRStyleMgr(OGRStyleTable *poDataSetStyleTable = nullptr); |
113 | | ~OGRStyleMgr(); |
114 | | |
115 | | GBool SetFeatureStyleString(OGRFeature *, |
116 | | const char *pszStyleString = nullptr, |
117 | | GBool bNoMatching = FALSE); |
118 | | /* It will set in the given feature the pszStyleString with |
119 | | the style or will set the style name found in |
120 | | dataset StyleTable (if bNoMatching == FALSE). */ |
121 | | |
122 | | const char *InitFromFeature(OGRFeature *); |
123 | | GBool InitStyleString(const char *pszStyleString = nullptr); |
124 | | |
125 | | const char *GetStyleName(const char *pszStyleString = nullptr); |
126 | | const char *GetStyleByName(const char *pszStyleName); |
127 | | |
128 | | GBool AddStyle(const char *pszStyleName, |
129 | | const char *pszStyleString = nullptr); |
130 | | |
131 | | const char *GetStyleString(OGRFeature * = nullptr); |
132 | | |
133 | | GBool AddPart(OGRStyleTool *); |
134 | | GBool AddPart(const char *); |
135 | | |
136 | | int GetPartCount(const char *pszStyleString = nullptr); |
137 | | OGRStyleTool *GetPart(int hPartId, const char *pszStyleString = nullptr); |
138 | | |
139 | | /* It could have a reference counting process us for the OGRStyleTable, if |
140 | | needed. */ |
141 | | //! @cond Doxygen_Suppress |
142 | | OGRStyleTable *GetDataSetStyleTable() |
143 | 0 | { |
144 | 0 | return m_poDataSetStyleTable; |
145 | 0 | } |
146 | | |
147 | | static OGRStyleTool * |
148 | | CreateStyleToolFromStyleString(const char *pszStyleString); |
149 | | //! @endcond |
150 | | }; |
151 | | |
152 | | /** |
153 | | * This class represents a style tool |
154 | | */ |
155 | | class CPL_DLL OGRStyleTool |
156 | | { |
157 | | private: |
158 | | GBool m_bModified = false; |
159 | | GBool m_bParsed = false; |
160 | | double m_dfScale = 1.0; |
161 | | OGRSTUnitId m_eUnit = OGRSTUMM; |
162 | | OGRSTClassId m_eClassId = OGRSTCNone; |
163 | | char *m_pszStyleString = nullptr; |
164 | | |
165 | | virtual GBool Parse() = 0; |
166 | | |
167 | | CPL_DISALLOW_COPY_ASSIGN(OGRStyleTool) |
168 | | |
169 | | protected: |
170 | | #ifndef DOXYGEN_SKIP |
171 | | GBool Parse(const OGRStyleParamId *pasStyle, OGRStyleValue *pasValue, |
172 | | int nCount); |
173 | | #endif |
174 | | |
175 | | public: |
176 | | OGRStyleTool() |
177 | | : m_bModified(FALSE), m_bParsed(FALSE), m_dfScale(0.0), |
178 | | m_eUnit(OGRSTUGround), m_eClassId(OGRSTCNone), |
179 | | m_pszStyleString(nullptr) |
180 | 0 | { |
181 | 0 | } |
182 | | |
183 | | explicit OGRStyleTool(OGRSTClassId eClassId); |
184 | | virtual ~OGRStyleTool(); |
185 | | |
186 | | static GBool GetRGBFromString(const char *pszColor, int &nRed, int &nGreen, |
187 | | int &nBlue, int &nTransparence); |
188 | | static int GetSpecificId(const char *pszId, const char *pszWanted); |
189 | | |
190 | | #ifndef DOXYGEN_SKIP |
191 | | GBool IsStyleModified() |
192 | 0 | { |
193 | 0 | return m_bModified; |
194 | 0 | } |
195 | | |
196 | | void StyleModified() |
197 | 0 | { |
198 | 0 | m_bModified = TRUE; |
199 | 0 | } |
200 | | |
201 | | GBool IsStyleParsed() |
202 | 0 | { |
203 | 0 | return m_bParsed; |
204 | 0 | } |
205 | | |
206 | | void StyleParsed() |
207 | 0 | { |
208 | 0 | m_bParsed = TRUE; |
209 | 0 | } |
210 | | #endif |
211 | | |
212 | | OGRSTClassId GetType(); |
213 | | |
214 | | #ifndef DOXYGEN_SKIP |
215 | | void SetInternalInputUnitFromParam(char *pszString); |
216 | | #endif |
217 | | |
218 | | void SetUnit(OGRSTUnitId, |
219 | | double dfScale = 1.0); // the dfScale will be |
220 | | |
221 | | // used if we are working with Ground |
222 | | // Unit ( ground = paper * scale); |
223 | | |
224 | | OGRSTUnitId GetUnit() |
225 | 0 | { |
226 | 0 | return m_eUnit; |
227 | 0 | } |
228 | | |
229 | | // There are two way to set the parameters in the Style, with generic |
230 | | // methods (using a defined enumeration) or with the reel method specific |
231 | | // for Each style tools. |
232 | | |
233 | | virtual const char *GetStyleString() = 0; |
234 | | void SetStyleString(const char *pszStyleString); |
235 | | const char *GetStyleString(const OGRStyleParamId *pasStyleParam, |
236 | | OGRStyleValue *pasStyleValue, int nSize); |
237 | | |
238 | | const char *GetParamStr(const OGRStyleParamId &sStyleParam, |
239 | | const OGRStyleValue &sStyleValue, |
240 | | GBool &bValueIsNull); |
241 | | |
242 | | int GetParamNum(const OGRStyleParamId &sStyleParam, |
243 | | const OGRStyleValue &sStyleValue, GBool &bValueIsNull); |
244 | | |
245 | | double GetParamDbl(const OGRStyleParamId &sStyleParam, |
246 | | const OGRStyleValue &sStyleValue, GBool &bValueIsNull); |
247 | | |
248 | | double GetRawParamDbl(const OGRStyleParamId &sStyleParam, |
249 | | const OGRStyleValue &sStyleValue, |
250 | | OGRSTUnitId &eRawUnit, GBool &bValueIsNull); |
251 | | |
252 | | void SetParamStr(const OGRStyleParamId &sStyleParam, |
253 | | OGRStyleValue &sStyleValue, const char *pszParamString); |
254 | | |
255 | | void SetParamNum(const OGRStyleParamId &sStyleParam, |
256 | | OGRStyleValue &sStyleValue, int nParam); |
257 | | |
258 | | void SetParamDbl(const OGRStyleParamId &sStyleParam, |
259 | | OGRStyleValue &sStyleValue, double dfParam); |
260 | | #ifndef DOXYGEN_SKIP |
261 | | double ComputeWithUnit(double, OGRSTUnitId); |
262 | | int ComputeWithUnit(int, OGRSTUnitId); |
263 | | #endif |
264 | | }; |
265 | | |
266 | | //! @cond Doxygen_Suppress |
267 | | |
268 | | /** |
269 | | * This class represents a style pen |
270 | | */ |
271 | | class CPL_DLL OGRStylePen : public OGRStyleTool |
272 | | { |
273 | | private: |
274 | | OGRStyleValue *m_pasStyleValue; |
275 | | |
276 | | GBool Parse() override; |
277 | | |
278 | | CPL_DISALLOW_COPY_ASSIGN(OGRStylePen) |
279 | | |
280 | | public: |
281 | | OGRStylePen(); |
282 | | ~OGRStylePen() override; |
283 | | |
284 | | /**********************************************************************/ |
285 | | /* Explicit fct for all parameters defined in the Drawing tools Pen */ |
286 | | /**********************************************************************/ |
287 | | |
288 | | const char *Color(GBool &bDefault) |
289 | 0 | { |
290 | 0 | return GetParamStr(OGRSTPenColor, bDefault); |
291 | 0 | } |
292 | | |
293 | | void SetColor(const char *pszColor) |
294 | 0 | { |
295 | 0 | SetParamStr(OGRSTPenColor, pszColor); |
296 | 0 | } |
297 | | |
298 | | double Width(GBool &bDefault) |
299 | 0 | { |
300 | 0 | return GetParamDbl(OGRSTPenWidth, bDefault); |
301 | 0 | } |
302 | | |
303 | | double RawWidth(OGRSTUnitId &eRawUnit, GBool &bDefault) |
304 | 0 | { |
305 | 0 | return GetRawParamDbl(OGRSTPenWidth, eRawUnit, bDefault); |
306 | 0 | } |
307 | | |
308 | | void SetWidth(double dfWidth) |
309 | 0 | { |
310 | 0 | SetParamDbl(OGRSTPenWidth, dfWidth); |
311 | 0 | } |
312 | | |
313 | | const char *Pattern(GBool &bDefault) |
314 | 0 | { |
315 | 0 | return GetParamStr(OGRSTPenPattern, bDefault); |
316 | 0 | } |
317 | | |
318 | | void SetPattern(const char *pszPattern) |
319 | 0 | { |
320 | 0 | SetParamStr(OGRSTPenPattern, pszPattern); |
321 | 0 | } |
322 | | |
323 | | const char *Id(GBool &bDefault) |
324 | 0 | { |
325 | 0 | return GetParamStr(OGRSTPenId, bDefault); |
326 | 0 | } |
327 | | |
328 | | void SetId(const char *pszId) |
329 | 0 | { |
330 | 0 | SetParamStr(OGRSTPenId, pszId); |
331 | 0 | } |
332 | | |
333 | | double PerpendicularOffset(GBool &bDefault) |
334 | 0 | { |
335 | 0 | return GetParamDbl(OGRSTPenPerOffset, bDefault); |
336 | 0 | } |
337 | | |
338 | | void SetPerpendicularOffset(double dfPerp) |
339 | 0 | { |
340 | 0 | SetParamDbl(OGRSTPenPerOffset, dfPerp); |
341 | 0 | } |
342 | | |
343 | | const char *Cap(GBool &bDefault) |
344 | 0 | { |
345 | 0 | return GetParamStr(OGRSTPenCap, bDefault); |
346 | 0 | } |
347 | | |
348 | | void SetCap(const char *pszCap) |
349 | 0 | { |
350 | 0 | SetParamStr(OGRSTPenCap, pszCap); |
351 | 0 | } |
352 | | |
353 | | const char *Join(GBool &bDefault) |
354 | 0 | { |
355 | 0 | return GetParamStr(OGRSTPenJoin, bDefault); |
356 | 0 | } |
357 | | |
358 | | void SetJoin(const char *pszJoin) |
359 | 0 | { |
360 | 0 | SetParamStr(OGRSTPenJoin, pszJoin); |
361 | 0 | } |
362 | | |
363 | | int Priority(GBool &bDefault) |
364 | 0 | { |
365 | 0 | return GetParamNum(OGRSTPenPriority, bDefault); |
366 | 0 | } |
367 | | |
368 | | void SetPriority(int nPriority) |
369 | 0 | { |
370 | 0 | SetParamNum(OGRSTPenPriority, nPriority); |
371 | 0 | } |
372 | | |
373 | | /*****************************************************************/ |
374 | | |
375 | | const char *GetParamStr(OGRSTPenParam eParam, GBool &bValueIsNull); |
376 | | int GetParamNum(OGRSTPenParam eParam, GBool &bValueIsNull); |
377 | | double GetParamDbl(OGRSTPenParam eParam, GBool &bValueIsNull); |
378 | | double GetRawParamDbl(OGRSTPenParam eParam, OGRSTUnitId &eRawUnit, |
379 | | GBool &bValueIsNull); |
380 | | void SetParamStr(OGRSTPenParam eParam, const char *pszParamString); |
381 | | void SetParamNum(OGRSTPenParam eParam, int nParam); |
382 | | void SetParamDbl(OGRSTPenParam eParam, double dfParam); |
383 | | const char *GetStyleString() override; |
384 | | }; |
385 | | |
386 | | /** |
387 | | * This class represents a style brush |
388 | | */ |
389 | | class CPL_DLL OGRStyleBrush : public OGRStyleTool |
390 | | { |
391 | | private: |
392 | | OGRStyleValue *m_pasStyleValue; |
393 | | |
394 | | GBool Parse() override; |
395 | | |
396 | | CPL_DISALLOW_COPY_ASSIGN(OGRStyleBrush) |
397 | | |
398 | | public: |
399 | | OGRStyleBrush(); |
400 | | ~OGRStyleBrush() override; |
401 | | |
402 | | /* Explicit fct for all parameters defined in the Drawing tools Brush */ |
403 | | |
404 | | const char *ForeColor(GBool &bDefault) |
405 | 0 | { |
406 | 0 | return GetParamStr(OGRSTBrushFColor, bDefault); |
407 | 0 | } |
408 | | |
409 | | void SetForeColor(const char *pszColor) |
410 | 0 | { |
411 | 0 | SetParamStr(OGRSTBrushFColor, pszColor); |
412 | 0 | } |
413 | | |
414 | | const char *BackColor(GBool &bDefault) |
415 | 0 | { |
416 | 0 | return GetParamStr(OGRSTBrushBColor, bDefault); |
417 | 0 | } |
418 | | |
419 | | void SetBackColor(const char *pszColor) |
420 | 0 | { |
421 | 0 | SetParamStr(OGRSTBrushBColor, pszColor); |
422 | 0 | } |
423 | | |
424 | | const char *Id(GBool &bDefault) |
425 | 0 | { |
426 | 0 | return GetParamStr(OGRSTBrushId, bDefault); |
427 | 0 | } |
428 | | |
429 | | void SetId(const char *pszId) |
430 | 0 | { |
431 | 0 | SetParamStr(OGRSTBrushId, pszId); |
432 | 0 | } |
433 | | |
434 | | double Angle(GBool &bDefault) |
435 | 0 | { |
436 | 0 | return GetParamDbl(OGRSTBrushAngle, bDefault); |
437 | 0 | } |
438 | | |
439 | | void SetAngle(double dfAngle) |
440 | 0 | { |
441 | 0 | SetParamDbl(OGRSTBrushAngle, dfAngle); |
442 | 0 | } |
443 | | |
444 | | double Size(GBool &bDefault) |
445 | 0 | { |
446 | 0 | return GetParamDbl(OGRSTBrushSize, bDefault); |
447 | 0 | } |
448 | | |
449 | | void SetSize(double dfSize) |
450 | 0 | { |
451 | 0 | SetParamDbl(OGRSTBrushSize, dfSize); |
452 | 0 | } |
453 | | |
454 | | double SpacingX(GBool &bDefault) |
455 | 0 | { |
456 | 0 | return GetParamDbl(OGRSTBrushDx, bDefault); |
457 | 0 | } |
458 | | |
459 | | void SetSpacingX(double dfX) |
460 | 0 | { |
461 | 0 | SetParamDbl(OGRSTBrushDx, dfX); |
462 | 0 | } |
463 | | |
464 | | double SpacingY(GBool &bDefault) |
465 | 0 | { |
466 | 0 | return GetParamDbl(OGRSTBrushDy, bDefault); |
467 | 0 | } |
468 | | |
469 | | void SetSpacingY(double dfY) |
470 | 0 | { |
471 | 0 | SetParamDbl(OGRSTBrushDy, dfY); |
472 | 0 | } |
473 | | |
474 | | int Priority(GBool &bDefault) |
475 | 0 | { |
476 | 0 | return GetParamNum(OGRSTBrushPriority, bDefault); |
477 | 0 | } |
478 | | |
479 | | void SetPriority(int nPriority) |
480 | 0 | { |
481 | 0 | SetParamNum(OGRSTBrushPriority, nPriority); |
482 | 0 | } |
483 | | |
484 | | /*****************************************************************/ |
485 | | |
486 | | const char *GetParamStr(OGRSTBrushParam eParam, GBool &bValueIsNull); |
487 | | int GetParamNum(OGRSTBrushParam eParam, GBool &bValueIsNull); |
488 | | double GetParamDbl(OGRSTBrushParam eParam, GBool &bValueIsNull); |
489 | | void SetParamStr(OGRSTBrushParam eParam, const char *pszParamString); |
490 | | void SetParamNum(OGRSTBrushParam eParam, int nParam); |
491 | | void SetParamDbl(OGRSTBrushParam eParam, double dfParam); |
492 | | const char *GetStyleString() override; |
493 | | }; |
494 | | |
495 | | /** |
496 | | * This class represents a style symbol |
497 | | */ |
498 | | class CPL_DLL OGRStyleSymbol : public OGRStyleTool |
499 | | { |
500 | | private: |
501 | | OGRStyleValue *m_pasStyleValue; |
502 | | |
503 | | GBool Parse() override; |
504 | | |
505 | | CPL_DISALLOW_COPY_ASSIGN(OGRStyleSymbol) |
506 | | |
507 | | public: |
508 | | OGRStyleSymbol(); |
509 | | ~OGRStyleSymbol() override; |
510 | | |
511 | | /*****************************************************************/ |
512 | | /* Explicit fct for all parameters defined in the Drawing tools */ |
513 | | /*****************************************************************/ |
514 | | |
515 | | const char *Id(GBool &bDefault) |
516 | 0 | { |
517 | 0 | return GetParamStr(OGRSTSymbolId, bDefault); |
518 | 0 | } |
519 | | |
520 | | void SetId(const char *pszId) |
521 | 0 | { |
522 | 0 | SetParamStr(OGRSTSymbolId, pszId); |
523 | 0 | } |
524 | | |
525 | | double Angle(GBool &bDefault) |
526 | 0 | { |
527 | 0 | return GetParamDbl(OGRSTSymbolAngle, bDefault); |
528 | 0 | } |
529 | | |
530 | | void SetAngle(double dfAngle) |
531 | 0 | { |
532 | 0 | SetParamDbl(OGRSTSymbolAngle, dfAngle); |
533 | 0 | } |
534 | | |
535 | | const char *Color(GBool &bDefault) |
536 | 0 | { |
537 | 0 | return GetParamStr(OGRSTSymbolColor, bDefault); |
538 | 0 | } |
539 | | |
540 | | void SetColor(const char *pszColor) |
541 | 0 | { |
542 | 0 | SetParamStr(OGRSTSymbolColor, pszColor); |
543 | 0 | } |
544 | | |
545 | | double Size(GBool &bDefault) |
546 | 0 | { |
547 | 0 | return GetParamDbl(OGRSTSymbolSize, bDefault); |
548 | 0 | } |
549 | | |
550 | | void SetSize(double dfSize) |
551 | 0 | { |
552 | 0 | SetParamDbl(OGRSTSymbolSize, dfSize); |
553 | 0 | } |
554 | | |
555 | | double SpacingX(GBool &bDefault) |
556 | 0 | { |
557 | 0 | return GetParamDbl(OGRSTSymbolDx, bDefault); |
558 | 0 | } |
559 | | |
560 | | void SetSpacingX(double dfX) |
561 | 0 | { |
562 | 0 | SetParamDbl(OGRSTSymbolDx, dfX); |
563 | 0 | } |
564 | | |
565 | | double SpacingY(GBool &bDefault) |
566 | 0 | { |
567 | 0 | return GetParamDbl(OGRSTSymbolDy, bDefault); |
568 | 0 | } |
569 | | |
570 | | void SetSpacingY(double dfY) |
571 | 0 | { |
572 | 0 | SetParamDbl(OGRSTSymbolDy, dfY); |
573 | 0 | } |
574 | | |
575 | | double Step(GBool &bDefault) |
576 | 0 | { |
577 | 0 | return GetParamDbl(OGRSTSymbolStep, bDefault); |
578 | 0 | } |
579 | | |
580 | | void SetStep(double dfStep) |
581 | 0 | { |
582 | 0 | SetParamDbl(OGRSTSymbolStep, dfStep); |
583 | 0 | } |
584 | | |
585 | | double Offset(GBool &bDefault) |
586 | 0 | { |
587 | 0 | return GetParamDbl(OGRSTSymbolOffset, bDefault); |
588 | 0 | } |
589 | | |
590 | | void SetOffset(double dfOffset) |
591 | 0 | { |
592 | 0 | SetParamDbl(OGRSTSymbolOffset, dfOffset); |
593 | 0 | } |
594 | | |
595 | | double Perp(GBool &bDefault) |
596 | 0 | { |
597 | 0 | return GetParamDbl(OGRSTSymbolPerp, bDefault); |
598 | 0 | } |
599 | | |
600 | | void SetPerp(double dfPerp) |
601 | 0 | { |
602 | 0 | SetParamDbl(OGRSTSymbolPerp, dfPerp); |
603 | 0 | } |
604 | | |
605 | | int Priority(GBool &bDefault) |
606 | 0 | { |
607 | 0 | return GetParamNum(OGRSTSymbolPriority, bDefault); |
608 | 0 | } |
609 | | |
610 | | void SetPriority(int nPriority) |
611 | 0 | { |
612 | 0 | SetParamNum(OGRSTSymbolPriority, nPriority); |
613 | 0 | } |
614 | | |
615 | | const char *FontName(GBool &bDefault) |
616 | 0 | { |
617 | 0 | return GetParamStr(OGRSTSymbolFontName, bDefault); |
618 | 0 | } |
619 | | |
620 | | void SetFontName(const char *pszFontName) |
621 | 0 | { |
622 | 0 | SetParamStr(OGRSTSymbolFontName, pszFontName); |
623 | 0 | } |
624 | | |
625 | | const char *OColor(GBool &bDefault) |
626 | 0 | { |
627 | 0 | return GetParamStr(OGRSTSymbolOColor, bDefault); |
628 | 0 | } |
629 | | |
630 | | void SetOColor(const char *pszColor) |
631 | 0 | { |
632 | 0 | SetParamStr(OGRSTSymbolOColor, pszColor); |
633 | 0 | } |
634 | | |
635 | | /*****************************************************************/ |
636 | | |
637 | | const char *GetParamStr(OGRSTSymbolParam eParam, GBool &bValueIsNull); |
638 | | int GetParamNum(OGRSTSymbolParam eParam, GBool &bValueIsNull); |
639 | | double GetParamDbl(OGRSTSymbolParam eParam, GBool &bValueIsNull); |
640 | | void SetParamStr(OGRSTSymbolParam eParam, const char *pszParamString); |
641 | | void SetParamNum(OGRSTSymbolParam eParam, int nParam); |
642 | | void SetParamDbl(OGRSTSymbolParam eParam, double dfParam); |
643 | | const char *GetStyleString() override; |
644 | | }; |
645 | | |
646 | | /** |
647 | | * This class represents a style label |
648 | | */ |
649 | | class CPL_DLL OGRStyleLabel : public OGRStyleTool |
650 | | { |
651 | | private: |
652 | | OGRStyleValue *m_pasStyleValue; |
653 | | |
654 | | GBool Parse() override; |
655 | | |
656 | | CPL_DISALLOW_COPY_ASSIGN(OGRStyleLabel) |
657 | | |
658 | | public: |
659 | | OGRStyleLabel(); |
660 | | ~OGRStyleLabel() override; |
661 | | |
662 | | /*****************************************************************/ |
663 | | /* Explicit fct for all parameters defined in the Drawing tools */ |
664 | | /*****************************************************************/ |
665 | | |
666 | | const char *FontName(GBool &bDefault) |
667 | 0 | { |
668 | 0 | return GetParamStr(OGRSTLabelFontName, bDefault); |
669 | 0 | } |
670 | | |
671 | | void SetFontName(const char *pszFontName) |
672 | 0 | { |
673 | 0 | SetParamStr(OGRSTLabelFontName, pszFontName); |
674 | 0 | } |
675 | | |
676 | | double Size(GBool &bDefault) |
677 | 0 | { |
678 | 0 | return GetParamDbl(OGRSTLabelSize, bDefault); |
679 | 0 | } |
680 | | |
681 | | void SetSize(double dfSize) |
682 | 0 | { |
683 | 0 | SetParamDbl(OGRSTLabelSize, dfSize); |
684 | 0 | } |
685 | | |
686 | | const char *TextString(GBool &bDefault) |
687 | 0 | { |
688 | 0 | return GetParamStr(OGRSTLabelTextString, bDefault); |
689 | 0 | } |
690 | | |
691 | | void SetTextString(const char *pszTextString) |
692 | 0 | { |
693 | 0 | SetParamStr(OGRSTLabelTextString, pszTextString); |
694 | 0 | } |
695 | | |
696 | | double Angle(GBool &bDefault) |
697 | 0 | { |
698 | 0 | return GetParamDbl(OGRSTLabelAngle, bDefault); |
699 | 0 | } |
700 | | |
701 | | void SetAngle(double dfAngle) |
702 | 0 | { |
703 | 0 | SetParamDbl(OGRSTLabelAngle, dfAngle); |
704 | 0 | } |
705 | | |
706 | | const char *ForeColor(GBool &bDefault) |
707 | 0 | { |
708 | 0 | return GetParamStr(OGRSTLabelFColor, bDefault); |
709 | 0 | } |
710 | | |
711 | | void SetForColor(const char *pszForColor) |
712 | 0 | { |
713 | 0 | SetParamStr(OGRSTLabelFColor, pszForColor); |
714 | 0 | } |
715 | | |
716 | | const char *BackColor(GBool &bDefault) |
717 | 0 | { |
718 | 0 | return GetParamStr(OGRSTLabelBColor, bDefault); |
719 | 0 | } |
720 | | |
721 | | void SetBackColor(const char *pszBackColor) |
722 | 0 | { |
723 | 0 | SetParamStr(OGRSTLabelBColor, pszBackColor); |
724 | 0 | } |
725 | | |
726 | | const char *Placement(GBool &bDefault) |
727 | 0 | { |
728 | 0 | return GetParamStr(OGRSTLabelPlacement, bDefault); |
729 | 0 | } |
730 | | |
731 | | void SetPlacement(const char *pszPlacement) |
732 | 0 | { |
733 | 0 | SetParamStr(OGRSTLabelPlacement, pszPlacement); |
734 | 0 | } |
735 | | |
736 | | int Anchor(GBool &bDefault) |
737 | 0 | { |
738 | 0 | return GetParamNum(OGRSTLabelAnchor, bDefault); |
739 | 0 | } |
740 | | |
741 | | void SetAnchor(int nAnchor) |
742 | 0 | { |
743 | 0 | SetParamNum(OGRSTLabelAnchor, nAnchor); |
744 | 0 | } |
745 | | |
746 | | double SpacingX(GBool &bDefault) |
747 | 0 | { |
748 | 0 | return GetParamDbl(OGRSTLabelDx, bDefault); |
749 | 0 | } |
750 | | |
751 | | void SetSpacingX(double dfX) |
752 | 0 | { |
753 | 0 | SetParamDbl(OGRSTLabelDx, dfX); |
754 | 0 | } |
755 | | |
756 | | double SpacingY(GBool &bDefault) |
757 | 0 | { |
758 | 0 | return GetParamDbl(OGRSTLabelDy, bDefault); |
759 | 0 | } |
760 | | |
761 | | void SetSpacingY(double dfY) |
762 | 0 | { |
763 | 0 | SetParamDbl(OGRSTLabelDy, dfY); |
764 | 0 | } |
765 | | |
766 | | double Perp(GBool &bDefault) |
767 | 0 | { |
768 | 0 | return GetParamDbl(OGRSTLabelPerp, bDefault); |
769 | 0 | } |
770 | | |
771 | | void SetPerp(double dfPerp) |
772 | 0 | { |
773 | 0 | SetParamDbl(OGRSTLabelPerp, dfPerp); |
774 | 0 | } |
775 | | |
776 | | GBool Bold(GBool &bDefault) |
777 | 0 | { |
778 | 0 | return GetParamNum(OGRSTLabelBold, bDefault); |
779 | 0 | } |
780 | | |
781 | | void SetBold(GBool bBold) |
782 | 0 | { |
783 | 0 | SetParamNum(OGRSTLabelBold, bBold); |
784 | 0 | } |
785 | | |
786 | | GBool Italic(GBool &bDefault) |
787 | 0 | { |
788 | 0 | return GetParamNum(OGRSTLabelItalic, bDefault); |
789 | 0 | } |
790 | | |
791 | | void SetItalic(GBool bItalic) |
792 | 0 | { |
793 | 0 | SetParamNum(OGRSTLabelItalic, bItalic); |
794 | 0 | } |
795 | | |
796 | | GBool Underline(GBool &bDefault) |
797 | 0 | { |
798 | 0 | return GetParamNum(OGRSTLabelUnderline, bDefault); |
799 | 0 | } |
800 | | |
801 | | void SetUnderline(GBool bUnderline) |
802 | 0 | { |
803 | 0 | SetParamNum(OGRSTLabelUnderline, bUnderline); |
804 | 0 | } |
805 | | |
806 | | int Priority(GBool &bDefault) |
807 | 0 | { |
808 | 0 | return GetParamNum(OGRSTLabelPriority, bDefault); |
809 | 0 | } |
810 | | |
811 | | void SetPriority(int nPriority) |
812 | 0 | { |
813 | 0 | SetParamNum(OGRSTLabelPriority, nPriority); |
814 | 0 | } |
815 | | |
816 | | GBool Strikeout(GBool &bDefault) |
817 | 0 | { |
818 | 0 | return GetParamNum(OGRSTLabelStrikeout, bDefault); |
819 | 0 | } |
820 | | |
821 | | void SetStrikeout(GBool bStrikeout) |
822 | 0 | { |
823 | 0 | SetParamNum(OGRSTLabelStrikeout, bStrikeout); |
824 | 0 | } |
825 | | |
826 | | double Stretch(GBool &bDefault) |
827 | 0 | { |
828 | 0 | return GetParamDbl(OGRSTLabelStretch, bDefault); |
829 | 0 | } |
830 | | |
831 | | void SetStretch(double dfStretch) |
832 | 0 | { |
833 | 0 | SetParamDbl(OGRSTLabelStretch, dfStretch); |
834 | 0 | } |
835 | | |
836 | | const char *ShadowColor(GBool &bDefault) |
837 | 0 | { |
838 | 0 | return GetParamStr(OGRSTLabelHColor, bDefault); |
839 | 0 | } |
840 | | |
841 | | void SetShadowColor(const char *pszShadowColor) |
842 | 0 | { |
843 | 0 | SetParamStr(OGRSTLabelHColor, pszShadowColor); |
844 | 0 | } |
845 | | |
846 | | const char *OutlineColor(GBool &bDefault) |
847 | 0 | { |
848 | 0 | return GetParamStr(OGRSTLabelOColor, bDefault); |
849 | 0 | } |
850 | | |
851 | | void SetOutlineColor(const char *pszOutlineColor) |
852 | 0 | { |
853 | 0 | SetParamStr(OGRSTLabelOColor, pszOutlineColor); |
854 | 0 | } |
855 | | |
856 | | /*****************************************************************/ |
857 | | |
858 | | const char *GetParamStr(OGRSTLabelParam eParam, GBool &bValueIsNull); |
859 | | int GetParamNum(OGRSTLabelParam eParam, GBool &bValueIsNull); |
860 | | double GetParamDbl(OGRSTLabelParam eParam, GBool &bValueIsNull); |
861 | | void SetParamStr(OGRSTLabelParam eParam, const char *pszParamString); |
862 | | void SetParamNum(OGRSTLabelParam eParam, int nParam); |
863 | | void SetParamDbl(OGRSTLabelParam eParam, double dfParam); |
864 | | const char *GetStyleString() override; |
865 | | }; |
866 | | |
867 | | //! @endcond |
868 | | |
869 | | #endif /* OGR_FEATURESTYLE_INCLUDE */ |