Skip to content

Commit 02fa126

Browse files
author
Meghan Jones
authored
Only report auto scaling if used (#4983)
1 parent 922af84 commit 02fa126

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/gmt_init.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9906,6 +9906,7 @@ void gmt_set_undefined_axes (struct GMT_CTRL *GMT, bool conf_update) {
99069906
void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim, bool conf_update) {
99079907
/* We must adjust all frame items with unspecified size according to plot dimension */
99089908
bool geo_frame = false;
9909+
bool auto_scale = false;
99099910
double fontsize, scale;
99109911
double const pt = 1.0/72.0; /* points to inch */
99119912

@@ -9938,67 +9939,79 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim, bool con
99389939
scale = fontsize / 10.0; /* scaling for offsets, pen widths and lengths normalized to the modern 10p size */
99399940
}
99409941

9941-
GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Computed primary annotation font size: %g p Dimension scaling: %g\n", fontsize, scale);
9942-
99439942
/* Only apply the automatic scaling to items NOT specifically set via a --PAR=value option */
99449943

99459944
if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_PRIMARY].size)) {
99469945
GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize;
9946+
auto_scale = true;
99479947
if (conf_update) GMT_keyword_updated[GMTCASE_FONT_ANNOT_PRIMARY] = true;
99489948
}
99499949
if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_SECONDARY].size)) {
99509950
GMT->current.setting.font_annot[GMT_SECONDARY].size = scale * 12.0; /* Modern 12p vs 10p */
9951+
auto_scale = true;
99519952
if (conf_update) GMT_keyword_updated[GMTCASE_FONT_ANNOT_SECONDARY] = true;
99529953
}
99539954
if (gmt_M_is_dnan (GMT->current.setting.font_label.size)) {
99549955
GMT->current.setting.font_label.size = scale * 14.0; /* Modern 14p vs 10p */
9956+
auto_scale = true;
99559957
if (conf_update) GMT_keyword_updated[GMTCASE_FONT_LABEL] = true;
99569958
}
99579959
if (gmt_M_is_dnan (GMT->current.setting.font_heading.size)) {
99589960
GMT->current.setting.font_heading.size = scale * 28.0; /* Modern 28p vs 10p */
9961+
auto_scale = true;
99599962
if (conf_update) GMT_keyword_updated[GMTCASE_FONT_HEADING] = true;
99609963
}
99619964
if (gmt_M_is_dnan (GMT->current.setting.font_tag.size)) {
99629965
GMT->current.setting.font_tag.size = scale * 16.0; /* Modern 16p vs 10p */
9966+
auto_scale = true;
99639967
if (conf_update) GMT_keyword_updated[GMTCASE_FONT_TAG] = true;
99649968
}
99659969
if (gmt_M_is_dnan (GMT->current.setting.font_title.size)) {
99669970
GMT->current.setting.font_title.size = scale * 22.0; /* Modern 22p vs 10p */
9971+
auto_scale = true;
99679972
if (conf_update) GMT_keyword_updated[GMTCASE_FONT_TITLE] = true;
99689973
}
99699974
if (gmt_M_is_dnan (GMT->current.setting.font_subtitle.size)) {
99709975
GMT->current.setting.font_subtitle.size = scale * 18.0; /* Modern 18p vs 10p */
9976+
auto_scale = true;
99719977
if (conf_update) GMT_keyword_updated[GMTCASE_FONT_SUBTITLE] = true;
99729978
}
99739979
if (gmt_M_is_dnan (GMT->current.setting.font_logo.size)) {
99749980
GMT->current.setting.font_logo.size = scale * 8.0; /* Classic 8p vs 10p */
9981+
auto_scale = true;
99759982
if (conf_update) GMT_keyword_updated[GMTCASE_FONT_LOGO] = true;
99769983
}
99779984

99789985
/* Offsets */
99799986

