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

Function GMT_subplot

src/subplot.c:851–1610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

849#define Return(code) {Free_Ctrl (GMT, Ctrl); gmt_end_module (GMT, GMT_cpy); bailout (code);}
850
851EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) {
852 int error = 0, fig;
853 char file[PATH_MAX] = {""}, command[GMT_LEN256] = {""};
854 struct GMT_CTRL *GMT = NULL, *GMT_cpy = NULL;
855 struct GMT_DATASET *D = NULL, *L = NULL;
856 struct GMT_OPTION *options = NULL, *opt = NULL;
857 struct GMT_SUBPLOT *P = NULL;
858 struct SUBPLOT_CTRL *Ctrl = NULL;
859 struct GMTAPI_CTRL *API = gmt_get_api_ptr (V_API); /* Cast from void to GMTAPI_CTRL pointer */
860
861 /*----------------------- Standard module initialization and parsing ----------------------*/
862
863 if (API == NULL) return (GMT_NOT_A_SESSION);
864 if (mode == GMT_MODULE_PURPOSE) return (usage (API, GMT_MODULE_PURPOSE)); /* Return the purpose of program */
865 options = GMT_Create_Options (API, mode, args); if (API->error) return (API->error); /* Set or get option list */
866
867 if ((error = gmt_report_usage (API, options, 0, usage)) != GMT_NOERROR) bailout (error); /* Give usage if requested */
868 if (API->GMT->current.setting.run_mode == GMT_CLASSIC) {
869 GMT_Report (API, GMT_MSG_ERROR, "Not available in classic mode\n");
870 bailout (GMT_NOT_MODERN_MODE);
871 }
872
873 /* When gmt subplot begin is called the gmt.history file for the figure or session may have a record of -R -J -X -Y
874 * settings. Once the subplot begin starts we may or may not be given -R -J -X -Y arguments. If not, then we do not
875 * want old history settings to leak into the subplot panels. The past history is read during session creation in
876 * GMT_Create_Session so at this point it is already stored in memory. Hence we need to reset all of that before we
877 * parse the common and specific arguments to this module */
878
879 if ((opt = GMT_Find_Option (API, GMT_OPT_INFILE, options)) && !strcmp (opt->arg, "begin")) /* Called gmt subplot begin */
880 gmt_reset_history (API->GMT); /* Remove any history obtained by GMT_Create_Session */
881
882 /* Parse the command-line arguments */
883
884 if ((GMT = gmt_init_module (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_KEYS, THIS_MODULE_NEEDS, module_kw, &options, &GMT_cpy)) == NULL) bailout (API->error); /* Save current state */
885 if (GMT_Parse_Common (API, THIS_MODULE_OPTIONS, options)) Return (API->error);
886
887 Ctrl = New_Ctrl (GMT); /* Allocate and initialize a new control structure */
888 if ((error = parse (GMT, Ctrl, options)) != 0) Return (error);
889
890 /*---------------------------- This is the subplot main code ----------------------------*/
891
892 fig = gmt_get_current_figure (API); /* Get current figure number */
893
894 if (Ctrl->In.mode == SUBPLOT_BEGIN) { /* Determine and save subplot attributes once */
895 int RP_id, RG_id, div_x = 1, div_y = 1;
896 unsigned int row, col, k, panel, nx, ny, factor, last_row, last_col, *Lx = NULL, *Ly = NULL;
897 uint64_t seg;
898 double gmean_dim, x, y, width = 0.0, height = 0.0, tick_height, annot_height, label_height, title_height, y_header_off = 0.0;
899 double *cx = NULL, *cy = NULL, *px = NULL, *py = NULL, y_heading, fluff[2] = {0.0, 0.0}, off[2] = {0.0, 0.0}, GMT_LETTER_HEIGHT = 0.736;
900 double master_scale = (GMT->current.setting.map_frame_type == GMT_IS_INSIDE) ? 0.0 : 1.0; /* THe 0 helps wipe any dimensions outside the panel to zero */
901 char **Bx = NULL, **By = NULL, *cmd = NULL, axes[3] = {""}, Bopt[GMT_LEN256] = {""}, origin_shift[GMT_LEN128] = {" "};
902 char vfile[GMT_VF_LEN] = {""}, xymode = 'r';
903 bool add_annot, no_frame = false, gave_X_or_Y;
904 FILE *fp = NULL;
905
906 /* Need geometric mean dimension of subplot to calculate the undefined quantities */
907
908 if (Ctrl->F.panel_scale) { /* Want the average panel geometric mean dimension */

Callers

nothing calls this directly

Calls 15

gmt_get_api_ptrFunction · 0.85
GMT_Create_OptionsFunction · 0.85
gmt_report_usageFunction · 0.85
GMT_ReportFunction · 0.85
GMT_Find_OptionFunction · 0.85
gmt_reset_historyFunction · 0.85
gmt_init_moduleFunction · 0.85
GMT_Parse_CommonFunction · 0.85
gmt_get_current_figureFunction · 0.85
gmt_remove_fileFunction · 0.85
GMT_Create_DataFunction · 0.85

Tested by

no test coverage detected