|
|
@ -35,6 +35,8 @@ class ObjectGMTClass: public ObjectBase |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
std::string Type() const override {return type;} |
|
|
|
std::string Type() const override {return type;} |
|
|
|
|
|
|
|
const int8_t* Blob(size_t* size) const override { *size=0; return 0; } |
|
|
|
|
|
|
|
void DeallocBlob(const int8_t* ptr) const override {}; |
|
|
|
|
|
|
|
|
|
|
|
// Own functions
|
|
|
|
// Own functions
|
|
|
|
ObjectBase* Get(const std::string& gname) const |
|
|
|
ObjectBase* Get(const std::string& gname) const |
|
|
@ -129,77 +131,17 @@ template<> inline ObjectBase* ObjectGMTFont::OGet(const std::string& name) const |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GMTLayer
|
|
|
|
// GMTLayer
|
|
|
|
class ObjectGMTLayer: public ObjectBase |
|
|
|
typedef ObjectGMTClass<struct gmt_layer> ObjectGMTLayer; |
|
|
|
{ |
|
|
|
template<> inline ObjectBase* ObjectGMTLayer::OGet(const std::string& name) const |
|
|
|
double shiftx,shifty; |
|
|
|
{ |
|
|
|
struct gmt_projection proj; |
|
|
|
if("proj"==name || "projection"==name) return new ObjectGMTProjection(s.proj); |
|
|
|
std::string creator; |
|
|
|
if("w"==name || "width"==name) return new ObjectReal(s.proj.rwidth); |
|
|
|
std::shared_ptr<std::string> data; |
|
|
|
if("h"==name || "height"==name) return new ObjectReal(s.proj.rheight); |
|
|
|
|
|
|
|
if("shiftx"==name) return new ObjectReal(s.shiftx); |
|
|
|
ObjectGMTLayer() {} |
|
|
|
if("shifty"==name) return new ObjectReal(s.shifty); |
|
|
|
// This is saveable object
|
|
|
|
|
|
|
|
virtual const int8_t* Blob(size_t* size) const override |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(Shifted()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::string b="V "+ToString(cm2GMT(shiftx))+" "+ToString(cm2GMT(shifty))+" T\n"; |
|
|
|
|
|
|
|
std::string e="U\n"; |
|
|
|
|
|
|
|
int8_t* p=new int8_t[b.size()+data->size()+e.size()]; |
|
|
|
|
|
|
|
memcpy(p,b.data(),b.size()); |
|
|
|
|
|
|
|
memcpy(p+b.size(),data->data(),data->size()); |
|
|
|
|
|
|
|
memcpy(p+b.size()+data->size(),e.data(),e.size()); |
|
|
|
|
|
|
|
return p; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
*size=data->size(); |
|
|
|
|
|
|
|
return reinterpret_cast<const int8_t*>(data->data()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
virtual void DeallocBlob(const int8_t* ptr) const override |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(Shifted()) delete[] ptr; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
// Constructor
|
|
|
|
|
|
|
|
ObjectGMTLayer(const std::string& newdata, const struct gmt_projection& newproj, const std::string& newcreator, double newshiftx=0.0, double newshifty=0.0):shiftx(newshiftx),shifty(newshifty),proj(newproj),creator(newcreator) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::string* pdata=new std::string(newdata.data(),newdata.length()); // To prevent COW
|
|
|
|
|
|
|
|
data.reset(pdata); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Pure virtual overrides
|
|
|
|
|
|
|
|
ObjectBase* Copy() const override |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto ret=new ObjectGMTLayer; |
|
|
|
|
|
|
|
ret->shiftx=shiftx; ret->shifty=shifty; |
|
|
|
|
|
|
|
ret->proj=proj; |
|
|
|
|
|
|
|
ret->creator=creator; |
|
|
|
|
|
|
|
ret->data=data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bool Print() const override |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
COUT(NORMAL)<<std::endl<<"Object type: "<<Type()<<std::endl; |
|
|
|
|
|
|
|
COUT(NORMAL)<<"Made by: "<<creator<<std::endl; |
|
|
|
|
|
|
|
COUT(NORMAL)<<"Size: "<<proj.rwidth<<"x"<<proj.rheight<<std::endl; |
|
|
|
|
|
|
|
if(Shifted()) COUT(NORMAL)<<"Shifted by: "<<shiftx<<"x"<<shifty<<std::endl; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string Type() const override {return "GMTLayer";} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Own functions
|
|
|
|
|
|
|
|
ObjectBase* Get(const std::string& gname) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::string name=gname; |
|
|
|
|
|
|
|
tolower(name); |
|
|
|
|
|
|
|
if("proj"==name || "projection"==name) return new ObjectGMTProjection(proj); |
|
|
|
|
|
|
|
if("w"==name || "width"==name) return new ObjectReal(proj.rwidth); |
|
|
|
|
|
|
|
if("h"==name || "height"==name) return new ObjectReal(proj.rheight); |
|
|
|
|
|
|
|
if("shiftx"==name) return new ObjectReal(shiftx); |
|
|
|
|
|
|
|
if("shifty"==name) return new ObjectReal(shifty); |
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
bool Shifted() const {return shiftx!=0.0 || shifty!=0.0;} |
|
|
|
template<> const int8_t* ObjectGMTLayer::Blob(size_t* size) const; |
|
|
|
}; |
|
|
|
template<> void ObjectGMTLayer::DeallocBlob(const int8_t* ptr) const; |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|