MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / gmt_plotinit

Function gmt_plotinit

src/gmt_plot.c:8960–9479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8958}
8959
8960struct PSL_CTRL *gmt_plotinit (struct GMT_CTRL *GMT, struct GMT_OPTION *options) {
8961 /* Shuffles parameters and calls PSL_beginplot, issues PS comments regarding the GMT options
8962 * and places a time stamp, if selected */
8963
8964 int k, id, fno[PSL_MAX_EPS_FONTS], n_fonts, last, form, justify;
8965 bool O_active = GMT->common.O.active, auto_media = false, do_paint = false;
8966 unsigned int this_proj, write_to_mem = 0, switch_charset = 0, n_movie_items[2] = {0, 0};
8967 char *mode[2] = {"w","a"}, *movie_item_arg[2][GMT_LEN32], not_used[GMT_LEN32] = {""};
8968 static char *ps_mode[2] = {"classic", "modern"}, *F_name[2] = {"label", "prog_indicator"};
8969 double media_size[2], plot_x, plot_y;
8970 FILE *fp = NULL; /* Default which means stdout in PSL */
8971 struct GMT_FILL fill;
8972 struct GMT_OPTION *Out = NULL;
8973 struct PSL_CTRL *PSL = NULL;
8974 struct GMT_SUBPLOT *P = NULL;
8975 struct GMT_INSET *I = &(GMT->current.plot.inset); /* I->active == 1 if an inset */
8976
8977 PSL = GMT->PSL; /* Shorthand */
8978
8979 gmt_set_undefined_defaults (GMT, sqrt (GMT->current.map.width * GMT->current.map.height), false); /* We must change any undefined defaults given max plot dimension */
8980
8981 if (GMT->current.map.frame.paint[GMT_Z]) { /* Must squirrel this away for now since we may call psbasemap during the movie-indicators below */
8982 do_paint = true;
8983 gmt_M_memcpy (&fill, &GMT->current.map.frame.fill[GMT_Z], 1U, struct GMT_FILL);
8984 GMT->current.map.frame.paint[GMT_Z] = false; /* Turn off for now */
8985 }
8986
8987 PSL->internal.verbose = GMT->current.setting.verbose; /* Inherit verbosity level from GMT */
8988 if (gmt_M_compat_check (GMT, 4) && GMT->current.setting.ps_copies > 1) PSL->init.copies = GMT->current.setting.ps_copies;
8989 PSL_setdefaults (PSL, GMT->current.setting.ps_magnify, GMT->current.setting.ps_page_rgb, GMT->current.setting.ps_encoding.name);
8990 GMT->current.ps.memory = false;
8991 if (doubleAlmostEqual (GMT->current.setting.ps_page_size[GMT_X], GMT_PAPER_DIM) && doubleAlmostEqual (GMT->current.setting.ps_page_size[GMT_Y], GMT_PAPER_DIM))
8992 auto_media = true;
8993 gmt_M_memcpy (media_size, GMT->current.setting.ps_page_size, 2, double);
8994
8995 GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Running in PS mode %s\n", ps_mode[GMT->current.setting.run_mode]);
8996 if (GMT->current.setting.run_mode == GMT_MODERN) { /* Write PS to hidden gmt_#.ps- file. No -O -K allowed */
8997 char *verb[2] = {"Create", "Append to"};
8998 bool wants_PS = false;
8999 double paper_margin = GMT_PAPER_MARGIN_AUTO;
9000
9001 if (gmtlib_fixed_paper_size (GMT->parent)) { /* Must honor paper size and regular margin */
9002 paper_margin = GMT_PAPER_MARGIN_FIXED;
9003 gmt_M_memcpy (media_size, GMT->current.setting.ps_def_page_size, 2, double);
9004 }
9005
9006 if ((k = gmt_set_psfilename (GMT)) == GMT_NOTSET) { /* Get hidden file name for PS */
9007 GMT_Report (GMT->parent, GMT_MSG_ERROR, "No workflow directory\n");
9008 GMT->parent->error = GMT_ERROR_ON_FOPEN;
9009 return NULL;
9010 }
9011 GMT_Report (GMT->parent, GMT_MSG_DEBUG, "%s hidden PS file %s\n", verb[k], GMT->current.ps.filename);
9012 if ((fp = PSL_fopen (PSL, GMT->current.ps.filename, mode[k])) == NULL) { /* Must open inside PSL DLL */
9013 GMT_Report (GMT->parent, GMT_MSG_ERROR, "Cannot open %s with mode %s\n", GMT->current.ps.filename, mode[k]);
9014 GMT->parent->error = GMT_ERROR_ON_FOPEN;
9015 return NULL;
9016 }
9017

Callers 15

GMT_pswiggleFunction · 0.85
GMT_pssolarFunction · 0.85
GMT_grdviewFunction · 0.85
GMT_psternaryFunction · 0.85
GMT_insetFunction · 0.85
GMT_gmtlogoFunction · 0.85
GMT_psmaskFunction · 0.85
GMT_pshistogramFunction · 0.85
GMT_pstextFunction · 0.85
GMT_pscoastFunction · 0.85
GMT_psscaleFunction · 0.85
GMT_grdimageFunction · 0.85

Calls 15

PSL_setdefaultsFunction · 0.85
GMT_ReportFunction · 0.85
gmtlib_fixed_paper_sizeFunction · 0.85
gmt_set_psfilenameFunction · 0.85
PSL_fopenFunction · 0.85
gmtlib_fig_is_psFunction · 0.85
gmt_chopFunction · 0.85
strdupFunction · 0.85
gmt_remove_fileFunction · 0.85
GMT_Find_OptionFunction · 0.85
gmt_sort_arrayFunction · 0.85

Tested by

no test coverage detected