|
|
@ -176,6 +176,7 @@ using Base2Proj =Base2Struct<struct gmt_projection>; |
|
|
|
using Base2Color =Base2Struct<struct gmt_color>; |
|
|
|
using Base2Color =Base2Struct<struct gmt_color>; |
|
|
|
using Base2Dash =Base2Struct<struct gmt_dash>; |
|
|
|
using Base2Dash =Base2Struct<struct gmt_dash>; |
|
|
|
using Base2Pen =Base2Struct<struct gmt_pen>; |
|
|
|
using Base2Pen =Base2Struct<struct gmt_pen>; |
|
|
|
|
|
|
|
using Base2Font =Base2Struct<struct gmt_font>; |
|
|
|
|
|
|
|
|
|
|
|
// Simple aliases of convertors with default values
|
|
|
|
// Simple aliases of convertors with default values
|
|
|
|
using Base2StringD=Base2StructD<std::string>; |
|
|
|
using Base2StringD=Base2StructD<std::string>; |
|
|
@ -982,90 +983,52 @@ class Convert2Struct<struct gmt_font, ObjectList> |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
|
|
|
|
struct gmt_font operator()(const ObjectList* input, bool* issuc) const |
|
|
|
struct gmt_font operator()(const ObjectList* input, bool* issuc, std::string& err) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct gmt_font f; |
|
|
|
struct gmt_font f; |
|
|
|
auto size=input->Size(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(1==size) // Cases 1, 2, 4 and 5
|
|
|
|
if(1==input->Size()) // Cases 1, 2, 4 and 5
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Base2Font font(input,0); |
|
|
|
Base2Font font; |
|
|
|
bool suc=true; |
|
|
|
bool suc=true; |
|
|
|
f=font(&suc); |
|
|
|
f=font.Convert(input->At(0),&suc,err); |
|
|
|
if(!suc) goto fail; // Conversion failed
|
|
|
|
if(!suc) goto fail; // Conversion failed
|
|
|
|
return f; |
|
|
|
return f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Case 3
|
|
|
|
// Case 6 and 7
|
|
|
|
{ |
|
|
|
|
|
|
|
bool casevalid=false; |
|
|
|
|
|
|
|
bool upd; |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
BaseMT2Font updarg(input,"font"); |
|
|
|
OPosPar<Base2PosD> size("size",gmt_font::default_size); |
|
|
|
bool suc=true; |
|
|
|
OPosPar<Base2ColorD> color("color",0.0); |
|
|
|
f=updarg(&upd,&suc); |
|
|
|
OPosPar<Base2StringD> family("family",gmt_font::default_family); |
|
|
|
if(upd && !suc) goto fail; // Conversion failed or too many arguments
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!upd) |
|
|
|
ParsePositionalParameters params(input,size,family,color); |
|
|
|
{ |
|
|
|
if(!params) goto case3; // May be case3 will work
|
|
|
|
// default font is Times-Roman, 12pt, black
|
|
|
|
f.color=color; |
|
|
|
f.size=gmt_font::default_size; |
|
|
|
f.size=size; |
|
|
|
f.color.Convert(0); |
|
|
|
f.family=family; |
|
|
|
f.family=gmt_font::default_family; |
|
|
|
return f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Size
|
|
|
|
// Case 3
|
|
|
|
{ |
|
|
|
case3: |
|
|
|
BaseM2Width s(input,"s","size"); |
|
|
|
|
|
|
|
if(s.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
bool suc=true; |
|
|
|
ONFPar<Base2Font,ObjectGMTFont> font("f[on]t"); |
|
|
|
f.size=s(&suc); |
|
|
|
ONFPar<Base2ColorD,ObjectGMTColor> color("color",0); |
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
ONFPar<Base2StringD,ObjectString> family("f[a]m[i]ly",gmt_font::default_family); |
|
|
|
casevalid=true; |
|
|
|
ONFPar<Base2PosD,ObjectReal> size("size",gmt_font::default_size); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Family
|
|
|
|
{ParseNamedParameters params(input,font,color,family,size); if(!params) {err=params.Error(); goto fail;} } // Fail to parse by variant 3
|
|
|
|
{ |
|
|
|
|
|
|
|
BaseM2String family(input,"family","f"); |
|
|
|
|
|
|
|
if(family.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
f.family=family(&suc); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
|
|
|
|
casevalid=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Color
|
|
|
|
bool upd=font.Exist(); |
|
|
|
{ |
|
|
|
if(upd) f=font; |
|
|
|
BaseMT2Color color(input,"color","c"); |
|
|
|
if(color.Exist() || !upd) f.color =color; |
|
|
|
if(color.Exist()) |
|
|
|
if(family.Exist() || !upd) f.family=family; |
|
|
|
{ |
|
|
|
if(size.Exist() || !upd) f.size =size; |
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
f.color=color(&suc); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
|
|
|
|
casevalid=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(casevalid || upd) return f; // Pen created or updated
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Case 6 and 7
|
|
|
|
if(color.Exist() || family.Exist() || size.Exist() || upd) return f; // Font created or updated
|
|
|
|
if(2==size || 3==size) |
|
|
|
err="Specify at least one of size, family or color"; |
|
|
|
{ |
|
|
|
|
|
|
|
Base2Width s(input,0); |
|
|
|
|
|
|
|
Base2String fam(input,1); |
|
|
|
|
|
|
|
Base2Color c(input,2); |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
f.size=s(&suc); |
|
|
|
|
|
|
|
f.family=fam(&suc); |
|
|
|
|
|
|
|
f.color=c(&suc); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Something wrong
|
|
|
|
|
|
|
|
return f; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fail: |
|
|
|
fail: |
|
|
|