99809987
if (gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_PRIMARY])) {
99819988
GMT->current.setting.map_annot_offset[GMT_PRIMARY] = 3 * pt * scale; /* 3p */
9989+
auto_scale = true;
99829990
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_ANNOT_OFFSET_PRIMARY] = true;
99839991
}
99849992
if (gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_SECONDARY])) {
99859993
GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */
9994+
auto_scale = true;
99869995
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_ANNOT_OFFSET_SECONDARY] = true;
99879996
}
99889997
if (gmt_M_is_dnan (GMT->current.setting.map_label_offset)) {
99899998
GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */
9999+
auto_scale = true;
999010000
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_LABEL_OFFSET] = true;
999110001
}
999210002
if (gmt_M_is_dnan (GMT->current.setting.map_title_offset)) {
999310003
GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */
10004+
auto_scale = true;
999410005
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TITLE_OFFSET] = true;
999510006
}
999610007
if (gmt_M_is_dnan (GMT->current.setting.map_heading_offset)) {
999710008
GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */
10009+
auto_scale = true;
999810010
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_HEADING_OFFSET] = true;
999910011
}
1000010012
if (gmt_M_is_dnan (GMT->current.setting.map_annot_min_spacing)) {
1000110013
GMT->current.setting.map_annot_min_spacing = 28 * pt * scale; /* 28p */
10014+
auto_scale = true;
1000210015
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_ANNOT_MIN_SPACING] = true;
1000310016
snprintf (GMT->current.setting.map_annot_min_spacing_txt, GMT_LEN16, "%.6gp", GMT->current.setting.map_annot_min_spacing / pt);
1000410017
}
@@ -10007,6 +10020,7 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim, bool con
1000710020

1000810021
if (gmt_M_is_dnan (GMT->current.setting.map_frame_width)) {
1000910022
GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */
10023+
auto_scale = true;
1001010024
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_FRAME_WIDTH] = true;
1001110025
}
1001210026

@@ -10022,6 +10036,7 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim, bool con
1002210036
GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 4 * pt * scale; /* 4p */
1002310037
GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 2 * pt * scale; /* 2p */
1002410038
}
10039+
auto_scale = true;
1002510040
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TICK_LENGTH_PRIMARY] = true;
1002610041
}
1002710042
if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) {
@@ -10034,6 +10049,7 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim, bool con
1003410049
GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */
1003510050
GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */
1003610051
}
10052+
auto_scale = true;
1003710053
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TICK_LENGTH_SECONDARY] = true;
1003810054
}
1003910055

@@ -10045,36 +10061,45 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim, bool con
1004510061
if (reach < 1.0) reach *= 60.0, f *= 60.0;
1004610062
reach = rint (reach) / f; /* Integer degrees, minutes or seconds */
1004710063
GMT->current.setting.map_polar_cap[0] = 90.0 - reach; /* Max 5 degrees from pole */
10064+
auto_scale = true;
1004810065
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_POLAR_CAP] = true;
1004910066
}
1005010067

1005110068
/* Frame, tick and gridline pens */
1005210069

1005310070
if (gmt_M_is_dnan (GMT->current.setting.map_frame_pen.width)) {
1005410071
GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */
10072+
auto_scale = true;
1005510073
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_FRAME_PEN] = true;
1005610074
}
1005710075
if (gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) {
1005810076
GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = 0.5 * scale; /* 0.5p (thinner) */
10077+
auto_scale = true;
1005910078
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TICK_PEN_PRIMARY] = true;
1006010079
}
1006110080
if (gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) {
1006210081
GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */
10082+
auto_scale = true;
1006310083
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TICK_PEN_SECONDARY] = true;
1006410084
}
1006510085
if (gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) {
1006610086
GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */
10087+
auto_scale = true;
1006710088
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_GRID_PEN_PRIMARY] = true;
1006810089
}
1006910090
if (gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) {
1007010091
GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */
10092+
auto_scale = true;
1007110093
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_GRID_PEN_SECONDARY] = true;
1007210094
}
1007310095

1007410096
if (gmt_M_is_dnan (GMT->current.setting.map_vector_shape)) {
1007510097
GMT->current.setting.map_vector_shape = 0.5;
10098+
auto_scale = true;
1007610099
if (conf_update) GMT_keyword_updated[GMTCASE_MAP_VECTOR_SHAPE] = true;
1007710100
}
10101+
10102+
if (auto_scale) GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Computed automatic parameters using dimension scaling: %g\n", scale);
1007810103
}
1007910104

1008010105
GMT_LOCAL unsigned int gmtinit_parse_map_annot_oblique (struct GMT_CTRL *GMT, char *text) {

0 commit comments

Comments
 (0)