|
|
@ -89,54 +89,44 @@ const ObjectBase* GMT_ColorCMYK(const ObjectList* input) |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Input: |
|
|
|
Input: |
|
|
|
1) Three arguments, first is Layer, second and third are double. Interprets as new absolute position in cm. |
|
|
|
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. |
|
|
|
2) Pairs list. Names are l (layer), x, y, relx (rx), rely (ry). 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, relx and rely are shift from current position. x (y) and relx (rely) are mutually exlusive, but x (y) and rely (relx) can be used simultaneously. If position for some axis is absent, then this position is unchanged. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
const ObjectBase* GMT_LayerShift(const ObjectList* input) |
|
|
|
const ObjectBase* GMT_LayerShift(const ObjectList* input) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto size=input->Size(); |
|
|
|
|
|
|
|
struct gmt_layer layer; |
|
|
|
struct gmt_layer layer; |
|
|
|
|
|
|
|
std::string err; |
|
|
|
|
|
|
|
|
|
|
|
// Case 1
|
|
|
|
// Case 1
|
|
|
|
if(3==size) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Base2Layer l(input,0); |
|
|
|
RPosPar<Base2Layer> l("layer"); |
|
|
|
Base2Double x(input,1), y(input,2); |
|
|
|
OPosPar<Base2DoubleD> x("x",0.0), y("y",0.0); |
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
layer=l(&suc); |
|
|
|
{ParsePositionalParameters params(input,l,x,y); if(!params) goto case2;} // Try case 2, if case 1 failed.
|
|
|
|
if(!suc) goto case2; |
|
|
|
layer=l; layer.shiftx=x; layer.shifty=y; |
|
|
|
layer.shiftx=x(&suc); |
|
|
|
|
|
|
|
layer.shifty=y(&suc); |
|
|
|
|
|
|
|
if(!suc) goto case2; |
|
|
|
|
|
|
|
return new ObjectGMTLayer(layer); |
|
|
|
return new ObjectGMTLayer(layer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case2: |
|
|
|
case2: |
|
|
|
|
|
|
|
|
|
|
|
// Search layer for shifting
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SearchParameter<struct gmt_layer> 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"); |
|
|
|
RNPar<Base2Layer> l("layer"); |
|
|
|
Base2Double x(input,"x"), y(input,"y"); |
|
|
|
ONPar<Base2Double> x("x"),y("y"),rx("r[el]x"),ry("r[el]y"); |
|
|
|
bool suc=true; |
|
|
|
|
|
|
|
|
|
|
|
{ParseNamedParameters params(input,l,x,y); if(!params) {err=params.Error(); goto fail;}} // Parsing error
|
|
|
|
|
|
|
|
|
|
|
|
// Check duplicate parameters
|
|
|
|
// Check duplicate parameters
|
|
|
|
if( ( x.Exist() && xr.Exist() ) || ( y.Exist() && yr.Exist() ) ) goto fail; |
|
|
|
if(x.Exist() && rx.Exist()) {err="Only one of "+x.Name()+" or "+rx.Name()+" can be specified."; goto fail;} |
|
|
|
if(x.Exist()) layer.shiftx=x(&suc); |
|
|
|
if(y.Exist() && ry.Exist()) {err="Only one of "+y.Name()+" or "+ry.Name()+" can be specified."; goto fail;} |
|
|
|
if(y.Exist()) layer.shifty=y(&suc); |
|
|
|
// Do shift
|
|
|
|
if(xr.Exist()) layer.shiftx+=x(&suc); |
|
|
|
if( x.Exist()) layer.shiftx=x; |
|
|
|
if(yr.Exist()) layer.shifty+=y(&suc); |
|
|
|
if( y.Exist()) layer.shifty=y; |
|
|
|
if(!suc) goto fail; |
|
|
|
if(rx.Exist()) layer.shiftx+=rx; |
|
|
|
|
|
|
|
if(ry.Exist()) layer.shifty+=ry; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new ObjectGMTLayer(layer); |
|
|
|
return new ObjectGMTLayer(layer); |
|
|
|
|
|
|
|
|
|
|
|
fail: |
|
|
|
fail: |
|
|
|
return 0; |
|
|
|
return new ObjectError("LayerShift",err); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|