/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 | | // used if we are working with Ground |
221 | | // Unit ( ground = paper * scale); |
222 | | |
223 | | OGRSTUnitId GetUnit() |
224 | 0 | { |
225 | 0 | return m_eUnit; |
226 | 0 | } |
227 | | |
228 | | // There are two way to set the parameters in the Style, with generic |
229 | | // methods (using a defined enumeration) or with the reel method specific |
230 | | // for Each style tools. |
231 | | |
232 | | virtual const char *GetStyleString() = 0; |
233 | | void SetStyleString(const char *pszStyleString); |
234 | | const char *GetStyleString(const OGRStyleParamId *pasStyleParam, |
235 | | OGRStyleValue *pasStyleValue, int nSize); |
236 | | |
237 | | const char *GetParamStr(const OGRStyleParamId &sStyleParam, |
238 | | const OGRStyleValue &sStyleValue, |
239 | | GBool &bValueIsNull); |
240 | | |
241 | | int GetParamNum(const OGRStyleParamId &sStyleParam, |
242 | | const OGRStyleValue &sStyleValue, GBool &bValueIsNull); |
243 | | |
244 | | double GetParamDbl(const OGRStyleParamId &sStyleParam, |
245 | | const OGRStyleValue &sStyleValue, GBool &bValueIsNull); |
246 | | |
247 | | double GetRawParamDbl(const OGRStyleParamId &sStyleParam, |
248 | | const OGRStyleValue &sStyleValue, |
249 | | OGRSTUnitId &eRawUnit, GBool &bValueIsNull); |
250 | | |
251 | | void SetParamStr(const OGRStyleParamId &sStyleParam, |
252 | | OGRStyleValue &sStyleValue, const char *pszParamString); |
253 | | |
254 | | void SetParamNum(const OGRStyleParamId &sStyleParam, |
255 | | OGRStyleValue &sStyleValue, int nParam); |
256 | | |
257 | | void SetParamDbl(const OGRStyleParamId &sStyleParam, |
258 | | OGRStyleValue &sStyleValue, double dfParam); |
259 | | #ifndef DOXYGEN_SKIP |
260 | | double ComputeWithUnit(double, OGRSTUnitId); |
261 | | int ComputeWithUnit(int, OGRSTUnitId); |
262 | | #endif |
263 | | }; |
264 | | |
265 | | //! @cond Doxygen_Suppress |
266 | | |
267 | | /** |
268 | | * This class represents a style pen |
269 | | */ |
270 | | class CPL_DLL OGRStylePen : public OGRStyleTool |
271 | | { |
272 | | private: |
273 | | OGRStyleValue *m_pasStyleValue; |
274 | | |
275 | | GBool Parse() override; |
276 | | |
277 | | CPL_DISALLOW_COPY_ASSIGN(OGRStylePen) |
278 | | |
279 | | public: |
280 | | OGRStylePen(); |
281 | | ~OGRStylePen() override; |
282 | | |
283 | | /**********************************************************************/ |
284 | | /* Explicit fct for all parameters defined in the Drawing tools Pen */ |
285 | | /**********************************************************************/ |
286 | | |
287 | | const char *Color(GBool &bDefault) |
288 | 0 | { |
289 | 0 | return GetParamStr(OGRSTPenColor, bDefault); |
290 | 0 | } |
291 | | |
292 | | void SetColor(const char *pszColor) |
293 | 0 | { |
294 | 0 | SetParamStr(OGRSTPenColor, pszColor); |
295 | 0 | } |
296 | | |
297 | | double Width(GBool &bDefault) |
298 | 0 | { |
299 | 0 | return GetParamDbl(OGRSTPenWidth, bDefault); |
300 | 0 | } |
301 | | |
302 | | double RawWidth(OGRSTUnitId &eRawUnit, GBool &bDefault) |
303 | 0 | { |
304 | 0 | return GetRawParamDbl(OGRSTPenWidth, eRawUnit, bDefault); |
305 | 0 | } |
306 | | |
307 | | void SetWidth(double dfWidth) |
308 | 0 | { |
309 | 0 | SetParamDbl(OGRSTPenWidth, dfWidth); |
310 | 0 | } |
311 | | |
312 | | const char *Pattern(GBool &bDefault) |
313 | 0 | { |
314 | 0 | return GetParamStr(OGRSTPenPattern, bDefault); |
315 | 0 | } |
316 | | |
317 | | void SetPattern(const char *pszPattern) |
318 | 0 | { |
319 | 0 | SetParamStr(OGRSTPenPattern, pszPattern); |
320 | 0 | } |
321 | | |
322 | | const char *Id(GBool &bDefault) |
323 | 0 | { |
324 | 0 | return GetParamStr(OGRSTPenId, bDefault); |
325 | 0 | } |
326 | | |
327 | | void SetId(const char *pszId) |
328 | 0 | { |
329 | 0 | SetParamStr(OGRSTPenId, pszId); |
330 | 0 | } |
331 | | |
332 | | double PerpendicularOffset(GBool &bDefault) |
333 | 0 | { |
334 | 0 | return GetParamDbl(OGRSTPenPerOffset, bDefault); |
335 | 0 | } |
336 | | |
337 | | void SetPerpendicularOffset(double dfPerp) |
338 | 0 | { |
339 | 0 | SetParamDbl(OGRSTPenPerOffset, dfPerp); |
340 | 0 | } |
341 | | |
342 | | const char *Cap(GBool &bDefault) |
343 | 0 | { |
344 | 0 | return GetParamStr(OGRSTPenCap, bDefault); |
345 | 0 | } |
346 | | |
347 | | void SetCap(const char *pszCap) |
348 | 0 | { |
349 | 0 | SetParamStr(OGRSTPenCap, pszCap); |
350 | 0 | } |
351 | | |
352 | | const char *Join(GBool &bDefault) |
353 | 0 | { |
354 | 0 | return GetParamStr(OGRSTPenJoin, bDefault); |
355 | 0 | } |
356 | | |
357 | | void SetJoin(const char *pszJoin) |
358 | 0 | { |
359 | 0 | SetParamStr(OGRSTPenJoin, pszJoin); |
360 | 0 | } |
361 | | |
362 | | int Priority(GBool &bDefault) |
363 | 0 | { |
364 | 0 | return GetParamNum(OGRSTPenPriority, bDefault); |
365 | 0 | } |
366 | | |
367 | | void SetPriority(int nPriority) |
368 | 0 | { |
369 | 0 | SetParamNum(OGRSTPenPriority, nPriority); |
370 | 0 | } |
371 | | |
372 | | /*****************************************************************/ |
373 | | |
374 | | const char *GetParamStr(OGRSTPenParam eParam, GBool &bValueIsNull); |
375 | | int GetParamNum(OGRSTPenParam eParam, GBool &bValueIsNull); |
376 | | double GetParamDbl(OGRSTPenParam eParam, GBool &bValueIsNull); |
377 | | double GetRawParamDbl(OGRSTPenParam eParam, OGRSTUnitId &eRawUnit, |
378 | | GBool &bValueIsNull); |
379 | | void SetParamStr(OGRSTPenParam eParam, const char *pszParamString); |
380 | | void SetParamNum(OGRSTPenParam eParam, int nParam); |
381 | | void SetParamDbl(OGRSTPenParam eParam, double dfParam); |
382 | | const char *GetStyleString() override; |
383 | | }; |
384 | | |
385 | | /** |
386 | | * This class represents a style brush |
387 | | */ |
388 | | class CPL_DLL OGRStyleBrush : public OGRStyleTool |
389 | | { |
390 | | private: |
391 | | OGRStyleValue *m_pasStyleValue; |
392 | | |
393 | | GBool Parse() override; |
394 | | |
395 | | CPL_DISALLOW_COPY_ASSIGN(OGRStyleBrush) |
396 | | |
397 | | public: |
398 | | OGRStyleBrush(); |
399 | | ~OGRStyleBrush() override; |
400 | | |
401 | | /* Explicit fct for all parameters defined in the Drawing tools Brush */ |
402 | | |
403 | | const char *ForeColor(GBool &bDefault) |
404 | 0 | { |
405 | 0 | return GetParamStr(OGRSTBrushFColor, bDefault); |
406 | 0 | } |
407 | | |
408 | | void SetForeColor(const char *pszColor) |
409 | 0 | { |
410 | 0 | SetParamStr(OGRSTBrushFColor, pszColor); |
411 | 0 | } |
412 | | |
413 | | const char *BackColor(GBool &bDefault) |
414 | 0 | { |
415 | 0 | return GetParamStr(OGRSTBrushBColor, bDefault); |
416 | 0 | } |
417 | | |
418 | | void SetBackColor(const char *pszColor) |
419 | 0 | { |
420 | 0 | SetParamStr(OGRSTBrushBColor, pszColor); |
421 | 0 | } |
422 | | |
423 | | const char *Id(GBool &bDefault) |
424 | 0 | { |
425 | 0 | return GetParamStr(OGRSTBrushId, bDefault); |
426 | 0 | } |
427 | | |
428 | | void SetId(const char *pszId) |
429 | 0 | { |
430 | 0 | SetParamStr(OGRSTBrushId, pszId); |
431 | 0 | } |
432 | | |
433 | | double Angle(GBool &bDefault) |
434 | 0 | { |
435 | 0 | return GetParamDbl(OGRSTBrushAngle, bDefault); |
436 | 0 | } |
437 | | |
438 | | void SetAngle(double dfAngle) |
439 | 0 | { |
440 | 0 | SetParamDbl(OGRSTBrushAngle, dfAngle); |
441 | 0 | } |
442 | | |
443 | | double Size(GBool &bDefault) |
444 | 0 | { |
445 | 0 | return GetParamDbl(OGRSTBrushSize, bDefault); |
446 | 0 | } |
447 | | |
448 | | void SetSize(double dfSize) |
449 | 0 | { |
450 | 0 | SetParamDbl(OGRSTBrushSize, dfSize); |
451 | 0 | } |
452 | | |
453 | | double SpacingX(GBool &bDefault) |
454 | 0 | { |
455 | 0 | return GetParamDbl(OGRSTBrushDx, bDefault); |
456 | 0 | } |
457 | | |
458 | | void SetSpacingX(double dfX) |
459 | 0 | { |
460 | 0 | SetParamDbl(OGRSTBrushDx, dfX); |
461 | 0 | } |
462 | | |
463 | | double SpacingY(GBool &bDefault) |
464 | 0 | { |
465 | 0 | return GetParamDbl(OGRSTBrushDy, bDefault); |
466 | 0 | } |
467 | | |
468 | | void SetSpacingY(double dfY) |
469 | 0 | { |
470 | 0 | SetParamDbl(OGRSTBrushDy, dfY); |
471 | 0 | } |
472 | | |
473 | | int Priority(GBool &bDefault) |
474 | 0 | { |
475 | 0 | return GetParamNum(OGRSTBrushPriority, bDefault); |
476 | 0 | } |
477 | | |
478 | | void SetPriority(int nPriority) |
479 | 0 | { |
480 | 0 | SetParamNum(OGRSTBrushPriority, nPriority); |
481 | 0 | } |
482 | | |
483 | | /*****************************************************************/ |
484 | | |
485 | | const char *GetParamStr(OGRSTBrushParam eParam, GBool &bValueIsNull); |
486 | | int GetParamNum(OGRSTBrushParam eParam, GBool &bValueIsNull); |
487 | | double GetParamDbl(OGRSTBrushParam eParam, GBool &bValueIsNull); |
488 | | void SetParamStr(OGRSTBrushParam eParam, const char *pszParamString); |
489 | | void SetParamNum(OGRSTBrushParam eParam, int nParam); |
490 | | void SetParamDbl(OGRSTBrushParam eParam, double dfParam); |
491 | | const char *GetStyleString() override; |
492 | | }; |
493 | | |
494 | | /** |
495 | | * This class represents a style symbol |
496 | | */ |
497 | | class CPL_DLL OGRStyleSymbol : public OGRStyleTool |
498 | | { |
499 | | private: |
500 | | OGRStyleValue *m_pasStyleValue; |
501 | | |
502 | | GBool Parse() override; |
503 | | |
504 | | CPL_DISALLOW_COPY_ASSIGN(OGRStyleSymbol) |
505 | | |
506 | | public: |
507 | | OGRStyleSymbol(); |
508 | | ~OGRStyleSymbol() override; |
509 | | |
510 | | /*****************************************************************/ |
511 | | /* Explicit fct for all parameters defined in the Drawing tools */ |
512 | | /*****************************************************************/ |
513 | | |
514 | | const char *Id(GBool &bDefault) |
515 | 0 | { |
516 | 0 | return GetParamStr(OGRSTSymbolId, bDefault); |
517 | 0 | } |
518 | | |
519 | | void SetId(const char *pszId) |
520 | 0 | { |
521 | 0 | SetParamStr(OGRSTSymbolId, pszId); |
522 | 0 | } |
523 | | |
524 | | double Angle(GBool &bDefault) |
525 | 0 | { |
526 | 0 | return GetParamDbl(OGRSTSymbolAngle, bDefault); |
527 | 0 | } |
528 | | |
529 | | void SetAngle(double dfAngle) |
530 | 0 | { |
531 | 0 | SetParamDbl(OGRSTSymbolAngle, dfAngle); |
532 | 0 | } |
533 | | |
534 | | const char *Color(GBool &bDefault) |
535 | 0 | { |
536 | 0 | return GetParamStr(OGRSTSymbolColor, bDefault); |
537 | 0 | } |
538 | | |
539 | | void SetColor(const char *pszColor) |
540 | 0 | { |
541 | 0 | SetParamStr(OGRSTSymbolColor, pszColor); |
542 | 0 | } |
543 | | |
544 | | double Size(GBool &bDefault) |
545 | 0 | { |
546 | 0 | return GetParamDbl(OGRSTSymbolSize, bDefault); |
547 | 0 | } |
548 | | |
549 | | void SetSize(double dfSize) |
550 | 0 | { |
551 | 0 | SetParamDbl(OGRSTSymbolSize, dfSize); |
552 | 0 | } |
553 | | |
554 | | double SpacingX(GBool &bDefault) |
555 | 0 | { |
556 | 0 | return GetParamDbl(OGRSTSymbolDx, bDefault); |
557 | 0 | } |
558 | | |
559 | | void SetSpacingX(double dfX) |
560 | 0 | { |
561 | 0 | SetParamDbl(OGRSTSymbolDx, dfX); |
562 | 0 | } |
563 | | |
564 | | double SpacingY(GBool &bDefault) |
565 | 0 | { |
566 | 0 | return GetParamDbl(OGRSTSymbolDy, bDefault); |
567 | 0 | } |
568 | | |
569 | | void SetSpacingY(double dfY) |
570 | 0 | { |
571 | 0 | SetParamDbl(OGRSTSymbolDy, dfY); |
572 | 0 | } |
573 | | |
574 | | double Step(GBool &bDefault) |
575 | 0 | { |
576 | 0 | return GetParamDbl(OGRSTSymbolStep, bDefault); |
577 | 0 | } |
578 | | |
579 | | void SetStep(double dfStep) |
580 | 0 | { |
581 | 0 | SetParamDbl(OGRSTSymbolStep, dfStep); |
582 | 0 | } |
583 | | |
584 | | double Offset(GBool &bDefault) |
585 | 0 | { |
586 | 0 | return GetParamDbl(OGRSTSymbolOffset, bDefault); |
587 | 0 | } |
588 | | |
589 | | void SetOffset(double dfOffset) |
590 | 0 | { |
591 | 0 | SetParamDbl(OGRSTSymbolOffset, dfOffset); |
592 | 0 | } |
593 | | |
594 | | double Perp(GBool &bDefault) |
595 | 0 | { |
596 | 0 | return GetParamDbl(OGRSTSymbolPerp, bDefault); |
597 | 0 | } |
598 | | |
599 | | void SetPerp(double dfPerp) |
600 | 0 | { |
601 | 0 | SetParamDbl(OGRSTSymbolPerp, dfPerp); |
602 | 0 | } |
603 | | |
604 | | int Priority(GBool &bDefault) |
605 | 0 | { |
606 | 0 | return GetParamNum(OGRSTSymbolPriority, bDefault); |
607 | 0 | } |
608 | | |
609 | | void SetPriority(int nPriority) |
610 | 0 | { |
611 | 0 | SetParamNum(OGRSTSymbolPriority, nPriority); |
612 | 0 | } |
613 | | |
614 | | const char *FontName(GBool &bDefault) |
615 | 0 | { |
616 | 0 | return GetParamStr(OGRSTSymbolFontName, bDefault); |
617 | 0 | } |
618 | | |
619 | | void SetFontName(const char *pszFontName) |
620 | 0 | { |
621 | 0 | SetParamStr(OGRSTSymbolFontName, pszFontName); |
622 | 0 | } |
623 | | |
624 | | const char *OColor(GBool &bDefault) |
625 | 0 | { |
626 | 0 | return GetParamStr(OGRSTSymbolOColor, bDefault); |
627 | 0 | } |
628 | | |
629 | | void SetOColor(const char *pszColor) |
630 | 0 | { |
631 | 0 | SetParamStr(OGRSTSymbolOColor, pszColor); |
632 | 0 | } |
633 | | |
634 | | /*****************************************************************/ |
635 | | |
636 | | const char *GetParamStr(OGRSTSymbolParam eParam, GBool &bValueIsNull); |
637 | | int GetParamNum(OGRSTSymbolParam eParam, GBool &bValueIsNull); |
638 | | double GetParamDbl(OGRSTSymbolParam eParam, GBool &bValueIsNull); |
639 | | void SetParamStr(OGRSTSymbolParam eParam, const char *pszParamString); |
640 | | void SetParamNum(OGRSTSymbolParam eParam, int nParam); |
641 | | void SetParamDbl(OGRSTSymbolParam eParam, double dfParam); |
642 | | const char *GetStyleString() override; |
643 | | }; |
644 | | |
645 | | /** |
646 | | * This class represents a style label |
647 | | */ |
648 | | class CPL_DLL OGRStyleLabel : public OGRStyleTool |
649 | | { |
650 | | private: |
651 | | OGRStyleValue *m_pasStyleValue; |
652 | | |
653 | | GBool Parse() override; |
654 | | |
655 | | CPL_DISALLOW_COPY_ASSIGN(OGRStyleLabel) |
656 | | |
657 | | public: |
658 | | OGRStyleLabel(); |
659 | | ~OGRStyleLabel() override; |
660 | | |
661 | | /*****************************************************************/ |
662 | | /* Explicit fct for all parameters defined in the Drawing tools */ |
663 | | /*****************************************************************/ |
664 | | |
665 | | const char *FontName(GBool &bDefault) |
666 | 0 | { |
667 | 0 | return GetParamStr(OGRSTLabelFontName, bDefault); |
668 | 0 | } |
669 | | |
670 | | void SetFontName(const char *pszFontName) |
671 | 0 | { |
672 | 0 | SetParamStr(OGRSTLabelFontName, pszFontName); |
673 | 0 | } |
674 | | |
675 | | double Size(GBool &bDefault) |
676 | 0 | { |
677 | 0 | return GetParamDbl(OGRSTLabelSize, bDefault); |
678 | 0 | } |
679 | | |
680 | | void SetSize(double dfSize) |
681 | 0 | { |
682 | 0 | SetParamDbl(OGRSTLabelSize, dfSize); |
683 | 0 | } |
684 | | |
685 | | const char *TextString(GBool &bDefault) |
686 | 0 | { |
687 | 0 | return GetParamStr(OGRSTLabelTextString, bDefault); |
688 | 0 | } |
689 | | |
690 | | void SetTextString(const char *pszTextString) |
691 | 0 | { |
692 | 0 | SetParamStr(OGRSTLabelTextString, pszTextString); |
693 | 0 | } |
694 | | |
695 | | double Angle(GBool &bDefault) |
696 | 0 | { |
697 | 0 | return GetParamDbl(OGRSTLabelAngle, bDefault); |
698 | 0 | } |
699 | | |
700 | | void SetAngle(double dfAngle) |
701 | 0 | { |
702 | 0 | SetParamDbl(OGRSTLabelAngle, dfAngle); |
703 | 0 | } |
704 | | |
705 | | const char *ForeColor(GBool &bDefault) |
706 | 0 | { |
707 | 0 | return GetParamStr(OGRSTLabelFColor, bDefault); |
708 | 0 | } |
709 | | |
710 | | void SetForColor(const char *pszForColor) |
711 | 0 | { |
712 | 0 | SetParamStr(OGRSTLabelFColor, pszForColor); |
713 | 0 | } |
714 | | |
715 | | const char *BackColor(GBool &bDefault) |
716 | 0 | { |
717 | 0 | return GetParamStr(OGRSTLabelBColor, bDefault); |
718 | 0 | } |
719 | | |
720 | | void SetBackColor(const char *pszBackColor) |
721 | 0 | { |
722 | 0 | SetParamStr(OGRSTLabelBColor, pszBackColor); |
723 | 0 | } |
724 | | |
725 | | const char *Placement(GBool &bDefault) |
726 | 0 | { |
727 | 0 | return GetParamStr(OGRSTLabelPlacement, bDefault); |
728 | 0 | } |
729 | | |
730 | | void SetPlacement(const char *pszPlacement) |
731 | 0 | { |
732 | 0 | SetParamStr(OGRSTLabelPlacement, pszPlacement); |
733 | 0 | } |
734 | | |
735 | | int Anchor(GBool &bDefault) |
736 | 0 | { |
737 | 0 | return GetParamNum(OGRSTLabelAnchor, bDefault); |
738 | 0 | } |
739 | | |
740 | | void SetAnchor(int nAnchor) |
741 | 0 | { |
742 | 0 | SetParamNum(OGRSTLabelAnchor, nAnchor); |
743 | 0 | } |
744 | | |
745 | | double SpacingX(GBool &bDefault) |
746 | 0 | { |
747 | 0 | return GetParamDbl(OGRSTLabelDx, bDefault); |
748 | 0 | } |
749 | | |
750 | | void SetSpacingX(double dfX) |
751 | 0 | { |
752 | 0 | SetParamDbl(OGRSTLabelDx, dfX); |
753 | 0 | } |
754 | | |
755 | | double SpacingY(GBool &bDefault) |
756 | 0 | { |
757 | 0 | return GetParamDbl(OGRSTLabelDy, bDefault); |
758 | 0 | } |
759 | | |
760 | | void SetSpacingY(double dfY) |
761 | 0 | { |
762 | 0 | SetParamDbl(OGRSTLabelDy, dfY); |
763 | 0 | } |
764 | | |
765 | | double Perp(GBool &bDefault) |
766 | 0 | { |
767 | 0 | return GetParamDbl(OGRSTLabelPerp, bDefault); |
768 | 0 | } |
769 | | |
770 | | void SetPerp(double dfPerp) |
771 | 0 | { |
772 | 0 | SetParamDbl(OGRSTLabelPerp, dfPerp); |
773 | 0 | } |
774 | | |
775 | | GBool Bold(GBool &bDefault) |
776 | 0 | { |
777 | 0 | return GetParamNum(OGRSTLabelBold, bDefault); |
778 | 0 | } |
779 | | |
780 | | void SetBold(GBool bBold) |
781 | 0 | { |
782 | 0 | SetParamNum(OGRSTLabelBold, bBold); |
783 | 0 | } |
784 | | |
785 | | GBool Italic(GBool &bDefault) |
786 | 0 | { |
787 | 0 | return GetParamNum(OGRSTLabelItalic, bDefault); |
788 | 0 | } |
789 | | |
790 | | void SetItalic(GBool bItalic) |
791 | 0 | { |
792 | 0 | SetParamNum(OGRSTLabelItalic, bItalic); |
793 | 0 | } |
794 | | |
795 | | GBool Underline(GBool &bDefault) |
796 | 0 | { |
797 | 0 | return GetParamNum(OGRSTLabelUnderline, bDefault); |
798 | 0 | } |
799 | | |
800 | | void SetUnderline(GBool bUnderline) |
801 | 0 | { |
802 | 0 | SetParamNum(OGRSTLabelUnderline, bUnderline); |
803 | 0 | } |
804 | | |
805 | | int Priority(GBool &bDefault) |
806 | 0 | { |
807 | 0 | return GetParamNum(OGRSTLabelPriority, bDefault); |
808 | 0 | } |
809 | | |
810 | | void SetPriority(int nPriority) |
811 | 0 | { |
812 | 0 | SetParamNum(OGRSTLabelPriority, nPriority); |
813 | 0 | } |
814 | | |
815 | | GBool Strikeout(GBool &bDefault) |
816 | 0 | { |
817 | 0 | return GetParamNum(OGRSTLabelStrikeout, bDefault); |
818 | 0 | } |
819 | | |
820 | | void SetStrikeout(GBool bStrikeout) |
821 | 0 | { |
822 | 0 | SetParamNum(OGRSTLabelStrikeout, bStrikeout); |
823 | 0 | } |
824 | | |
825 | | double Stretch(GBool &bDefault) |
826 | 0 | { |
827 | 0 | return GetParamDbl(OGRSTLabelStretch, bDefault); |
828 | 0 | } |
829 | | |
830 | | void SetStretch(double dfStretch) |
831 | 0 | { |
832 | 0 | SetParamDbl(OGRSTLabelStretch, dfStretch); |
833 | 0 | } |
834 | | |
835 | | const char *ShadowColor(GBool &bDefault) |
836 | 0 | { |
837 | 0 | return GetParamStr(OGRSTLabelHColor, bDefault); |
838 | 0 | } |
839 | | |
840 | | void SetShadowColor(const char *pszShadowColor) |
841 | 0 | { |
842 | 0 | SetParamStr(OGRSTLabelHColor, pszShadowColor); |
843 | 0 | } |
844 | | |
845 | | const char *OutlineColor(GBool &bDefault) |
846 | 0 | { |
847 | 0 | return GetParamStr(OGRSTLabelOColor, bDefault); |
848 | 0 | } |
849 | | |
850 | | void SetOutlineColor(const char *pszOutlineColor) |
851 | 0 | { |
852 | 0 | SetParamStr(OGRSTLabelOColor, pszOutlineColor); |
853 | 0 | } |
854 | | |
855 | | /*****************************************************************/ |
856 | | |
857 | | const char *GetParamStr(OGRSTLabelParam eParam, GBool &bValueIsNull); |
858 | | int GetParamNum(OGRSTLabelParam eParam, GBool &bValueIsNull); |
859 | | double GetParamDbl(OGRSTLabelParam eParam, GBool &bValueIsNull); |
860 | | void SetParamStr(OGRSTLabelParam eParam, const char *pszParamString); |
861 | | void SetParamNum(OGRSTLabelParam eParam, int nParam); |
862 | | void SetParamDbl(OGRSTLabelParam eParam, double dfParam); |
863 | | const char *GetStyleString() override; |
864 | | }; |
865 | | |
866 | | //! @endcond |
867 | | |
868 | | #endif /* OGR_FEATURESTYLE_INCLUDE */ |