#include "modgmt_func.h" ObjectBase* GMT_Header(const ObjectList* input) { return new ObjectString(header); } ObjectBase* GMT_Footer(const ObjectList* input) { return new ObjectString(footer); } ObjectBase* GMT_ColorGray(const ObjectList* input) { struct gmt_color c; bool suc=true; Base2RGB g(input,0); Base2Transp t(input,1); c.model=gmt_color::GRAY; c.gray=g(&suc); c.transparency=t(&suc); if(suc) return new ObjectGMTColor(c); else return 0; } ObjectBase* GMT_ColorRGB(const ObjectList* input) { struct gmt_color c; bool suc=true; Base2RGB r(input,0),g(input,1),b(input,2); Base2Transp t(input,3); c.model=gmt_color::RGB; c.r=r(&suc); c.g=g(&suc); c.b=b(&suc); c.transparency=t(&suc); if(suc) return new ObjectGMTColor(c); else return 0; } ObjectBase* GMT_ColorHSV(const ObjectList* input) { struct gmt_color c; bool suc=true; Base2Hue h(input,0); Base2SV s(input,1),v(input,2); Base2Transp t(input,3); c.model=gmt_color::HSV; c.hue=h(&suc); c.saturation=s(&suc); c.value=v(&suc); c.transparency=t(&suc); if(suc) return new ObjectGMTColor(c); else return 0; } ObjectBase* GMT_ColorCMYK(const ObjectList* input) { struct gmt_color c; bool suc=true; Base2CMYK cyan(input,0),m(input,1),y(input,2),k(input,3); Base2Transp t(input,4); c.model=gmt_color::CMYK; c.cyan=cyan(&suc); c.magenta=m(&suc); c.yellow=y(&suc); c.black=k(&suc); c.transparency=t(&suc); if(suc) return new ObjectGMTColor(c); else return 0; } // Shifting layer /* Input: 1) Three arguments, first is Layer, second and third are double. Interprets as new absolute position in cm. 2) Pairs list. Names are l (layer), x, y, xrel (xr), yrel (yr). Pair with name l may be absent, in this case search in list and using as layer object with ObjectGMTLayer type. x and y are absolute positions in cm, xrel and yrel are shift from current position. x (y) and xrel (yrel) are mutually exlusive, but x (y) and yrel (xrel) can be used simultaneously. If position for some axis is absent, then this position is unchanged. */ ObjectBase* GMT_LayerShift(const ObjectList* input) { auto size=input->Size(); struct gmt_layer layer; // Case 1 if(3==size) { Base2Layer l(input,0); Base2Double x(input,1), y(input,2); bool suc=true; layer=l(&suc); if(!suc) goto case2; layer.shiftx=x(&suc); layer.shifty=y(&suc); if(!suc) goto case2; return new ObjectGMTLayer(layer); } case2: // Search layer for shifting { SearchParameter original(input,"layer","l"); bool suc=true; layer=original(&suc); if(!suc) goto fail; // Conversion failed or too many arguments } // Do shift { BaseM2Double xr(input,"xrel","xr"), yr(input,"yrel","yr"); Base2Double x(input,"x"), y(input,"y"); bool suc=true; // Check duplicate parameters if( ( x.Exist() && xr.Exist() ) || ( y.Exist() && yr.Exist() ) ) goto fail; if(x.Exist()) layer.shiftx=x(&suc); if(y.Exist()) layer.shifty=y(&suc); if(xr.Exist()) layer.shiftx+=x(&suc); if(yr.Exist()) layer.shifty+=y(&suc); if(!suc) goto fail; } return new ObjectGMTLayer(layer); fail: return 0; }