|
|
@ -1122,6 +1122,225 @@ class ColorConv<ObjectList> |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Helper types
|
|
|
|
|
|
|
|
typedef GetDouble<PMin<0>,PDefaultVal<>> Base2Width; |
|
|
|
|
|
|
|
typedef GetDouble<PMin<0>,PMultiInputNames> BaseM2Width; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converting String to GMTDash
|
|
|
|
|
|
|
|
template<class O> class DashConv |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
struct gmt_dash operator()(const O* o, bool* issuc, const double& w) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct gmt_dash d; |
|
|
|
|
|
|
|
if(!d.Convert(o->Value(),w)) *issuc=false; |
|
|
|
|
|
|
|
return d; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
// Special case is GMTDash
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
|
|
|
class DashConv<ObjectGMTDash> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
struct gmt_dash operator()(const ObjectGMTDash* o, bool* suc, const double& w) const {return o->Data();} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
typedef Base2Something<DashConv,ObjectString,ObjectGMTDash> Base2Dash; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converting List to GMTPen
|
|
|
|
|
|
|
|
template<class O> class PenConv |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
struct gmt_pen operator()(const O* o, bool* issuc) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct gmt_pen p; |
|
|
|
|
|
|
|
if(!p.Convert(o->Value())) *issuc=false; |
|
|
|
|
|
|
|
return p; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
// Special case is GMTPen
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
|
|
|
class PenConv<ObjectGMTPen> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
struct gmt_pen operator()(const ObjectGMTPen* o, bool* suc) const {return o->Data();} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
typedef Base2Something<PenConv,ObjectList,ObjectString,ObjectReal,ObjectInt,ObjectGMTPen> Base2Pen; |
|
|
|
|
|
|
|
// Conversion from List
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
|
|
|
class PenConv<ObjectList> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
// Cases see in description of GMT_Pen function
|
|
|
|
|
|
|
|
struct gmt_pen operator()(const ObjectList* input, bool* issuc) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct gmt_pen p; |
|
|
|
|
|
|
|
auto size=input->Size(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(1==size) // Cases 1, 2 and 4
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Base2Pen a(input,0); |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
p=a(&suc); |
|
|
|
|
|
|
|
if(suc) return p; |
|
|
|
|
|
|
|
goto fail; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Case 3
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool upd=false; |
|
|
|
|
|
|
|
bool casevalid=false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update case, arguments list contains parameter with type GMTPen.
|
|
|
|
|
|
|
|
for(ObjectList::ListValues::size_type i=0;i<size;i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
OBType<ObjectGMTPen> pen(input->At(i)); |
|
|
|
|
|
|
|
if(pen) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(upd) goto fail; // Only one pen in list allowed
|
|
|
|
|
|
|
|
p=pen->Data(); |
|
|
|
|
|
|
|
upd=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update case, arguments list contains parameter p or pen.
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Base2Pen pshort(input,"p"); |
|
|
|
|
|
|
|
Base2Pen plong(input,"pen"); |
|
|
|
|
|
|
|
if(pshort.Exist() && plong.Exist()) goto fail; // Only one parameter allowed
|
|
|
|
|
|
|
|
if(pshort.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(upd) goto fail; // Already have pen to update
|
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
upd=true; |
|
|
|
|
|
|
|
p=pshort(&suc); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Parse error
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(plong.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(upd) goto fail; // Already have pen to update
|
|
|
|
|
|
|
|
upd=true; |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
p=plong(&suc); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Parse error
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!upd) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// default pen is solid black 1mm width
|
|
|
|
|
|
|
|
p.width=1; |
|
|
|
|
|
|
|
p.color.Convert(0); |
|
|
|
|
|
|
|
p.dash.Clear(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
BaseM2Width w(input,"w","width"); |
|
|
|
|
|
|
|
if(w.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
p.width=w(&suc); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
|
|
|
|
casevalid=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Color
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool havec=false; |
|
|
|
|
|
|
|
// Find parameter with type GMTColor.
|
|
|
|
|
|
|
|
for(ObjectList::ListValues::size_type i=0;i<size;i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
OBType<ObjectGMTColor> c(input->At(i)); |
|
|
|
|
|
|
|
if(c) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(havec) goto fail; // Only one color in list allowed
|
|
|
|
|
|
|
|
p.color=c->Data(); |
|
|
|
|
|
|
|
havec=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Base2Color sh(input,"c"), lo(input,"color"); |
|
|
|
|
|
|
|
if(sh.Exist() && lo.Exist()) goto fail; // Only one parameter allowed
|
|
|
|
|
|
|
|
if(sh.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(havec) goto fail; // Already have color
|
|
|
|
|
|
|
|
havec=true; |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
p.color=sh(&suc); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(lo.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(havec) goto fail; // Already have color
|
|
|
|
|
|
|
|
havec=true; |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
p.color=lo(&suc); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(havec) casevalid=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Dash
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool haved=false; |
|
|
|
|
|
|
|
// Find parameter with type GMTDash.
|
|
|
|
|
|
|
|
for(ObjectList::ListValues::size_type i=0;i<size;i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
OBType<ObjectGMTDash> d(input->At(i)); |
|
|
|
|
|
|
|
if(d) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(haved) goto fail; // Only one color in list allowed
|
|
|
|
|
|
|
|
p.dash=d->Data(); |
|
|
|
|
|
|
|
haved=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Base2Dash sh(input,"d"), lo(input,"dash"); |
|
|
|
|
|
|
|
if(sh.Exist() && lo.Exist()) goto fail; // Only one parameter allowed
|
|
|
|
|
|
|
|
if(sh.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(haved) goto fail; // Already have color
|
|
|
|
|
|
|
|
haved=true; |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
p.dash=sh(&suc,p.width); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(lo.Exist()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(haved) goto fail; // Already have color
|
|
|
|
|
|
|
|
haved=true; |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
p.dash=lo(&suc,p.width); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Parsing error
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(haved) casevalid=true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(casevalid || upd) return p; // Pen created or updated
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Case 5 and 6
|
|
|
|
|
|
|
|
if(2==size || 3==size) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Base2Width w(input,0); |
|
|
|
|
|
|
|
Base2Color c(input,1); |
|
|
|
|
|
|
|
Base2Dash d(input,2); |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
if(w && c) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
p.width=w(&suc); |
|
|
|
|
|
|
|
p.color=c(&suc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else goto fail; // Something wrong
|
|
|
|
|
|
|
|
if(d) p.dash=d(&suc,p.width); |
|
|
|
|
|
|
|
if(!suc) goto fail; // Something wrong
|
|
|
|
|
|
|
|
return p; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fail: |
|
|
|
|
|
|
|
*issuc=false; |
|
|
|
|
|
|
|
return p; // Something go wrong
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Input is one argument, Int, Real, String or GMTCoord. |
|
|
|
Input is one argument, Int, Real, String or GMTCoord. |
|
|
|
ObjectString can be number or in form "dd:mm[:ss]", where dd is degrees from -360 to 360, mm is minutes from 0 to 59 |
|
|
|
ObjectString can be number or in form "dd:mm[:ss]", where dd is degrees from -360 to 360, mm is minutes from 0 to 59 |
|
|
@ -1269,3 +1488,23 @@ ObjectBase* GMT_ColorCMYK(const ObjectList* input) |
|
|
|
if(suc) return new ObjectGMTColor(c); |
|
|
|
if(suc) return new ObjectGMTColor(c); |
|
|
|
else return 0; |
|
|
|
else return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Input: |
|
|
|
|
|
|
|
1) One argument, Pen. Return copy of this argument. |
|
|
|
|
|
|
|
2) One argument, list. Recursively calling GMT_Pen. |
|
|
|
|
|
|
|
3) Pairs list. Names are width (w), color(c), dash(f). Default values is 1 for width, black for color and solid for dash. |
|
|
|
|
|
|
|
If pair with name pen(p) exists in list, when recursively calling GMT_Line on the value of this parameter, when modify it with specified parameters. |
|
|
|
|
|
|
|
If argument with type Pen exists in list, when copy it and modify with specified parameters. |
|
|
|
|
|
|
|
Instead of color and dash unnamed parameters with Color and Dash types may be used. |
|
|
|
|
|
|
|
4) One argument, interprets as width of black solid line. |
|
|
|
|
|
|
|
5) Two arguments, interprets as width and color of solid line. |
|
|
|
|
|
|
|
6) Three arguments, interprets as width, color and dash. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
ObjectBase* GMT_Pen(const ObjectList* input) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
struct gmt_pen p=PenConv<ObjectList>()(input,&suc); |
|
|
|
|
|
|
|
if(suc) return new ObjectGMTPen(p); |
|
|
|
|
|
|
|
else return 0; |
|
|
|
|
|
|
|
} |
|
|
|