#ifndef MODGMT_INTERNALS_H #define MODGMT_INTERNALS_H #include #include #include "modgmt_filters.h" #include "modgmt_structs.h" // here we save header and footer of gmt-produced eps files extern std::string header,footer; extern const int GMTMODE; // Parameters for working thread struct gmtworkthreadpars { void* api; const char* module; struct GMT_OPTION* opts; int fd; int ret; }; // Calling GMT module with filtering int callgmtmodule(void *api, const char *module, struct GMT_OPTION *opts, std::string* res, gmt_filter filt=gmt_filter_default, void* filtpar=0); int callgmtmodule(void *api, const char *module, const std::string& opts, std::string* res, gmt_filter filt=gmt_filter_default, void* filtpar=0); int callgmtmodule(void *api, const char *module, const char* opts, std::string* res, gmt_filter filt=gmt_filter_default, void* filtpar=0); // Workaround non-const pointer in GMT_Create_Options inline struct GMT_OPTION* str2options(void *api, const char* str, size_t size=0) { static char default_gmt_options[]="--GMT_HISTORY=f --PS_LINE_CAP=round --PS_LINE_JOIN=round --GMT_COMPATIBILITY=5 --PS_PAGE_ORIENTATION=portrait --PS_IMAGE_COMPRESS=deflate,9 --PROJ_LENGTH_UNIT=cm"; char* t; if(0==size) t=strdup(str); else { t=static_cast(malloc(size+1)); memcpy(t,str,size); t[size]=0; } struct GMT_OPTION* opts=GMT_Create_Options(api,0,t); GMT_Append_Option(api,GMT_Create_Options(api,0,default_gmt_options),opts); free(t); return opts; } inline struct GMT_OPTION* str2options(void *api, const std::string& str) { return str2options(api,str.data(),str.length()); } // Calculate real width and height of projection. If height!=0 recalculate width accordingly. bool ProjectionRealSize(struct gmt_projection& p, double height=0.0); #endif