@@ -101,6 +101,9 @@ struct PSSCALE_CTRL {
101101 bool active ;
102102 double z_low , z_high ;
103103 } G ;
104+ struct PSSCALE_H { /* -H */
105+ bool active ;
106+ } H ;
104107 struct PSSCALE_I { /* -I[<intens>|<min_i>/<max_i>] */
105108 bool active ;
106109 double min , max ;
@@ -167,13 +170,13 @@ static void Free_Ctrl (struct GMT_CTRL *GMT, struct PSSCALE_CTRL *C) { /* Deallo
167170 gmt_M_free (GMT , C );
168171}
169172
170- static int usage (struct GMTAPI_CTRL * API , int level ) {
173+ static int usage (struct GMTAPI_CTRL * API , int level ) {
171174 /* This displays the psscale synopsis and optionally full usage information */
172175
173176 const char * name = gmt_show_name_and_purpose (API , THIS_MODULE_LIB , THIS_MODULE_CLASSIC_NAME , THIS_MODULE_PURPOSE );
174177 if (level == GMT_MODULE_PURPOSE ) return (GMT_NOERROR );
175178 GMT_Usage (API , 0 , "usage: %s [%s] [-C<cpt>] [-D%s[+w<length>[/<width>]][+e[b|f][<length>]][+h|v][+j<justify>][+ma|c|l|u][+n|N[<txt>]]%s[+r]] "
176- "[-F%s] [-G<zlo>/<zhi>] [-I[<max_intens>|<low_i>/<high_i>]] [%s] %s[-L[i|I][<gap>]] [-M] [-N[p|<dpi>]] %s%s[-Q] [%s] "
179+ "[-F%s] [-G<zlo>/<zhi>] [-H] [- I[<max_intens>|<low_i>/<high_i>]] [%s] %s[-L[i|I][<gap>]] [-M] [-N[p|<dpi>]] %s%s[-Q] [%s] "
177180 "[-S[+a<angle>][+c|n][+r][+s][+x<label>][+y<unit>]] [%s] [%s] [-W<scale>] [%s] [%s] [-Z<widthfile>] %s[%s] [%s] [%s]\n" ,
178181 name , GMT_B_OPT , GMT_XYANCHOR , GMT_OFFSET , GMT_PANEL , GMT_J_OPT , API -> K_OPT , API -> O_OPT , API -> P_OPT , GMT_Rgeoz_OPT ,
179182 GMT_U_OPT , GMT_V_OPT , GMT_X_OPT , GMT_Y_OPT , API -> c_OPT , GMT_p_OPT , GMT_t_OPT , GMT_PAR_OPT );
@@ -210,6 +213,8 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
210213 GMT_Usage (API , 1 , "\n-G<zlo>/<zhi>" );
211214 GMT_Usage (API , -2 , "Truncate incoming CPT to be limited to the z-range <zlo>/<zhi>. "
212215 "To accept one of the incoming limits, set that limit to NaN." );
216+ GMT_Usage (API , 1 , "\n-H" );
217+ GMT_Usage (API , -2 , "From GMT 6.5 on, colorbar annotation fonts are auto-scaled. Use this option to prevent that and let user set them as they wish." );
213218 GMT_Usage (API , 1 , "\n-I[<max_intens>|<low_i>/<high_i>]" );
214219 GMT_Usage (API , -2 , "Add illumination for +-<max_intens> or <low_i> to <high_i> [-1.0/1.0]. "
215220 "Alternatively, specify <lower>/<upper> intensity values." );
@@ -366,6 +371,9 @@ static int parse (struct GMT_CTRL *GMT, struct PSSCALE_CTRL *Ctrl, struct GMT_OP
366371 if (!(txt_b [0 ] == 'N' || txt_b [0 ] == 'n' ) || !strcmp (txt_b , "-" )) Ctrl -> G .z_high = atof (txt_b );
367372 n_errors += gmt_M_check_condition (GMT , gmt_M_is_dnan (Ctrl -> G .z_low ) && gmt_M_is_dnan (Ctrl -> G .z_high ), "Option -G: Both of zlo/zhi cannot be NaN\n" );
368373 break ;
374+ case 'H' :
375+ n_errors += gmt_M_repeated_module_option (API , Ctrl -> H .active );
376+ break ;
369377 case 'I' :
370378 n_errors += gmt_M_repeated_module_option (API , Ctrl -> I .active );
371379 if (opt -> arg [0 ]) {
@@ -993,20 +1001,27 @@ GMT_LOCAL void psscale_draw_colorbar (struct GMT_CTRL *GMT, struct PSSCALE_CTRL
9931001 }
9941002
9951003 /* Scale parameters to sqrt of the ratio of color bar length to default map dimension of 15 cm */
996- scale_down = sqrt (MAX (fabs (Ctrl -> D .R .dim [GMT_X ]), fabs (Ctrl -> D .R .dim [GMT_Y ])) / (15.0 / 2.54 ));
997- GMT -> current .setting .font_annot [GMT_PRIMARY ].size *= scale_down ;
998- GMT -> current .setting .font_annot [GMT_SECONDARY ].size *= scale_down ;
999- GMT -> current .setting .font_label .size *= scale_down ;
1000- GMT -> current .setting .map_frame_pen .width *= scale_down ;
1001- GMT -> current .setting .map_tick_pen [GMT_PRIMARY ].width *= scale_down ;
1002- GMT -> current .setting .map_tick_pen [GMT_SECONDARY ].width *= scale_down ;
1003- GMT -> current .setting .map_tick_length [GMT_ANNOT_UPPER ] *= scale_down ;
1004- GMT -> current .setting .map_tick_length [GMT_TICK_UPPER ] *= scale_down ;
1005- GMT -> current .setting .map_annot_offset [GMT_PRIMARY ] *= scale_down ;
1006- GMT -> current .setting .map_annot_offset [GMT_SECONDARY ] *= scale_down ;
1007- GMT -> current .setting .map_label_offset [GMT_X ] *= scale_down ;
1008- GMT -> current .setting .map_label_offset [GMT_Y ] *= scale_down ;
1009- GMT_Report (GMT -> parent , GMT_MSG_DEBUG , "Color bar parameters scaled by %lg\n" , scale_down );
1004+
1005+ /* The condition bellow should be changed to "if (Ctrl->H.active && strcmp(GMT->current.setting.theme, "classic"))"
1006+ because auto-scaling is not part of classic mode. But that would break not only compat with 6.5-6.6
1007+ but also a ton of CI tests, so I'm leaving this just as a comment so far.
1008+ */
1009+ if (!Ctrl -> H .active ) { /* Do auto-scaling */
1010+ scale_down = sqrt (MAX (fabs (Ctrl -> D .R .dim [GMT_X ]), fabs (Ctrl -> D .R .dim [GMT_Y ])) / (15.0 / 2.54 ));
1011+ GMT -> current .setting .font_annot [GMT_PRIMARY ].size *= scale_down ;
1012+ GMT -> current .setting .font_annot [GMT_SECONDARY ].size *= scale_down ;
1013+ GMT -> current .setting .font_label .size *= scale_down ;
1014+ GMT -> current .setting .map_frame_pen .width *= scale_down ;
1015+ GMT -> current .setting .map_tick_pen [GMT_PRIMARY ].width *= scale_down ;
1016+ GMT -> current .setting .map_tick_pen [GMT_SECONDARY ].width *= scale_down ;
1017+ GMT -> current .setting .map_tick_length [GMT_ANNOT_UPPER ] *= scale_down ;
1018+ GMT -> current .setting .map_tick_length [GMT_TICK_UPPER ] *= scale_down ;
1019+ GMT -> current .setting .map_annot_offset [GMT_PRIMARY ] *= scale_down ;
1020+ GMT -> current .setting .map_annot_offset [GMT_SECONDARY ] *= scale_down ;
1021+ GMT -> current .setting .map_label_offset [GMT_X ] *= scale_down ;
1022+ GMT -> current .setting .map_label_offset [GMT_Y ] *= scale_down ;
1023+ GMT_Report (GMT -> parent , GMT_MSG_DEBUG , "Color bar parameters scaled by %lg\n" , scale_down );
1024+ }
10101025 /* Defeat the auto-repeat of axis info */
10111026 if (!strcmp (GMT -> current .map .frame .axis [GMT_X ].label , GMT -> current .map .frame .axis [GMT_Y ].label )) GMT -> current .map .frame .axis [GMT_Y ].label [0 ] = 0 ;
10121027
0 commit comments