00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
#ifndef OGR_FEATURESTYLE_INCLUDE
00056
#define OGR_FEATURESTYLE_INCLUDE
00057
00058
#include "cpl_conv.h"
00059
00060
class OGRFeature;
00061
00062
typedef enum ogr_style_tool_class_id
00063 {
00064 OGRSTCNone,
00065 OGRSTCPen,
00066 OGRSTCBrush,
00067 OGRSTCSymbol,
00068 OGRSTCLabel
00069 } OGRSTClassId;
00070
00071
typedef enum ogr_style_tool_units_id
00072 {
00073 OGRSTUGround,
00074 OGRSTUPixel,
00075 OGRSTUPoints,
00076 OGRSTUMM,
00077 OGRSTUCM,
00078 OGRSTUInches
00079 } OGRSTUnitId;
00080
00081
typedef enum ogr_style_tool_param_pen_id
00082 {
00083 OGRSTPenColor = 0,
00084 OGRSTPenWidth,
00085 OGRSTPenPattern,
00086 OGRSTPenId,
00087 OGRSTPenPerOffset,
00088 OGRSTPenCap,
00089 OGRSTPenJoin,
00090 OGRSTPenPriority,
00091 OGRSTPenLast
00092
00093 } OGRSTPenParam;
00094
00095
typedef enum ogr_style_tool_param_brush_id
00096 {
00097 OGRSTBrushFColor = 0,
00098 OGRSTBrushBColor,
00099 OGRSTBrushId,
00100 OGRSTBrushAngle,
00101 OGRSTBrushSize,
00102 OGRSTBrushDx,
00103 OGRSTBrushDy,
00104 OGRSTBrushPriority,
00105 OGRSTBrushLast
00106
00107 } OGRSTBrushParam;
00108
00109
00110
00111
typedef enum ogr_style_tool_param_symbol_id
00112 {
00113 OGRSTSymbolId = 0,
00114 OGRSTSymbolAngle,
00115 OGRSTSymbolColor,
00116 OGRSTSymbolSize,
00117 OGRSTSymbolDx,
00118 OGRSTSymbolDy,
00119 OGRSTSymbolStep,
00120 OGRSTSymbolPerp,
00121 OGRSTSymbolOffset,
00122 OGRSTSymbolPriority,
00123 OGRSTSymbolLast
00124
00125 } OGRSTSymbolParam;
00126
00127
typedef enum ogr_style_tool_param_label_id
00128 {
00129 OGRSTLabelFontName = 0,
00130 OGRSTLabelSize,
00131 OGRSTLabelTextString,
00132 OGRSTLabelAngle,
00133 OGRSTLabelFColor,
00134 OGRSTLabelBColor,
00135 OGRSTLabelPlacement,
00136 OGRSTLabelAnchor,
00137 OGRSTLabelDx,
00138 OGRSTLabelDy,
00139 OGRSTLabelPerp,
00140 OGRSTLabelBold,
00141 OGRSTLabelItalic,
00142 OGRSTLabelUnderline,
00143 OGRSTLabelPriority,
00144 OGRSTLabelLast
00145
00146 } OGRSTLabelParam;
00147
00148
typedef enum ogr_style_type
00149 {
00150 OGRSTypeString,
00151 OGRSTypeDouble,
00152 OGRSTypeInteger
00153 } OGRSType;
00154
00155
typedef struct ogr_style_param
00156 {
00157
int eParam;
00158
char *pszToken;
00159 GBool bGeoref;
00160 OGRSType eType;
00161 }OGRStyleParamId;
00162
00163
00164
typedef struct ogr_style_value
00165 {
00166
char *pszValue;
00167
double dfValue;
00168
int nValue;
00169 GBool bValid;
00170 OGRSTUnitId eUnit;
00171 }OGRStyleValue;
00172
00173
00174
00175
00176
00177
class CPL_DLL OGRStyleTable
00178 {
00179
public:
00180
char **m_papszStyleTable;
00181
00182 OGRStyleTable();
00183 ~OGRStyleTable();
00184 GBool AddStyle(
const char *pszName,
const char *pszStyleString);
00185 GBool RemoveStyle(
const char *pszName);
00186 GBool ModifyStyle(
const char *pszName,
const char *pszStyleString);
00187
00188 GBool SaveStyleTable(
const char *pszFilename);
00189 GBool LoadStyleTable(
const char *pszFilename);
00190
const char *Find(
const char *pszStyleString);
00191 GBool IsExist(
const char *pszName);
00192
const char *GetStyleName(
const char *pszName);
00193
void Print(FILE *fpOut);
00194
void Clear();
00195 };
00196
00197
00198
class OGRStyleTool;
00199
00200
class CPL_DLL OGRStyleMgr
00201 {
00202
public:
00203
char *m_pszStyleString;
00204 OGRStyleTable *m_poDataSetStyleTable;
00205
00206 OGRStyleMgr(OGRStyleTable *poDataSetStyleTable =NULL);
00207
00208 ~OGRStyleMgr();
00209 GBool SetFeatureStyleString(
OGRFeature *,
const char *pszStyleString=NULL,
00210 GBool bNoMatching = FALSE);
00211
00212
00213
00214
00215
const char *InitFromFeature(
OGRFeature *);
00216 GBool InitStyleString(
const char *pszStyleString = NULL);
00217
00218
const char *GetStyleName(
const char *pszStyleString= NULL);
00219
const char *GetStyleByName(
const char *pszStyleName);
00220
00221 GBool AddStyle(
const char *pszStyleName,
const char *pszStyleString=NULL);
00222
00223
const char *GetStyleString(
OGRFeature * = NULL);
00224
00225 GBool AddPart(OGRStyleTool *);
00226 GBool AddPart(
const char *);
00227
00228
int GetPartCount(
const char *pszStyleString = NULL);
00229 OGRStyleTool *GetPart(
int hPartId,
const char *pszStyleString = NULL);
00230
00231
00232
00233
00234 OGRStyleTable *GetDataSetStyleTable(){
return m_poDataSetStyleTable;}
00235
00236 OGRStyleTool *CreateStyleToolFromStyleString(
const char *pszStyleString);
00237
00238 };
00239
00240
class CPL_DLL OGRStyleTool
00241 {
00242
public:
00243
00244 GBool m_bModified;
00245 GBool m_bParsed;
00246
double m_dfScale;
00247 OGRSTUnitId m_eUnit;
00248 OGRSTClassId m_eClassId;
00249 OGRStyleTool(){}
00250 OGRStyleTool(OGRSTClassId eClassId);
00251
virtual ~OGRStyleTool();
00252
00253 GBool GetRGBFromString(
const char *pszColor,
int &nRed,
int &nGreen,
00254
int &nBlue,
int &nTransparence);
00255
int GetSpecificId(
const char *pszId,
const char *pszWanted);
00256
00257 GBool IsStyleModified() {
return m_bModified;}
00258
void StyleModified() {m_bModified = TRUE;}
00259
00260 GBool IsStyleParsed() {
return m_bParsed;}
00261
void StyleParsed() {m_bParsed = TRUE;}
00262
00263
char *m_pszStyleString;
00264
00265 OGRSTClassId GetType();
00266
00267
void SetInternalInputUnitFromParam(
char *pszString);
00268
00269
void SetUnit(OGRSTUnitId,
double dfScale = 1.0);
00270
00271
00272 OGRSTUnitId GetUnit(){
return m_eUnit;}
00273
00274
00275
00276
00277
00278
virtual const char *GetStyleString() = 0;
00279
void SetStyleString(
const char *pszStyleString);
00280
const char *GetStyleString(OGRStyleParamId *pasStyleParam ,
00281 OGRStyleValue *pasStyleValue,
int nSize);
00282
00283
const char *GetParamStr(OGRStyleParamId &sStyleParam ,
00284 OGRStyleValue &sStyleValue,
00285 GBool &bValueIsNull);
00286
00287
int GetParamNum(OGRStyleParamId &sStyleParam ,
00288 OGRStyleValue &sStyleValue,
00289 GBool &bValueIsNull);
00290
00291
double GetParamDbl(OGRStyleParamId &sStyleParam ,
00292 OGRStyleValue &sStyleValue,
00293 GBool &bValueIsNull);
00294
00295
void SetParamStr(OGRStyleParamId &sStyleParam ,
00296 OGRStyleValue &sStyleValue,
00297
const char *pszParamString);
00298
00299
void SetParamNum(OGRStyleParamId &sStyleParam ,
00300 OGRStyleValue &sStyleValue,
00301
int nParam);
00302
00303
void SetParamDbl(OGRStyleParamId &sStyleParam ,
00304 OGRStyleValue &sStyleValue,
00305
double dfParam);
00306
00307
virtual GBool Parse() = 0;
00308 GBool Parse(OGRStyleParamId* pasStyle,
00309 OGRStyleValue* pasValue,
00310
int nCount);
00311
00312
double ComputeWithUnit(
double, OGRSTUnitId);
00313
int ComputeWithUnit(
int , OGRSTUnitId);
00314
00315 };
00316
00317
extern OGRStyleParamId CPL_DLL asStylePen[];
00318
00319
class CPL_DLL OGRStylePen :
public OGRStyleTool
00320 {
00321
public:
00322
00323 OGRStyleValue *m_pasStyleValue;
00324
00325 OGRStylePen();
00326
virtual ~OGRStylePen();
00327
00328
00329
00330
00331
00332
const char *Color(GBool &bDefault){
return GetParamStr(OGRSTPenColor,bDefault);}
00333
void SetColor(
const char *pszColor){SetParamStr(OGRSTPenColor,pszColor);}
00334
double Width(GBool &bDefault){
return GetParamDbl(OGRSTPenWidth,bDefault);}
00335
void SetWidth(
double dfWidth){SetParamDbl(OGRSTPenWidth,dfWidth);}
00336
const char *Pattern(GBool &bDefault){
return (
char *)GetParamStr(OGRSTPenPattern,bDefault);}
00337
void SetPattern(
const char *pszPattern){SetParamStr(OGRSTPenPattern,pszPattern);}
00338
const char *Id(GBool &bDefault){
return GetParamStr(OGRSTPenId,bDefault);}
00339
void SetId(
const char *pszId){SetParamStr(OGRSTPenId,pszId);}
00340
double PerpendicularOffset(GBool &bDefault){
return GetParamDbl(OGRSTPenPerOffset,bDefault);}
00341
void SetPerpendicularOffset(
double dfPerp){SetParamDbl(OGRSTPenPerOffset,dfPerp);}
00342
const char *Cap(GBool &bDefault){
return GetParamStr(OGRSTPenCap,bDefault);}
00343
void SetCap(
const char *pszCap){SetParamStr(OGRSTPenCap,pszCap);}
00344
const char *Join(GBool &bDefault){
return GetParamStr(OGRSTPenJoin,bDefault);}
00345
void SetJoin(
const char *pszJoin){SetParamStr(OGRSTPenJoin,pszJoin);}
00346
int Priority(GBool &bDefault){
return GetParamNum(OGRSTPenPriority,bDefault);}
00347
void SetPriority(
int nPriority){SetParamNum(OGRSTPenPriority,nPriority);}
00348
00349
00350
00351 GBool Parse();
00352
const char *GetParamStr(OGRSTPenParam eParam, GBool &bValueIsNull);
00353
int GetParamNum(OGRSTPenParam eParam,GBool &bValueIsNull);
00354
double GetParamDbl(OGRSTPenParam eParam,GBool &bValueIsNull);
00355
void SetParamStr(OGRSTPenParam eParam,
const char *pszParamString);
00356
void SetParamNum(OGRSTPenParam eParam,
int nParam);
00357
void SetParamDbl(OGRSTPenParam eParam,
double dfParam);
00358
const char *GetStyleString();
00359 };
00360
00361
extern OGRStyleParamId CPL_DLL asStyleBrush[];
00362
00363
class CPL_DLL OGRStyleBrush :
public OGRStyleTool
00364 {
00365
public:
00366
00367 OGRStyleValue *m_pasStyleValue;
00368
00369 OGRStyleBrush();
00370
virtual ~OGRStyleBrush();
00371
00372
00373
00374
const char *ForeColor(GBool &bDefault){
return GetParamStr(OGRSTBrushFColor,bDefault);}
00375
void SetForeColor(
const char *pszColor){SetParamStr(OGRSTBrushFColor,pszColor);}
00376
const char *BackColor(GBool &bDefault){
return GetParamStr(OGRSTBrushBColor,bDefault);}
00377
void SetBackColor(
const char *pszColor){SetParamStr(OGRSTBrushBColor,pszColor);}
00378
const char *Id(GBool &bDefault){
return GetParamStr(OGRSTBrushId,bDefault);}
00379
void SetId(
const char *pszId){SetParamStr(OGRSTBrushId,pszId);}
00380
double Angle(GBool &bDefault){
return GetParamDbl(OGRSTBrushAngle,bDefault);}
00381
void SetAngle(
double dfAngle){SetParamDbl(OGRSTBrushAngle,dfAngle );}
00382
double Size(GBool &bDefault){
return GetParamDbl(OGRSTBrushSize,bDefault);}
00383
void SetSize(
double dfSize){SetParamDbl(OGRSTBrushSize,dfSize );}
00384
double SpacingX(GBool &bDefault){
return GetParamDbl(OGRSTBrushDx,bDefault);}
00385
void SetSpacingX(
double dfX){SetParamDbl(OGRSTBrushDx,dfX );}
00386
double SpacingY(GBool &bDefault){
return GetParamDbl(OGRSTBrushDy,bDefault);}
00387
void SetSpacingY(
double dfY){SetParamDbl(OGRSTBrushDy,dfY );}
00388
int Priority(GBool &bDefault){
return GetParamNum(OGRSTBrushPriority,bDefault);}
00389
void SetPriority(
int nPriority){ SetParamNum(OGRSTBrushPriority,nPriority);}
00390
00391
00392
00393
00394 GBool Parse();
00395
const char *GetParamStr(OGRSTBrushParam eParam, GBool &bValueIsNull);
00396
int GetParamNum(OGRSTBrushParam eParam,GBool &bValueIsNull);
00397
double GetParamDbl(OGRSTBrushParam eParam,GBool &bValueIsNull);
00398
void SetParamStr(OGRSTBrushParam eParam,
const char *pszParamString);
00399
void SetParamNum(OGRSTBrushParam eParam,
int nParam);
00400
void SetParamDbl(OGRSTBrushParam eParam,
double dfParam);
00401
const char *GetStyleString();
00402 };
00403
00404
extern OGRStyleParamId CPL_DLL asStyleSymbol[];
00405
00406
class CPL_DLL OGRStyleSymbol :
public OGRStyleTool
00407 {
00408
public:
00409
00410 OGRStyleValue *m_pasStyleValue;
00411
00412 OGRStyleSymbol();
00413
virtual ~OGRStyleSymbol();
00414
00415
00416
00417
00418
00419
const char *Id(GBool &bDefault){
return GetParamStr(OGRSTSymbolId,bDefault);}
00420
void SetId(
const char *pszId){ SetParamStr(OGRSTSymbolId,pszId);}
00421
double Angle(GBool &bDefault){
return GetParamDbl(OGRSTSymbolAngle,bDefault);}
00422
void SetAngle(
double dfAngle){SetParamDbl(OGRSTSymbolAngle,dfAngle );}
00423
const char *Color(GBool &bDefault){
return GetParamStr(OGRSTSymbolColor,bDefault);}
00424
void SetColor(
const char *pszColor){SetParamStr(OGRSTSymbolColor,pszColor);}
00425
double Size(GBool &bDefault){
return GetParamDbl(OGRSTSymbolSize,bDefault);}
00426
void SetSize(
double dfSize){ SetParamDbl(OGRSTSymbolSize,dfSize );}
00427
double SpacingX(GBool &bDefault){
return GetParamDbl(OGRSTSymbolDx,bDefault);}
00428
void SetSpacingX(
double dfX){SetParamDbl(OGRSTSymbolDx,dfX );}
00429
double SpacingY(GBool &bDefault){
return GetParamDbl(OGRSTSymbolDy,bDefault);}
00430
void SetSpacingY(
double dfY){SetParamDbl(OGRSTSymbolDy,dfY );}
00431
double Step(GBool &bDefault){
return GetParamDbl(OGRSTSymbolStep,bDefault);}
00432
void SetStep(
double dfStep){SetParamDbl(OGRSTSymbolStep,dfStep );}
00433
double Offset(GBool &bDefault){
return GetParamDbl(OGRSTSymbolOffset,bDefault);}
00434
void SetOffset(
double dfOffset){SetParamDbl(OGRSTSymbolOffset,dfOffset );}
00435
double Perp(GBool &bDefault){
return GetParamDbl(OGRSTSymbolPerp,bDefault);}
00436
void SetPerp(
double dfPerp){SetParamDbl(OGRSTSymbolPerp,dfPerp );}
00437
int Priority(GBool &bDefault){
return GetParamNum(OGRSTSymbolPriority,bDefault);}
00438
void SetPriority(
int nPriority){SetParamNum(OGRSTSymbolPriority,nPriority);}
00439
00440
00441
00442
00443
00444 GBool Parse();
00445
const char *GetParamStr(OGRSTSymbolParam eParam, GBool &bValueIsNull);
00446
int GetParamNum(OGRSTSymbolParam eParam,GBool &bValueIsNull);
00447
double GetParamDbl(OGRSTSymbolParam eParam,GBool &bValueIsNull);
00448
void SetParamStr(OGRSTSymbolParam eParam,
const char *pszParamString);
00449
void SetParamNum(OGRSTSymbolParam eParam,
int nParam);
00450
void SetParamDbl(OGRSTSymbolParam eParam,
double dfParam);
00451
const char *GetStyleString();
00452 };
00453
00454
extern OGRStyleParamId CPL_DLL asStyleLabel[];
00455
00456
class CPL_DLL OGRStyleLabel :
public OGRStyleTool
00457 {
00458
public:
00459
00460 OGRStyleValue *m_pasStyleValue;
00461
00462 OGRStyleLabel();
00463
virtual ~OGRStyleLabel();
00464
00465
00466
00467
00468
00469
const char *FontName(GBool &bDefault){
return GetParamStr(OGRSTLabelFontName,bDefault);}
00470
void SetFontName(
const char *pszFontName){SetParamStr(OGRSTLabelFontName,pszFontName);}
00471
double Size(GBool &bDefault){
return GetParamDbl(OGRSTLabelSize,bDefault);}
00472
void SetSize(
double dfSize){SetParamDbl(OGRSTLabelSize,dfSize);}
00473
const char *TextString(GBool &bDefault){
return GetParamStr(OGRSTLabelTextString,bDefault);}
00474
void SetTextString(
const char *pszTextString){SetParamStr(OGRSTLabelTextString,pszTextString);}
00475
double Angle(GBool &bDefault){
return GetParamDbl(OGRSTLabelAngle,bDefault);}
00476
void SetAngle(
double dfAngle){SetParamDbl(OGRSTLabelAngle,dfAngle);}
00477
const char *ForeColor(GBool &bDefault){
return GetParamStr(OGRSTLabelFColor,bDefault);}
00478
void SetForColor(
const char *pszForColor){SetParamStr(OGRSTLabelFColor,pszForColor);}
00479
const char *BackColor(GBool &bDefault){
return GetParamStr(OGRSTLabelBColor,bDefault);}
00480
void SetBackColor(
const char *pszBackColor){SetParamStr(OGRSTLabelBColor,pszBackColor);}
00481
const char *Placement(GBool &bDefault){
return GetParamStr(OGRSTLabelPlacement,bDefault);}
00482
void SetPlacement(
const char *pszPlacement){SetParamStr(OGRSTLabelPlacement,pszPlacement);}
00483
int Anchor(GBool &bDefault){
return GetParamNum(OGRSTLabelAnchor,bDefault);}
00484
void SetAnchor(
int nAnchor){SetParamNum(OGRSTLabelAnchor,nAnchor);}
00485
double SpacingX(GBool &bDefault){
return GetParamDbl(OGRSTLabelDx,bDefault);}
00486
void SetSpacingX(
double dfX){SetParamDbl(OGRSTLabelDx,dfX);}
00487
double SpacingY(GBool &bDefault){
return GetParamDbl(OGRSTLabelDy,bDefault);}
00488
void SetSpacingY(
double dfY){SetParamDbl(OGRSTLabelDy,dfY);}
00489
double Perp(GBool &bDefault){
return GetParamDbl(OGRSTLabelPerp,bDefault);}
00490
void SetPerp(
double dfPerp){SetParamDbl(OGRSTLabelPerp,dfPerp);}
00491 GBool Bold(GBool &bDefault){
return GetParamNum(OGRSTLabelBold,bDefault);}
00492
void SetBold(GBool bBold){SetParamNum(OGRSTLabelBold,bBold);}
00493 GBool Italic(GBool &bDefault){
return GetParamNum(OGRSTLabelItalic,bDefault);}
00494
void SetItalic(GBool bItalic){SetParamNum(OGRSTLabelItalic,bItalic);}
00495 GBool Underline(GBool &bDefault){
return GetParamNum(OGRSTLabelUnderline,bDefault);}
00496
void SetUnderline(GBool bUnderline){SetParamNum(OGRSTLabelUnderline,bUnderline);}
00497
int Priority(GBool &bDefault){
return GetParamNum(OGRSTLabelPriority,bDefault);}
00498
void SetPriority(
int nPriority){SetParamNum(OGRSTLabelPriority,nPriority);}
00499
00500
00501
00502 GBool Parse();
00503
const char *GetParamStr(OGRSTLabelParam eParam, GBool &bValueIsNull);
00504
int GetParamNum(OGRSTLabelParam eParam,GBool &bValueIsNull);
00505
double GetParamDbl(OGRSTLabelParam eParam,GBool &bValueIsNull);
00506
void SetParamStr(OGRSTLabelParam eParam,
const char *pszParamString);
00507
void SetParamNum(OGRSTLabelParam eParam,
int nParam);
00508
void SetParamDbl(OGRSTLabelParam eParam,
double dfParam);
00509
const char *GetStyleString();
00510 };
00511
00512
#endif
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526