|
|
|
@ -254,7 +254,9 @@ typedef TypeStorage<struct gmt_dash>::Base2Type Base2Dash;
|
|
|
|
|
// Definitions for ObjectGMTPen
|
|
|
|
|
template<> class TypeStorage<struct gmt_pen>: public gTypeStorage<struct gmt_pen,ObjectList,ObjectString,ObjectReal,ObjectInt,ObjectGMTPen> {}; |
|
|
|
|
typedef TypeStorage<struct gmt_pen>::Base2Type Base2Pen; |
|
|
|
|
|
|
|
|
|
// Definitions for ObjectGMTFont
|
|
|
|
|
template<> class TypeStorage<struct gmt_font>: public gTypeStorage<struct gmt_font,ObjectList,ObjectString,ObjectReal,ObjectInt,ObjectGMTFont> {}; |
|
|
|
|
typedef TypeStorage<struct gmt_font>::Base2Type Base2Font; |
|
|
|
|
|
|
|
|
|
// Conversion from List to GMTRegion
|
|
|
|
|
/*
|
|
|
|
@ -1204,6 +1206,123 @@ class Convert2Struct<struct gmt_pen, ObjectList>
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converting List to GMTFont
|
|
|
|
|
/*
|
|
|
|
|
Input: |
|
|
|
|
1) One argument, Font. Return copy of this argument. |
|
|
|
|
2) One argument, list. Recursively calling GMT_Font. |
|
|
|
|
3) Pairs list. Names are size (s), family (f) and color(c). Default values is 12pt for size, Times-Roman for family and black for color. |
|
|
|
|
If pair with name font exists in list, when recursively calling GMT_Font on the value of this parameter, when modify it with specified parameters. |
|
|
|
|
If argument with type Font exists in list, when copy it and modify with specified parameters. |
|
|
|
|
Instead of color unnamed parameter with Color type may be used. |
|
|
|
|
4) One numeric argument, interprets as size of Times-Roman black font. |
|
|
|
|
5) One string argument, interprets as [size][,family][,color] or [family][,color]. |
|
|
|
|
6) Two arguments, interprets as size and family of black font. |
|
|
|
|
7) Three arguments, interprets as size, family and color. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
class Convert2Struct<struct gmt_font, ObjectList> |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
struct gmt_font operator()(const ObjectList* input, bool* issuc) const |
|
|
|
|
{ |
|
|
|
|
struct gmt_font f; |
|
|
|
|
auto size=input->Size(); |
|
|
|
|
|
|
|
|
|
if(1==size) // Cases 1, 2, 4 and 5
|
|
|
|
|
{ |
|
|
|
|
Base2Font font(input,0); |
|
|
|
|
bool suc=true; |
|
|
|
|
f=font(&suc); |
|
|
|
|
if(!suc) goto fail; // Conversion failed
|
|
|
|
|
return f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Case 3
|
|
|
|
|
{ |
|
|
|
|
bool casevalid=false; |
|
|
|
|
bool upd; |
|
|
|
|
{ |
|
|
|
|
SearchParameter<struct gmt_font> updarg(input,"font"); |
|
|
|
|
bool suc=true; |
|
|
|
|
f=updarg(&upd,&suc); |
|
|
|
|
if(upd && !suc) goto fail; // Conversion failed or too many arguments
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!upd) |
|
|
|
|
{ |
|
|
|
|
// default font is Times-Roman, 12pt, black
|
|
|
|
|
f.size=gmt_font::default_size; |
|
|
|
|
f.color.Convert(0); |
|
|
|
|
f.family=gmt_font::default_family; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Size
|
|
|
|
|
{ |
|
|
|
|
BaseM2Width s(input,"s","size"); |
|
|
|
|
if(s.Exist()) |
|
|
|
|
{ |
|
|
|
|
bool suc=true; |
|
|
|
|
f.size=s(&suc); |
|
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
|
casevalid=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Family
|
|
|
|
|
{ |
|
|
|
|
SearchParameter<std::string> family(input,"family","f"); |
|
|
|
|
if(family.Exist()) |
|
|
|
|
{ |
|
|
|
|
bool suc=true; |
|
|
|
|
f.family=family(&suc); |
|
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
|
casevalid=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Color
|
|
|
|
|
{ |
|
|
|
|
SearchParameter<struct gmt_color> color(input,"color","c"); |
|
|
|
|
if(color.Exist()) |
|
|
|
|
{ |
|
|
|
|
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(2==size || 3==size) |
|
|
|
|
{ |
|
|
|
|
Base2Width s(input,0); |
|
|
|
|
Base2String fam(input,1); |
|
|
|
|
Base2Color c(input,2); |
|
|
|
|
bool suc=true; |
|
|
|
|
if(s && fam) |
|
|
|
|
{ |
|
|
|
|
f.size=s(&suc); |
|
|
|
|
f.family=fam(&suc); |
|
|
|
|
} |
|
|
|
|
else goto fail; // Something wrong
|
|
|
|
|
if(c) f.color=c(&suc); |
|
|
|
|
if(!suc) goto fail; // Something wrong
|
|
|
|
|
return f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fail: |
|
|
|
|
*issuc=false; |
|
|
|
|
return f; // Something go wrong
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Template for generating GMTObject from ObjectList
|
|
|
|
|
template<class Struct> |
|
|
|
|
ObjectBase* GMT_Type(const ObjectList* input) |
|
|
|
|