diff --git a/src/gmt_init.c b/src/gmt_init.c index 182e31c94ae..de0f2b5783f 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -4072,7 +4072,7 @@ GMT_LOCAL int gmtinit_split_info_strings (struct GMT_CTRL *GMT, const char *in, } /*! . */ -GMT_LOCAL int gmtinit_init_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_AXIS *A, int *n_int) { +GMT_LOCAL int gmtinit_init_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_AXIS *A, int *n_int, char *filename) { /* Reads a file with one or more records of the form * value types [label] * where value is the coordinate of the tickmark, types is a combination @@ -4080,6 +4080,7 @@ GMT_LOCAL int gmtinit_init_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_A * The a|i will take a label string (or sentence). * The item argument specifies which type to consider [a|i,f,g]. We return * an array with coordinates and labels, and set interval to true if applicable. + * filename is the custom annotation file to read (either primary or secondary). */ int error, k, n_errors = 0; bool save_trailing; @@ -4099,7 +4100,7 @@ GMT_LOCAL int gmtinit_init_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_A GMT->current.io.trailing_text[GMT_IN] = true; GMT->current.io.max_cols_to_read = 1; if ((error = GMT_Set_Columns (GMT->parent, GMT_IN, 1, GMT_COL_FIX)) != GMT_NOERROR) return (1); - if ((D = GMT_Read_Data (GMT->parent, GMT_IS_DATASET, GMT_IS_FILE, GMT_IS_NONE, GMT_READ_NORMAL, NULL, A->file_custom, NULL)) == NULL) { + if ((D = GMT_Read_Data (GMT->parent, GMT_IS_DATASET, GMT_IS_FILE, GMT_IS_NONE, GMT_READ_NORMAL, NULL, filename, NULL)) == NULL) { gmt_set_column_type (GMT, GMT_IN, GMT_X, save_coltype); return (1); } @@ -4119,7 +4120,7 @@ GMT_LOCAL int gmtinit_init_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_A for (row = 0; row < S->n_rows; row++) { k = sscanf (S->text[row], "%s", type); if (k != 1) { - GMT_Report (GMT->parent, GMT_MSG_ERROR, "Bad format record [%s] at row %d in custom file %s.\n", S->text[row], (int)row, A->file_custom); + GMT_Report (GMT->parent, GMT_MSG_ERROR, "Bad format record [%s] at row %d in custom file %s.\n", S->text[row], (int)row, filename); n_errors++; continue; } @@ -4138,7 +4139,7 @@ GMT_LOCAL int gmtinit_init_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_A n_int[GMT_ITEM_GRID]++; break; default: - GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unrecognized type (%c) at row %d in custom file %s.\n", type[k], (int)row, A->file_custom); + GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unrecognized type (%c) at row %d in custom file %s.\n", type[k], (int)row, filename); n_errors++; break; } @@ -4146,9 +4147,9 @@ GMT_LOCAL int gmtinit_init_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_A } GMT_Destroy_Data (GMT->parent, &D); - GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Processed custom annotations via %s for axis %d.\n", A->file_custom, A->id); + GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Processed custom annotations via %s for axis %d.\n", filename, A->id); if (n_int[GMT_ITEM_ANNOT] && n_int[GMT_ITEM_INTVAL]) { - GMT_Report (GMT->parent, GMT_MSG_ERROR, "Cannot mix interval and regular annotations in custom file %s.\n", A->file_custom); + GMT_Report (GMT->parent, GMT_MSG_ERROR, "Cannot mix interval and regular annotations in custom file %s.\n", filename); n_errors++; } return (n_errors); @@ -4315,12 +4316,13 @@ GMT_LOCAL int gmtinit_decode_tinfo (struct GMT_CTRL *GMT, int axis, char flag, c if (flag == 'c') { /* Custom annotation arrangement */ int k, n_int[GMT_N_AXIS_ITEMS]; + unsigned int pi = GMT->current.map.frame.primary ? 0 : 1; /* 0 = primary, 1 = secondary */ char *list = "aifg"; if (!(gmt_access (GMT, &in[1], R_OK))) { - gmt_M_str_free (A->file_custom); - A->file_custom = strdup (&in[1]); + gmt_M_str_free (A->file_custom[pi]); + A->file_custom[pi] = strdup (&in[1]); A->special = GMT_CUSTOM; - if (gmtinit_init_custom_annot (GMT, A, n_int)) return (GMT_NOTSET); /* See what ticks, anots, gridlines etc are requested */ + if (gmtinit_init_custom_annot (GMT, A, n_int, A->file_custom[pi])) return (GMT_NOTSET); /* See what ticks, anots, gridlines etc are requested */ for (k = 0; k < GMT_N_AXIS_ITEMS; k++) { if (n_int[k] == 0) continue; flag = list[k]; @@ -4328,10 +4330,10 @@ GMT_LOCAL int gmtinit_decode_tinfo (struct GMT_CTRL *GMT, int axis, char flag, c if ((error = gmtinit_set_titem (GMT, A, "0", flag, str[axis], true))) /* Store the findings for this segment */ return (error); } - if (n_int[GMT_ITEM_ANNOT]) A->item[GMT_ANNOT_UPPER].special = true; /* custom annotations selected */ - if (n_int[GMT_ITEM_INTVAL]) A->item[GMT_ANNOT_UPPER+!GMT->current.map.frame.primary].special = true; /* custom interval annotations selected */ - if (n_int[GMT_ITEM_TICK]) A->item[GMT_TICK_UPPER+!GMT->current.map.frame.primary].special = true; /* custom tick annotations selected */ - if (n_int[GMT_ITEM_GRID]) A->item[GMT_GRID_UPPER+!GMT->current.map.frame.primary].special = true; /* custom gridlines selected */ + if (n_int[GMT_ITEM_ANNOT]) A->item[GMT_ANNOT_UPPER+pi].special = true; /* custom annotations selected */ + if (n_int[GMT_ITEM_INTVAL]) A->item[GMT_ANNOT_UPPER+pi].special = true; /* custom interval annotations selected */ + if (n_int[GMT_ITEM_TICK]) A->item[GMT_TICK_UPPER+pi].special = true; /* custom tick annotations selected */ + if (n_int[GMT_ITEM_GRID]) A->item[GMT_GRID_UPPER+pi].special = true; /* custom gridlines selected */ if (axis == GMT_Z) GMT->current.map.frame.drawz = true; else diff --git a/src/gmt_internals.h b/src/gmt_internals.h index e03f4346949..111ede38867 100644 --- a/src/gmt_internals.h +++ b/src/gmt_internals.h @@ -85,7 +85,7 @@ EXTERN_MSC double gmtlib_distance_type (struct GMT_CTRL *GMT, double lonS, doubl EXTERN_MSC bool gmtlib_genper_reset (struct GMT_CTRL *GMT, bool reset); EXTERN_MSC double gmtlib_left_boundary (struct GMT_CTRL *GMT, double y); EXTERN_MSC double gmtlib_right_boundary (struct GMT_CTRL *GMT, double y); -EXTERN_MSC unsigned int gmtlib_load_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_AXIS *A, char item, double **xx, char ***labels); +EXTERN_MSC unsigned int gmtlib_load_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_AXIS *A, char item, double **xx, char ***labels, unsigned int which); EXTERN_MSC int gmtlib_report_error (void *C, int error); /* Lives in gmt_api.c */ EXTERN_MSC void gmtlib_iobl (struct GMT_CTRL *GMT, double *lon, double *lat, double olon, double olat); /* Convert oblique lon/lat to regular lon/lat */ EXTERN_MSC char *gmtlib_create_header_item (struct GMTAPI_CTRL *API, unsigned int mode, void *arg); diff --git a/src/gmt_plot.c b/src/gmt_plot.c index 005efe16a42..e04fc012770 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -2021,7 +2021,7 @@ GMT_LOCAL void gmtplot_map_gridlines (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL gmt_setpen (GMT, &GMT->current.setting.map_grid_pen[k]); - if (A[GMT_X]->item[item[k]].special && (np = gmtlib_load_custom_annot (GMT, &GMT->current.map.frame.axis[GMT_X], 'g', &v, NULL))) { + if (A[GMT_X]->item[item[k]].special && (np = gmtlib_load_custom_annot(GMT, &GMT->current.map.frame.axis[GMT_X], 'g', &v, NULL, k))) { gmtplot_x_grid (GMT, PSL, s, n, v, np); gmt_M_free (GMT, v); } @@ -2037,7 +2037,7 @@ GMT_LOCAL void gmtplot_map_gridlines (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL else /* Draw grid lines that go S to N */ gmt_linearx_grid (GMT, PSL, w, e, s, n, dx); - if (A[GMT_Y]->item[item[k]].special && (np = gmtlib_load_custom_annot (GMT, &GMT->current.map.frame.axis[GMT_Y], 'g', &v, NULL))) { + if (A[GMT_Y]->item[item[k]].special && (np = gmtlib_load_custom_annot(GMT, &GMT->current.map.frame.axis[GMT_Y], 'g', &v, NULL, k))) { gmtplot_y_grid (GMT, PSL, w, e, v, np); gmt_M_free (GMT, v); } @@ -2352,8 +2352,8 @@ GMT_LOCAL void gmtplot_map_tickitem (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, if (! (GMT->current.map.frame.axis[GMT_X].item[item].active || GMT->current.map.frame.axis[GMT_Y].item[item].active)) return; - dx = (GMT->current.map.frame.axis[GMT_X].file_custom) ? 1.0 : gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_X].type, &GMT->current.map.frame.axis[GMT_X].item[item]); - dy = (GMT->current.map.frame.axis[GMT_Y].file_custom) ? 1.0 : gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_Y].type, &GMT->current.map.frame.axis[GMT_Y].item[item]); + dx = (GMT->current.map.frame.axis[GMT_X].file_custom[item & 1]) ? 1.0 : gmtlib_get_map_interval(GMT, GMT->current.map.frame.axis[GMT_X].type, &GMT->current.map.frame.axis[GMT_X].item[item]); + dy = (GMT->current.map.frame.axis[GMT_Y].file_custom[item & 1]) ? 1.0 : gmtlib_get_map_interval(GMT, GMT->current.map.frame.axis[GMT_Y].type, &GMT->current.map.frame.axis[GMT_Y].item[item]); if (dx <= 0.0 && dy <= 0.0) return; @@ -2369,7 +2369,7 @@ GMT_LOCAL void gmtplot_map_tickitem (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, GMT->current.map.on_border_is_outside = true; /* Temporarily, points on the border are outside */ if (do_x) { /* Draw grid lines that go E to W */ - if (GMT->current.map.frame.axis[GMT_X].file_custom) + if (GMT->current.map.frame.axis[GMT_X].file_custom[item & 1]) nx = gmtlib_coordinate_array (GMT, w, e, &GMT->current.map.frame.axis[GMT_X].item[item], &val, NULL); else nx = gmtlib_linear_array (GMT, w, e, dx, GMT->current.map.frame.axis[GMT_X].phase, &val); @@ -2382,7 +2382,7 @@ GMT_LOCAL void gmtplot_map_tickitem (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, if (do_y) { /* Draw grid lines that go S to N */ if (GMT->current.proj.z_down) { - if (GMT->current.map.frame.axis[GMT_Y].file_custom) + if (GMT->current.map.frame.axis[GMT_Y].file_custom[item & 1]) ny = gmtlib_coordinate_array (GMT, 0.0, GMT->current.proj.z_radius-s, &GMT->current.map.frame.axis[GMT_Y].item[item], &val, NULL); else if (GMT->current.proj.z_down == GMT_ZDOWN_Z) /* z = n - r */ ny = gmtlib_linear_array (GMT, 0.0, GMT->current.proj.z_radius-s, dy, GMT->current.map.frame.axis[GMT_Y].phase, &val); @@ -2396,7 +2396,7 @@ GMT_LOCAL void gmtplot_map_tickitem (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, } } else { - if (GMT->current.map.frame.axis[GMT_Y].file_custom) + if (GMT->current.map.frame.axis[GMT_Y].file_custom[item & 1]) ny = gmtlib_coordinate_array (GMT, s, n, &GMT->current.map.frame.axis[GMT_Y].item[item], &val, NULL); else ny = gmtlib_linear_array (GMT, s, n, dy, GMT->current.map.frame.axis[GMT_Y].phase, &val); @@ -2520,7 +2520,7 @@ GMT_LOCAL void gmtplot_consider_internal_annotations (struct GMT_CTRL *GMT, stru } if (GMT->current.proj.z_down) { /* Want to annotate depth rather than radius */ - if (GMT->current.map.frame.axis[GMT_Y].file_custom) + if (GMT->current.map.frame.axis[GMT_Y].file_custom[0]) ny = gmtlib_coordinate_array (GMT, 0.0, GMT->current.proj.z_radius-s, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER], &tval, &label_c); else if (GMT->current.proj.z_down == GMT_ZDOWN_Z) /* z = n - r */ ny = gmtlib_linear_array (GMT, 0.0, GMT->current.proj.z_radius-s, dy, GMT->current.map.frame.axis[GMT_Y].phase, &tval); @@ -2535,7 +2535,7 @@ GMT_LOCAL void gmtplot_consider_internal_annotations (struct GMT_CTRL *GMT, stru } } else { /* Annotate radius */ - if (GMT->current.map.frame.axis[GMT_Y].file_custom) + if (GMT->current.map.frame.axis[GMT_Y].file_custom[0]) ny = gmtlib_coordinate_array (GMT, s, n, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER], &val, &label_c); else ny = gmtlib_linear_array (GMT, s, n, dy, GMT->current.map.frame.axis[GMT_Y].phase, &val); @@ -2615,7 +2615,7 @@ GMT_LOCAL void gmtplot_consider_internal_annotations (struct GMT_CTRL *GMT, stru do_minutes = (fabs (fmod (dx, 1.0)) > GMT_CONV4_LIMIT); do_seconds = gmtlib_set_do_seconds (GMT, dx); - if (GMT->current.map.frame.axis[GMT_X].file_custom) + if (GMT->current.map.frame.axis[GMT_X].file_custom[0]) nx = gmtlib_coordinate_array (GMT, w, e, &GMT->current.map.frame.axis[GMT_X].item[GMT_ANNOT_UPPER], &val, &label_c); else nx = gmtlib_linear_array (GMT, w, e, dx, GMT->current.map.frame.axis[GMT_X].phase, &val); @@ -2815,8 +2815,10 @@ GMT_LOCAL void gmtplot_map_annotate (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, else dy[0] = dy[1] = 0.0; - if (GMT->current.map.frame.axis[GMT_X].file_custom) dx[0] = 1.0; /* To pass checks below */ - if (GMT->current.map.frame.axis[GMT_Y].file_custom) dy[0] = 1.0; /* To pass checks below */ + if (GMT->current.map.frame.axis[GMT_X].file_custom[0]) dx[0] = 1.0; /* To pass checks below */ + if (GMT->current.map.frame.axis[GMT_X].file_custom[1]) dx[1] = 1.0; /* Secondary custom file also needs valid interval */ + if (GMT->current.map.frame.axis[GMT_Y].file_custom[0]) dy[0] = 1.0; /* To pass checks below */ + if (GMT->current.map.frame.axis[GMT_Y].file_custom[1]) dy[1] = 1.0; /* Secondary custom file also needs valid interval */ if (dx[0] <= 0.0 && dy[0] <= 0.0) return; @@ -2848,8 +2850,8 @@ GMT_LOCAL void gmtplot_map_annotate (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, do_minutes = (fabs (fmod (dx[k], 1.0)) > GMT_CONV4_LIMIT); do_seconds = gmtlib_set_do_seconds (GMT, dx[k]); - if (GMT->current.map.frame.axis[GMT_X].file_custom) - nx = gmtlib_coordinate_array (GMT, w, e, &GMT->current.map.frame.axis[GMT_X].item[GMT_ANNOT_UPPER], &val, &label_c); + if (GMT->current.map.frame.axis[GMT_X].file_custom[k]) + nx = gmtlib_coordinate_array(GMT, w, e, &GMT->current.map.frame.axis[GMT_X].item[GMT_ANNOT_UPPER+k], &val, &label_c); else nx = gmtlib_linear_array (GMT, w, e, dx[k], GMT->current.map.frame.axis[GMT_X].phase, &val); last = nx - 1; @@ -2911,8 +2913,8 @@ GMT_LOCAL void gmtplot_map_annotate (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, } if (GMT->current.proj.z_down) { /* Want to annotate depth rather than radius */ - if (GMT->current.map.frame.axis[GMT_Y].file_custom) - ny = gmtlib_coordinate_array (GMT, 0.0, GMT->current.proj.z_radius-s, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER], &tval, &label_c); + if (GMT->current.map.frame.axis[GMT_Y].file_custom[k]) + ny = gmtlib_coordinate_array(GMT, 0.0, GMT->current.proj.z_radius-s, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER+k], &tval, &label_c); else if (GMT->current.proj.z_down == GMT_ZDOWN_Z) /* z = n - r */ ny = gmtlib_linear_array (GMT, 0.0, GMT->current.proj.z_radius-s, dy[k], GMT->current.map.frame.axis[GMT_Y].phase, &tval); else if (GMT->current.proj.z_down == GMT_ZDOWN_ZP) /* z = n - r */ @@ -2926,8 +2928,8 @@ GMT_LOCAL void gmtplot_map_annotate (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, } } else { /* Annotate radius */ - if (GMT->current.map.frame.axis[GMT_Y].file_custom) - ny = gmtlib_coordinate_array (GMT, s, n, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER], &val, &label_c); + if (GMT->current.map.frame.axis[GMT_Y].file_custom[k]) + ny = gmtlib_coordinate_array(GMT, s, n, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER+k], &val, &label_c); else ny = gmtlib_linear_array (GMT, s, n, dy[k], GMT->current.map.frame.axis[GMT_Y].phase, &val); tval = val; /* Here they are the same thing */ @@ -9604,7 +9606,7 @@ void gmt_plotend (struct GMT_CTRL *GMT) { GMT_Report (GMT->parent, GMT_MSG_WARNING, "%d extra terminations of external clip operations!\n", -GMT->current.ps.clip_level); GMT->current.ps.clip_level = 0; /* Reset to zero, so it will no longer show up in gmt.history */ } - for (i = 0; i < 3; i++) gmt_M_str_free (GMT->current.map.frame.axis[i].file_custom); + for (i = 0; i < 3; i++) { gmt_M_str_free(GMT->current.map.frame.axis[i].file_custom[0]); gmt_M_str_free (GMT->current.map.frame.axis[i].file_custom[1]); } PSL_endplot (PSL, !K_active); if (GMT->current.setting.run_mode == GMT_MODERN) { /* Reset file pointer and name */ diff --git a/src/gmt_project.h b/src/gmt_project.h index f37752f0cbc..dd05a059d4e 100644 --- a/src/gmt_project.h +++ b/src/gmt_project.h @@ -511,7 +511,7 @@ struct GMT_PLOT_AXIS { /* Information for one time axis */ char secondary_label[GMT_LEN256]; /* Optionally use this label when axis is right or top */ char unit[GMT_LEN64]; /* Axis unit appended to annotations */ char prefix[GMT_LEN64]; /* Axis prefix starting all annotations */ - char *file_custom; /* File with custom annotations */ + char *file_custom[2]; /* Files with custom annotations [0] = primary, [1] = secondary */ }; struct GMT_PLOT_FRAME { /* Various parameters for plotting of time axis boundaries */ diff --git a/src/gmt_support.c b/src/gmt_support.c index 6399b7d065f..f701188546a 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -15740,7 +15740,7 @@ unsigned int gmtlib_time_array (struct GMT_CTRL *GMT, double min, double max, st } /*! . */ -unsigned int gmtlib_load_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_AXIS *A, char item, double **xx, char ***labels) { +unsigned int gmtlib_load_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_AXIS *A, char item, double **xx, char ***labels, unsigned int which) { /* Reads a file with one or more records of the form * value types [label] * where value is the coordinate of the tickmark, types is a combination @@ -15748,6 +15748,7 @@ unsigned int gmtlib_load_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_AXI * The a|i will take a label string (or sentence). * The item argument specifies which type to consider [a|i,f,g]. We return * an array with coordinates and labels, and set interval to true if applicable. + * which: 0 = primary custom file, 1 = secondary custom file. */ int nc, error; unsigned int k = 0, save_coltype, save_max_cols_to_read; @@ -15772,8 +15773,8 @@ unsigned int gmtlib_load_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_AXI gmt_disable_bghio_opts (GMT); /* Do not want any -b -g -h -i -o to affect the reading from -F files */ GMT->current.io.max_cols_to_read = 1; if ((error = GMT_Set_Columns (GMT->parent, GMT_IN, 1, GMT_COL_FIX)) != GMT_NOERROR) return (1); - if ((D = GMT_Read_Data (GMT->parent, GMT_IS_DATASET, GMT_IS_FILE, GMT_IS_NONE, GMT_READ_NORMAL, NULL, A->file_custom, NULL)) == NULL) { - GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unable to open custom annotation file %s!\n", A->file_custom); + if ((D = GMT_Read_Data (GMT->parent, GMT_IS_DATASET, GMT_IS_FILE, GMT_IS_NONE, GMT_READ_NORMAL, NULL, A->file_custom[which], NULL)) == NULL) { + GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unable to open custom annotation file %s!\n", A->file_custom[which]); gmt_set_column_type (GMT, GMT_IN, GMT_X, save_coltype); return (0); } @@ -15826,14 +15827,17 @@ unsigned int gmtlib_load_custom_annot (struct GMT_CTRL *GMT, struct GMT_PLOT_AXI } /*! . */ -unsigned int gmtlib_coordinate_array (struct GMT_CTRL *GMT, double min, double max, struct GMT_PLOT_AXIS_ITEM *T, double **array, char ***labels) { +unsigned int gmtlib_coordinate_array(struct GMT_CTRL *GMT, double min, double max, struct GMT_PLOT_AXIS_ITEM *T, double **array, char ***labels) { unsigned int n = 0; if (!T->active) return (0); /* Nothing to do */ - if (T->special && GMT->current.map.frame.axis[T->parent].file_custom) { /* Want custom intervals */ - n = gmtlib_load_custom_annot (GMT, &GMT->current.map.frame.axis[T->parent], (char)tolower((unsigned char) T->type), array, labels); - return (n); + { /* Determine which custom file to use: uppercase T->type means secondary (1), lowercase means primary (0) */ + unsigned int which = isupper((unsigned char)T->type) ? 1 : 0; + if (T->special && GMT->current.map.frame.axis[T->parent].file_custom[which]) { /* Want custom intervals */ + n = gmtlib_load_custom_annot(GMT, &GMT->current.map.frame.axis[T->parent], (char)tolower((unsigned char) T->type), array, labels, which); + return (n); + } } switch (GMT->current.proj.xyz_projection[T->parent]) { diff --git a/src/psscale.c b/src/psscale.c index da2a5763735..2c150c8bf15 100644 --- a/src/psscale.c +++ b/src/psscale.c @@ -1786,7 +1786,7 @@ GMT_LOCAL void psscale_draw_colorbar (struct GMT_CTRL *GMT, struct PSSCALE_CTRL } if (B_set) { /* Used -B. Must kludge by copying x-axis and scaling to y since we must use gmt_xy_axis to draw a y-axis based on x parameters. */ void (*tmp) (struct GMT_CTRL *, double, double *) = NULL; - char *custum; + char *custum[2]; double wesn_cpy[4]; A = &GMT->current.map.frame.axis[GMT_X]; @@ -1804,7 +1804,8 @@ GMT_LOCAL void psscale_draw_colorbar (struct GMT_CTRL *GMT, struct PSSCALE_CTRL } PSL_setorigin (PSL, 0.0, 0.0, -90.0, PSL_FWD); /* Rotate back so we can plot y-axis */ /* Copy x-axis annotation and scale info to y-axis. We don't need to undo this since gmt_end_module will restore it for us */ - custum = GMT->current.map.frame.axis[GMT_Y].file_custom; /* Need to remember what this was */ + custum[0] = GMT->current.map.frame.axis[GMT_Y].file_custom[0]; /* Need to remember what this was */ + custum[1] = GMT->current.map.frame.axis[GMT_Y].file_custom[1]; gmt_M_memcpy (&GMT->current.map.frame.axis[GMT_Y], &GMT->current.map.frame.axis[GMT_X], 1, struct GMT_PLOT_AXIS); gmt_M_double_swap (GMT->current.proj.scale[GMT_X], GMT->current.proj.scale[GMT_Y]); gmt_M_double_swap (GMT->current.proj.origin[GMT_X], GMT->current.proj.origin[GMT_Y]); @@ -1819,7 +1820,8 @@ GMT_LOCAL void psscale_draw_colorbar (struct GMT_CTRL *GMT, struct PSSCALE_CTRL gmt_xy_axis2 (GMT, -y_base, 0.0, length, start_val, stop_val, &GMT->current.map.frame.axis[GMT_Y], flip & PSSCALE_FLIP_ANNOT, GMT->current.map.frame.side[flip & PSSCALE_FLIP_ANNOT ? W_SIDE : E_SIDE] & GMT_AXIS_ANNOT, GMT->current.map.frame.side[flip & PSSCALE_FLIP_ANNOT ? W_SIDE : E_SIDE]); gmt_M_memcpy (GMT->common.R.wesn, wesn_cpy, 4U, double); /* Must temporarily switch x and y */ PSL_setorigin (PSL, 0.0, 0.0, 90.0, PSL_INV); /* Rotate back to where we started in this branch */ - GMT->current.map.frame.axis[GMT_Y].file_custom = custum; /* Restore correct pointer */ + GMT->current.map.frame.axis[GMT_Y].file_custom[0] = custum[0]; /* Restore correct pointers */ + GMT->current.map.frame.axis[GMT_Y].file_custom[1] = custum[1]; } else { /* When no -B we annotate every CPT bound which may be non-equidistant, hence this code (i.e., we cannot fake a call to -B) */ if (!skip_lines) { /* First draw gridlines */