Skip to content

Commit 922af84

Browse files
author
Meghan Jones
authored
Use parameter settings in auto_scale (#4982)
* Use parameter settings in auto_scale * Continue if argument is malformed * Add test * Update PostScript files
1 parent 6f5677f commit 922af84

File tree

13 files changed

+23
-3
lines changed

13 files changed

+23
-3
lines changed

doc/examples/ex02/ex02.ps

-6 Bytes
Binary file not shown.

doc/examples/ex29/ex29.ps

-10 Bytes
Binary file not shown.

doc/scripts/GMT_colorbar.ps

-517 Bytes
Binary file not shown.

doc/scripts/GMT_cycle_5.ps

-6 Bytes
Binary file not shown.

doc/scripts/GMT_cyclic.ps

-6 Bytes
Binary file not shown.

doc/scripts/GMT_tut_15.ps

-7 Bytes
Binary file not shown.

doc/scripts/GMT_tut_16.ps

-7 Bytes
Binary file not shown.

src/gmt_init.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18890,7 +18890,7 @@ unsigned int gmt_file_type (struct GMT_CTRL *GMT, const char *file, unsigned int
1889018890
}
1889118891
#endif
1889218892

18893-
void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int justify) {
18893+
void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int justify, struct GMT_OPTION *options) {
1889418894
/* We wish to examine the previous -B setting for information as to which axes was
1889518895
* annotated and possibly labeled, and if the colorbar is requested to be placed on
1889618896
* such an axis side we need to make more space by increasing the offset. This is
@@ -18902,6 +18902,9 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j
1890218902
unsigned int pos = 0, sides[5];
1890318903
bool add_label = false, add_annot = false, axis_set = false, was;
1890418904
double GMT_LETTER_HEIGHT = 0.736;
18905+
struct GMT_OPTION *opt = NULL;
18906+
char *c = NULL;
18907+
unsigned int n_errors = 0;
1890518908
FILE *fp = NULL;
1890618909
/* Initialize the default settings before considering any -B history */
1890718910
gmt_set_undefined_defaults (GMT, 0.0, false); /* Must set undefined to their reference values for now */
@@ -18951,6 +18954,13 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j
1895118954
gmt_M_memcpy (sides, GMT->current.map.frame.side, 5U, unsigned int);
1895218955
was = GMT->current.map.frame.draw;
1895318956
gmtinit_conf_modern_override (GMT); /* Reset */
18957+
(void)gmt_getdefaults (GMT, NULL);
18958+
for (opt = options; opt; opt = opt->next) {
18959+
if (opt->option != '-') continue; /* Not a parameter setting */
18960+
if ((c = strchr (opt->arg, '=')) == NULL) continue;
18961+
c[0] = '\0'; /* Remove = */
18962+
n_errors += gmtlib_setparameter (GMT, opt->arg, &c[1], false);
18963+
}
1895418964
gmt_M_memcpy (GMT->current.map.frame.side, sides, 5U, unsigned int);
1895518965
GMT->current.map.frame.draw = was;
1895618966
}

src/gmt_prototypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ EXTERN_MSC int gmt_get_option_id (int start, char *this_option);
6969
EXTERN_MSC bool gmt_is_integer (char *L);
7070
EXTERN_MSC int gmt_get_next_panel (struct GMTAPI_CTRL *API, int fig, int *row, int *col);
7171
EXTERN_MSC int gmt_report_usage (struct GMTAPI_CTRL *API, struct GMT_OPTION *options, unsigned int special, int (*usage)(struct GMTAPI_CTRL *, int));
72-
EXTERN_MSC void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int justify);
72+
EXTERN_MSC void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int justify, struct GMT_OPTION *options);
7373
EXTERN_MSC struct GMT_SUBPLOT * gmt_subplot_info (struct GMTAPI_CTRL *API, int fig);
7474
EXTERN_MSC int gmt_get_V (char arg);
7575
EXTERN_MSC char gmt_set_V (int mode);

src/psscale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static int parse (struct GMT_CTRL *GMT, struct PSSCALE_CTRL *Ctrl, struct GMT_OP
451451
else if (Ctrl->D.refpoint->mode != GMT_REFPOINT_PLOT || strstr (Ctrl->D.refpoint->args, "+w")) { /* New syntax: */
452452
/* Args are +w<length>[/<width>][+e[b|f][<length>]][+h|v][+j<justify>][+ma|c|l|u][+n[<txt>]][+o<dx>[/<dy>]] */
453453
double bar_offset[2]; /* Will be initialized in gmt_auto_offsets_for_colorbar */
454-
gmt_auto_offsets_for_colorbar (GMT, bar_offset, Ctrl->D.refpoint->justify);
454+
gmt_auto_offsets_for_colorbar (GMT, bar_offset, Ctrl->D.refpoint->justify, options);
455455
if (gmt_get_modifier (Ctrl->D.refpoint->args, 'j', string))
456456
Ctrl->D.justify = gmt_just_decode (GMT, string, PSL_NO_DEF);
457457
else { /* With -Dj or -DJ, set default to reference (mirrored) justify point, else BL */

0 commit comments

Comments
 (0)