From c3a130753d5af60bebebd7f9a908a23b9810398d Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 16 May 2020 11:32:40 -1000 Subject: [PATCH 001/109] Add new GMT_THEME default setting This will take the name of a separate .conf file that will override the current settings. --- doc/rst/source/gmt.conf.rst | 7 +++++++ share/movie.conf | 5 +++++ src/gmt_defaults.h | 2 ++ src/gmt_init.c | 26 +++++++++++++++++++++++++- src/gmt_keywords.txt | 1 + 5 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 share/movie.conf diff --git a/doc/rst/source/gmt.conf.rst b/doc/rst/source/gmt.conf.rst index f7bb651ffe7..62d79b633a4 100644 --- a/doc/rst/source/gmt.conf.rst +++ b/doc/rst/source/gmt.conf.rst @@ -426,6 +426,13 @@ GMT Miscellaneous Parameters Sets the upper limit on the number of cores any multi-threaded module might use (whether **-x** is selected or not) [0, i.e., as many as are available]. + **GMT_THEME** + Override GMT default settings with those of the selected theme. Choose from + *classic* [Default for classic mode], *modern* [Default for modern mode], + *movie* (suitable for movie making) and *darkmode*. You can also add your + own themes by compiling sets of settings and place them in your GMT user + directory (usually ~/.gmt) and name them *theme*.conf. + **GMT_TRIANGULATE** Determines if we use the **Watson** [Default] or **Shewchuk** algorithm (if configured during installation) for triangulation. diff --git a/share/movie.conf b/share/movie.conf new file mode 100644 index 00000000000..53dd4e79c8b --- /dev/null +++ b/share/movie.conf @@ -0,0 +1,5 @@ +# Default overrides suitable for movie making +COLOR_HSV_MAX_S = 0 +COLOR_HSV_MIN_V = 0 +MAP_ORIGIN_X = 0 +MAP_ORIGIN_Y = 0 diff --git a/src/gmt_defaults.h b/src/gmt_defaults.h index b6fa479dee2..f3cf86ed685 100644 --- a/src/gmt_defaults.h +++ b/src/gmt_defaults.h @@ -98,6 +98,7 @@ struct GMT_DEFAULTS { unsigned int fft; /* Any of FFT_implementations: k_fft_auto, k_fft_accelerate, k_fft_fftw3, k_fft_kiss, k_fft_brenner */ unsigned int fftw_plan; /* Only accessed if HAVE_FFTW3F is defined: Any of FFTW_planner_flags: FFTW_ESTIMATE, FFTW_MEASURE, FFTW_PATIENT, FFTW_EXHAUSTIVE */ unsigned int run_mode; /* Either classic [0] or modern [1] */ + bool update_theme; /* Refresh defaults with contents of selected theme */ bool use_modern_name; /* true if we should use the modern name in usage message */ double extrapolate_val[2];/* Choose between [0] = 0, 1D extrapolated vals are NaN, = 1 -> extrapolate, = 2 -> set to const stored in [1] */ bool fftwf_threads; /* Only accessed if HAVE_FFTW3F_THREADS is defined: Any of FFTW_planner_flags: FFTW_ESTIMATE, FFTW_MEASURE, FFTW_PATIENT, FFTW_EXHAUSTIVE */ @@ -106,6 +107,7 @@ struct GMT_DEFAULTS { unsigned int export_type; /* What data type to export to external APIs [GMT_DOUBLE] */ unsigned graphics_format; /* The default graphics format in modern mode [GMT_SESSION_FORMAT] */ int max_cores; /* The maximum number of cores for a multi-threaded module [GMT_MAX_CORES] */ + char theme[GMT_LEN64]; /* User-selected defaults theme */ /* IO group */ uint64_t n_bin_header_cols; /* Minimum number of columns in a binary file for which the all cols == NaN means segment header [2] */ unsigned int io_n_header_items; /* Number of header records expected when -h is used [1]; else 0 */ diff --git a/src/gmt_init.c b/src/gmt_init.c index d19941aeb75..df5b0623acb 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -185,6 +185,7 @@ static struct GMT5_params GMT5_keywords[]= { { 0, "GMT_INTERPOLANT"}, { 0, "GMT_LANGUAGE"}, { 0, "GMT_MAX_CORES"}, + { 0, "GMT_THEME"}, { 0, "GMT_TRIANGULATE"}, { 0, "GMT_VERBOSE"}, { 1, "I/O Parameters"}, @@ -5962,6 +5963,8 @@ void gmt_conf (struct GMT_CTRL *GMT) { strcpy (GMT->current.setting.language, "us"); /* GMT_MAX_CORES */ GMT->current.setting.max_cores = 0; + /* GMT_THEME */ + strcpy (GMT->current.setting.theme, "classic"); /* GMT_TRIANGULATE */ #ifdef TRIANGLE_D GMT->current.setting.triangulate = GMT_TRIANGLE_SHEWCHUK; @@ -9193,8 +9196,16 @@ GMT_LOCAL int gmtinit_loaddefaults (struct GMT_CTRL *GMT, char *file) { if (case_val >= 0) GMT_keywords_updated[case_val] = true; /* Leave a record that this keyword is no longer a default one */ } } - fclose (fp); + + if (GMT->current.settings.update_theme) { /* Got a GMT_THEME setting, take action */ + char theme_file[PATH_MAX] = {""}; + GMT->current.settings.update_theme = false; + if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { + error = gmtinit_loaddefaults (GMT, theme_file); + } + } + gmtinit_verify_encodings (GMT); if (error) gmt_message (GMT, "%d GMT Defaults conversion errors in file %s!\n", error, file); @@ -10601,6 +10612,16 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha else error = true; break; + case GMTCASE_GMT_THEME: + if (strlen (value) < GMT_LEN64) { + strncpy (GMT->current.setting.theme, value, GMT_LEN64-1); + GMT->current.setting.update_theme = true; + } + else { + GMT_Report (GMT->parent, GMT_MSG_ERROR, "GMT_THEME must be less than %d characters\n", GMT_LEN64); + error = true; + } + break; case GMTCASE_VERBOSE: if (gmt_M_compat_check (GMT, 4)) { /* GMT4: */ GMT_COMPAT_CHANGE ("GMT_VERBOSE"); @@ -11829,6 +11850,9 @@ char *gmtlib_putparameter (struct GMT_CTRL *GMT, const char *keyword) { strncpy (value, GMT->current.setting.language, GMT_LEN64-1); gmtinit_get_language (GMT); /* Load in names and abbreviations in chosen language */ break; + case GMTCASE_GMT_THEME: + snprintf (value, GMT_LEN256, GMT->current.setting.theme); + break; case GMTCASE_GMT_TRIANGULATE: if (GMT->current.setting.triangulate == GMT_TRIANGLE_WATSON) strcpy (value, "Watson"); diff --git a/src/gmt_keywords.txt b/src/gmt_keywords.txt index 1ff74a7e8c5..448d0ab7252 100644 --- a/src/gmt_keywords.txt +++ b/src/gmt_keywords.txt @@ -70,6 +70,7 @@ GMT_HISTORY # Should we update the command history? GMT_INTERPOLANT # Spline interpolant GMT_LANGUAGE # Language used for annotations GMT_MAX_CORES # Maximum number of cores a multi-threaded module can use [0 = all available] +GMT_THEME # Group of GMT defaults to override GMT_TRIANGULATE # Triangulation algorithm GMT_VERBOSE # Verbosity level #------------------------------------------------------- From 07af5abcf934fdfc20c38dd9ad837ae57469a852 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 16 May 2020 14:20:24 -1000 Subject: [PATCH 002/109] Update names --- share/{ => themes}/movie.conf | 0 src/gmt_api.c | 2 +- src/gmt_init.c | 154 ++++++++++++++++++++++------------ src/gmt_internals.h | 2 +- src/gmt_prototypes.h | 2 +- src/gmtdefaults.c | 2 +- 6 files changed, 106 insertions(+), 56 deletions(-) rename share/{ => themes}/movie.conf (100%) diff --git a/share/movie.conf b/share/themes/movie.conf similarity index 100% rename from share/movie.conf rename to share/themes/movie.conf diff --git a/src/gmt_api.c b/src/gmt_api.c index 5e81d7d883b..6c02665b6cd 100644 --- a/src/gmt_api.c +++ b/src/gmt_api.c @@ -11346,7 +11346,7 @@ int GMT_Get_Default (void *V_API, const char *keyword, char *value) { strcpy (value, "rows"); } else { /* Must process as a GMT setting */ - strcpy (value, gmtlib_putparameter (API->GMT, keyword)); + strcpy (value, gmtlib_getparameter (API->GMT, keyword)); error = (value[0] == '\0') ? GMT_OPTION_NOT_FOUND : GMT_NOERROR; } return_error (V_API, error); diff --git a/src/gmt_init.c b/src/gmt_init.c index df5b0623acb..2f5f5bfd031 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -42,7 +42,7 @@ * gmtlib_putcmyk Encode color argument into c/m/y/k textstring * gmtlib_putfill * gmtlib_setparameter Sets a default value given keyword,value-pair\n - * gmtlib_putparameter + * gmtlib_getparameter * gmt_GSHHG_syntax * gmt_label_syntax * gmt_cont_syntax @@ -132,7 +132,7 @@ struct GMT5_params { /* These are the active GMT5+ keywords, containing no backwards-compatible variants. * Also, some grouped keywords such as FONT and FONT_ANNOT are also not listed since they are not in gmt.conf. * If new keywords are added they need to be added here as well as to gmt_keywords.txt, plus - * specific entries in both gmtlib_setparameter and gmtlib_putparameter, and gmt.conf.rst */ + * specific entries in both gmtlib_setparameter and gmtlib_getparameter, and gmt.conf.rst */ static struct GMT5_params GMT5_keywords[]= { { 1, "COLOR Parameters"}, @@ -2575,7 +2575,7 @@ GMT_LOCAL int gmtinit_savedefaults (struct GMT_CTRL *GMT, char *file) { fprintf (fpo, "#\n# %s\n#\n", GMT5_keywords[current_group].name); header = true; } - fprintf (fpo, "%-30s = %s\n", GMT5_keywords[k].name, gmtlib_putparameter (GMT, GMT5_keywords[k].name)); + fprintf (fpo, "%-30s = %s\n", GMT5_keywords[k].name, gmtlib_getparameter (GMT, GMT5_keywords[k].name)); k++; } @@ -5667,7 +5667,46 @@ GMT_LOCAL int gmtinit_get_language (struct GMT_CTRL *GMT) { } /*! . */ -void gmt_conf (struct GMT_CTRL *GMT) { +GMT_LOCAL void gmtinit_conf_classic_US (struct GMT_CTRL *GMT) { + int i, case_val; + /* Update the settings to US where they differ from standard SI settings: + * Setting SI US + * -------------------------------------------- + * PROJ_LENGTH_UNIT cm inch + * PS_CHAR_ENCODING ISOLatin1+ Standard+ + * PS_MEDIA a4 letter + * TIME_WEEK_START Monday Sunday + */ + + /* PROJ_LENGTH_UNIT */ + case_val = gmt_hash_lookup (GMT, "PROJ_LENGTH_UNIT", keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); + if (case_val >= 0) GMT_keywords_updated[case_val] = true; + GMT->current.setting.proj_length_unit = GMT_INCH; + /* PS_CHAR_ENCODING */ + case_val = gmt_hash_lookup (GMT, "PS_CHAR_ENCODING", keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); + if (case_val >= 0) GMT_keywords_updated[case_val] = true; + strcpy (GMT->current.setting.ps_encoding.name, "Standard+"); + gmtinit_load_encoding (GMT); + /* PS_MEDIA */ + if (GMT->current.setting.run_mode == GMT_MODERN) + gmtinit_setautopagesize (GMT); + else { + case_val = gmt_hash_lookup (GMT, "PS_MEDIA", keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); + if (case_val >= 0) GMT_keywords_updated[case_val] = true; + i = gmtinit_key_lookup ("letter", GMT_media_name, GMT_N_MEDIA); + /* Use the specified standard format */ + GMT->current.setting.ps_media = i; + GMT->current.setting.ps_page_size[0] = GMT_media[i].width; + GMT->current.setting.ps_page_size[1] = GMT_media[i].height; + } + /* TIME_WEEK_START */ + case_val = gmt_hash_lookup (GMT, "TIME_WEEK_START", keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); + if (case_val >= 0) GMT_keywords_updated[case_val] = true; + GMT->current.setting.time_week_start = gmtinit_key_lookup ("Sunday", GMT_weekdays, 7); +} + +/*! . */ +GMT_LOCAL void gmtinit_conf_classic (struct GMT_CTRL *GMT) { int i, error = 0; double const pt = 1.0/72.0; /* points to inch */ /* Initialize all the settings to standard SI settings */ @@ -6015,46 +6054,35 @@ void gmt_conf (struct GMT_CTRL *GMT) { GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unrecognized value during gmtdefaults initialization.\n"); if (!strncmp (GMT_DEF_UNITS, "US", 2U)) - gmt_conf_US (GMT); /* Override with US settings */ + gmtinit_conf_classic_US (GMT); /* Override with US settings */ +} + +/*! . */ +GMT_LOCAL void gmtinit_conf_modern_US (struct GMT_CTRL *GMT) { + /* REPLACE WITH gmtinit_conf_modern_US when ready */ + gmtinit_conf_classic_US (GMT); /* Override with US settings */ +} + +/*! . */ +GMT_LOCAL void gmtinit_conf_modern (struct GMT_CTRL *GMT) { + /* REPLACE WITH gmtinit_conf_modern when ready */ + gmtinit_conf_classic (GMT); } /*! . */ void gmt_conf_US (struct GMT_CTRL *GMT) { - int i, case_val; - /* Update the settings to US where they differ from standard SI settings: - * Setting SI US - * -------------------------------------------- - * PROJ_LENGTH_UNIT cm inch - * PS_CHAR_ENCODING ISOLatin1+ Standard+ - * PS_MEDIA a4 letter - * TIME_WEEK_START Monday Sunday - */ + if (GMT->current.setting.run_mode == GMT_MODERN) + gmtinit_conf_modern_US (GMT); + else + gmtinit_conf_classic_US (GMT); +} - /* PROJ_LENGTH_UNIT */ - case_val = gmt_hash_lookup (GMT, "PROJ_LENGTH_UNIT", keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); - if (case_val >= 0) GMT_keywords_updated[case_val] = true; - GMT->current.setting.proj_length_unit = GMT_INCH; - /* PS_CHAR_ENCODING */ - case_val = gmt_hash_lookup (GMT, "PS_CHAR_ENCODING", keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); - if (case_val >= 0) GMT_keywords_updated[case_val] = true; - strcpy (GMT->current.setting.ps_encoding.name, "Standard+"); - gmtinit_load_encoding (GMT); - /* PS_MEDIA */ +/*! . */ +void gmt_conf_SI (struct GMT_CTRL *GMT) { if (GMT->current.setting.run_mode == GMT_MODERN) - gmtinit_setautopagesize (GMT); - else { - case_val = gmt_hash_lookup (GMT, "PS_MEDIA", keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); - if (case_val >= 0) GMT_keywords_updated[case_val] = true; - i = gmtinit_key_lookup ("letter", GMT_media_name, GMT_N_MEDIA); - /* Use the specified standard format */ - GMT->current.setting.ps_media = i; - GMT->current.setting.ps_page_size[0] = GMT_media[i].width; - GMT->current.setting.ps_page_size[1] = GMT_media[i].height; - } - /* TIME_WEEK_START */ - case_val = gmt_hash_lookup (GMT, "TIME_WEEK_START", keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); - if (case_val >= 0) GMT_keywords_updated[case_val] = true; - GMT->current.setting.time_week_start = gmtinit_key_lookup ("Sunday", GMT_weekdays, 7); + gmtinit_conf_modern (GMT); /* REPLACE WITH gmtinit_conf_modern when ready */ + else + gmtinit_conf_classic (GMT); } /*! . */ @@ -9178,18 +9206,17 @@ GMT_LOCAL int gmtinit_loaddefaults (struct GMT_CTRL *GMT, char *file) { return (GMT_NOERROR); } - if (rec != 2) { /* Nothing */ } - else if (strlen (line) < 7 || (ver = strtol (&line[6], NULL, 10)) < 5 ) + if (rec == 2 && strstr (line, "# GMT ") && (strlen (line) < 7 || (ver = strtol (&line[6], NULL, 10)) < 5)) gmt_message (GMT, "Your gmt.conf file (%s) may not be GMT %d compatible\n", file, gmt_version_major); else if (!strncmp (&line[6], "5.0.0", 5)) - gmt_message (GMT, "Your gmt.conf file (%s) is of version 5.0.0 and may need to be updated. Use \"gmtset -G%s\"\n", file, file); + gmt_message (GMT, "Your gmt.conf file (%s) is of version 5.0.0 and may need to be updated. Use \"gmt set -G%s\"\n", file, file); if (line[0] == '#') continue; /* Skip comments */ if (line[0] == '\0') continue; /* Skip Blank lines */ keyword[0] = value[0] = '\0'; /* Initialize */ sscanf (line, "%s = %[^\n]", keyword, value); - if (gmtlib_setparameter (GMT, keyword, value, false)) + if (gmtlib_setparameter (GMT, keyword, value, true)) error++; else { int case_val = gmt_hash_lookup (GMT, keyword, keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); @@ -9198,9 +9225,9 @@ GMT_LOCAL int gmtinit_loaddefaults (struct GMT_CTRL *GMT, char *file) { } fclose (fp); - if (GMT->current.settings.update_theme) { /* Got a GMT_THEME setting, take action */ + if (GMT->current.setting.update_theme) { /* Got a GMT_THEME setting, take delayed action now */ char theme_file[PATH_MAX] = {""}; - GMT->current.settings.update_theme = false; + GMT->current.setting.update_theme = false; if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { error = gmtinit_loaddefaults (GMT, theme_file); } @@ -9247,6 +9274,14 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) } } + if (GMT->current.setting.update_theme) { /* Got a --GMT_THEME=theme setting, take delayed action now */ + char theme_file[PATH_MAX] = {""}; + GMT->current.setting.update_theme = false; + if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { + n_errors += gmtinit_loaddefaults (GMT, theme_file); + } + } + if (param != NULL) /* param should be NULL unless no value were added */ GMT_Report (GMT->parent, GMT_MSG_WARNING, "Last GMT Defaults parameter from command options had no value\n"); @@ -9256,6 +9291,11 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) /*! . */ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, char *value, bool core) { + /* core is true if we are calling gmtlib_setparameter from gmtinit_loaddefaults, while it is + * false when just called once, such as via --PAR=value on the comment line. The reason is + * that when GMT_THEME=theme is given we want to wait to address the theme change until all the items + * in gmt.conf has been read, but must act right away if a single entry. */ + unsigned int pos; size_t len; int i, ival, case_val, manual, limit; @@ -9263,7 +9303,6 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha char txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[GMT_LEN256] = {""}, lower_value[GMT_BUFSIZ] = {""}; double dval; - gmt_M_unused(core); if (!value) return (1); /* value argument missing */ strncpy (lower_value, value, GMT_BUFSIZ-1); /* Get a lower case version */ @@ -10615,7 +10654,18 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha case GMTCASE_GMT_THEME: if (strlen (value) < GMT_LEN64) { strncpy (GMT->current.setting.theme, value, GMT_LEN64-1); - GMT->current.setting.update_theme = true; + if (core == false) { /* Must deal with this right away */ + char theme_file[PATH_MAX] = {""}; + if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { /* File exist */ + error = gmtinit_loaddefaults (GMT, theme_file); + } + else { + GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unable to fine file %s selected by GMT_THEME\n", theme_file); + error = true; + } + } + else /* Do it when all of gmt.conf has been processed */ + GMT->current.setting.update_theme = true; } else { GMT_Report (GMT->parent, GMT_MSG_ERROR, "GMT_THEME must be less than %d characters\n", GMT_LEN64); @@ -10803,7 +10853,7 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha } /*! . */ -char *gmtlib_putparameter (struct GMT_CTRL *GMT, const char *keyword) { +char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { /* value must hold at least GMT_BUFSIZ chars */ static char value[GMT_BUFSIZ] = {""}, txt[GMT_LEN8], *PRE[3] = {"", "-", "+"}; int case_val; @@ -11851,7 +11901,7 @@ char *gmtlib_putparameter (struct GMT_CTRL *GMT, const char *keyword) { gmtinit_get_language (GMT); /* Load in names and abbreviations in chosen language */ break; case GMTCASE_GMT_THEME: - snprintf (value, GMT_LEN256, GMT->current.setting.theme); + strncpy (value, GMT->current.setting.theme, GMT_LEN256-1); break; case GMTCASE_GMT_TRIANGULATE: if (GMT->current.setting.triangulate == GMT_TRIANGLE_WATSON) @@ -11975,7 +12025,7 @@ int gmt_pickdefaults (struct GMT_CTRL *GMT, bool lines, struct GMT_OPTION *optio if (lines) record[0] = '\0'; /* Start over */ if (!lines && n) strcat (record, " "); /* Separate by spaces */ - param = gmtlib_putparameter (GMT, opt->arg); + param = gmtlib_getparameter (GMT, opt->arg); if (*param == '\0') { /* if keyword unknown */ error = GMT_OPTION_NOT_FOUND; @@ -14056,7 +14106,7 @@ void gmt_end_module (struct GMT_CTRL *GMT, struct GMT_CTRL *Ccopy) { /* if (GMT->parent->external) { - gmt_conf (GMT); + gmt_conf_SI (GMT); gmt_getdefaults (GMT, NULL); // Re-read local GMT default settings (if any) } */ @@ -16217,7 +16267,7 @@ struct GMT_CTRL *gmt_begin (struct GMTAPI_CTRL *API, const char *session, unsign gmt_hash_init (GMT, GMT->session.rgb_hashnode, gmt_M_color_name, GMT_N_COLOR_NAMES, GMT_N_COLOR_NAMES); - gmt_conf (GMT); /* Initialize the standard GMT system default settings */ + gmt_conf_SI (GMT); /* Initialize the standard GMT system default SI settings */ GMT_Report (API, GMT_MSG_DEBUG, "Enter: gmt_getdefaults\n"); gmt_getdefaults (GMT, NULL); /* Override using local GMT default settings (if any) [and PSL if selected] */ @@ -17260,7 +17310,7 @@ int gmt_manage_workflow (struct GMTAPI_CTRL *API, unsigned int mode, char *text) } } if (error) return (error); /* Bail at this point */ - gmt_conf (API->GMT); /* Get the original system defaults */ + gmt_conf_SI (API->GMT); /* Get the original system defaults */ gmt_getdefaults (API->GMT, NULL); /* Overload user defaults */ snprintf (dir, PATH_MAX, "%s/gmt.conf", API->gwf_dir); /* Reuse dir string for saving gmt.conf to this dir */ API->GMT->current.setting.run_mode = GMT_MODERN; /* Enable modern mode here so putdefaults can skip writing PS_MEDIA if not PostScript output */ diff --git a/src/gmt_internals.h b/src/gmt_internals.h index 97a55f80c27..c809e2bcede 100644 --- a/src/gmt_internals.h +++ b/src/gmt_internals.h @@ -115,7 +115,7 @@ EXTERN_MSC char * gmtlib_putcmyk (struct GMT_CTRL *GMT, double *cmyk); EXTERN_MSC char * gmtlib_puthsv (struct GMT_CTRL *GMT, double *hsv); EXTERN_MSC enum gmt_enum_units gmtlib_get_unit_number (struct GMT_CTRL *GMT, char unit); EXTERN_MSC void gmtlib_explain_options (struct GMT_CTRL *GMT, char *options); -EXTERN_MSC char * gmtlib_putparameter (struct GMT_CTRL *GMT, const char *keyword); +EXTERN_MSC char * gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword); EXTERN_MSC unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, char *value, bool core); EXTERN_MSC int gmtlib_report_func (struct GMT_CTRL *GMT, unsigned int level, const char *source_line, const char *format, ...); EXTERN_MSC int gmtlib_get_num_processors (); diff --git a/src/gmt_prototypes.h b/src/gmt_prototypes.h index 1dc0ae733d5..11c4511b1fc 100644 --- a/src/gmt_prototypes.h +++ b/src/gmt_prototypes.h @@ -65,8 +65,8 @@ EXTERN_MSC void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offs EXTERN_MSC struct GMT_SUBPLOT * gmt_subplot_info (struct GMTAPI_CTRL *API, int fig); EXTERN_MSC int gmt_get_V (char arg); EXTERN_MSC char gmt_set_V (int mode); +EXTERN_MSC void gmt_conf_SI (struct GMT_CTRL *GMT); EXTERN_MSC void gmt_conf_US (struct GMT_CTRL *GMT); -EXTERN_MSC void gmt_conf (struct GMT_CTRL *GMT); EXTERN_MSC int gmt_truncate_file (struct GMTAPI_CTRL *API, char *file, size_t size); EXTERN_MSC int gmt_set_current_panel (struct GMTAPI_CTRL *API, int fig, int row, int col, double gap[], char *label, unsigned int first); EXTERN_MSC int gmt_get_current_figure (struct GMTAPI_CTRL *API); diff --git a/src/gmtdefaults.c b/src/gmtdefaults.c index c935ec426c0..f8edd7e56ef 100644 --- a/src/gmtdefaults.c +++ b/src/gmtdefaults.c @@ -144,7 +144,7 @@ EXTERN_MSC int GMT_gmtdefaults (void *V_API, int mode, void *args) { /*---------------------------- This is the gmtdefaults main code ----------------------------*/ if (Ctrl->D.active) { /* Start with default params using SI settings */ - gmt_conf (GMT); /* Get SI defaults */ + gmt_conf_SI (GMT); /* Get SI defaults */ if (Ctrl->D.mode == 'u') gmt_conf_US (GMT); /* Change a few to US defaults */ } From 1df55ec8843c0fcba2852e5759060290696aab1b Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 16 May 2020 14:23:38 -1000 Subject: [PATCH 003/109] Create darkmode.conf --- share/themes/darkmode.conf | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 share/themes/darkmode.conf diff --git a/share/themes/darkmode.conf b/share/themes/darkmode.conf new file mode 100644 index 00000000000..4ea661605a3 --- /dev/null +++ b/share/themes/darkmode.conf @@ -0,0 +1,28 @@ +# +# GMT 6.1.0 Defaults file for darkmode +# +# COLOR Parameters +# +# +# FONT Parameters +# +FONT_ANNOT_PRIMARY = 12p,Helvetica,white +FONT_ANNOT_SECONDARY = 14p,Helvetica,white +FONT_HEADING = 32p,Helvetica,white +FONT_LABEL = 16p,Helvetica,white +FONT_LOGO = 8p,Helvetica,white +FONT_TAG = 20p,Helvetica,white +FONT_TITLE = 24p,Helvetica,white +# +# MAP Parameters +# +MAP_DEFAULT_PEN = default,white +MAP_FRAME_PEN = thicker,white +MAP_GRID_PEN_PRIMARY = default,white +MAP_GRID_PEN_SECONDARY = thinner,white +MAP_TICK_PEN_PRIMARY = thinner,white +MAP_TICK_PEN_SECONDARY = thinner,white +# +# PostScript Parameters +# +PS_PAGE_COLOR = black From f05bb23533eb8a31806597db44fb4d171b775271 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 16 May 2020 15:03:49 -1000 Subject: [PATCH 004/109] Wrap up theme machinery --- share/CMakeLists.txt | 2 +- share/themes/darkmode.conf | 28 ++++++++++----------- share/themes/inverse.conf | 28 +++++++++++++++++++++ src/gmt_init.c | 51 +++++++++++++++++++------------------- 4 files changed, 68 insertions(+), 41 deletions(-) create mode 100644 share/themes/inverse.conf diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 45def06daf4..37f4b38c201 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -18,7 +18,7 @@ # share/CMakeLists.txt # -set (_gmt_share_dirs cpt custom localization mgd77 mgg spotter x2sys) +set (_gmt_share_dirs cpt custom localization mgd77 mgg spotter themes x2sys) # install target for data install (DIRECTORY ${_gmt_share_dirs} diff --git a/share/themes/darkmode.conf b/share/themes/darkmode.conf index 4ea661605a3..07631cd2b2c 100644 --- a/share/themes/darkmode.conf +++ b/share/themes/darkmode.conf @@ -6,23 +6,23 @@ # # FONT Parameters # -FONT_ANNOT_PRIMARY = 12p,Helvetica,white -FONT_ANNOT_SECONDARY = 14p,Helvetica,white -FONT_HEADING = 32p,Helvetica,white -FONT_LABEL = 16p,Helvetica,white -FONT_LOGO = 8p,Helvetica,white -FONT_TAG = 20p,Helvetica,white -FONT_TITLE = 24p,Helvetica,white +FONT_ANNOT_PRIMARY = 12p,Helvetica,gray98 +FONT_ANNOT_SECONDARY = 14p,Helvetica,gray90 +FONT_HEADING = 32p,Helvetica,gray98 +FONT_LABEL = 16p,Helvetica,gray98 +FONT_LOGO = 8p,Helvetica,gray98 +FONT_TAG = 20p,Helvetica,gray98 +FONT_TITLE = 24p,Helvetica,gray98 # # MAP Parameters # -MAP_DEFAULT_PEN = default,white -MAP_FRAME_PEN = thicker,white -MAP_GRID_PEN_PRIMARY = default,white -MAP_GRID_PEN_SECONDARY = thinner,white -MAP_TICK_PEN_PRIMARY = thinner,white -MAP_TICK_PEN_SECONDARY = thinner,white +MAP_DEFAULT_PEN = default,gray98 +MAP_FRAME_PEN = thicker,gray98 +MAP_GRID_PEN_PRIMARY = default,gray98 +MAP_GRID_PEN_SECONDARY = thinner,gray90 +MAP_TICK_PEN_PRIMARY = thinner,gray98 +MAP_TICK_PEN_SECONDARY = thinner,gray90 # # PostScript Parameters # -PS_PAGE_COLOR = black +PS_PAGE_COLOR = 5/5/35 diff --git a/share/themes/inverse.conf b/share/themes/inverse.conf new file mode 100644 index 00000000000..ad72b7a1c1a --- /dev/null +++ b/share/themes/inverse.conf @@ -0,0 +1,28 @@ +# +# GMT 6.1.0 Defaults file for inverse +# +# COLOR Parameters +# +# +# FONT Parameters +# +FONT_ANNOT_PRIMARY = 12p,Helvetica,white +FONT_ANNOT_SECONDARY = 14p,Helvetica,white +FONT_HEADING = 32p,Helvetica,white +FONT_LABEL = 16p,Helvetica,white +FONT_LOGO = 8p,Helvetica,white +FONT_TAG = 20p,Helvetica,white +FONT_TITLE = 24p,Helvetica,white +# +# MAP Parameters +# +MAP_DEFAULT_PEN = default,white +MAP_FRAME_PEN = thicker,white +MAP_GRID_PEN_PRIMARY = default,white +MAP_GRID_PEN_SECONDARY = thinner,white +MAP_TICK_PEN_PRIMARY = thinner,white +MAP_TICK_PEN_SECONDARY = thinner,white +# +# PostScript Parameters +# +PS_PAGE_COLOR = black diff --git a/src/gmt_init.c b/src/gmt_init.c index 2f5f5bfd031..852bd479b0b 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -9189,6 +9189,8 @@ int GMT_get_V (char arg) { return gmt_get_V (arg); } +GMT_LOCAL int gmtinit_update_theme (struct GMT_CTRL *GMT); + /*! . */ GMT_LOCAL int gmtinit_loaddefaults (struct GMT_CTRL *GMT, char *file) { static int gmt_version_major = GMT_PACKAGE_VERSION_MAJOR; @@ -9225,13 +9227,7 @@ GMT_LOCAL int gmtinit_loaddefaults (struct GMT_CTRL *GMT, char *file) { } fclose (fp); - if (GMT->current.setting.update_theme) { /* Got a GMT_THEME setting, take delayed action now */ - char theme_file[PATH_MAX] = {""}; - GMT->current.setting.update_theme = false; - if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { - error = gmtinit_loaddefaults (GMT, theme_file); - } - } + error += gmtinit_update_theme (GMT); /* If we got a GMT_THEME setting, take delayed action now */ gmtinit_verify_encodings (GMT); @@ -9240,6 +9236,24 @@ GMT_LOCAL int gmtinit_loaddefaults (struct GMT_CTRL *GMT, char *file) { return (GMT_NOERROR); } +GMT_LOCAL int gmtinit_update_theme (struct GMT_CTRL *GMT) { + int error = GMT_NOERROR; + char theme_file[PATH_MAX] = {""}; + + if (!GMT->current.setting.update_theme) return GMT_NOERROR; /* Nothing to do */ + + /* Got a GMT_THEME setting, take delayed action now */ + GMT->current.setting.update_theme = false; + if (!strcmp (GMT->current.setting.theme, "classic")) /* Just reload the classic defaults */ + gmtinit_conf_classic (GMT); + else if (!strcmp (GMT->current.setting.theme, "modern")) /* Just reload the modern defaults */ + gmtinit_conf_modern (GMT); + else if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { /* Load given theme */ + error = gmtinit_loaddefaults (GMT, theme_file); + } + return (error); +} + void gmtinit_update_keys (struct GMT_CTRL *GMT, bool arg) { gmt_M_unused(GMT); if (arg == false) @@ -9274,13 +9288,7 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) } } - if (GMT->current.setting.update_theme) { /* Got a --GMT_THEME=theme setting, take delayed action now */ - char theme_file[PATH_MAX] = {""}; - GMT->current.setting.update_theme = false; - if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { - n_errors += gmtinit_loaddefaults (GMT, theme_file); - } - } + n_errors += gmtinit_update_theme (GMT); /* If we got a GMT_THEME setting, take delayed action now */ if (param != NULL) /* param should be NULL unless no value were added */ GMT_Report (GMT->parent, GMT_MSG_WARNING, "Last GMT Defaults parameter from command options had no value\n"); @@ -10654,18 +10662,9 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha case GMTCASE_GMT_THEME: if (strlen (value) < GMT_LEN64) { strncpy (GMT->current.setting.theme, value, GMT_LEN64-1); - if (core == false) { /* Must deal with this right away */ - char theme_file[PATH_MAX] = {""}; - if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { /* File exist */ - error = gmtinit_loaddefaults (GMT, theme_file); - } - else { - GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unable to fine file %s selected by GMT_THEME\n", theme_file); - error = true; - } - } - else /* Do it when all of gmt.conf has been processed */ - GMT->current.setting.update_theme = true; + GMT->current.setting.update_theme = true; + if (core == false) /* Must deal with this right away */ + error = gmtinit_update_theme (GMT); } else { GMT_Report (GMT->parent, GMT_MSG_ERROR, "GMT_THEME must be less than %d characters\n", GMT_LEN64); From 0def46ee6311456a674af42115f32f3c13ad7858 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 16 May 2020 15:05:53 -1000 Subject: [PATCH 005/109] Update gmt.conf.rst --- doc/rst/source/gmt.conf.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/rst/source/gmt.conf.rst b/doc/rst/source/gmt.conf.rst index 62d79b633a4..549b17fdfca 100644 --- a/doc/rst/source/gmt.conf.rst +++ b/doc/rst/source/gmt.conf.rst @@ -429,9 +429,9 @@ GMT Miscellaneous Parameters **GMT_THEME** Override GMT default settings with those of the selected theme. Choose from *classic* [Default for classic mode], *modern* [Default for modern mode], - *movie* (suitable for movie making) and *darkmode*. You can also add your - own themes by compiling sets of settings and place them in your GMT user - directory (usually ~/.gmt) and name them *theme*.conf. + *inverse* (white on black), *movie* (suitable for movie making) and *darkmode*. + You can also create and use your own themes by compiling files of desired settings + and place them in your GMT user directory (usually ~/.gmt) and name them *theme*.conf. **GMT_TRIANGULATE** Determines if we use the **Watson** [Default] or **Shewchuk** From 611a61b7d2c2c107fbf9ee56ff804860ee75d428 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 16 May 2020 15:20:53 -1000 Subject: [PATCH 006/109] Update darkmode.conf --- share/themes/darkmode.conf | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/share/themes/darkmode.conf b/share/themes/darkmode.conf index 07631cd2b2c..4932512fdeb 100644 --- a/share/themes/darkmode.conf +++ b/share/themes/darkmode.conf @@ -6,22 +6,22 @@ # # FONT Parameters # -FONT_ANNOT_PRIMARY = 12p,Helvetica,gray98 -FONT_ANNOT_SECONDARY = 14p,Helvetica,gray90 -FONT_HEADING = 32p,Helvetica,gray98 -FONT_LABEL = 16p,Helvetica,gray98 -FONT_LOGO = 8p,Helvetica,gray98 -FONT_TAG = 20p,Helvetica,gray98 -FONT_TITLE = 24p,Helvetica,gray98 +FONT_ANNOT_PRIMARY = 12p,Helvetica,gray92 +FONT_ANNOT_SECONDARY = 14p,Helvetica,gray86 +FONT_HEADING = 32p,Helvetica,gray92 +FONT_LABEL = 16p,Helvetica,gray92 +FONT_LOGO = 8p,Helvetica,gray92 +FONT_TAG = 20p,Helvetica,gray92 +FONT_TITLE = 24p,Helvetica,gray92 # # MAP Parameters # -MAP_DEFAULT_PEN = default,gray98 -MAP_FRAME_PEN = thicker,gray98 -MAP_GRID_PEN_PRIMARY = default,gray98 -MAP_GRID_PEN_SECONDARY = thinner,gray90 -MAP_TICK_PEN_PRIMARY = thinner,gray98 -MAP_TICK_PEN_SECONDARY = thinner,gray90 +MAP_DEFAULT_PEN = default,gray92 +MAP_FRAME_PEN = thicker,gray92 +MAP_GRID_PEN_PRIMARY = default,gray92 +MAP_GRID_PEN_SECONDARY = thinner,gray86 +MAP_TICK_PEN_PRIMARY = thinner,gray92 +MAP_TICK_PEN_SECONDARY = thinner,gray86 # # PostScript Parameters # From cbd49f955701eee9557e4a6c029be52d4570646f Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 16 May 2020 16:41:47 -1000 Subject: [PATCH 007/109] Play with modern.conf --- share/themes/darkmode.conf | 5 +---- share/themes/inverse.conf | 5 +---- share/themes/modern.conf | 37 +++++++++++++++++++++++++++++++++++++ share/themes/movie.conf | 17 ++++++++++++----- src/gmt_init.c | 4 ++-- 5 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 share/themes/modern.conf diff --git a/share/themes/darkmode.conf b/share/themes/darkmode.conf index 4932512fdeb..a82251d2783 100644 --- a/share/themes/darkmode.conf +++ b/share/themes/darkmode.conf @@ -1,8 +1,5 @@ # -# GMT 6.1.0 Defaults file for darkmode -# -# COLOR Parameters -# +# GMT 6.1.0 Defaults file for darkmode theme # # FONT Parameters # diff --git a/share/themes/inverse.conf b/share/themes/inverse.conf index ad72b7a1c1a..4b1bfcd47f4 100644 --- a/share/themes/inverse.conf +++ b/share/themes/inverse.conf @@ -1,8 +1,5 @@ # -# GMT 6.1.0 Defaults file for inverse -# -# COLOR Parameters -# +# GMT 6.1.0 Defaults file for inverse theme # # FONT Parameters # diff --git a/share/themes/modern.conf b/share/themes/modern.conf new file mode 100644 index 00000000000..5382fd36949 --- /dev/null +++ b/share/themes/modern.conf @@ -0,0 +1,37 @@ +# +# GMT 6.1.0 Defaults file for modern theme +# +# FONT Parameters +# +FONT_ANNOT_PRIMARY = 12p,Palatino-Bold,black +FONT_ANNOT_SECONDARY = 14p,Palatino,black +FONT_HEADING = 32p,Palatino-Bold,black +FONT_LABEL = 16p,Palatino-Bold,black +FONT_LOGO = 8p,Helvetica,black +FONT_TAG = 20p,Palatino,black +FONT_TITLE = 24p,Palatino-Bold,black +# +# FORMAT Parameters +# +FORMAT_GEO_MAP = ddd:mm:ssF +# +# MAP Parameters +# +MAP_ANNOT_ORTHO = we +MAP_FRAME_AXES = WeSnZ +MAP_FRAME_PEN = thicker,black +MAP_FRAME_TYPE = fancy +MAP_FRAME_WIDTH = 3.5p +MAP_GRID_PEN_PRIMARY = default,gray +MAP_GRID_PEN_SECONDARY = thinner,gray +MAP_VECTOR_SHAPE = 0.5 +# +# PostScript Parameters +# +PS_CHAR_ENCODING = ISOLatin1+ +PS_CONVERT = A +PS_LINE_CAP = round +PS_LINE_JOIN = miter +PS_MITER_LIMIT = 35 +PS_MEDIA = a4 +PS_PAGE_COLOR = floralwhite diff --git a/share/themes/movie.conf b/share/themes/movie.conf index 53dd4e79c8b..e5cc0718723 100644 --- a/share/themes/movie.conf +++ b/share/themes/movie.conf @@ -1,5 +1,12 @@ -# Default overrides suitable for movie making -COLOR_HSV_MAX_S = 0 -COLOR_HSV_MIN_V = 0 -MAP_ORIGIN_X = 0 -MAP_ORIGIN_Y = 0 +# +# GMT 6.1.0 Defaults file for movie theme +# +# COLOR Parameters +# +COLOR_HSV_MAX_S = 0 +COLOR_HSV_MIN_V = 0 +# +# MAP Parameters +# +MAP_ORIGIN_X = 0 +MAP_ORIGIN_Y = 0 diff --git a/src/gmt_init.c b/src/gmt_init.c index 852bd479b0b..e137223ff0b 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -9246,8 +9246,8 @@ GMT_LOCAL int gmtinit_update_theme (struct GMT_CTRL *GMT) { GMT->current.setting.update_theme = false; if (!strcmp (GMT->current.setting.theme, "classic")) /* Just reload the classic defaults */ gmtinit_conf_classic (GMT); - else if (!strcmp (GMT->current.setting.theme, "modern")) /* Just reload the modern defaults */ - gmtinit_conf_modern (GMT); + //else if (!strcmp (GMT->current.setting.theme, "modern")) /* Just reload the modern defaults TESTING VIA MODERN.CONF FOR NOW */ + // gmtinit_conf_modern (GMT); else if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { /* Load given theme */ error = gmtinit_loaddefaults (GMT, theme_file); } From 4551f91425a632af629ebc35506bf6f35c460802 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 16 May 2020 17:11:03 -1000 Subject: [PATCH 008/109] Trial modern.conf --- share/themes/modern.conf | 25 ++++++++++++------------- src/gmt_support.c | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 5382fd36949..745723ce1b3 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -3,13 +3,13 @@ # # FONT Parameters # -FONT_ANNOT_PRIMARY = 12p,Palatino-Bold,black -FONT_ANNOT_SECONDARY = 14p,Palatino,black -FONT_HEADING = 32p,Palatino-Bold,black -FONT_LABEL = 16p,Palatino-Bold,black +FONT_ANNOT_PRIMARY = 10p,Palatino-Bold,black +FONT_ANNOT_SECONDARY = 12p,Palatino-Roman,black +FONT_HEADING = 28p,Palatino-Bold,black +FONT_LABEL = 14p,Palatino-Bold,black FONT_LOGO = 8p,Helvetica,black -FONT_TAG = 20p,Palatino,black -FONT_TITLE = 24p,Palatino-Bold,black +FONT_TAG = 18p,Palatino-Roman,black +FONT_TITLE = 22p,Palatino-Bold,black # # FORMAT Parameters # @@ -19,19 +19,18 @@ FORMAT_GEO_MAP = ddd:mm:ssF # MAP_ANNOT_ORTHO = we MAP_FRAME_AXES = WeSnZ +MAP_ANNOT_OFFSET_PRIMARY = 4p +MAP_ANNOT_OFFSET_SECONDARY = 4p MAP_FRAME_PEN = thicker,black MAP_FRAME_TYPE = fancy -MAP_FRAME_WIDTH = 3.5p +MAP_FRAME_WIDTH = 3p MAP_GRID_PEN_PRIMARY = default,gray MAP_GRID_PEN_SECONDARY = thinner,gray +MAP_HEADING_OFFSET = 16p +MAP_LABEL_OFFSET = 6p +MAP_TITLE_OFFSET = 12p MAP_VECTOR_SHAPE = 0.5 # # PostScript Parameters # -PS_CHAR_ENCODING = ISOLatin1+ -PS_CONVERT = A PS_LINE_CAP = round -PS_LINE_JOIN = miter -PS_MITER_LIMIT = 35 -PS_MEDIA = a4 -PS_PAGE_COLOR = floralwhite diff --git a/src/gmt_support.c b/src/gmt_support.c index f72284363d4..4b2619af111 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -6464,7 +6464,7 @@ int gmt_getfont (struct GMT_CTRL *GMT, char *buffer, struct GMT_FONT *F) { /* Assign font size, type, and fill, if given */ if (!size[0] || size[0] == '-') { /* Skip */ } else if ((pointsize = gmt_convert_units (GMT, size, GMT_PT, GMT_PT)) < GMT_CONV4_LIMIT) - GMT_Report (GMT->parent, GMT_MSG_WARNING, "Representation of font size not recognised. Using default.\n"); + GMT_Report (GMT->parent, GMT_MSG_WARNING, "Representation of font size not recognized. Using default.\n"); else F->size = pointsize; if (!name[0] || name[0] == '-') { /* Skip */ } From 01feca1702739d97f65b5a060ba293daf3f3b7df Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 16 May 2020 19:04:50 -1000 Subject: [PATCH 009/109] Address comments --- doc/rst/source/gmt.conf.rst | 3 ++- share/themes/darkmode.conf | 2 +- share/themes/inverse.conf | 2 +- share/themes/modern.conf | 2 +- share/themes/movie.conf | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/rst/source/gmt.conf.rst b/doc/rst/source/gmt.conf.rst index 549b17fdfca..c8eb144fb86 100644 --- a/doc/rst/source/gmt.conf.rst +++ b/doc/rst/source/gmt.conf.rst @@ -431,7 +431,8 @@ GMT Miscellaneous Parameters *classic* [Default for classic mode], *modern* [Default for modern mode], *inverse* (white on black), *movie* (suitable for movie making) and *darkmode*. You can also create and use your own themes by compiling files of desired settings - and place them in your GMT user directory (usually ~/.gmt) and name them *theme*.conf. + and place them in your GMT user themes directory (usually ~/.gmt/themes) and name + them *theme*.conf. **GMT_TRIANGULATE** Determines if we use the **Watson** [Default] or **Shewchuk** diff --git a/share/themes/darkmode.conf b/share/themes/darkmode.conf index a82251d2783..05e85463e74 100644 --- a/share/themes/darkmode.conf +++ b/share/themes/darkmode.conf @@ -1,5 +1,5 @@ # -# GMT 6.1.0 Defaults file for darkmode theme +# Defaults file for darkmode theme # # FONT Parameters # diff --git a/share/themes/inverse.conf b/share/themes/inverse.conf index 4b1bfcd47f4..c85bef0b29d 100644 --- a/share/themes/inverse.conf +++ b/share/themes/inverse.conf @@ -1,5 +1,5 @@ # -# GMT 6.1.0 Defaults file for inverse theme +# Defaults file for inverse theme # # FONT Parameters # diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 745723ce1b3..06b29dc9ebb 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -1,5 +1,5 @@ # -# GMT 6.1.0 Defaults file for modern theme +# Defaults file for modern theme # # FONT Parameters # diff --git a/share/themes/movie.conf b/share/themes/movie.conf index e5cc0718723..b4fdce8bcee 100644 --- a/share/themes/movie.conf +++ b/share/themes/movie.conf @@ -1,5 +1,5 @@ # -# GMT 6.1.0 Defaults file for movie theme +# Defaults file for movie theme # # COLOR Parameters # From cdb903044fe22ed3db629217b4e3d2ed8820d73c Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 17 May 2020 07:58:15 -1000 Subject: [PATCH 010/109] use AvantGarde font --- share/themes/modern.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 06b29dc9ebb..53a9f3b7baa 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -3,13 +3,13 @@ # # FONT Parameters # -FONT_ANNOT_PRIMARY = 10p,Palatino-Bold,black -FONT_ANNOT_SECONDARY = 12p,Palatino-Roman,black -FONT_HEADING = 28p,Palatino-Bold,black -FONT_LABEL = 14p,Palatino-Bold,black +FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,black +FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,black +FONT_HEADING = 28p,AvantGarde-Book,black +FONT_LABEL = 14p,AvantGarde-Book,black FONT_LOGO = 8p,Helvetica,black -FONT_TAG = 18p,Palatino-Roman,black -FONT_TITLE = 22p,Palatino-Bold,black +FONT_TAG = 18p,AvantGarde-Book,black +FONT_TITLE = 22p,AvantGarde-Book,black # # FORMAT Parameters # From e9bff3e098b4b0b93aff1f24f76bd3b490141cbe Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 18 May 2020 08:25:28 -1000 Subject: [PATCH 011/109] Bold titles --- share/themes/modern.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 53a9f3b7baa..0b7cc88d5cb 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -5,11 +5,11 @@ # FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,black FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,black -FONT_HEADING = 28p,AvantGarde-Book,black +FONT_HEADING = 28p,AvantGarde-Bold,black FONT_LABEL = 14p,AvantGarde-Book,black FONT_LOGO = 8p,Helvetica,black FONT_TAG = 18p,AvantGarde-Book,black -FONT_TITLE = 22p,AvantGarde-Book,black +FONT_TITLE = 22p,AvantGarde-Bold,black # # FORMAT Parameters # From 511f552ccfecf3b4138ba56f8eb4690f8a446e3b Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 18 May 2020 08:27:10 -1000 Subject: [PATCH 012/109] Update modern.conf --- share/themes/modern.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 0b7cc88d5cb..84bb3f22e38 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -5,11 +5,11 @@ # FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,black FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,black -FONT_HEADING = 28p,AvantGarde-Bold,black +FONT_HEADING = 28p,AvantGarde-Demi,black FONT_LABEL = 14p,AvantGarde-Book,black FONT_LOGO = 8p,Helvetica,black FONT_TAG = 18p,AvantGarde-Book,black -FONT_TITLE = 22p,AvantGarde-Bold,black +FONT_TITLE = 22p,AvantGarde-Demi,black # # FORMAT Parameters # From 8b2a6b38a5b963fbf8d54b45cd4d12d1abe23ad0 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 18 May 2020 09:17:01 -1000 Subject: [PATCH 013/109] Update modern.conf --- share/themes/modern.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 84bb3f22e38..777be5015a1 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -22,7 +22,7 @@ MAP_FRAME_AXES = WeSnZ MAP_ANNOT_OFFSET_PRIMARY = 4p MAP_ANNOT_OFFSET_SECONDARY = 4p MAP_FRAME_PEN = thicker,black -MAP_FRAME_TYPE = fancy +MAP_FRAME_TYPE = plain MAP_FRAME_WIDTH = 3p MAP_GRID_PEN_PRIMARY = default,gray MAP_GRID_PEN_SECONDARY = thinner,gray From 8d41cabcca460b64e160c1e7b2cc820b27c4e313 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 8 Jun 2020 19:44:38 -1000 Subject: [PATCH 014/109] Implement auto scaling --- doc/rst/source/gmt.conf.rst | 9 ++++-- src/gmt_defaults.h | 1 + src/gmt_init.c | 27 +++++++++++++--- src/gmt_keywords.txt | 1 + src/gmt_map.c | 7 +++++ src/gmt_plot.c | 61 +++++++++++++++++++++++++++++++++++++ src/psbasemap.c | 2 +- 7 files changed, 100 insertions(+), 8 deletions(-) diff --git a/doc/rst/source/gmt.conf.rst b/doc/rst/source/gmt.conf.rst index c8eb144fb86..b8779c84bc7 100644 --- a/doc/rst/source/gmt.conf.rst +++ b/doc/rst/source/gmt.conf.rst @@ -613,6 +613,10 @@ MAP Parameters **e**, **s**, **n**, **z** (uppercase allowed as well). [we] (if nothing specified). Note that this setting can be overridden via the **+a** modifier in **-B**. + **MAP_AUTO_SCALE** + Determines if basemap font sizes, pen thicknesses, tick-lengths, and offsets will + be computed from the plot dimensions (**on**) or if they should be set manually (**off**) [off]. + **MAP_DEFAULT_PEN** Sets the default of all pens related to **-W** options. Prepend **+** to overrule the color of the parameters @@ -630,8 +634,9 @@ MAP Parameters Sets which axes to draw and annotate. Combine any uppercase **W**, **E**, **S**, **N**, **Z** to draw and annotate west, east, south, north and/or vertical (perspective view only) axis. Use lower case - to draw the axis only, but not annotate. Add an optional **+** to - draw a cube of axes in perspective view. [WESN]. + to draw and tick the axis only, but not annotate, or use **l**, **r**, + **b** or **t** to just draw the axis. Add an optional **+** to + draw a cube of axes in perspective view. [WrSt]. **MAP_FRAME_PEN** Pen attributes used to draw plain map frame [thicker,black]. diff --git a/src/gmt_defaults.h b/src/gmt_defaults.h index f3cf86ed685..3f94019e26c 100644 --- a/src/gmt_defaults.h +++ b/src/gmt_defaults.h @@ -150,6 +150,7 @@ struct GMT_DEFAULTS { unsigned int map_frame_type; /* Fancy (0), plain (1), or graph (2) [0] */ unsigned int map_graph_extension_unit; /* If mapframetype is graph, the unit is GMT_CM, GMT_INCH, GMT_PT [%] */ bool map_logo; /* Plot time and map projection on map [false] */ + bool map_auto_scale; /* Auto-scale pens, fonts, offsets based on map dimension [manual|auto] */ struct GMT_PEN map_default_pen; /* Default pen for most pens [0.25p] */ struct GMT_PEN map_frame_pen; /* Pen attributes for map boundary [1.25p] */ struct GMT_PEN map_grid_pen[2]; /* Pen attributes for primary and secondary gridlines [default,black/thinner,black] */ diff --git a/src/gmt_init.c b/src/gmt_init.c index 90362905f3b..ae2ab8a8d48 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -209,6 +209,7 @@ static struct GMT5_params GMT5_keywords[]= { { 0, "MAP_ANNOT_OFFSET_PRIMARY"}, { 0, "MAP_ANNOT_OFFSET_SECONDARY"}, { 0, "MAP_ANNOT_ORTHO"}, + { 0, "MAP_AUTO_SCALE"}, { 0, "MAP_DEFAULT_PEN"}, { 0, "MAP_DEGREE_SYMBOL"}, { 0, "MAP_FRAME_AXES"}, @@ -5791,6 +5792,8 @@ GMT_LOCAL void gmtinit_conf_classic (struct GMT_CTRL *GMT) { GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_MIN_SPACING] = 'p'; /* MAP_ANNOT_ORTHO */ strcpy (GMT->current.setting.map_annot_ortho, "we"); + /* MAP_AUTO_SCALE */ + GMT->current.setting.map_auto_scale = 0; /* MAP_DEGREE_SYMBOL (degree) */ GMT->current.setting.map_degree_symbol = gmt_degree; /* MAP_FRAME_AXES */ @@ -9431,11 +9434,11 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha case GMTCASE_FONT: /* Special to set all fonts */ error = gmtlib_setparameter (GMT, "FONT_ANNOT_PRIMARY", value, core) + - gmtlib_setparameter (GMT, "FONT_ANNOT_SECONDARY", value, core) + - gmtlib_setparameter (GMT, "FONT_TITLE", value, core) + - gmtlib_setparameter (GMT, "FONT_TAG", value, core) + - gmtlib_setparameter (GMT, "FONT_HEADING", value, core) + - gmtlib_setparameter (GMT, "FONT_LABEL", value, core); + gmtlib_setparameter (GMT, "FONT_ANNOT_SECONDARY", value, core) + + gmtlib_setparameter (GMT, "FONT_TITLE", value, core) + + gmtlib_setparameter (GMT, "FONT_TAG", value, core) + + gmtlib_setparameter (GMT, "FONT_HEADING", value, core) + + gmtlib_setparameter (GMT, "FONT_LABEL", value, core); /* FONT_LOGO is purposely skipped */ break; case GMTCASE_FONT_ANNOT: @@ -9643,6 +9646,14 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha case GMTCASE_MAP_ANNOT_ORTHO: strncpy (GMT->current.setting.map_annot_ortho, lower_value, 5U); break; + case GMTCASE_MAP_AUTO_SCALE: + if (value[0] == '\0' || !strcmp (lower_value, "off")) /* Default */ + GMT->current.setting.map_auto_scale = false; + else if (!strcmp (lower_value, "on")) + GMT->current.setting.map_auto_scale = true; + else + error = true; + break; case GMTCASE_DEGREE_SYMBOL: GMT_COMPAT_TRANSLATE ("MAP_DEGREE_SYMBOL"); break; @@ -11114,6 +11125,12 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { case GMTCASE_MAP_ANNOT_ORTHO: strncpy (value, GMT->current.setting.map_annot_ortho, GMT_BUFSIZ-1); break; + case GMTCASE_MAP_AUTO_SCALE: + if (GMT->current.setting.map_auto_scale) + snprintf (value, GMT_LEN256, "on"); + else + snprintf (value, GMT_LEN256, "off"); + break; case GMTCASE_DEGREE_SYMBOL: if (gmt_M_compat_check (GMT, 4)) /* GMT4: */ GMT_COMPAT_WARN; diff --git a/src/gmt_keywords.txt b/src/gmt_keywords.txt index 448d0ab7252..463bac52b94 100644 --- a/src/gmt_keywords.txt +++ b/src/gmt_keywords.txt @@ -99,6 +99,7 @@ MAP_ANNOT_ORTHO # Specifies which axes should have orthogonal annotations [WES MAP_ANNOT_OBLIQUE # Bit-flags to control behavior of annotations for oblique projections MAP_ANNOT_MIN_ANGLE # Cut-off angle to eliminate very oblique annotations MAP_ANNOT_MIN_SPACING # Cut-off distance to eliminate crowding of annotations +MAP_AUTO_SCALE # Set font sizes, offsets, tick lengths, and pen widths relative to map size MAP_DEFAULT_PEN # Default for all pens MAP_DEGREE_SYMBOL # Symbol for "degree" to use on maps MAP_FRAME_AXES # Which axes should be plotted [WESNZ] diff --git a/src/gmt_map.c b/src/gmt_map.c index 8126de72520..8cd192523fa 100644 --- a/src/gmt_map.c +++ b/src/gmt_map.c @@ -6610,6 +6610,13 @@ void gmt_auto_frame_interval (struct GMT_CTRL *GMT, unsigned int axis, unsigned } f *= GMT->session.u2u[GMT_INCH][GMT_PT]; /* Change to points */ + if (gmt_M_axis_is_geo (GMT, axis)) { /* Need more space for degree symbol and WESN letters not considered in the algorithm */ + if (strchr (GMT->current.setting.format_geo_map, 'F')) /* Need more space for degree symbol and letter */ + d *= 1.75; + else /* Just more space for degree symbol */ + d *= 1.25; + } + /* First guess of interval */ d *= MAX (0.05, MIN (5.0 * GMT->current.setting.font_annot[item].size / f, 0.20)); diff --git a/src/gmt_plot.c b/src/gmt_plot.c index ffe79eec536..d099d89815b 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -5436,12 +5436,73 @@ GMT_LOCAL void gmtplot_check_primary_secondary (struct GMT_CTRL *GMT) { } } +GMT_LOCAL void gmtplot_auto_font_tick_sizes (struct GMT_CTRL *GMT) { + /* If the primary font size is zero then we want auto-scaling based on plot size */ + double fontsize, map_dim_cm, scale; + double const pt = 1.0/72.0; /* points to inch */ + + /* If map frame is fancy then we cannot have lrbt */ + + if (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED) { + for (unsigned int k = 0; k < 4; k++) + GMT->current.map.frame.side[k] |= GMT_AXIS_BARB; + } + + if (!GMT->current.setting.map_auto_scale) return; + /* use this equation to compute the primary annotation font size */ + + map_dim_cm = MAX (GMT->current.map.width, GMT->current.map.height) * GMT->session.u2u[GMT_INCH][GMT_CM]; + fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; + scale = fontsize / 10.0; /* scaling of offsets and lengths related to the modern 10p size */ + fprintf (stderr, "Primary annotation font size: %g p dim scaling %g\n", fontsize, scale); + + GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; + GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ + GMT->current.setting.font_label.size = fontsize * (16.0/12.0); /* Modern 14p vs 10p */ + GMT->current.setting.font_heading.size = fontsize * (32.0/12.0); /* Modern 28p vs 10p */ + GMT->current.setting.font_tag.size = fontsize * (20.0/12.0); /* Modern 18p vs 10p */ + GMT->current.setting.font_title.size = fontsize * (24.0/12.0); /* Modern 22p vs 10p */ + GMT->current.setting.font_logo.size = fontsize * (8.0/12.0); /* Classic 8p vs 10p */ + + /* Offsets */ + + GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 4 * pt * scale; /* 4p */ + GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ + GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ + GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ + + /* Tick lengths */ + + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ + + /* Frame, tick and gridline pens */ + + GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ + GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ + GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ + GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ + GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ + + if (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED) { + /* Extend ticks the width of the fancy frame */ + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] += GMT->current.setting.map_frame_width; + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] += GMT->current.setting.map_frame_width; + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] += GMT->current.setting.map_frame_width; + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] += GMT->current.setting.map_frame_width; + } +} + void gmt_map_basemap (struct GMT_CTRL *GMT) { unsigned int side; bool clip_on = false; double w, e, s, n; struct PSL_CTRL *PSL= GMT->PSL; + gmtplot_auto_font_tick_sizes (GMT); + if (!GMT->common.B.active[GMT_PRIMARY] && !GMT->common.B.active[GMT_SECONDARY]) return; /* No frame annotation/ticks/gridlines specified */ if (GMT->common.B.active[GMT_PRIMARY] && GMT->common.B.active[GMT_SECONDARY]) { diff --git a/src/psbasemap.c b/src/psbasemap.c index d9606223b34..0e3aeaf019a 100644 --- a/src/psbasemap.c +++ b/src/psbasemap.c @@ -300,7 +300,7 @@ EXTERN_MSC int GMT_psbasemap (void *V_API, int mode, void *args) { Return (GMT_NOERROR); } - /* Regular plot behaviour */ + /* Regular plot behavior */ if ((PSL = gmt_plotinit (GMT, options)) == NULL) Return (GMT_RUNTIME_ERROR); From 3f4c3a36408a047243f25d70db10a2bb3c77081d Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 8 Jun 2020 19:47:52 -1000 Subject: [PATCH 015/109] Update modern.conf --- share/themes/modern.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 777be5015a1..70ab4035ecb 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -18,7 +18,8 @@ FORMAT_GEO_MAP = ddd:mm:ssF # MAP Parameters # MAP_ANNOT_ORTHO = we -MAP_FRAME_AXES = WeSnZ +MAP_AUTO_SCALE = on +MAP_FRAME_AXES = WrStZ MAP_ANNOT_OFFSET_PRIMARY = 4p MAP_ANNOT_OFFSET_SECONDARY = 4p MAP_FRAME_PEN = thicker,black @@ -28,6 +29,8 @@ MAP_GRID_PEN_PRIMARY = default,gray MAP_GRID_PEN_SECONDARY = thinner,gray MAP_HEADING_OFFSET = 16p MAP_LABEL_OFFSET = 6p +MAP_TICK_LENGTH_PRIMARY = 3p/1.5p +MAP_TICK_LENGTH_SECONDARY = 12p/3p MAP_TITLE_OFFSET = 12p MAP_VECTOR_SHAPE = 0.5 # From 6f1028469e794de8105a1e50035024285b197dcc Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 8 Jun 2020 20:49:10 -1000 Subject: [PATCH 016/109] Update gmt_plot.c --- src/gmt_plot.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gmt_plot.c b/src/gmt_plot.c index d099d89815b..c286199f47a 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -5438,12 +5438,14 @@ GMT_LOCAL void gmtplot_check_primary_secondary (struct GMT_CTRL *GMT) { GMT_LOCAL void gmtplot_auto_font_tick_sizes (struct GMT_CTRL *GMT) { /* If the primary font size is zero then we want auto-scaling based on plot size */ + bool geo = false; double fontsize, map_dim_cm, scale; double const pt = 1.0/72.0; /* points to inch */ /* If map frame is fancy then we cannot have lrbt */ - if (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED) { + geo = (gmt_M_is_geographic (GMT, GMT_IN) && (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED)); + if (geo) { for (unsigned int k = 0; k < 4; k++) GMT->current.map.frame.side[k] |= GMT_AXIS_BARB; } @@ -5486,7 +5488,7 @@ GMT_LOCAL void gmtplot_auto_font_tick_sizes (struct GMT_CTRL *GMT) { GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED) { + if (geo) { /* Extend ticks the width of the fancy frame */ GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] += GMT->current.setting.map_frame_width; GMT->current.setting.map_tick_length[GMT_TICK_UPPER] += GMT->current.setting.map_frame_width; From b58d03fa524818cd57528bd42c80c1ef5d0f9ae7 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 8 Jun 2020 20:50:59 -1000 Subject: [PATCH 017/109] Update gmt_map.c --- src/gmt_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gmt_map.c b/src/gmt_map.c index 8cd192523fa..7c45c43a20a 100644 --- a/src/gmt_map.c +++ b/src/gmt_map.c @@ -6610,7 +6610,7 @@ void gmt_auto_frame_interval (struct GMT_CTRL *GMT, unsigned int axis, unsigned } f *= GMT->session.u2u[GMT_INCH][GMT_PT]; /* Change to points */ - if (gmt_M_axis_is_geo (GMT, axis)) { /* Need more space for degree symbol and WESN letters not considered in the algorithm */ + if (GMT->current.setting.run_mode == GMT_MODERN && gmt_M_axis_is_geo (GMT, axis)) { /* Need more space for degree symbol and WESN letters not considered in the algorithm */ if (strchr (GMT->current.setting.format_geo_map, 'F')) /* Need more space for degree symbol and letter */ d *= 1.75; else /* Just more space for degree symbol */ From 1f2948aea849820c8167daa866013774bd1147ec Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 8 Jun 2020 22:00:47 -1000 Subject: [PATCH 018/109] smaller offsets --- share/themes/modern.conf | 4 ++-- src/gmt_plot.c | 35 ++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 70ab4035ecb..e4dea617215 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -20,8 +20,8 @@ FORMAT_GEO_MAP = ddd:mm:ssF MAP_ANNOT_ORTHO = we MAP_AUTO_SCALE = on MAP_FRAME_AXES = WrStZ -MAP_ANNOT_OFFSET_PRIMARY = 4p -MAP_ANNOT_OFFSET_SECONDARY = 4p +MAP_ANNOT_OFFSET_PRIMARY = 3p +MAP_ANNOT_OFFSET_SECONDARY = 3p MAP_FRAME_PEN = thicker,black MAP_FRAME_TYPE = plain MAP_FRAME_WIDTH = 3p diff --git a/src/gmt_plot.c b/src/gmt_plot.c index c286199f47a..1b6cfbe3b7d 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -5438,37 +5438,38 @@ GMT_LOCAL void gmtplot_check_primary_secondary (struct GMT_CTRL *GMT) { GMT_LOCAL void gmtplot_auto_font_tick_sizes (struct GMT_CTRL *GMT) { /* If the primary font size is zero then we want auto-scaling based on plot size */ - bool geo = false; + bool geo_frame = false; double fontsize, map_dim_cm, scale; double const pt = 1.0/72.0; /* points to inch */ - /* If map frame is fancy then we cannot have lrbt */ + /* If a geographic map frame is fancy then we cannot have lrbt */ - geo = (gmt_M_is_geographic (GMT, GMT_IN) && (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED)); - if (geo) { + geo_frame = (gmt_M_is_geographic (GMT, GMT_IN) && (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED)); + if (geo_frame) { /* Turn any l,r,b,t to w,e,s,n */ for (unsigned int k = 0; k < 4; k++) GMT->current.map.frame.side[k] |= GMT_AXIS_BARB; } - if (!GMT->current.setting.map_auto_scale) return; - /* use this equation to compute the primary annotation font size */ + if (!GMT->current.setting.map_auto_scale) return; /* Auto scaling is off */ + + /* Use this equation to compute the primary annotation font size given map max dimension */ map_dim_cm = MAX (GMT->current.map.width, GMT->current.map.height) * GMT->session.u2u[GMT_INCH][GMT_CM]; - fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; - scale = fontsize / 10.0; /* scaling of offsets and lengths related to the modern 10p size */ - fprintf (stderr, "Primary annotation font size: %g p dim scaling %g\n", fontsize, scale); + fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; /* Gives result in points */ + scale = fontsize / 10.0; /* scaling for offsets, pen widths and lengths normalized to the modern 10p size */ + GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Computed primary annotation font size: %g p Dimension scaling: %g\n", fontsize, scale); GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ - GMT->current.setting.font_label.size = fontsize * (16.0/12.0); /* Modern 14p vs 10p */ - GMT->current.setting.font_heading.size = fontsize * (32.0/12.0); /* Modern 28p vs 10p */ - GMT->current.setting.font_tag.size = fontsize * (20.0/12.0); /* Modern 18p vs 10p */ - GMT->current.setting.font_title.size = fontsize * (24.0/12.0); /* Modern 22p vs 10p */ - GMT->current.setting.font_logo.size = fontsize * (8.0/12.0); /* Classic 8p vs 10p */ + GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ + GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ + GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ + GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ + GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ /* Offsets */ - GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 4 * pt * scale; /* 4p */ + GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ @@ -5488,8 +5489,8 @@ GMT_LOCAL void gmtplot_auto_font_tick_sizes (struct GMT_CTRL *GMT) { GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (geo) { - /* Extend ticks the width of the fancy frame */ + if (geo_frame) { + /* Extend ticks by the width of the fancy frame */ GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] += GMT->current.setting.map_frame_width; GMT->current.setting.map_tick_length[GMT_TICK_UPPER] += GMT->current.setting.map_frame_width; GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] += GMT->current.setting.map_frame_width; From 30076a890d16259f49842264abca7f249182e334 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Wed, 10 Jun 2020 18:27:00 -1000 Subject: [PATCH 019/109] Let modern have modern defaults --- src/gmt_init.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 5 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 5839ddf1004..ed9d416a3d7 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -5793,7 +5793,7 @@ GMT_LOCAL void gmtinit_conf_classic (struct GMT_CTRL *GMT) { /* MAP_ANNOT_ORTHO */ strcpy (GMT->current.setting.map_annot_ortho, "we"); /* MAP_AUTO_SCALE */ - GMT->current.setting.map_auto_scale = 0; + GMT->current.setting.map_auto_scale = false; /* MAP_DEGREE_SYMBOL (degree) */ GMT->current.setting.map_degree_symbol = gmt_degree; /* MAP_FRAME_AXES */ @@ -6063,16 +6063,99 @@ GMT_LOCAL void gmtinit_conf_classic (struct GMT_CTRL *GMT) { gmtinit_conf_classic_US (GMT); /* Override with US settings */ } +/*! . */ +GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { + int i, error = 0; + double const pt = 1.0/72.0; /* points to inch */ + + /* FONT group */ + + /* FONT_ANNOT_PRIMARY */ + error += gmt_getfont (GMT, "10p,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_PRIMARY]); + GMT->current.setting.given_unit[GMTCASE_FONT_ANNOT_PRIMARY] = 'p'; + /* FONT_ANNOT_SECONDARY */ + error += gmt_getfont (GMT, "12p,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_SECONDARY]); + GMT->current.setting.given_unit[GMTCASE_FONT_ANNOT_SECONDARY] = 'p'; + /* FONT_HEADING */ + error += gmt_getfont (GMT, "28p,AvantGarde-Demi,black", &GMT->current.setting.font_heading); + GMT->current.setting.given_unit[GMTCASE_FONT_HEADING] = 'p'; + /* FONT_TITLE */ + error += gmt_getfont (GMT, "22p,AvantGarde-Demi,black", &GMT->current.setting.font_title); + GMT->current.setting.given_unit[GMTCASE_FONT_TITLE] = 'p'; + /* FONT_LABEL */ + error += gmt_getfont (GMT, "14p,AvantGarde-Book,black", &GMT->current.setting.font_label); + GMT->current.setting.given_unit[GMTCASE_FONT_LABEL] = 'p'; + /* FONT_TAG */ + error += gmt_getfont (GMT, "18p,AvantGarde-Book,black", &GMT->current.setting.font_tag); + GMT->current.setting.given_unit[GMTCASE_FONT_TAG] = 'p'; + /* FONT_LOGO */ + error += gmt_getfont (GMT, "8p,Helvetica,black", &GMT->current.setting.font_logo); + GMT->current.setting.given_unit[GMTCASE_FONT_LOGO] = 'p'; + + /* FORMAT_GEO_MAP */ + strcpy (GMT->current.setting.format_geo_map, "ddd:mm:ssF"); + gmtlib_plot_C_format (GMT); /* Update format statements */ + + /* MAP group */ + + /* MAP_ANNOT_OFFSET_PRIMARY, MAP_ANNOT_OFFSET_SECONDARY */ + GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt; /* 3p */ + GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_PRIMARY] = 'p'; + GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_SECONDARY] = 'p'; + /* MAP_AUTO_SCALE */ + GMT->current.setting.map_auto_scale = true; + /* MAP_DEGREE_SYMBOL (degree) */ + GMT->current.setting.map_degree_symbol = gmt_degree; + /* MAP_FRAME_AXES */ + strcpy (GMT->current.setting.map_frame_axes, "WrStZ"); + for (i = 0; i < 5; i++) GMT->current.map.frame.side[i] = 0; /* Unset default settings */ + GMT->current.map.frame.draw_box = false; + error += gmtinit_decode5_wesnz (GMT, GMT->current.setting.map_frame_axes, false); + /* MAP_FRAME_TYPE (plain) */ + GMT->current.setting.map_frame_type = GMT_IS_PLAIN; + /* MAP_FRAME_WIDTH */ + GMT->current.setting.map_frame_width = 3 * pt; /* 3p */ + GMT->current.setting.given_unit[GMTCASE_MAP_FRAME_WIDTH] = 'p'; + /* MAP_GRID_PEN_PRIMARY */ + error += gmt_getpen (GMT, "default,gray", &GMT->current.setting.map_grid_pen[GMT_PRIMARY]); + /* MAP_GRID_PEN_SECONDARY */ + error += gmt_getpen (GMT, "thinner,gray", &GMT->current.setting.map_grid_pen[GMT_SECONDARY]); + /* MAP_HEADING_OFFSET */ + GMT->current.setting.map_heading_offset = 16 * pt; /* 16p */ + GMT->current.setting.given_unit[GMTCASE_MAP_HEADING_OFFSET] = 'p'; + /* MAP_LABEL_OFFSET */ + GMT->current.setting.map_label_offset = 6 * pt; /* 6p */ + GMT->current.setting.given_unit[GMTCASE_MAP_LABEL_OFFSET] = 'p'; + /* MAP_TICK_LENGTH_PRIMARY */ + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt; /* 3p */ + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt; /* 1.5p */ + GMT->current.setting.given_unit[GMTCASE_MAP_TICK_LENGTH_PRIMARY] = 'p'; + /* MAP_TICK_LENGTH_SECONDARY */ + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt; /* 12p */ + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt; /* 3p */ + GMT->current.setting.given_unit[GMTCASE_MAP_TICK_LENGTH_SECONDARY] = 'p'; + /* MAP_TITLE_OFFSET */ + GMT->current.setting.map_title_offset = 12 * pt; /* 12p */ + GMT->current.setting.given_unit[GMTCASE_MAP_TITLE_OFFSET] = 'p'; + /* MAP_VECTOR_SHAPE */ + GMT->current.setting.map_vector_shape = 0.5; + + /* PS_LINE_CAP */ + GMT->PSL->internal.line_cap = PSL_ROUND_CAP; + if (error) + GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unrecognized value during gmtdefaults modern initialization.\n");} + /*! . */ GMT_LOCAL void gmtinit_conf_modern_US (struct GMT_CTRL *GMT) { - /* REPLACE WITH gmtinit_conf_modern_US when ready */ gmtinit_conf_classic_US (GMT); /* Override with US settings */ + gmtinit_conf_modern_override (GMT); } /*! . */ GMT_LOCAL void gmtinit_conf_modern (struct GMT_CTRL *GMT) { /* REPLACE WITH gmtinit_conf_modern when ready */ gmtinit_conf_classic (GMT); + gmtinit_conf_modern_override (GMT); } /*! . */ @@ -6086,7 +6169,7 @@ void gmt_conf_US (struct GMT_CTRL *GMT) { /*! . */ void gmt_conf_SI (struct GMT_CTRL *GMT) { if (GMT->current.setting.run_mode == GMT_MODERN) - gmtinit_conf_modern (GMT); /* REPLACE WITH gmtinit_conf_modern when ready */ + gmtinit_conf_modern (GMT); else gmtinit_conf_classic (GMT); } @@ -9267,8 +9350,8 @@ GMT_LOCAL int gmtinit_update_theme (struct GMT_CTRL *GMT) { GMT->current.setting.update_theme = false; if (!strcmp (GMT->current.setting.theme, "classic")) /* Just reload the classic defaults */ gmtinit_conf_classic (GMT); - //else if (!strcmp (GMT->current.setting.theme, "modern")) /* Just reload the modern defaults TESTING VIA MODERN.CONF FOR NOW */ - // gmtinit_conf_modern (GMT); + else if (!strcmp (GMT->current.setting.theme, "modern")) + gmtinit_conf_modern (GMT); else if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { /* Load given theme */ error = gmtinit_loaddefaults (GMT, theme_file); } @@ -13342,6 +13425,7 @@ GMT_LOCAL int gmtinit_set_modern_mode_if_oneliner (struct GMTAPI_CTRL *API, stru } API->GMT->hidden.func_level++; /* Must do this here since it has not yet been increased by gmtinit_begin_module_sub ! */ gmt_reset_history (API->GMT); /* A one-liner should have no history */ + gmtinit_conf_modern_override (API->GMT); if ((error = GMT_Call_Module (API, "begin", GMT_MODULE_CMD, session))) { GMT_Report (API, GMT_MSG_ERROR, "Unable to call module begin from gmtinit_set_modern_mode_if_oneliner.\n"); From 919fef04f475bca10485853a3a35bd0005431ca8 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Wed, 10 Jun 2020 18:43:03 -1000 Subject: [PATCH 020/109] Update modern.conf --- share/themes/modern.conf | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/themes/modern.conf b/share/themes/modern.conf index e4dea617215..96362f10f3c 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -17,12 +17,10 @@ FORMAT_GEO_MAP = ddd:mm:ssF # # MAP Parameters # -MAP_ANNOT_ORTHO = we MAP_AUTO_SCALE = on MAP_FRAME_AXES = WrStZ MAP_ANNOT_OFFSET_PRIMARY = 3p MAP_ANNOT_OFFSET_SECONDARY = 3p -MAP_FRAME_PEN = thicker,black MAP_FRAME_TYPE = plain MAP_FRAME_WIDTH = 3p MAP_GRID_PEN_PRIMARY = default,gray From 2d2292dca6b7c48bf627d966d9257b8c2846d4a5 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Wed, 10 Jun 2020 19:19:22 -1000 Subject: [PATCH 021/109] Updates --- doc/rst/source/gmt.conf.rst | 3 ++- share/tools/gmt_uninstall.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/rst/source/gmt.conf.rst b/doc/rst/source/gmt.conf.rst index b8779c84bc7..8f932730a87 100644 --- a/doc/rst/source/gmt.conf.rst +++ b/doc/rst/source/gmt.conf.rst @@ -615,7 +615,8 @@ MAP Parameters **MAP_AUTO_SCALE** Determines if basemap font sizes, pen thicknesses, tick-lengths, and offsets will - be computed from the plot dimensions (**on**) or if they should be set manually (**off**) [off]. + be computed from the plot dimensions (**on**) or if they should be set manually (**off**) + [off for classic mode, on for modern]. **MAP_DEFAULT_PEN** Sets the default of all pens related to **-W** options. Prepend diff --git a/share/tools/gmt_uninstall.sh b/share/tools/gmt_uninstall.sh index 934c371516a..652480a8607 100755 --- a/share/tools/gmt_uninstall.sh +++ b/share/tools/gmt_uninstall.sh @@ -46,7 +46,7 @@ else fi # 3. Remove share directory -for dir in cpt custom doc localization man mgd77 mgg spotter tools x2sys; do +for dir in cpt custom doc localization man mgd77 mgg spotter tools themes x2sys; do printf "Remove: %s/%s\n" $share $dir rm -rf $share/$dir done From 2e027ac108fba5c5df107cdd28c4970994864a20 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Thu, 11 Jun 2020 07:47:01 -1000 Subject: [PATCH 022/109] Leave gridlines black and lines with butt cap --- share/themes/modern.conf | 6 ------ src/gmt_init.c | 8 ++------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 96362f10f3c..8aa6f3f643a 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -23,15 +23,9 @@ MAP_ANNOT_OFFSET_PRIMARY = 3p MAP_ANNOT_OFFSET_SECONDARY = 3p MAP_FRAME_TYPE = plain MAP_FRAME_WIDTH = 3p -MAP_GRID_PEN_PRIMARY = default,gray -MAP_GRID_PEN_SECONDARY = thinner,gray MAP_HEADING_OFFSET = 16p MAP_LABEL_OFFSET = 6p MAP_TICK_LENGTH_PRIMARY = 3p/1.5p MAP_TICK_LENGTH_SECONDARY = 12p/3p MAP_TITLE_OFFSET = 12p MAP_VECTOR_SHAPE = 0.5 -# -# PostScript Parameters -# -PS_LINE_CAP = round diff --git a/src/gmt_init.c b/src/gmt_init.c index ed9d416a3d7..2799ac54ae6 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6116,10 +6116,6 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { /* MAP_FRAME_WIDTH */ GMT->current.setting.map_frame_width = 3 * pt; /* 3p */ GMT->current.setting.given_unit[GMTCASE_MAP_FRAME_WIDTH] = 'p'; - /* MAP_GRID_PEN_PRIMARY */ - error += gmt_getpen (GMT, "default,gray", &GMT->current.setting.map_grid_pen[GMT_PRIMARY]); - /* MAP_GRID_PEN_SECONDARY */ - error += gmt_getpen (GMT, "thinner,gray", &GMT->current.setting.map_grid_pen[GMT_SECONDARY]); /* MAP_HEADING_OFFSET */ GMT->current.setting.map_heading_offset = 16 * pt; /* 16p */ GMT->current.setting.given_unit[GMTCASE_MAP_HEADING_OFFSET] = 'p'; @@ -6140,8 +6136,6 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { /* MAP_VECTOR_SHAPE */ GMT->current.setting.map_vector_shape = 0.5; - /* PS_LINE_CAP */ - GMT->PSL->internal.line_cap = PSL_ROUND_CAP; if (error) GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unrecognized value during gmtdefaults modern initialization.\n");} @@ -9355,6 +9349,8 @@ GMT_LOCAL int gmtinit_update_theme (struct GMT_CTRL *GMT) { else if (gmt_getsharepath (GMT, "themes", GMT->current.setting.theme, ".conf", theme_file, R_OK)) { /* Load given theme */ error = gmtinit_loaddefaults (GMT, theme_file); } + else + gmt_message (GMT, "Theme %s file not found - ignored\n", GMT->current.setting.theme); return (error); } From 10c9d39d134fe53249fa9a17c39b86cc923f1de5 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Thu, 11 Jun 2020 09:54:27 -1000 Subject: [PATCH 023/109] Update inverse and darkmode to be modern --- share/themes/darkmode.conf | 12 ++++++------ share/themes/inverse.conf | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/share/themes/darkmode.conf b/share/themes/darkmode.conf index 05e85463e74..1998273bd29 100644 --- a/share/themes/darkmode.conf +++ b/share/themes/darkmode.conf @@ -3,13 +3,13 @@ # # FONT Parameters # -FONT_ANNOT_PRIMARY = 12p,Helvetica,gray92 -FONT_ANNOT_SECONDARY = 14p,Helvetica,gray86 -FONT_HEADING = 32p,Helvetica,gray92 -FONT_LABEL = 16p,Helvetica,gray92 +FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,gray92 +FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,gray86 +FONT_HEADING = 28p,AvantGarde-Demi,gray92 +FONT_LABEL = 14p,AvantGarde-Book,black FONT_LOGO = 8p,Helvetica,gray92 -FONT_TAG = 20p,Helvetica,gray92 -FONT_TITLE = 24p,Helvetica,gray92 +FONT_TAG = 18p,AvantGarde-Book,gray92 +FONT_TITLE = 22p,AvantGarde-Demi,gray92 # # MAP Parameters # diff --git a/share/themes/inverse.conf b/share/themes/inverse.conf index c85bef0b29d..458448cbab1 100644 --- a/share/themes/inverse.conf +++ b/share/themes/inverse.conf @@ -3,13 +3,13 @@ # # FONT Parameters # -FONT_ANNOT_PRIMARY = 12p,Helvetica,white -FONT_ANNOT_SECONDARY = 14p,Helvetica,white -FONT_HEADING = 32p,Helvetica,white -FONT_LABEL = 16p,Helvetica,white -FONT_LOGO = 8p,Helvetica,white -FONT_TAG = 20p,Helvetica,white -FONT_TITLE = 24p,Helvetica,white +FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,black +FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,black +FONT_HEADING = 28p,AvantGarde-Demi,black +FONT_LABEL = 14p,AvantGarde-Book,black +FONT_LOGO = 8p,Helvetica,black +FONT_TAG = 18p,AvantGarde-Book,black +FONT_TITLE = 22p,AvantGarde-Demi,black # # MAP Parameters # From 47a982b387be7d6eee0453180db336f5c80f3a10 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 13 Jun 2020 08:55:42 -1000 Subject: [PATCH 024/109] Move the auto-font-size function to gmt_init.c --- src/gmt_init.c | 62 +++++++++++++++++++++++++++++++++++++++++++ src/gmt_internals.h | 1 + src/gmt_plot.c | 64 +-------------------------------------------- 3 files changed, 64 insertions(+), 63 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 3fc8395b123..c05fd859aaa 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -9397,6 +9397,68 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) return (n_errors); } +void gmtlib_auto_font_tick_sizes (struct GMT_CTRL *GMT) { + /* If the primary font size is zero then we want auto-scaling based on plot size */ + bool geo_frame = false; + double fontsize, map_dim_cm, scale; + double const pt = 1.0/72.0; /* points to inch */ + + /* If a geographic map frame is fancy then we cannot have lrbt */ + + geo_frame = (gmt_M_is_geographic (GMT, GMT_IN) && (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED)); + if (geo_frame) { /* Turn any l,r,b,t to w,e,s,n */ + for (unsigned int k = 0; k < 4; k++) + GMT->current.map.frame.side[k] |= GMT_AXIS_BARB; + } + + if (!GMT->current.setting.map_auto_scale) return; /* Auto scaling is off */ + + /* Use this equation to compute the primary annotation font size given map max dimension */ + + map_dim_cm = MAX (GMT->current.map.width, GMT->current.map.height) * GMT->session.u2u[GMT_INCH][GMT_CM]; + fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; /* Gives result in points */ + scale = fontsize / 10.0; /* scaling for offsets, pen widths and lengths normalized to the modern 10p size */ + GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Computed primary annotation font size: %g p Dimension scaling: %g\n", fontsize, scale); + + GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; + GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ + GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ + GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ + GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ + GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ + GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ + + /* Offsets */ + + GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ + GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ + GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ + GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ + + /* Tick lengths */ + + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ + + /* Frame, tick and gridline pens */ + + GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ + GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ + GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ + GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ + GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ + + if (geo_frame) { + /* Extend ticks by the width of the fancy frame */ + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] += GMT->current.setting.map_frame_width; + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] += GMT->current.setting.map_frame_width; + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] += GMT->current.setting.map_frame_width; + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] += GMT->current.setting.map_frame_width; + } +} + /*! . */ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, char *value, bool core) { /* core is true if we are calling gmtlib_setparameter from gmtinit_loaddefaults, while it is diff --git a/src/gmt_internals.h b/src/gmt_internals.h index d78081c3280..d9bab85658c 100644 --- a/src/gmt_internals.h +++ b/src/gmt_internals.h @@ -52,6 +52,7 @@ struct GMT_XINGS { EXTERN_MSC char *dlerror (void); #endif +EXTERN_MSC void gmtlib_auto_font_tick_sizes (struct GMT_CTRL *GMT); EXTERN_MSC int gmtlib_file_is_jpeg2000_tile (struct GMTAPI_CTRL *API, char *file); EXTERN_MSC int gmtlib_download_remote_file (struct GMT_CTRL *GMT, const char* file_name, char *path, int k_data, unsigned int mode); EXTERN_MSC int gmtlib_get_serverfile_index (struct GMTAPI_CTRL *API, const char *file); diff --git a/src/gmt_plot.c b/src/gmt_plot.c index 7b5ab203a5e..84a573d44e6 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -5436,75 +5436,13 @@ GMT_LOCAL void gmtplot_check_primary_secondary (struct GMT_CTRL *GMT) { } } -GMT_LOCAL void gmtplot_auto_font_tick_sizes (struct GMT_CTRL *GMT) { - /* If the primary font size is zero then we want auto-scaling based on plot size */ - bool geo_frame = false; - double fontsize, map_dim_cm, scale; - double const pt = 1.0/72.0; /* points to inch */ - - /* If a geographic map frame is fancy then we cannot have lrbt */ - - geo_frame = (gmt_M_is_geographic (GMT, GMT_IN) && (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED)); - if (geo_frame) { /* Turn any l,r,b,t to w,e,s,n */ - for (unsigned int k = 0; k < 4; k++) - GMT->current.map.frame.side[k] |= GMT_AXIS_BARB; - } - - if (!GMT->current.setting.map_auto_scale) return; /* Auto scaling is off */ - - /* Use this equation to compute the primary annotation font size given map max dimension */ - - map_dim_cm = MAX (GMT->current.map.width, GMT->current.map.height) * GMT->session.u2u[GMT_INCH][GMT_CM]; - fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; /* Gives result in points */ - scale = fontsize / 10.0; /* scaling for offsets, pen widths and lengths normalized to the modern 10p size */ - GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Computed primary annotation font size: %g p Dimension scaling: %g\n", fontsize, scale); - - GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; - GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ - GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ - GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ - GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ - GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ - GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ - - /* Offsets */ - - GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ - GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ - GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ - GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ - - /* Tick lengths */ - - GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ - GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ - GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ - GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ - - /* Frame, tick and gridline pens */ - - GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ - GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ - GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ - GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - - if (geo_frame) { - /* Extend ticks by the width of the fancy frame */ - GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] += GMT->current.setting.map_frame_width; - GMT->current.setting.map_tick_length[GMT_TICK_UPPER] += GMT->current.setting.map_frame_width; - GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] += GMT->current.setting.map_frame_width; - GMT->current.setting.map_tick_length[GMT_TICK_LOWER] += GMT->current.setting.map_frame_width; - } -} - void gmt_map_basemap (struct GMT_CTRL *GMT) { unsigned int side; bool clip_on = false; double w, e, s, n; struct PSL_CTRL *PSL= GMT->PSL; - gmtplot_auto_font_tick_sizes (GMT); + gmtlib_auto_font_tick_sizes (GMT); if (!GMT->common.B.active[GMT_PRIMARY] && !GMT->common.B.active[GMT_SECONDARY]) return; /* No frame annotation/ticks/gridlines specified */ From 09661e3fad6f201ddb74b3733e07a098d983efe9 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 13 Jun 2020 10:09:04 -1000 Subject: [PATCH 025/109] Allow --PAR-value overrides for auto scaling --- src/gmt_defaults.h | 1 + src/gmt_init.c | 108 ++++++++++++++++++++++++++++++++------------- 2 files changed, 78 insertions(+), 31 deletions(-) diff --git a/src/gmt_defaults.h b/src/gmt_defaults.h index 3f94019e26c..09f27e56a35 100644 --- a/src/gmt_defaults.h +++ b/src/gmt_defaults.h @@ -58,6 +58,7 @@ struct GMT_ENCODING { /*! Holds all variables directly controlled by GMT Default parameters */ struct GMT_DEFAULTS { + bool par_set[GMT_N_KEYS]; /* True if a parameter is set via --PAR=value on the command line */ /* COLOR group [sorted by type to optimize storage] */ unsigned int color_model; /* 1 = read RGB, 2 = use RGB, 4 = read HSV, 8 = use HSV, 16 = read CMYK, 32 = use CMYK [1+2] * Add 128 to disallow output of color names */ diff --git a/src/gmt_init.c b/src/gmt_init.c index c05fd859aaa..0a56f7ceeea 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -117,8 +117,7 @@ /* Leave a record that this keyword is no longer a default one So far, only gmtset calls this function with core = true, but this is a too fragile solution */ -#define GMT_KEYWORD_UPDATE(val) if (core) GMT_keywords_updated[val] = true - +#define GMT_KEYWORD_UPDATE(val) if (core) GMT_keywords_updated[val] = true; else GMT->current.setting.par_set[val] = updated /*--------------------------------------------------------------------*/ /* Load private fixed array parameters from include files */ @@ -9397,58 +9396,90 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) return (n_errors); } +GMT_LOCAL bool gmtinit_auto_allowed (struct GMT_CTRL *GMT, char *item) { + int kase = gmt_hash_lookup (GMT, item, keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); + if (kase == -1) return false; /* WTF? */ + return !GMT->current.setting.par_set[kase]; +} + void gmtlib_auto_font_tick_sizes (struct GMT_CTRL *GMT) { - /* If the primary font size is zero then we want auto-scaling based on plot size */ + /* If MAP_AUTO_SCALE is on then we must adjust all frame items according to plot size */ bool geo_frame = false; double fontsize, map_dim_cm, scale; double const pt = 1.0/72.0; /* points to inch */ - /* If a geographic map frame is fancy then we cannot have lrbt */ + /* If a geographic map frame is fancy then we cannot have lrbt regardless of mode */ geo_frame = (gmt_M_is_geographic (GMT, GMT_IN) && (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED)); if (geo_frame) { /* Turn any l,r,b,t to w,e,s,n */ for (unsigned int k = 0; k < 4; k++) - GMT->current.map.frame.side[k] |= GMT_AXIS_BARB; + if (GMT->current.map.frame.side[k] & GMT_AXIS_DRAW) GMT->current.map.frame.side[k] |= GMT_AXIS_BARB; } - if (!GMT->current.setting.map_auto_scale) return; /* Auto scaling is off */ + if (!GMT->current.setting.map_auto_scale) return; /* Auto scaling is off; we are done here */ - /* Use this equation to compute the primary annotation font size given map max dimension */ + /* Use this equation for fontsize to compute the primary annotation font size given map max dimension */ map_dim_cm = MAX (GMT->current.map.width, GMT->current.map.height) * GMT->session.u2u[GMT_INCH][GMT_CM]; - fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; /* Gives result in points */ + fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; /* Gives result in points for plot dimension in cm */ scale = fontsize / 10.0; /* scaling for offsets, pen widths and lengths normalized to the modern 10p size */ GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Computed primary annotation font size: %g p Dimension scaling: %g\n", fontsize, scale); - GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; - GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ - GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ - GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ - GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ - GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ - GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ + /* Only apply the automatic scaling to items NOT specifically set via a --PAR=value option */ + + if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_PRIMARY")) + GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; + if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_SECONDARY")) + GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ + if (gmtinit_auto_allowed (GMT, "FONT_LABEL")) + GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ + if (gmtinit_auto_allowed (GMT, "FONT_HEADING")) + GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ + if (gmtinit_auto_allowed (GMT, "FONT_TAG")) + GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ + if (gmtinit_auto_allowed (GMT, "FONT_TITLE")) + GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ + if (gmtinit_auto_allowed (GMT, "FONT_LOGO")) + GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ /* Offsets */ - GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ - GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ - GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ - GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ + if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_PRIMARY")) + GMT->current.setting.map_annot_offset[GMT_PRIMARY] = 3 * pt * scale; /* 3p */ + if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_SECONDARY")) + GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ + if (gmtinit_auto_allowed (GMT, "MAP_LABEL_OFFSET")) + GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ + if (gmtinit_auto_allowed (GMT, "MAP_TITLE_OFFSET")) + GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ + if (gmtinit_auto_allowed (GMT, "MAP_HEADING_OFFSET")) + GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ /* Tick lengths */ - GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ - GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ - GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ - GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ + if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_PRIMARY")) { + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ + } + if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_SECONDARY")) { + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ + } /* Frame, tick and gridline pens */ - GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ - GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ - GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ - GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ + if (gmtinit_auto_allowed (GMT, "MAP_FRAME_WIDTH")) + GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ + if (gmtinit_auto_allowed (GMT, "MAP_FRAME_PEN")) + GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ + if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_PRIMARY")) + GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = 0.5 * scale; /* 0.5p (thinner) */ + if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_SECONDARY")) + GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ + if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_PRIMARY")) + GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ + if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_SECONDARY")) + GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ if (geo_frame) { /* Extend ticks by the width of the fancy frame */ @@ -9469,7 +9500,7 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha unsigned int pos; size_t len; int i, ival, case_val, manual, limit; - bool error = false, tf_answer = false; + bool error = false, tf_answer = false, updated = true; char txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[GMT_LEN256] = {""}, lower_value[GMT_BUFSIZ] = {""}; double dval; @@ -9581,6 +9612,7 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha gmtlib_setparameter (GMT, "FONT_HEADING", value, core) + gmtlib_setparameter (GMT, "FONT_LABEL", value, core); /* FONT_LOGO is purposely skipped */ + updated = false; /* No size was specified so auto-scaling is still possible */ break; case GMTCASE_FONT_ANNOT: error = gmtlib_setparameter (GMT, "FONT_ANNOT_PRIMARY", value, core) + @@ -9633,32 +9665,41 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha if (p >= 0) GMT_keywords_updated[p] = true; /* Leave a record that this keyword is no longer a default one */ } } - else + else { if (gmt_getfont (GMT, value, &GMT->current.setting.font_annot[GMT_PRIMARY])) error = true; + if (strstr (value, "p,") == NULL) updated = false; /* No size given */ + } break; case GMTCASE_ANNOT_FONT_SECONDARY: GMT_COMPAT_TRANSLATE ("FONT_ANNOT_SECONDARY"); break; case GMTCASE_FONT_ANNOT_SECONDARY: if (gmt_getfont (GMT, value, &GMT->current.setting.font_annot[GMT_SECONDARY])) error = true; + if (strstr (value, "p,") == NULL) updated = false; /* No size given */ break; case GMTCASE_FONT_HEADING: if (gmt_getfont (GMT, value, &GMT->current.setting.font_heading)) error = true; + if (strstr (value, "p,") == NULL) updated = false; /* No size given */ break; case GMTCASE_FONT_TITLE: if (gmt_getfont (GMT, value, &GMT->current.setting.font_title)) error = true; + if (strstr (value, "p,") == NULL) updated = false; /* No size given */ break; case GMTCASE_FONT_TAG: if (gmt_getfont (GMT, value, &GMT->current.setting.font_tag)) error = true; + if (strstr (value, "p,") == NULL) updated = false; /* No size given */ break; case GMTCASE_LABEL_FONT: GMT_COMPAT_TRANSLATE ("FONT_LABEL"); + if (strstr (value, "p,") == NULL) updated = false; /* No size given */ break; case GMTCASE_FONT_LABEL: if (gmt_getfont (GMT, value, &GMT->current.setting.font_label)) error = true; + if (strstr (value, "p,") == NULL) updated = false; /* No size given */ break; case GMTCASE_FONT_LOGO: if (gmt_getfont (GMT, value, &GMT->current.setting.font_logo)) error = true; + if (strstr (value, "p,") == NULL) updated = false; /* No size given */ break; /* FONT GROUP ... obsolete options */ @@ -9840,6 +9881,7 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_MAP_FRAME_PEN: error = gmt_getpen (GMT, value, &GMT->current.setting.map_frame_pen); + if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_BASEMAP_TYPE: GMT_COMPAT_TRANSLATE ("MAP_FRAME_TYPE"); @@ -9917,12 +9959,14 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_MAP_GRID_PEN_PRIMARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_grid_pen[GMT_PRIMARY]); + if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_GRID_PEN_SECONDARY: GMT_COMPAT_TRANSLATE ("MAP_GRID_PEN_SECONDARY"); break; case GMTCASE_MAP_GRID_PEN_SECONDARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_grid_pen[GMT_SECONDARY]); + if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_MAP_HEADING_OFFSET: GMT->current.setting.map_heading_offset = gmt_M_to_inch (GMT, value); @@ -10039,9 +10083,11 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_MAP_TICK_PEN_PRIMARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_tick_pen[GMT_PRIMARY]); + if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_MAP_TICK_PEN_SECONDARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_tick_pen[GMT_SECONDARY]); + if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_HEADER_OFFSET: GMT_COMPAT_TRANSLATE ("MAP_TITLE_OFFSET"); @@ -17357,7 +17403,7 @@ void gmt_add_legend_item (struct GMTAPI_CTRL *API, struct GMT_SYMBOL *S, bool do * +N corresponds to command N in the legend codes and changes the number of columns. * +S sets symbol size or line length for symbols that otherwise won't have a dimension. * +V corresponds to command V in the legend codes and starts/ends a vertical line. - * +f sets the font to use the header string [FONT_HEADER]. + * +f sets the font to use the header string [FONT_TITLE]. * +g sets the frame fill [white]. * +j -Dj?? as to where to place legend * +o sets the frame offset [0.2c]. From b0042eb7eaea30b9bf97d188fc35081f33a03553 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 13 Jun 2020 10:29:16 -1000 Subject: [PATCH 026/109] Update gmt_init.c --- src/gmt_init.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 0a56f7ceeea..9b15edff305 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -9490,6 +9490,19 @@ void gmtlib_auto_font_tick_sizes (struct GMT_CTRL *GMT) { } } +GMT_LOCAL bool gmtinit_no_fontsize (char *string) { + /* Font specs look like one of these: + * size,name,color[=style] + * size + * + * If no size is given then only the font family is set and we are allowed to scale size later. + * So we look for a leading fontsize spec, e.g. 0.7i, 12p, 1c + */ + + if (string[0] == '.' || isdigit (string[0])) return false; /* Apparently we specified size */ + return true; +} + /*! . */ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, char *value, bool core) { /* core is true if we are calling gmtlib_setparameter from gmtinit_loaddefaults, while it is @@ -9667,7 +9680,7 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha } else { if (gmt_getfont (GMT, value, &GMT->current.setting.font_annot[GMT_PRIMARY])) error = true; - if (strstr (value, "p,") == NULL) updated = false; /* No size given */ + if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ } break; case GMTCASE_ANNOT_FONT_SECONDARY: @@ -9675,31 +9688,31 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_FONT_ANNOT_SECONDARY: if (gmt_getfont (GMT, value, &GMT->current.setting.font_annot[GMT_SECONDARY])) error = true; - if (strstr (value, "p,") == NULL) updated = false; /* No size given */ + if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_HEADING: if (gmt_getfont (GMT, value, &GMT->current.setting.font_heading)) error = true; - if (strstr (value, "p,") == NULL) updated = false; /* No size given */ + if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_TITLE: if (gmt_getfont (GMT, value, &GMT->current.setting.font_title)) error = true; - if (strstr (value, "p,") == NULL) updated = false; /* No size given */ + if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_TAG: if (gmt_getfont (GMT, value, &GMT->current.setting.font_tag)) error = true; - if (strstr (value, "p,") == NULL) updated = false; /* No size given */ + if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_LABEL_FONT: GMT_COMPAT_TRANSLATE ("FONT_LABEL"); - if (strstr (value, "p,") == NULL) updated = false; /* No size given */ + if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_LABEL: if (gmt_getfont (GMT, value, &GMT->current.setting.font_label)) error = true; - if (strstr (value, "p,") == NULL) updated = false; /* No size given */ + if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_LOGO: if (gmt_getfont (GMT, value, &GMT->current.setting.font_logo)) error = true; - if (strstr (value, "p,") == NULL) updated = false; /* No size given */ + if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; /* FONT GROUP ... obsolete options */ From 946a0b0c31c05efa75b0a801e6d217d700f9119a Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 13 Jun 2020 13:01:08 -1000 Subject: [PATCH 027/109] Improve scripts in general --- doc/examples/ex02/ex02.sh | 4 ++-- doc/examples/ex09/ex09.sh | 2 +- doc/examples/ex19/ex19.sh | 8 ++++---- doc/examples/ex22/ex22.sh | 6 ++---- doc/scripts/GMT_API_use.sh | 2 +- doc/scripts/GMT_TM.sh | 2 +- doc/scripts/GMT_atan.sh | 4 ++-- doc/scripts/GMT_dir_rose.sh | 2 +- test/movie/movie_indicator_de.sh | 4 ++-- 9 files changed, 16 insertions(+), 18 deletions(-) diff --git a/doc/examples/ex02/ex02.sh b/doc/examples/ex02/ex02.sh index f5acb20c6bf..d3e90174f0c 100755 --- a/doc/examples/ex02/ex02.sh +++ b/doc/examples/ex02/ex02.sh @@ -10,11 +10,11 @@ gmt begin ex02 gmt subplot set 0,0 -Ce3c gmt grd2cpt @HI_topo_02.nc -Crelief -Z gmt grdimage @HI_topo_02.nc -I+a0 - gmt colorbar -DJRM+o1.5c/0+mc -I0.3 -Bx2+lTOPO -By+lkm + gmt colorbar -DJRM+o1c/0+mc -I0.3 -Bx2+lTOPO -By+lkm gmt subplot set 1,0 -Ce3c gmt makecpt -Crainbow -T-2/14/2 gmt grdimage @HI_geoid_02.nc - gmt colorbar -DJRM+o1.5c/0+e+mc -Bx2+lGEOID -By+lm + gmt colorbar -DJRM+o1c/0+e+mc -Bx2+lGEOID -By+lm gmt subplot end gmt end show diff --git a/doc/examples/ex09/ex09.sh b/doc/examples/ex09/ex09.sh index 2062596fefe..9de3ad443a8 100755 --- a/doc/examples/ex09/ex09.sh +++ b/doc/examples/ex09/ex09.sh @@ -10,5 +10,5 @@ gmt begin ex09 gmt plot @ridge_09.txt -Wthicker gmt plot @fz_09.txt -Wthinner,- # Take label from segment header and plot near coordinates of last record of each track - gmt convert -El @tracks_09.txt | gmt text -F+f10p,Helvetica-Bold+a50+jRM+h -D-4p + gmt convert -El @tracks_09.txt | gmt text -F+f10p,Helvetica-Bold+a50+jRM+h -D-4p -Ghoneydew gmt end show diff --git a/doc/examples/ex19/ex19.sh b/doc/examples/ex19/ex19.sh index 655e80b3424..f0b006d4917 100755 --- a/doc/examples/ex19/ex19.sh +++ b/doc/examples/ex19/ex19.sh @@ -16,9 +16,9 @@ gmt begin ex19 gmt grdimage lon.nc -Clon.cpt -nl gmt coast -Q gmt coast -Dc -A5000 -Wthinnest - echo "0 20 16TH INTERNATIONAL" | gmt text -F+f32p,Helvetica-Bold,red=thinner + echo "0 20 17TH INTERNATIONAL" | gmt text -F+f32p,Helvetica-Bold,red=thinner echo "0 -10 GMT CONFERENCE" | gmt text -F+f32p,Helvetica-Bold,red=thinner - echo "0 -30 Honolulu, Hawaii, April 1, 2020" | gmt text -F+f18p,Helvetica-Bold,green=thinnest + echo "0 -30 Honolulu, Hawaii, April 1, 2021" | gmt text -F+f18p,Helvetica-Bold,green=thinnest # Then show example of color patterns and placing a PostScript image gmt coast -Dc -A5000 -Gp86+fred+byellow+r100 -Sp@circuit.png+r100 -c1,0 echo "0 30 SILLY USES OF" | gmt text -F+f32p,Helvetica-Bold,lightgreen=thinner @@ -30,9 +30,9 @@ gmt begin ex19 gmt grdimage lat.nc -Clat.cpt -nl gmt coast -Q gmt coast -Dc -A5000 -Wthinnest - echo "0 20 16TH INTERNATIONAL" | gmt text -F+f32p,Helvetica-Bold,red=thinner + echo "0 20 17TH INTERNATIONAL" | gmt text -F+f32p,Helvetica-Bold,red=thinner echo "0 -10 GMT CONFERENCE" | gmt text -F+f32p,Helvetica-Bold,red=thinner - echo "0 -30 Honolulu, Hawaii, April 1, 2020" | gmt text -F+f18p,Helvetica-Bold,green=thinnest + echo "0 -30 Honolulu, Hawaii, April 1, 2021" | gmt text -F+f18p,Helvetica-Bold,green=thinnest gmt subplot end gmt end show rm -f lat.nc lon.nc lat.cpt lon.cpt diff --git a/doc/examples/ex22/ex22.sh b/doc/examples/ex22/ex22.sh index 4bffc950f27..74626afecd1 100755 --- a/doc/examples/ex22/ex22.sh +++ b/doc/examples/ex22/ex22.sh @@ -2,12 +2,10 @@ # GMT EXAMPLE 22 # # Purpose: Automatic map of last month of world-wide seismicity -# GMT modules: set, coast, plot, legend +# GMT modules: coast, plot, legend # Unix progs: cat, sed, awk, wget|curl # gmt begin ex22 - gmt set FONT_ANNOT_PRIMARY 10p FONT_TITLE 18p FORMAT_GEO_MAP ddd:mm:ssF - # Get the data (-s silently) from USGS using the curl # Hardwired here to the month of October, 2017 # SITE="https://earthquake.usgs.gov/fdsnws/event/1/query.csv" @@ -81,7 +79,7 @@ gmt begin ex22 # OK, now we can actually run gmt legend. We center the legend below the map. # Trial and error shows that 1.7i is a good legend height: - gmt legend -DJBC+o0/1c+w18c/4.2c -F+p+glightyellow neis.legend + gmt legend -DJBC+o0/1c+w18c/4.2c -F+p+glightyellow neis.legend --FONT_ANNOT_PRIMARY=10p,Helvetica rm neis.legend usgs_quakes_22.txt gmt end show diff --git a/doc/scripts/GMT_API_use.sh b/doc/scripts/GMT_API_use.sh index 1e4c38682d7..e36107d398b 100755 --- a/doc/scripts/GMT_API_use.sh +++ b/doc/scripts/GMT_API_use.sh @@ -34,7 +34,7 @@ EOF EOF gmt text -F+f12p+jCM -Gwhite -W0.25p -C50% << EOF -2.8 0.75 FILES OR STDIN -+2.8 0.75 FILES OR STDIN ++2.8 0.75 FILES OR STDOUT EOF gmt text -F+f12p+jCM -Glightblue -W0.25p -C50% << EOF -2.8 0.0 STREAMS, FILE DESCRIPTORS diff --git a/doc/scripts/GMT_TM.sh b/doc/scripts/GMT_TM.sh index cec771acda9..8ebbc0cdb5e 100755 --- a/doc/scripts/GMT_TM.sh +++ b/doc/scripts/GMT_TM.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -gmt coast -R0/360/-80/80 -JT330/-45/10c -Ba30g -BWSne -Dc -A2000 -Slightblue -G0 -ps GMT_TM +gmt coast -R0/360/-80/80 -JT330/-45/10c -Ba30g -BWSne -Dc -A2000 -Slightblue -G0 -ps GMT_TM --MAP_ANNOT_OBLIQUE=2 diff --git a/doc/scripts/GMT_atan.sh b/doc/scripts/GMT_atan.sh index b18f0260588..facabd6908b 100755 --- a/doc/scripts/GMT_atan.sh +++ b/doc/scripts/GMT_atan.sh @@ -4,7 +4,7 @@ gmt begin GMT_atan gmt grd2xyz -Z tt.t.nc > tt.d gmt histogram tt.d -R-0.75/0.75/0/20 -JX1.5i/1i -Bx0.5 -By5f5 -BWSne -W0.01 -Gblack -Z1 - gmt text -F+f9p+jLB << EOF + gmt text -F+f9p,Helvetica+jLB << EOF -0.7 17 Raw -0.7 15 slopes EOF @@ -25,7 +25,7 @@ EOF gmt grdgradient -A45 @tut_relief.nc -Nt -fg -Gtt.tt.nc gmt grd2xyz -Z tt.tt.nc > tt.d gmt histogram tt.d -R-0.75/0.75/0/5 -Bx0.5 -By2f1 -BWSne -W0.01 -Gblack -X1.85i -Z1 - gmt text -F+f9p+jLB << EOF + gmt text -F+f9p,Helvetica+jLB << EOF -0.7 4.3 tan@+-1@+ -0.7 3.7 transformed EOF diff --git a/doc/scripts/GMT_dir_rose.sh b/doc/scripts/GMT_dir_rose.sh index f8d347744e9..f46b1556716 100755 --- a/doc/scripts/GMT_dir_rose.sh +++ b/doc/scripts/GMT_dir_rose.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Showing map directional roses gmt begin GMT_dir_rose - gmt set FONT_LABEL 10p FONT_TITLE 12p MAP_ANNOT_OBLIQUE 34 MAP_TITLE_OFFSET 5p \ + gmt set MAP_AUTO_SCALE off MAP_FRAME_TYPE fancy FONT_LABEL 10p FONT_TITLE 12p MAP_ANNOT_OBLIQUE 34 MAP_TITLE_OFFSET 5p \ MAP_FRAME_WIDTH 3p FORMAT_GEO_MAP dddF FONT_ANNOT_PRIMARY 10p # left: Fancy kind = 1 gmt basemap -R-5/5/-5/5 -Jm0.15i -Ba5f -BWSne+gazure1 -Tdg0/0+w1i+jCM -X1i diff --git a/test/movie/movie_indicator_de.sh b/test/movie/movie_indicator_de.sh index 2b97e1cc6e1..c0b19c7d43e 100755 --- a/test/movie/movie_indicator_de.sh +++ b/test/movie/movie_indicator_de.sh @@ -9,5 +9,5 @@ gmt begin gmt plot -R0/9.2/0/5 -Jx1i -T -X0.2i -Y0.2i -B0 gmt end EOF -gmt movie map.sh -CHD -T1850/2010/5 -Fnone -M10,ps -Nmovie_indicator_de -Pe+w8i+ap+jTC+o0/0.2i -Pe+af+jTC+o0/0.7i -Pe+w5i+ae+s60+jTC+o0/1.2i -Pe+w4i+ac0+jTC+o0/1.7i -Pe+w3i+ac0+jTC+o0/2.2i \ - -Pd+w2i+ac0+jTC+o0/2.7i -Pd+w3i+ac0+jTC+o0/3.2i -Pd+w5i+ae+s60+jTC+o0/3.7i -Pd+af+jTC+o0/4.2i -Pd+w8i+ap+jTC+o0/4.7i +gmt movie map.sh -CHD -T1850/2010/5 -Fnone -M10,ps -Nmovie_indicator_de -Pe+w8i+ap+jTC+o0/0.3i -Pe+af+jTC+o0/0.8i -Pe+w5i+ae+s60+jTC+o0/1.3i -Pe+w4i+ac0+jTC+o0/1.8i -Pe+w3i+ac0+jTC+o0/2.3i \ + -Pd+w2i+ac0+jTC+o0/2.8i -Pd+w3i+ac0+jTC+o0/3.3i -Pd+w5i+ae+s60+jTC+o0/3.8i -Pd+af+jTC+o0/4.3i -Pd+w8i+ap+jTC+o0/4.8i From 06025aab0621bd72b677df7815008220315ad937 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 13 Jun 2020 14:25:18 -1000 Subject: [PATCH 028/109] Update scripts and fix internals --- doc/examples/ex41/ex41.sh | 4 ++-- doc/examples/ex42/ex42.sh | 8 ++++---- doc/examples/ex50/ex50.sh | 1 - doc/scripts/GMT_legend.sh | 4 +--- doc/scripts/GMT_tut_4.sh | 2 +- doc/scripts/GMT_utm_zones.sh | 4 +--- src/gmt_init.c | 12 ++++++++---- src/gmt_internals.h | 1 - src/gmt_plot.c | 4 ++-- src/gmt_prototypes.h | 1 + src/pslegend.c | 2 ++ 11 files changed, 22 insertions(+), 21 deletions(-) diff --git a/doc/examples/ex41/ex41.sh b/doc/examples/ex41/ex41.sh index c7ee0127f5c..f526a2739d0 100755 --- a/doc/examples/ex41/ex41.sh +++ b/doc/examples/ex41/ex41.sh @@ -5,11 +5,11 @@ # GMT modules: set, coast, legend, plot, makecpt # gmt begin ex41 - gmt set FONT_ANNOT_PRIMARY 12p FONT_LABEL 12p + #gmt set FONT_ANNOT_PRIMARY 12p FONT_LABEL 12p gmt makecpt -Cred,orange,yellow,green,bisque,cyan,magenta,white,gray -T1/10/1 -N gmt coast -R130W/50W/8N/56N -JM14c -B0 -Glightgray -Sazure1 -A1000 -Wfaint --MAP_FRAME_TYPE=plain gmt coast -EUS+glightyellow+pfaint -ECU+glightred+pfaint -EMX+glightgreen+pfaint -ECA+glightblue+pfaint gmt coast -N1/1p,darkred -A1000/2/2 -Wfaint -Cazure1 gmt plot -Sk@symbol_41/0.25c -C -W0.25p -: @data_41.txt - gmt legend -DJTL+w14c+jBL+l1.2+o0/0.3c -C4p -F+p+gsnow1 @table_41.txt + gmt legend -DJTL+w14c+jBL+l1.2+o0/0.3c -C4p -F+p+gsnow1 @table_41.txt --FONT_ANNOT_PRIMARY=12p,Helvetica -V gmt end show diff --git a/doc/examples/ex42/ex42.sh b/doc/examples/ex42/ex42.sh index fc57a8e0079..0118ed3e56a 100755 --- a/doc/examples/ex42/ex42.sh +++ b/doc/examples/ex42/ex42.sh @@ -2,11 +2,11 @@ # GMT EXAMPLE 42 # # Purpose: Illustrate Antarctica and stereographic projection -# GMT modules: makecpt, grdimage, coast, legend, colorbar, text, plot +# GMT modules: makecpt, grdimage, coast, legend, colorbar, set, text, plot # Unix progs: [curl grdconvert] # gmt begin ex42 - gmt set FONT_ANNOT_PRIMARY 12p FONT_LABEL 12p PROJ_ELLIPSOID WGS-84 FORMAT_GEO_MAP dddF + gmt set PROJ_ELLIPSOID WGS-84 # Data obtained via website and converted to netCDF thus: # curl http://www.antarctica.ac.uk//bas_research/data/access/bedmap/download/bedelev.asc.gz # gunzip bedelev.asc.gz @@ -14,11 +14,11 @@ gmt begin ex42 gmt makecpt -Cearth -T-7000/4000 gmt grdimage @BEDMAP_elevation.nc -Jx1:60000000 -Q gmt coast -R-180/180/-90/-60 -Js0/-90/-71/1:60000000 -Bafg -Di -W0.25p - gmt colorbar -DJRM+w6.5c/0.5c+o1.5c/0+mc -F+p+i -Bxa1000+lELEVATION -By+lm + gmt colorbar -DJRM+w6.5c/0.5c+o1c/0+mc -F+p+i -Bxa1000+lELEVATION -By+lm # GSHHG gmt coast -Glightblue -Sroyalblue2 -X5c -Y12c gmt coast -Glightbrown -A+ag -Bafg - gmt legend -DjLM+w4c+jRM+o1c/0 -F+p+i <<- EOF + gmt legend -DjLM+w3.5c+jRM+o1c/0 -F+p+i <<- EOF H 18p,Times-Roman Legend D 0.25c 1p S 0.4c s 0.5c blue 0.25p 0.75c Ocean diff --git a/doc/examples/ex50/ex50.sh b/doc/examples/ex50/ex50.sh index 3d5384105fb..838891911a1 100755 --- a/doc/examples/ex50/ex50.sh +++ b/doc/examples/ex50/ex50.sh @@ -7,7 +7,6 @@ gmt begin ex50 # Left column have all the PDFs - gmt set FONT_ANNOT_PRIMARY 10p,Helvetica,black # Binomial distribution gmt math -T0/8/1 0.25 8 T BPDF = p.txt gmt plot -R-0.6/8.6/0/0.35 -JX7.5c/1.25c -Glightgreen p.txt -Sb0.8u -W0.5p -BWS -Bxa1 -Byaf diff --git a/doc/scripts/GMT_legend.sh b/doc/scripts/GMT_legend.sh index d58f3555761..ce8a5df4d4e 100755 --- a/doc/scripts/GMT_legend.sh +++ b/doc/scripts/GMT_legend.sh @@ -3,8 +3,6 @@ # Testing gmt legend capabilities for tables with colors gmt begin GMT_legend -gmt set FONT_ANNOT_PRIMARY 12p FONT_LABEL 12p - cat < table.txt #G 0.04i H 24 Times-Roman Eight Largest Cities in North America @@ -103,6 +101,6 @@ cat << EOF > t.cpt 7 magenta 8 white EOF -gmt legend -Dx0/0+w5.6i+jBL+l1.2 -C0.05i -F+p+gsnow1 -B0 table.txt --FONT_ANNOT_PRIMARY=12p --FONT_LABEL=12p +gmt legend -Dx0/0+w5.6i+jBL+l1.2 -C0.05i -F+p+gsnow1 -B0 table.txt --FONT_ANNOT_PRIMARY=12p,Helvetica rm -f table.txt t.cpt gmt end show diff --git a/doc/scripts/GMT_tut_4.sh b/doc/scripts/GMT_tut_4.sh index 532ccafaa68..7ee598d632c 100755 --- a/doc/scripts/GMT_tut_4.sh +++ b/doc/scripts/GMT_tut_4.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash gmt begin GMT_tut_4 - gmt coast -R-130/-70/24/52 -JB-100/35/33/45/6i -B -B+t"Conic Projection" -N1/thickest -N2/thinnest -A500 -Ggray -Wthinnest + gmt coast -R-130/-70/24/52 -JB-100/35/33/45/6i -B -B+t"Conic Projection" -N1/thicker -N2/thinnest -A500 -Ggray -Wthinnest gmt end show diff --git a/doc/scripts/GMT_utm_zones.sh b/doc/scripts/GMT_utm_zones.sh index 16c15d26041..1106b1753ad 100755 --- a/doc/scripts/GMT_utm_zones.sh +++ b/doc/scripts/GMT_utm_zones.sh @@ -3,9 +3,7 @@ # Makes a plot of the global UTM zone grid including the exceptions near Norway/Spitsbergen # gmt begin GMT_utm_zones -gmt set MAP_FRAME_TYPE plain FORMAT_GEO_MAP dddF MAP_TITLE_OFFSET 0.25i MAP_ANNOT_OFFSET_PRIMARY 0.15i FONT_TITLE 24p FONT_ANNOT_PRIMARY 10p PS_MEDIA 11ix8.5i - -gmt coast -Rd -JQ9i -Groyalblue -Sazure -Dl -A2000 -Bx60f6 -By0 -BwsNe +gmt coast -Rd -JQ9i -Groyalblue -Sazure -Dl -A2000 -Bx60f6 -By0 -BwsNe --MAP_ANNOT_OFFSET_PRIMARY=0.15i cat << EOF > tt.z.d > Do S pole zone -180 -80 diff --git a/src/gmt_init.c b/src/gmt_init.c index 9b15edff305..d5d30cfb350 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -9397,12 +9397,16 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) } GMT_LOCAL bool gmtinit_auto_allowed (struct GMT_CTRL *GMT, char *item) { + bool ret_val; int kase = gmt_hash_lookup (GMT, item, keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); - if (kase == -1) return false; /* WTF? */ - return !GMT->current.setting.par_set[kase]; + if (kase == -1) ret_val = false; /* WTF? */ + else + ret_val = !GMT->current.setting.par_set[kase]; + if (ret_val) GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Scaling %s\n", item); + return (ret_val); } -void gmtlib_auto_font_tick_sizes (struct GMT_CTRL *GMT) { +void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { /* If MAP_AUTO_SCALE is on then we must adjust all frame items according to plot size */ bool geo_frame = false; double fontsize, map_dim_cm, scale; @@ -9447,7 +9451,7 @@ void gmtlib_auto_font_tick_sizes (struct GMT_CTRL *GMT) { if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_PRIMARY")) GMT->current.setting.map_annot_offset[GMT_PRIMARY] = 3 * pt * scale; /* 3p */ if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_SECONDARY")) - GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ + GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ if (gmtinit_auto_allowed (GMT, "MAP_LABEL_OFFSET")) GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ if (gmtinit_auto_allowed (GMT, "MAP_TITLE_OFFSET")) diff --git a/src/gmt_internals.h b/src/gmt_internals.h index d9bab85658c..d78081c3280 100644 --- a/src/gmt_internals.h +++ b/src/gmt_internals.h @@ -52,7 +52,6 @@ struct GMT_XINGS { EXTERN_MSC char *dlerror (void); #endif -EXTERN_MSC void gmtlib_auto_font_tick_sizes (struct GMT_CTRL *GMT); EXTERN_MSC int gmtlib_file_is_jpeg2000_tile (struct GMTAPI_CTRL *API, char *file); EXTERN_MSC int gmtlib_download_remote_file (struct GMT_CTRL *GMT, const char* file_name, char *path, int k_data, unsigned int mode); EXTERN_MSC int gmtlib_get_serverfile_index (struct GMTAPI_CTRL *API, const char *file); diff --git a/src/gmt_plot.c b/src/gmt_plot.c index 84a573d44e6..ddf3ee79261 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -5442,8 +5442,6 @@ void gmt_map_basemap (struct GMT_CTRL *GMT) { double w, e, s, n; struct PSL_CTRL *PSL= GMT->PSL; - gmtlib_auto_font_tick_sizes (GMT); - if (!GMT->common.B.active[GMT_PRIMARY] && !GMT->common.B.active[GMT_SECONDARY]) return; /* No frame annotation/ticks/gridlines specified */ if (GMT->common.B.active[GMT_PRIMARY] && GMT->common.B.active[GMT_SECONDARY]) { @@ -7570,6 +7568,8 @@ struct PSL_CTRL *gmt_plotinit (struct GMT_CTRL *GMT, struct GMT_OPTION *options) PSL = GMT->PSL; /* Shorthand */ + gmt_auto_font_tick_sizes (GMT); /* if MAP_AUTO_SCALE is in effect we must change some defaults */ + PSL->internal.verbose = GMT->current.setting.verbose; /* Inherit verbosity level from GMT */ if (gmt_M_compat_check (GMT, 4) && GMT->current.setting.ps_copies > 1) PSL->init.copies = GMT->current.setting.ps_copies; PSL_setdefaults (PSL, GMT->current.setting.ps_magnify, GMT->current.setting.ps_page_rgb, GMT->current.setting.ps_encoding.name); diff --git a/src/gmt_prototypes.h b/src/gmt_prototypes.h index 998f1cfe272..92b80fb2705 100644 --- a/src/gmt_prototypes.h +++ b/src/gmt_prototypes.h @@ -45,6 +45,7 @@ EXTERN_MSC int gmt_examine_nc_cube (struct GMT_CTRL *GMT, char *file, uint64_t * /* gmt_init.c: */ +EXTERN_MSC void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT); EXTERN_MSC unsigned int gmt_parse_d_option (struct GMT_CTRL *GMT, char *arg); EXTERN_MSC int gmt_parse_g_option (struct GMT_CTRL *GMT, char *txt); EXTERN_MSC int gmt_parse_i_option (struct GMT_CTRL *GMT, char *arg); diff --git a/src/pslegend.c b/src/pslegend.c index a192089e6d7..1823e78389a 100644 --- a/src/pslegend.c +++ b/src/pslegend.c @@ -496,6 +496,8 @@ EXTERN_MSC int GMT_pslegend (void *V_API, int mode, void *args) { gmt_M_memset (S, N_DAT, struct GMT_DATASEGMENT *); gmt_M_memset (krow, N_DAT, uint64_t); + gmt_auto_font_tick_sizes (GMT); /* Need to do any auto-scaling here since font-sizes are used below to compute heights */ + GMT_Report (API, GMT_MSG_INFORMATION, "Processing input text table data\n"); if (gmt_M_compat_check (GMT, 4)) { /* Since pslegend v4 used '>' to indicate a paragraph record we avoid confusion with multiple segment-headers by * From aedb084277113e9f9471f072cde1320dbb7f614b Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 13 Jun 2020 15:04:54 -1000 Subject: [PATCH 029/109] Eliminate unneeded gmt set calls --- doc/examples/ex01/ex01.sh | 3 +-- doc/examples/ex16/ex16.sh | 1 - doc/examples/ex34/ex34.sh | 2 +- doc/examples/ex37/ex37.sh | 2 +- doc/examples/ex41/ex41.sh | 6 +++--- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/doc/examples/ex01/ex01.sh b/doc/examples/ex01/ex01.sh index 6542dc6cd96..6c549d8133e 100755 --- a/doc/examples/ex01/ex01.sh +++ b/doc/examples/ex01/ex01.sh @@ -2,10 +2,9 @@ # GMT EXAMPLE 01 # # Purpose: Make two contour maps based on the data in the file osu91a1f_16.nc -# GMT modules: set, subplot, grdcontour, coast +# GMT modules: subplot, grdcontour, coast # gmt begin ex01 - gmt set MAP_GRID_CROSS_SIZE_PRIMARY 0 FONT_ANNOT_PRIMARY 10p gmt subplot begin 2x1 -A -M0.5c -Blrtb -Bafg -T"Low Order Geoid" -Fs16c/0 -Rg -JH16c gmt coast -JH? -Glightbrown -Slightblue -c0,0 gmt grdcontour @osu91a1f_16.nc -C10 -A50+f7p -Gd10c -Ln -Wcthinnest,- -Wathin,- -T+d8p/2p+l diff --git a/doc/examples/ex16/ex16.sh b/doc/examples/ex16/ex16.sh index 4ebf268686e..04b45848937 100755 --- a/doc/examples/ex16/ex16.sh +++ b/doc/examples/ex16/ex16.sh @@ -6,7 +6,6 @@ # Unix progs: rm # gmt begin ex16 - gmt set FONT_ANNOT_PRIMARY 9p FONT_TITLE 18p,Times-Roman gmt subplot begin 2x2 -M0.1c -Fs8c/0 -R0/6.5/-0.2/6.5 -Jx1c -SCb -SRl+t -Bwesn -T"Gridding of Data" gmt contour @Table_5_11.txt -C@ex_16.cpt -I -B+t"contour (triangulate)" -c0,0 # diff --git a/doc/examples/ex34/ex34.sh b/doc/examples/ex34/ex34.sh index f4b208f6b6a..1af4c6d0707 100755 --- a/doc/examples/ex34/ex34.sh +++ b/doc/examples/ex34/ex34.sh @@ -5,7 +5,7 @@ # GMT modules: set, coast, makecpt, grdimage, subplot # gmt begin ex34 - gmt set FORMAT_GEO_MAP dddF FONT_HEADING 24p + gmt set FONT_HEADING 24p gmt makecpt -Cglobe -T-5000/5000 gmt subplot begin 2x1 -Fs11c/0 -M0.1c -JM11c -R-6/20/35/52 -SRl -SCb -Bwesn -T"Franco-Italian Union, 2042-45" gmt coast -EFR,IT+gP300/8 -Glightgray -c1,0 diff --git a/doc/examples/ex37/ex37.sh b/doc/examples/ex37/ex37.sh index e36f9f4d35a..2816b57cbbd 100755 --- a/doc/examples/ex37/ex37.sh +++ b/doc/examples/ex37/ex37.sh @@ -11,7 +11,7 @@ gmt begin ex37 # Prefix of two .nc files G=grav.V18.par.surf.1km.sq T=mb.par.surf.1km.sq - gmt set FONT_TITLE 14p GMT_FFT kiss + gmt set GMT_FFT kiss gmt grdinfo @$T.nc -Ib > bbox scl=1.4e-5 diff --git a/doc/examples/ex41/ex41.sh b/doc/examples/ex41/ex41.sh index f526a2739d0..29f8b08a26c 100755 --- a/doc/examples/ex41/ex41.sh +++ b/doc/examples/ex41/ex41.sh @@ -5,11 +5,11 @@ # GMT modules: set, coast, legend, plot, makecpt # gmt begin ex41 - #gmt set FONT_ANNOT_PRIMARY 12p FONT_LABEL 12p + gmt set MAP_AUTO_SCALE off FONT_ANNOT_PRIMARY 12p,Helvetica FONT_LABEL 12p,Helvetica gmt makecpt -Cred,orange,yellow,green,bisque,cyan,magenta,white,gray -T1/10/1 -N - gmt coast -R130W/50W/8N/56N -JM14c -B0 -Glightgray -Sazure1 -A1000 -Wfaint --MAP_FRAME_TYPE=plain + gmt coast -R130W/50W/8N/56N -JM14c -B0 -Glightgray -Sazure1 -A1000 -Wfaint gmt coast -EUS+glightyellow+pfaint -ECU+glightred+pfaint -EMX+glightgreen+pfaint -ECA+glightblue+pfaint gmt coast -N1/1p,darkred -A1000/2/2 -Wfaint -Cazure1 gmt plot -Sk@symbol_41/0.25c -C -W0.25p -: @data_41.txt - gmt legend -DJTL+w14c+jBL+l1.2+o0/0.3c -C4p -F+p+gsnow1 @table_41.txt --FONT_ANNOT_PRIMARY=12p,Helvetica -V + gmt legend -DJTL+w14c+jBL+l1.2+o0/0.3c -C4p -F+p+gsnow1 @table_41.txt gmt end show From 6bc2bca498b6a95cca2748b28caa60e6173746ba Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 07:55:47 -1000 Subject: [PATCH 030/109] Update gmt_init.c --- src/gmt_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 3bf58a7604a..8aff9c9c705 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -117,7 +117,8 @@ /* Leave a record that this keyword is no longer a default one So far, only gmtset calls this function with core = true, but this is a too fragile solution */ -#define GMT_KEYWORD_UPDATE(val) if (core) GMT_keywords_updated[val] = true; else GMT->current.setting.par_set[val] = updated +//#define GMT_KEYWORD_UPDATE(val) if (core) GMT_keywords_updated[val] = true; else GMT->current.setting.par_set[val] = updated +#define GMT_KEYWORD_UPDATE(val) GMT->current.setting.par_set[val] = updated; if (core) GMT_keywords_updated[val] = true /*--------------------------------------------------------------------*/ /* Load private fixed array parameters from include files */ From 38cc749024a7dc97958dceaf13296cb268d065c4 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 13:22:42 -1000 Subject: [PATCH 031/109] Update gmt_init.c --- src/gmt_init.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gmt_init.c b/src/gmt_init.c index 8aff9c9c705..a887e9cbd5f 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6080,6 +6080,11 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { int i, error = 0; double const pt = 1.0/72.0; /* points to inch */ + /* These settings override the classic defaults settings and make the modern settings. + * In addition to some changes in fonts, the key thing is lack of dimension as those + * will be set based on map size. The user can override any of those with a specific + * dimension (font size, length, etc.) with gmt set or --PAR=value */ + /* FONT group */ /* FONT_ANNOT_PRIMARY */ From 89cd1ff22d552daed9089d3c82d1a699e13293e2 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 14:50:16 -1000 Subject: [PATCH 032/109] Use auto <--> NaN in gmt.conf parsing --- src/gmt_init.c | 156 ++++++++++++++++++++++++++++------------------ src/gmt_support.c | 31 ++++++--- 2 files changed, 117 insertions(+), 70 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index a887e9cbd5f..b684a6128b2 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6078,35 +6078,36 @@ GMT_LOCAL void gmtinit_conf_classic (struct GMT_CTRL *GMT) { /*! . */ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { int i, error = 0; - double const pt = 1.0/72.0; /* points to inch */ /* These settings override the classic defaults settings and make the modern settings. - * In addition to some changes in fonts, the key thing is lack of dimension as those + * In addition to some changes in font names, the key thing is lack of dimension as those * will be set based on map size. The user can override any of those with a specific - * dimension (font size, length, etc.) with gmt set or --PAR=value */ - + * dimension (font size, length, etc.) with gmt set or --PAR=value. Below, all modern + * font sizes are set to 0 and all dimensions are set to NaN. If these remain 0 and + * NaN after reading gmt.conf then they are auto-scaled in gmt_auto_font_tick_sizes. */ + /* FONT group */ /* FONT_ANNOT_PRIMARY */ - error += gmt_getfont (GMT, "10p,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_PRIMARY]); + error += gmt_getfont (GMT, "0p,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_PRIMARY]); GMT->current.setting.given_unit[GMTCASE_FONT_ANNOT_PRIMARY] = 'p'; /* FONT_ANNOT_SECONDARY */ - error += gmt_getfont (GMT, "12p,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_SECONDARY]); + error += gmt_getfont (GMT, "0p,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_SECONDARY]); GMT->current.setting.given_unit[GMTCASE_FONT_ANNOT_SECONDARY] = 'p'; /* FONT_HEADING */ - error += gmt_getfont (GMT, "28p,AvantGarde-Demi,black", &GMT->current.setting.font_heading); + error += gmt_getfont (GMT, "0p,AvantGarde-Demi,black", &GMT->current.setting.font_heading); GMT->current.setting.given_unit[GMTCASE_FONT_HEADING] = 'p'; /* FONT_TITLE */ - error += gmt_getfont (GMT, "22p,AvantGarde-Demi,black", &GMT->current.setting.font_title); + error += gmt_getfont (GMT, "0p,AvantGarde-Demi,black", &GMT->current.setting.font_title); GMT->current.setting.given_unit[GMTCASE_FONT_TITLE] = 'p'; /* FONT_LABEL */ - error += gmt_getfont (GMT, "14p,AvantGarde-Book,black", &GMT->current.setting.font_label); + error += gmt_getfont (GMT, "0p,AvantGarde-Book,black", &GMT->current.setting.font_label); GMT->current.setting.given_unit[GMTCASE_FONT_LABEL] = 'p'; /* FONT_TAG */ - error += gmt_getfont (GMT, "18p,AvantGarde-Book,black", &GMT->current.setting.font_tag); + error += gmt_getfont (GMT, "0p,AvantGarde-Book,black", &GMT->current.setting.font_tag); GMT->current.setting.given_unit[GMTCASE_FONT_TAG] = 'p'; /* FONT_LOGO */ - error += gmt_getfont (GMT, "8p,Helvetica,black", &GMT->current.setting.font_logo); + error += gmt_getfont (GMT, "0p,Helvetica,black", &GMT->current.setting.font_logo); GMT->current.setting.given_unit[GMTCASE_FONT_LOGO] = 'p'; /* FORMAT_GEO_MAP */ @@ -6116,7 +6117,7 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { /* MAP group */ /* MAP_ANNOT_OFFSET_PRIMARY, MAP_ANNOT_OFFSET_SECONDARY */ - GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt; /* 3p */ + GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = GMT->session.d_NaN; /* 3p */ GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_PRIMARY] = 'p'; GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_SECONDARY] = 'p'; /* MAP_AUTO_SCALE */ @@ -6131,27 +6132,39 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { /* MAP_FRAME_TYPE (plain) */ GMT->current.setting.map_frame_type = GMT_IS_PLAIN; /* MAP_FRAME_WIDTH */ - GMT->current.setting.map_frame_width = 3 * pt; /* 3p */ + GMT->current.setting.map_frame_width = GMT->session.d_NaN; /* 3p */ GMT->current.setting.given_unit[GMTCASE_MAP_FRAME_WIDTH] = 'p'; /* MAP_HEADING_OFFSET */ - GMT->current.setting.map_heading_offset = 16 * pt; /* 16p */ + GMT->current.setting.map_heading_offset = GMT->session.d_NaN; /* 16p */ GMT->current.setting.given_unit[GMTCASE_MAP_HEADING_OFFSET] = 'p'; /* MAP_LABEL_OFFSET */ - GMT->current.setting.map_label_offset = 6 * pt; /* 6p */ + GMT->current.setting.map_label_offset = GMT->session.d_NaN; /* 6p */ GMT->current.setting.given_unit[GMTCASE_MAP_LABEL_OFFSET] = 'p'; /* MAP_TICK_LENGTH_PRIMARY */ - GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt; /* 3p */ - GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt; /* 1.5p */ + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = GMT->session.d_NaN; /* 3p */ + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = GMT->session.d_NaN; /* 1.5p */ GMT->current.setting.given_unit[GMTCASE_MAP_TICK_LENGTH_PRIMARY] = 'p'; /* MAP_TICK_LENGTH_SECONDARY */ - GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt; /* 12p */ - GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt; /* 3p */ + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = GMT->session.d_NaN; /* 12p */ + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = GMT->session.d_NaN; /* 3p */ GMT->current.setting.given_unit[GMTCASE_MAP_TICK_LENGTH_SECONDARY] = 'p'; /* MAP_TITLE_OFFSET */ - GMT->current.setting.map_title_offset = 12 * pt; /* 12p */ + GMT->current.setting.map_title_offset = GMT->session.d_NaN; /* 12p */ GMT->current.setting.given_unit[GMTCASE_MAP_TITLE_OFFSET] = 'p'; /* MAP_VECTOR_SHAPE */ - GMT->current.setting.map_vector_shape = 0.5; + GMT->current.setting.map_vector_shape = GMT->session.d_NaN; /* 0.5 */ + + + /* MAP_FRAME_PEN */ + GMT->current.setting.map_frame_pen.width = GMT->session.d_NaN; /* 1.5p (thicker) */ + /* MAP_TICK_PEN_PRIMARY */ + GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = GMT->session.d_NaN; /* 0.5p (thinner) */ + /* MAP_TICK_PEN_SECONDARY */ + GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = GMT->session.d_NaN; /* 0.5p (thinner) */ + /* MAP_GRID_PEN_PRIMARY */ + GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = GMT->session.d_NaN; /* 0.25p (default) */ + /* MAP_GRID_PEN_SECONDARY */ + GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = GMT->session.d_NaN; /* 0.5p (thinner) */ if (error) GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unrecognized value during gmtdefaults modern initialization.\n");} @@ -9425,7 +9438,7 @@ GMT_LOCAL bool gmtinit_auto_allowed (struct GMT_CTRL *GMT, char *item) { } void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { - /* If MAP_AUTO_SCALE is on then we must adjust all frame items according to plot size */ + /* If MAP_AUTO_SCALE is on then we must adjust all frame items with unspecified size according to plot size */ bool geo_frame = false; double fontsize, map_dim_cm, scale; double const pt = 1.0/72.0; /* points to inch */ @@ -9449,60 +9462,63 @@ void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { /* Only apply the automatic scaling to items NOT specifically set via a --PAR=value option */ - if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_PRIMARY")) + if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_PRIMARY") && gmt_M_is_zero (GMT->current.setting.font_annot[GMT_PRIMARY].size)) GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; - if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_SECONDARY")) + if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_SECONDARY") && gmt_M_is_zero (GMT->current.setting.font_annot[GMT_SECONDARY].size)) GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_LABEL")) + if (gmtinit_auto_allowed (GMT, "FONT_LABEL") && gmt_M_is_zero (GMT->current.setting.font_label.size)) GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_HEADING")) + if (gmtinit_auto_allowed (GMT, "FONT_HEADING") && gmt_M_is_zero (GMT->current.setting.font_heading.size)) GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_TAG")) + if (gmtinit_auto_allowed (GMT, "FONT_TAG") && gmt_M_is_zero (GMT->current.setting.font_tag.size)) GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_TITLE")) + if (gmtinit_auto_allowed (GMT, "FONT_TITLE") && gmt_M_is_zero (GMT->current.setting.font_title.size)) GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_LOGO")) + if (gmtinit_auto_allowed (GMT, "FONT_LOGO") && gmt_M_is_zero (GMT->current.setting.font_logo.size)) GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ /* Offsets */ - if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_PRIMARY")) + if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_PRIMARY") && gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_PRIMARY])) GMT->current.setting.map_annot_offset[GMT_PRIMARY] = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_SECONDARY")) + if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_SECONDARY") && gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_SECONDARY])) GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed (GMT, "MAP_LABEL_OFFSET")) + if (gmtinit_auto_allowed (GMT, "MAP_LABEL_OFFSET") && gmt_M_is_dnan (GMT->current.setting.map_label_offset)) GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ - if (gmtinit_auto_allowed (GMT, "MAP_TITLE_OFFSET")) + if (gmtinit_auto_allowed (GMT, "MAP_TITLE_OFFSET") && gmt_M_is_dnan (GMT->current.setting.map_title_offset)) GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ - if (gmtinit_auto_allowed (GMT, "MAP_HEADING_OFFSET")) + if (gmtinit_auto_allowed (GMT, "MAP_HEADING_OFFSET") && gmt_M_is_dnan (GMT->current.setting.map_heading_offset)) GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ /* Tick lengths */ - if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_PRIMARY")) { + if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_PRIMARY") && gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) { GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ } - if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_SECONDARY")) { + if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_SECONDARY") && gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ } /* Frame, tick and gridline pens */ - if (gmtinit_auto_allowed (GMT, "MAP_FRAME_WIDTH")) + if (gmtinit_auto_allowed (GMT, "MAP_FRAME_WIDTH") && gmt_M_is_dnan (GMT->current.setting.map_frame_width)) GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed (GMT, "MAP_FRAME_PEN")) + if (gmtinit_auto_allowed (GMT, "MAP_FRAME_PEN") && gmt_M_is_dnan (GMT->current.setting.map_frame_pen.width)) GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ - if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_PRIMARY")) + if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_PRIMARY") && gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_SECONDARY")) + if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_SECONDARY") && gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_PRIMARY")) + if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_PRIMARY") && gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ - if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_SECONDARY")) + if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_SECONDARY") && gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ + if (gmtinit_auto_allowed (GMT, "MAP_VECTOR_SHAPE") && gmt_M_is_dnan (GMT->current.setting.map_vector_shape)) + GMT->current.setting.map_vector_shape = 0.5; + if (geo_frame) { /* Extend ticks by the width of the fancy frame */ GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] += GMT->current.setting.map_frame_width; @@ -9957,7 +9973,7 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_MAP_FRAME_PEN: error = gmt_getpen (GMT, value, &GMT->current.setting.map_frame_pen); - if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ + if (gmt_M_is_zero (GMT->current.setting.map_frame_pen.width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_BASEMAP_TYPE: GMT_COMPAT_TRANSLATE ("MAP_FRAME_TYPE"); @@ -10035,14 +10051,14 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_MAP_GRID_PEN_PRIMARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_grid_pen[GMT_PRIMARY]); - if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ + if (gmt_M_is_zero (GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_GRID_PEN_SECONDARY: GMT_COMPAT_TRANSLATE ("MAP_GRID_PEN_SECONDARY"); break; case GMTCASE_MAP_GRID_PEN_SECONDARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_grid_pen[GMT_SECONDARY]); - if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ + if (gmt_M_is_zero (GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_MAP_HEADING_OFFSET: GMT->current.setting.map_heading_offset = gmt_M_to_inch (GMT, value); @@ -10159,11 +10175,11 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_MAP_TICK_PEN_PRIMARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_tick_pen[GMT_PRIMARY]); - if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ + if (gmt_M_is_zero (GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_MAP_TICK_PEN_SECONDARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_tick_pen[GMT_SECONDARY]); - if (!isdigit (value[0])) updated = false; /* No pen width set so auto-scaling can still happen */ + if (gmt_M_is_zero (GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_HEADER_OFFSET: GMT_COMPAT_TRANSLATE ("MAP_TITLE_OFFSET"); @@ -11143,6 +11159,13 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha return ((error) ? 1 : 0); } +GMT_LOCAL void gmtinit_place_value (struct GMT_CTRL *GMT, double dim, int kase, char *value) { + if (gmt_M_is_dnan (dim)) + snprintf (value, GMT_LEN256, "auto"); + else + snprintf (value, GMT_LEN256, "%g%c", dim * GMT_def_scale(kase), GMT_def_unit(kase)); +} + /*! . */ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { /* value must hold at least GMT_BUFSIZ chars */ @@ -11346,7 +11369,7 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { else { error = gmtinit_badvalreport (GMT, keyword); break; } /* Not recognized so give error message */ /* Intentionally fall through */ case GMTCASE_MAP_ANNOT_OFFSET_PRIMARY: - snprintf (value, GMT_LEN256, "%g%c", GMT->current.setting.map_annot_offset[GMT_PRIMARY] * GMT_def_scale(GMTCASE_MAP_ANNOT_OFFSET_PRIMARY), GMT_def_unit(GMTCASE_MAP_ANNOT_OFFSET_PRIMARY)); + gmtinit_place_value (GMT, GMT->current.setting.map_annot_offset[GMT_PRIMARY], GMTCASE_MAP_ANNOT_OFFSET_PRIMARY, value); break; case GMTCASE_ANNOT_OFFSET_SECONDARY: if (gmt_M_compat_check (GMT, 4)) /* GMT4: */ @@ -11354,7 +11377,7 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { else { error = gmtinit_badvalreport (GMT, keyword); break; } /* Not recognized so give error message */ /* Intentionally fall through */ case GMTCASE_MAP_ANNOT_OFFSET_SECONDARY: - snprintf (value, GMT_LEN256, "%g%c", GMT->current.setting.map_annot_offset[GMT_SECONDARY] * GMT_def_scale(GMTCASE_MAP_ANNOT_OFFSET_SECONDARY), GMT_def_unit(GMTCASE_MAP_ANNOT_OFFSET_SECONDARY)); + gmtinit_place_value (GMT, GMT->current.setting.map_annot_offset[GMT_SECONDARY], GMTCASE_MAP_ANNOT_OFFSET_SECONDARY, value); break; case GMTCASE_OBLIQUE_ANNOTATION: if (gmt_M_compat_check (GMT, 4)) /* GMT4: */ @@ -11471,7 +11494,7 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { else { error = gmtinit_badvalreport (GMT, keyword); break; } /* Not recognized so give error message */ /* Intentionally fall through */ case GMTCASE_MAP_FRAME_WIDTH: - snprintf (value, GMT_LEN256, "%g%c", GMT->current.setting.map_frame_width * GMT_def_scale(GMTCASE_MAP_FRAME_WIDTH), GMT_def_unit(GMTCASE_MAP_FRAME_WIDTH)); + gmtinit_place_value (GMT, GMT->current.setting.map_frame_width, GMTCASE_MAP_FRAME_WIDTH, value); break; case GMTCASE_GRID_CROSS_SIZE_PRIMARY: if (gmt_M_compat_check (GMT, 4)) /* GMT4: */ @@ -11506,7 +11529,7 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { snprintf (value, GMT_LEN256, "%s", gmt_putpen (GMT, &GMT->current.setting.map_grid_pen[GMT_SECONDARY])); break; case GMTCASE_MAP_HEADING_OFFSET: - snprintf (value, GMT_LEN256, "%g%c", GMT->current.setting.map_heading_offset * GMT_def_scale(GMTCASE_MAP_HEADING_OFFSET), GMT_def_unit(GMTCASE_MAP_HEADING_OFFSET)); + gmtinit_place_value (GMT, GMT->current.setting.map_heading_offset, GMTCASE_MAP_HEADING_OFFSET, value); break; case GMTCASE_LABEL_OFFSET: if (gmt_M_compat_check (GMT, 4)) /* GMT4: */ @@ -11514,7 +11537,7 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { else { error = gmtinit_badvalreport (GMT, keyword); break; } /* Not recognized so give error message */ /* Intentionally fall through */ case GMTCASE_MAP_LABEL_OFFSET: - snprintf (value, GMT_LEN256, "%g%c", GMT->current.setting.map_label_offset * GMT_def_scale(GMTCASE_MAP_LABEL_OFFSET), GMT_def_unit(GMTCASE_MAP_LABEL_OFFSET)); + gmtinit_place_value (GMT, GMT->current.setting.map_label_offset, GMTCASE_MAP_LABEL_OFFSET, value); break; case GMTCASE_LINE_STEP: if (gmt_M_compat_check (GMT, 4)) /* GMT4: */ @@ -11579,14 +11602,22 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { else { error = gmtinit_badvalreport (GMT, keyword); break; } /* Not recognized so give error message */ /* Intentionally fall through */ case GMTCASE_MAP_TICK_LENGTH_PRIMARY: - snprintf (value, GMT_LEN256, "%g%c/%g%c", - GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] * GMT_def_scale(GMTCASE_MAP_TICK_LENGTH_PRIMARY), GMT_def_unit(GMTCASE_MAP_TICK_LENGTH_PRIMARY), - GMT->current.setting.map_tick_length[GMT_TICK_UPPER] * GMT_def_scale(GMTCASE_MAP_TICK_LENGTH_PRIMARY), GMT_def_unit(GMTCASE_MAP_TICK_LENGTH_PRIMARY)); + if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) + snprintf (value, GMT_LEN256, "auto"); + else { + snprintf (value, GMT_LEN256, "%g%c/%g%c", + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] * GMT_def_scale(GMTCASE_MAP_TICK_LENGTH_PRIMARY), GMT_def_unit(GMTCASE_MAP_TICK_LENGTH_PRIMARY), + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] * GMT_def_scale(GMTCASE_MAP_TICK_LENGTH_PRIMARY), GMT_def_unit(GMTCASE_MAP_TICK_LENGTH_PRIMARY)); + } break; case GMTCASE_MAP_TICK_LENGTH_SECONDARY: - snprintf (value, GMT_LEN256, "%g%c/%g%c", - GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] * GMT_def_scale(GMTCASE_MAP_TICK_LENGTH_SECONDARY), GMT_def_unit(GMTCASE_MAP_TICK_LENGTH_SECONDARY), - GMT->current.setting.map_tick_length[GMT_TICK_LOWER] * GMT_def_scale(GMTCASE_MAP_TICK_LENGTH_SECONDARY), GMT_def_unit(GMTCASE_MAP_TICK_LENGTH_SECONDARY)); + if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) + snprintf (value, GMT_LEN256, "auto"); + else { + snprintf (value, GMT_LEN256, "%g%c/%g%c", + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] * GMT_def_scale(GMTCASE_MAP_TICK_LENGTH_SECONDARY), GMT_def_unit(GMTCASE_MAP_TICK_LENGTH_SECONDARY), + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] * GMT_def_scale(GMTCASE_MAP_TICK_LENGTH_SECONDARY), GMT_def_unit(GMTCASE_MAP_TICK_LENGTH_SECONDARY)); + } break; case GMTCASE_MAP_TICK_PEN: case GMTCASE_TICK_PEN: @@ -11606,7 +11637,7 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { else { error = gmtinit_badvalreport (GMT, keyword); break; } /* Not recognized so give error message */ /* Intentionally fall through */ case GMTCASE_MAP_TITLE_OFFSET: - snprintf (value, GMT_LEN256, "%g%c", GMT->current.setting.map_title_offset * GMT_def_scale(GMTCASE_MAP_TITLE_OFFSET), GMT_def_unit(GMTCASE_MAP_TITLE_OFFSET)); + gmtinit_place_value (GMT, GMT->current.setting.map_title_offset, GMTCASE_MAP_TITLE_OFFSET, value); break; case GMTCASE_VECTOR_SHAPE: if (gmt_M_compat_check (GMT, 4)) /* GMT4: */ @@ -11614,7 +11645,10 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { else { error = gmtinit_badvalreport (GMT, keyword); break; } /* Not recognized so give error message */ /* Intentionally fall through */ case GMTCASE_MAP_VECTOR_SHAPE: - snprintf (value, GMT_LEN256, "%g", GMT->current.setting.map_vector_shape); + if (gmt_M_is_dnan (GMT->current.setting.map_vector_shape)) + snprintf (value, GMT_LEN256, "auto"); + else + snprintf (value, GMT_LEN256, "%g", GMT->current.setting.map_vector_shape); break; /* COLOR GROUP */ @@ -12486,6 +12520,8 @@ double gmt_convert_units (struct GMT_CTRL *GMT, char *string, unsigned int defau bool have_unit = false; double value; + if (string && strncmp (string, "auto", 4U) == 0) return GMT->session.d_NaN; /* Auto in gmt.conf settings means undefined = NaN */ + if ((len = (int)strlen(string))) { c = string[len-1]; if ((have_unit = isalpha ((int)c))) string[len-1] = '\0'; /* Temporarily remove unit */ diff --git a/src/gmt_support.c b/src/gmt_support.c index 01d236b6b56..591302a2e5a 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -976,6 +976,8 @@ GMT_LOCAL int gmtsupport_pen2name (double width) { int i, k; + if (gmt_M_is_dnan (width)) return -2; /* Pen width undefined */ + for (i = 0, k = -1; k < 0 && i < GMT_N_PEN_NAMES; i++) if (gmt_M_eq (width, GMT_penname[i].width)) k = i; return (k); @@ -6460,7 +6462,8 @@ int gmt_getfont (struct GMT_CTRL *GMT, char *buffer, struct GMT_FONT *F) { /* Assign font size, type, and fill, if given */ if (!size[0] || size[0] == '-') { /* Skip */ } - else if ((pointsize = gmt_convert_units (GMT, size, GMT_PT, GMT_PT)) < GMT_CONV4_LIMIT) + //else if ((pointsize = gmt_convert_units (GMT, size, GMT_PT, GMT_PT)) < GMT_CONV4_LIMIT) + else if ((pointsize = gmt_convert_units (GMT, size, GMT_PT, GMT_PT)) < 0) GMT_Report (GMT->parent, GMT_MSG_WARNING, "Representation of font size not recognized. Using default.\n"); else F->size = pointsize; @@ -6491,15 +6494,19 @@ char *gmt_putfont (struct GMT_CTRL *GMT, struct GMT_FONT *F) { /* gmt_putfont creates a GMT textstring equivalent of the specified font */ static char text[GMT_BUFSIZ]; + char size[GMT_LEN32] = {""}; + + if (F->size > 0) + snprintf (size, GMT_LEN32, "%gp,", F->size); if (F->form & 2) { if (F->form & 8) - snprintf (text, GMT_BUFSIZ, "%gp,%s,%s=~%s", F->size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill), gmt_putpen (GMT, &F->pen)); + snprintf (text, GMT_BUFSIZ, "%s%s,%s=~%s", size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill), gmt_putpen (GMT, &F->pen)); else - snprintf (text, GMT_BUFSIZ, "%gp,%s,%s=%s", F->size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill), gmt_putpen (GMT, &F->pen)); + snprintf (text, GMT_BUFSIZ, "%s%s,%s=%s", size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill), gmt_putpen (GMT, &F->pen)); } else - snprintf (text, GMT_BUFSIZ, "%gp,%s,%s", F->size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill)); + snprintf (text, GMT_BUFSIZ, "%s%s,%s", size, GMT->session.font[F->id].name, gmtlib_putfill (GMT, &F->fill)); return (text); } @@ -6713,18 +6720,22 @@ char *gmt_putpen (struct GMT_CTRL *GMT, struct GMT_PEN *P) { k = gmtsupport_pen2name (P->width); if (P->style[0]) { - if (k < 0) + if (k == -2) /* Width is undefined */ + snprintf (text, GMT_BUFSIZ, "%s,%s:%.5gp", gmt_putcolor (GMT, P->rgb), P->style, P->offset); + else if (k == -1) /* Width has no name */ snprintf (text, GMT_BUFSIZ, "%.5gp,%s,%s:%.5gp", P->width, gmt_putcolor (GMT, P->rgb), P->style, P->offset); - else + else /* Named pen width */ snprintf (text, GMT_BUFSIZ, "%s,%s,%s:%.5gp", GMT_penname[k].name, gmt_putcolor (GMT, P->rgb), P->style, P->offset); for (i = 0; text[i]; i++) if (text[i] == ' ') text[i] = '_'; } - else - if (k < 0) + else { + if (k == -2) /* Width is undefined */ + snprintf (text, GMT_BUFSIZ, "%s", gmt_putcolor (GMT, P->rgb)); + else if (k == -1) /* Width has no name */ snprintf (text, GMT_BUFSIZ, "%.5gp,%s", P->width, gmt_putcolor (GMT, P->rgb)); - else + else /* Named pen width */ snprintf (text, GMT_BUFSIZ, "%s,%s", GMT_penname[k].name, gmt_putcolor (GMT, P->rgb)); - + } return (text); } From e4c24c9fa6c17f422574dc0c1844c5854934fee8 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 15:05:18 -1000 Subject: [PATCH 033/109] Update gmt_init.c --- src/gmt_init.c | 61 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index b684a6128b2..d7405181931 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -9427,16 +9427,29 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) return (n_errors); } -GMT_LOCAL bool gmtinit_auto_allowed (struct GMT_CTRL *GMT, char *item) { +GMT_LOCAL bool gmtinit_auto_allowed_if_zero (struct GMT_CTRL *GMT, char *item, double size) { bool ret_val; int kase = gmt_hash_lookup (GMT, item, keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); if (kase == -1) ret_val = false; /* WTF? */ else ret_val = !GMT->current.setting.par_set[kase]; + if (size > 0.0) ret_val = false; /* Already set */ if (ret_val) GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Scaling %s\n", item); return (ret_val); } +GMT_LOCAL bool gmtinit_auto_allowed_if_NaN (struct GMT_CTRL *GMT, char *item, double size) { + bool ret_val; + int kase = gmt_hash_lookup (GMT, item, keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); + if (kase == -1) ret_val = false; /* WTF? */ + else + ret_val = !GMT->current.setting.par_set[kase]; + if (!gmt_M_is_dnan (size)) ret_val = false; /* Already set */ + if (ret_val) GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Scaling %s\n", item); + return (ret_val); +} + + void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { /* If MAP_AUTO_SCALE is on then we must adjust all frame items with unspecified size according to plot size */ bool geo_frame = false; @@ -9451,7 +9464,7 @@ void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { if (GMT->current.map.frame.side[k] & GMT_AXIS_DRAW) GMT->current.map.frame.side[k] |= GMT_AXIS_BARB; } - if (!GMT->current.setting.map_auto_scale) return; /* Auto scaling is off; we are done here */ + //if (!GMT->current.setting.map_auto_scale) return; /* Auto scaling is off; we are done here */ /* Use this equation for fontsize to compute the primary annotation font size given map max dimension */ @@ -9462,64 +9475,64 @@ void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { /* Only apply the automatic scaling to items NOT specifically set via a --PAR=value option */ - if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_PRIMARY") && gmt_M_is_zero (GMT->current.setting.font_annot[GMT_PRIMARY].size)) + if (gmtinit_auto_allowed_if_zero (GMT, "FONT_ANNOT_PRIMARY", GMT->current.setting.font_annot[GMT_PRIMARY].size)) GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; - if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_SECONDARY") && gmt_M_is_zero (GMT->current.setting.font_annot[GMT_SECONDARY].size)) + if (gmtinit_auto_allowed_if_zero (GMT, "FONT_ANNOT_SECONDARY", GMT->current.setting.font_annot[GMT_SECONDARY].size)) GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_LABEL") && gmt_M_is_zero (GMT->current.setting.font_label.size)) + if (gmtinit_auto_allowed_if_zero (GMT, "FONT_LABEL", GMT->current.setting.font_label.size)) GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_HEADING") && gmt_M_is_zero (GMT->current.setting.font_heading.size)) + if (gmtinit_auto_allowed_if_zero (GMT, "FONT_HEADING", GMT->current.setting.font_heading.size)) GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_TAG") && gmt_M_is_zero (GMT->current.setting.font_tag.size)) + if (gmtinit_auto_allowed_if_zero (GMT, "FONT_TAG", GMT->current.setting.font_tag.size)) GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_TITLE") && gmt_M_is_zero (GMT->current.setting.font_title.size)) + if (gmtinit_auto_allowed_if_zero (GMT, "FONT_TITLE", GMT->current.setting.font_title.size)) GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_LOGO") && gmt_M_is_zero (GMT->current.setting.font_logo.size)) + if (gmtinit_auto_allowed_if_zero (GMT, "FONT_LOGO", GMT->current.setting.font_logo.size)) GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ /* Offsets */ - if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_PRIMARY") && gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_PRIMARY])) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_ANNOT_OFFSET_PRIMARY", GMT->current.setting.map_annot_offset[GMT_PRIMARY])) GMT->current.setting.map_annot_offset[GMT_PRIMARY] = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_SECONDARY") && gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_SECONDARY])) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_ANNOT_OFFSET_SECONDARY", GMT->current.setting.map_annot_offset[GMT_SECONDARY])) GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed (GMT, "MAP_LABEL_OFFSET") && gmt_M_is_dnan (GMT->current.setting.map_label_offset)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_LABEL_OFFSET", GMT->current.setting.map_label_offset)) GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ - if (gmtinit_auto_allowed (GMT, "MAP_TITLE_OFFSET") && gmt_M_is_dnan (GMT->current.setting.map_title_offset)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TITLE_OFFSET", GMT->current.setting.map_title_offset)) GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ - if (gmtinit_auto_allowed (GMT, "MAP_HEADING_OFFSET") && gmt_M_is_dnan (GMT->current.setting.map_heading_offset)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_HEADING_OFFSET", GMT->current.setting.map_heading_offset)) GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ /* Tick lengths */ - if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_PRIMARY") && gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) { + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TICK_LENGTH_PRIMARY", GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) { GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ } - if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_SECONDARY") && gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TICK_LENGTH_SECONDARY", GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ } /* Frame, tick and gridline pens */ - if (gmtinit_auto_allowed (GMT, "MAP_FRAME_WIDTH") && gmt_M_is_dnan (GMT->current.setting.map_frame_width)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_FRAME_WIDTH", GMT->current.setting.map_frame_width)) GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed (GMT, "MAP_FRAME_PEN") && gmt_M_is_dnan (GMT->current.setting.map_frame_pen.width)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_FRAME_PEN", GMT->current.setting.map_frame_pen.width)) GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ - if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_PRIMARY") && gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TICK_PEN_PRIMARY", GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_SECONDARY") && gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TICK_PEN_SECONDARY", GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_PRIMARY") && gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_GRID_PEN_PRIMARY", GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ - if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_SECONDARY") && gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_GRID_PEN_SECONDARY", GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed (GMT, "MAP_VECTOR_SHAPE") && gmt_M_is_dnan (GMT->current.setting.map_vector_shape)) + if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_VECTOR_SHAPE", GMT->current.setting.map_vector_shape)) GMT->current.setting.map_vector_shape = 0.5; - if (geo_frame) { + if (geo_frame && GMT->current.setting.run_mode == GMT_MODERN) { /* Extend ticks by the width of the fancy frame */ GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] += GMT->current.setting.map_frame_width; GMT->current.setting.map_tick_length[GMT_TICK_UPPER] += GMT->current.setting.map_frame_width; From 4891b97ac637624c5355be268c9c03cae101169b Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 15:13:27 -1000 Subject: [PATCH 034/109] Use NaN for undefined font size as well --- src/gmt_init.c | 71 ++++++++++++++++++++--------------------------- src/gmt_support.c | 7 +++-- 2 files changed, 34 insertions(+), 44 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index d7405181931..fc0b7fcc55e 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6083,31 +6083,31 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { * In addition to some changes in font names, the key thing is lack of dimension as those * will be set based on map size. The user can override any of those with a specific * dimension (font size, length, etc.) with gmt set or --PAR=value. Below, all modern - * font sizes are set to 0 and all dimensions are set to NaN. If these remain 0 and + * font sizes are set to auto [->NaN] and all dimensions are set to NaN. If these remain * NaN after reading gmt.conf then they are auto-scaled in gmt_auto_font_tick_sizes. */ /* FONT group */ /* FONT_ANNOT_PRIMARY */ - error += gmt_getfont (GMT, "0p,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_PRIMARY]); + error += gmt_getfont (GMT, "auto,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_PRIMARY]); GMT->current.setting.given_unit[GMTCASE_FONT_ANNOT_PRIMARY] = 'p'; /* FONT_ANNOT_SECONDARY */ - error += gmt_getfont (GMT, "0p,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_SECONDARY]); + error += gmt_getfont (GMT, "auto,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_SECONDARY]); GMT->current.setting.given_unit[GMTCASE_FONT_ANNOT_SECONDARY] = 'p'; /* FONT_HEADING */ - error += gmt_getfont (GMT, "0p,AvantGarde-Demi,black", &GMT->current.setting.font_heading); + error += gmt_getfont (GMT, "auto,AvantGarde-Demi,black", &GMT->current.setting.font_heading); GMT->current.setting.given_unit[GMTCASE_FONT_HEADING] = 'p'; /* FONT_TITLE */ - error += gmt_getfont (GMT, "0p,AvantGarde-Demi,black", &GMT->current.setting.font_title); + error += gmt_getfont (GMT, "auto,AvantGarde-Demi,black", &GMT->current.setting.font_title); GMT->current.setting.given_unit[GMTCASE_FONT_TITLE] = 'p'; /* FONT_LABEL */ - error += gmt_getfont (GMT, "0p,AvantGarde-Book,black", &GMT->current.setting.font_label); + error += gmt_getfont (GMT, "auto,AvantGarde-Book,black", &GMT->current.setting.font_label); GMT->current.setting.given_unit[GMTCASE_FONT_LABEL] = 'p'; /* FONT_TAG */ - error += gmt_getfont (GMT, "0p,AvantGarde-Book,black", &GMT->current.setting.font_tag); + error += gmt_getfont (GMT, "auto,AvantGarde-Book,black", &GMT->current.setting.font_tag); GMT->current.setting.given_unit[GMTCASE_FONT_TAG] = 'p'; /* FONT_LOGO */ - error += gmt_getfont (GMT, "0p,Helvetica,black", &GMT->current.setting.font_logo); + error += gmt_getfont (GMT, "auto,Helvetica,black", &GMT->current.setting.font_logo); GMT->current.setting.given_unit[GMTCASE_FONT_LOGO] = 'p'; /* FORMAT_GEO_MAP */ @@ -9427,18 +9427,7 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) return (n_errors); } -GMT_LOCAL bool gmtinit_auto_allowed_if_zero (struct GMT_CTRL *GMT, char *item, double size) { - bool ret_val; - int kase = gmt_hash_lookup (GMT, item, keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); - if (kase == -1) ret_val = false; /* WTF? */ - else - ret_val = !GMT->current.setting.par_set[kase]; - if (size > 0.0) ret_val = false; /* Already set */ - if (ret_val) GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Scaling %s\n", item); - return (ret_val); -} - -GMT_LOCAL bool gmtinit_auto_allowed_if_NaN (struct GMT_CTRL *GMT, char *item, double size) { +GMT_LOCAL bool gmtinit_auto_allowed (struct GMT_CTRL *GMT, char *item, double size) { bool ret_val; int kase = gmt_hash_lookup (GMT, item, keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); if (kase == -1) ret_val = false; /* WTF? */ @@ -9475,61 +9464,61 @@ void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { /* Only apply the automatic scaling to items NOT specifically set via a --PAR=value option */ - if (gmtinit_auto_allowed_if_zero (GMT, "FONT_ANNOT_PRIMARY", GMT->current.setting.font_annot[GMT_PRIMARY].size)) + if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_PRIMARY", GMT->current.setting.font_annot[GMT_PRIMARY].size)) GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; - if (gmtinit_auto_allowed_if_zero (GMT, "FONT_ANNOT_SECONDARY", GMT->current.setting.font_annot[GMT_SECONDARY].size)) + if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_SECONDARY", GMT->current.setting.font_annot[GMT_SECONDARY].size)) GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ - if (gmtinit_auto_allowed_if_zero (GMT, "FONT_LABEL", GMT->current.setting.font_label.size)) + if (gmtinit_auto_allowed (GMT, "FONT_LABEL", GMT->current.setting.font_label.size)) GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ - if (gmtinit_auto_allowed_if_zero (GMT, "FONT_HEADING", GMT->current.setting.font_heading.size)) + if (gmtinit_auto_allowed (GMT, "FONT_HEADING", GMT->current.setting.font_heading.size)) GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ - if (gmtinit_auto_allowed_if_zero (GMT, "FONT_TAG", GMT->current.setting.font_tag.size)) + if (gmtinit_auto_allowed (GMT, "FONT_TAG", GMT->current.setting.font_tag.size)) GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ - if (gmtinit_auto_allowed_if_zero (GMT, "FONT_TITLE", GMT->current.setting.font_title.size)) + if (gmtinit_auto_allowed (GMT, "FONT_TITLE", GMT->current.setting.font_title.size)) GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ - if (gmtinit_auto_allowed_if_zero (GMT, "FONT_LOGO", GMT->current.setting.font_logo.size)) + if (gmtinit_auto_allowed (GMT, "FONT_LOGO", GMT->current.setting.font_logo.size)) GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ /* Offsets */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_ANNOT_OFFSET_PRIMARY", GMT->current.setting.map_annot_offset[GMT_PRIMARY])) + if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_PRIMARY", GMT->current.setting.map_annot_offset[GMT_PRIMARY])) GMT->current.setting.map_annot_offset[GMT_PRIMARY] = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_ANNOT_OFFSET_SECONDARY", GMT->current.setting.map_annot_offset[GMT_SECONDARY])) + if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_SECONDARY", GMT->current.setting.map_annot_offset[GMT_SECONDARY])) GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_LABEL_OFFSET", GMT->current.setting.map_label_offset)) + if (gmtinit_auto_allowed (GMT, "MAP_LABEL_OFFSET", GMT->current.setting.map_label_offset)) GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TITLE_OFFSET", GMT->current.setting.map_title_offset)) + if (gmtinit_auto_allowed (GMT, "MAP_TITLE_OFFSET", GMT->current.setting.map_title_offset)) GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_HEADING_OFFSET", GMT->current.setting.map_heading_offset)) + if (gmtinit_auto_allowed (GMT, "MAP_HEADING_OFFSET", GMT->current.setting.map_heading_offset)) GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ /* Tick lengths */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TICK_LENGTH_PRIMARY", GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) { + if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_PRIMARY", GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) { GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ } - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TICK_LENGTH_SECONDARY", GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { + if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_SECONDARY", GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ } /* Frame, tick and gridline pens */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_FRAME_WIDTH", GMT->current.setting.map_frame_width)) + if (gmtinit_auto_allowed (GMT, "MAP_FRAME_WIDTH", GMT->current.setting.map_frame_width)) GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_FRAME_PEN", GMT->current.setting.map_frame_pen.width)) + if (gmtinit_auto_allowed (GMT, "MAP_FRAME_PEN", GMT->current.setting.map_frame_pen.width)) GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TICK_PEN_PRIMARY", GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) + if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_PRIMARY", GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_TICK_PEN_SECONDARY", GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) + if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_SECONDARY", GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_GRID_PEN_PRIMARY", GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) + if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_PRIMARY", GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_GRID_PEN_SECONDARY", GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) + if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_SECONDARY", GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed_if_NaN (GMT, "MAP_VECTOR_SHAPE", GMT->current.setting.map_vector_shape)) + if (gmtinit_auto_allowed (GMT, "MAP_VECTOR_SHAPE", GMT->current.setting.map_vector_shape)) GMT->current.setting.map_vector_shape = 0.5; if (geo_frame && GMT->current.setting.run_mode == GMT_MODERN) { diff --git a/src/gmt_support.c b/src/gmt_support.c index 591302a2e5a..c583a2232fa 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -6462,8 +6462,9 @@ int gmt_getfont (struct GMT_CTRL *GMT, char *buffer, struct GMT_FONT *F) { /* Assign font size, type, and fill, if given */ if (!size[0] || size[0] == '-') { /* Skip */ } - //else if ((pointsize = gmt_convert_units (GMT, size, GMT_PT, GMT_PT)) < GMT_CONV4_LIMIT) - else if ((pointsize = gmt_convert_units (GMT, size, GMT_PT, GMT_PT)) < 0) + else if (!strncmp (size, "auto", 4U)) + F->size = GMT->session.d_NaN; + else if ((pointsize = gmt_convert_units (GMT, size, GMT_PT, GMT_PT)) < GMT_CONV4_LIMIT) GMT_Report (GMT->parent, GMT_MSG_WARNING, "Representation of font size not recognized. Using default.\n"); else F->size = pointsize; @@ -6496,7 +6497,7 @@ char *gmt_putfont (struct GMT_CTRL *GMT, struct GMT_FONT *F) { static char text[GMT_BUFSIZ]; char size[GMT_LEN32] = {""}; - if (F->size > 0) + if (!gmt_M_is_dnan (F->size)) snprintf (size, GMT_LEN32, "%gp,", F->size); if (F->form & 2) { From 495f25189c80c3e8f1cb4a1fb8b9851c2f2aca48 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 15:43:41 -1000 Subject: [PATCH 035/109] Eliminate unneeded MAP_AUTO_SCALE --- doc/rst/source/gmt.conf.rst | 5 -- src/gmt_defaults.h | 2 - src/gmt_init.c | 111 ++++++++---------------------------- src/gmt_keywords.txt | 1 - src/gmt_plot.c | 2 +- 5 files changed, 26 insertions(+), 95 deletions(-) diff --git a/doc/rst/source/gmt.conf.rst b/doc/rst/source/gmt.conf.rst index e1306144a20..b60b3d80614 100644 --- a/doc/rst/source/gmt.conf.rst +++ b/doc/rst/source/gmt.conf.rst @@ -611,11 +611,6 @@ MAP Parameters **e**, **s**, **n**, **z** (uppercase allowed as well). [we] (if nothing specified). Note that this setting can be overridden via the **+a** modifier in **-B**. - **MAP_AUTO_SCALE** - Determines if basemap font sizes, pen thicknesses, tick-lengths, and offsets will - be computed from the plot dimensions (**on**) or if they should be set manually (**off**) - [off for classic mode, on for modern]. - **MAP_DEFAULT_PEN** Sets the default of all pens related to **-W** options. Prepend **+** to overrule the color of the parameters diff --git a/src/gmt_defaults.h b/src/gmt_defaults.h index 09f27e56a35..f3cf86ed685 100644 --- a/src/gmt_defaults.h +++ b/src/gmt_defaults.h @@ -58,7 +58,6 @@ struct GMT_ENCODING { /*! Holds all variables directly controlled by GMT Default parameters */ struct GMT_DEFAULTS { - bool par_set[GMT_N_KEYS]; /* True if a parameter is set via --PAR=value on the command line */ /* COLOR group [sorted by type to optimize storage] */ unsigned int color_model; /* 1 = read RGB, 2 = use RGB, 4 = read HSV, 8 = use HSV, 16 = read CMYK, 32 = use CMYK [1+2] * Add 128 to disallow output of color names */ @@ -151,7 +150,6 @@ struct GMT_DEFAULTS { unsigned int map_frame_type; /* Fancy (0), plain (1), or graph (2) [0] */ unsigned int map_graph_extension_unit; /* If mapframetype is graph, the unit is GMT_CM, GMT_INCH, GMT_PT [%] */ bool map_logo; /* Plot time and map projection on map [false] */ - bool map_auto_scale; /* Auto-scale pens, fonts, offsets based on map dimension [manual|auto] */ struct GMT_PEN map_default_pen; /* Default pen for most pens [0.25p] */ struct GMT_PEN map_frame_pen; /* Pen attributes for map boundary [1.25p] */ struct GMT_PEN map_grid_pen[2]; /* Pen attributes for primary and secondary gridlines [default,black/thinner,black] */ diff --git a/src/gmt_init.c b/src/gmt_init.c index fc0b7fcc55e..6be73ac65da 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -117,8 +117,7 @@ /* Leave a record that this keyword is no longer a default one So far, only gmtset calls this function with core = true, but this is a too fragile solution */ -//#define GMT_KEYWORD_UPDATE(val) if (core) GMT_keywords_updated[val] = true; else GMT->current.setting.par_set[val] = updated -#define GMT_KEYWORD_UPDATE(val) GMT->current.setting.par_set[val] = updated; if (core) GMT_keywords_updated[val] = true +#define GMT_KEYWORD_UPDATE(val) if (core) GMT_keywords_updated[val] = true /*--------------------------------------------------------------------*/ /* Load private fixed array parameters from include files */ @@ -209,7 +208,6 @@ static struct GMT5_params GMT5_keywords[]= { { 0, "MAP_ANNOT_OFFSET_PRIMARY"}, { 0, "MAP_ANNOT_OFFSET_SECONDARY"}, { 0, "MAP_ANNOT_ORTHO"}, - { 0, "MAP_AUTO_SCALE"}, { 0, "MAP_DEFAULT_PEN"}, { 0, "MAP_DEGREE_SYMBOL"}, { 0, "MAP_FRAME_AXES"}, @@ -5804,8 +5802,6 @@ GMT_LOCAL void gmtinit_conf_classic (struct GMT_CTRL *GMT) { GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_MIN_SPACING] = 'p'; /* MAP_ANNOT_ORTHO */ strcpy (GMT->current.setting.map_annot_ortho, "we"); - /* MAP_AUTO_SCALE */ - GMT->current.setting.map_auto_scale = false; /* MAP_DEGREE_SYMBOL (degree) */ GMT->current.setting.map_degree_symbol = gmt_degree; /* MAP_FRAME_AXES */ @@ -6120,8 +6116,6 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = GMT->session.d_NaN; /* 3p */ GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_PRIMARY] = 'p'; GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_SECONDARY] = 'p'; - /* MAP_AUTO_SCALE */ - GMT->current.setting.map_auto_scale = true; /* MAP_DEGREE_SYMBOL (degree) */ GMT->current.setting.map_degree_symbol = gmt_degree; /* MAP_FRAME_AXES */ @@ -9317,7 +9311,7 @@ int GMT_get_V (char arg) { return gmt_get_V (arg); } -GMT_LOCAL int gmtinit_update_theme (struct GMT_CTRL *GMT); +GMT_LOCAL int gmtinit_update_theme (struct GMT_CTRL *GMT); /* Must set this here since the next two functions call each other */ /*! . */ GMT_LOCAL int gmtinit_loaddefaults (struct GMT_CTRL *GMT, char *file) { @@ -9427,20 +9421,8 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) return (n_errors); } -GMT_LOCAL bool gmtinit_auto_allowed (struct GMT_CTRL *GMT, char *item, double size) { - bool ret_val; - int kase = gmt_hash_lookup (GMT, item, keys_hashnode, GMT_N_KEYS, GMT_N_KEYS); - if (kase == -1) ret_val = false; /* WTF? */ - else - ret_val = !GMT->current.setting.par_set[kase]; - if (!gmt_M_is_dnan (size)) ret_val = false; /* Already set */ - if (ret_val) GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Scaling %s\n", item); - return (ret_val); -} - - void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { - /* If MAP_AUTO_SCALE is on then we must adjust all frame items with unspecified size according to plot size */ + /* We must adjust all frame items with unspecified size according to plot size */ bool geo_frame = false; double fontsize, map_dim_cm, scale; double const pt = 1.0/72.0; /* points to inch */ @@ -9453,8 +9435,6 @@ void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { if (GMT->current.map.frame.side[k] & GMT_AXIS_DRAW) GMT->current.map.frame.side[k] |= GMT_AXIS_BARB; } - //if (!GMT->current.setting.map_auto_scale) return; /* Auto scaling is off; we are done here */ - /* Use this equation for fontsize to compute the primary annotation font size given map max dimension */ map_dim_cm = MAX (GMT->current.map.width, GMT->current.map.height) * GMT->session.u2u[GMT_INCH][GMT_CM]; @@ -9464,61 +9444,61 @@ void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { /* Only apply the automatic scaling to items NOT specifically set via a --PAR=value option */ - if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_PRIMARY", GMT->current.setting.font_annot[GMT_PRIMARY].size)) + if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_PRIMARY].size)) GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; - if (gmtinit_auto_allowed (GMT, "FONT_ANNOT_SECONDARY", GMT->current.setting.font_annot[GMT_SECONDARY].size)) + if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_SECONDARY].size)) GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_LABEL", GMT->current.setting.font_label.size)) + if (gmt_M_is_dnan (GMT->current.setting.font_label.size)) GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_HEADING", GMT->current.setting.font_heading.size)) + if (gmt_M_is_dnan (GMT->current.setting.font_heading.size)) GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_TAG", GMT->current.setting.font_tag.size)) + if (gmt_M_is_dnan (GMT->current.setting.font_tag.size)) GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_TITLE", GMT->current.setting.font_title.size)) + if (gmt_M_is_dnan (GMT->current.setting.font_title.size)) GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ - if (gmtinit_auto_allowed (GMT, "FONT_LOGO", GMT->current.setting.font_logo.size)) + if (gmt_M_is_dnan (GMT->current.setting.font_logo.size)) GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ /* Offsets */ - if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_PRIMARY", GMT->current.setting.map_annot_offset[GMT_PRIMARY])) + if (gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_PRIMARY])) GMT->current.setting.map_annot_offset[GMT_PRIMARY] = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed (GMT, "MAP_ANNOT_OFFSET_SECONDARY", GMT->current.setting.map_annot_offset[GMT_SECONDARY])) + if (gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_SECONDARY])) GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed (GMT, "MAP_LABEL_OFFSET", GMT->current.setting.map_label_offset)) + if (gmt_M_is_dnan (GMT->current.setting.map_label_offset)) GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ - if (gmtinit_auto_allowed (GMT, "MAP_TITLE_OFFSET", GMT->current.setting.map_title_offset)) + if (gmt_M_is_dnan (GMT->current.setting.map_title_offset)) GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ - if (gmtinit_auto_allowed (GMT, "MAP_HEADING_OFFSET", GMT->current.setting.map_heading_offset)) + if (gmt_M_is_dnan (GMT->current.setting.map_heading_offset)) GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ /* Tick lengths */ - if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_PRIMARY", GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) { + if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) { GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ } - if (gmtinit_auto_allowed (GMT, "MAP_TICK_LENGTH_SECONDARY", GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { + if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ } /* Frame, tick and gridline pens */ - if (gmtinit_auto_allowed (GMT, "MAP_FRAME_WIDTH", GMT->current.setting.map_frame_width)) + if (gmt_M_is_dnan (GMT->current.setting.map_frame_width)) GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ - if (gmtinit_auto_allowed (GMT, "MAP_FRAME_PEN", GMT->current.setting.map_frame_pen.width)) + if (gmt_M_is_dnan (GMT->current.setting.map_frame_pen.width)) GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ - if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_PRIMARY", GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) + if (gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed (GMT, "MAP_TICK_PEN_SECONDARY", GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) + if (gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_PRIMARY", GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) + if (gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ - if (gmtinit_auto_allowed (GMT, "MAP_GRID_PEN_SECONDARY", GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) + if (gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmtinit_auto_allowed (GMT, "MAP_VECTOR_SHAPE", GMT->current.setting.map_vector_shape)) + if (gmt_M_is_dnan (GMT->current.setting.map_vector_shape)) GMT->current.setting.map_vector_shape = 0.5; if (geo_frame && GMT->current.setting.run_mode == GMT_MODERN) { @@ -9530,19 +9510,6 @@ void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { } } -GMT_LOCAL bool gmtinit_no_fontsize (char *string) { - /* Font specs look like one of these: - * size,name,color[=style] - * size - * - * If no size is given then only the font family is set and we are allowed to scale size later. - * So we look for a leading fontsize spec, e.g. 0.7i, 12p, 1c - */ - - if (string[0] == '.' || isdigit (string[0])) return false; /* Apparently we specified size */ - return true; -} - GMT_LOCAL unsigned int gmtinit_parse_map_annot_oblique (struct GMT_CTRL *GMT, char *text) { /* Break down a comma-separated list of keywords for MAP_ANNOT_OBLIQUE or * just return the integer if old-fashion bit-sum @@ -9594,7 +9561,7 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha unsigned int pos; size_t len; int i, ival, case_val, manual, limit; - bool error = false, tf_answer = false, updated = true; + bool error = false, tf_answer = false; char txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[GMT_LEN256] = {""}, lower_value[GMT_BUFSIZ] = {""}; double dval; @@ -9706,7 +9673,6 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha gmtlib_setparameter (GMT, "FONT_HEADING", value, core) + gmtlib_setparameter (GMT, "FONT_LABEL", value, core); /* FONT_LOGO is purposely skipped */ - updated = false; /* No size was specified so auto-scaling is still possible */ break; case GMTCASE_FONT_ANNOT: error = gmtlib_setparameter (GMT, "FONT_ANNOT_PRIMARY", value, core) + @@ -9761,7 +9727,6 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha } else { if (gmt_getfont (GMT, value, &GMT->current.setting.font_annot[GMT_PRIMARY])) error = true; - if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ } break; case GMTCASE_ANNOT_FONT_SECONDARY: @@ -9769,31 +9734,24 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_FONT_ANNOT_SECONDARY: if (gmt_getfont (GMT, value, &GMT->current.setting.font_annot[GMT_SECONDARY])) error = true; - if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_HEADING: if (gmt_getfont (GMT, value, &GMT->current.setting.font_heading)) error = true; - if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_TITLE: if (gmt_getfont (GMT, value, &GMT->current.setting.font_title)) error = true; - if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_TAG: if (gmt_getfont (GMT, value, &GMT->current.setting.font_tag)) error = true; - if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_LABEL_FONT: GMT_COMPAT_TRANSLATE ("FONT_LABEL"); - if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_LABEL: if (gmt_getfont (GMT, value, &GMT->current.setting.font_label)) error = true; - if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; case GMTCASE_FONT_LOGO: if (gmt_getfont (GMT, value, &GMT->current.setting.font_logo)) error = true; - if (gmtinit_no_fontsize (value)) updated = false; /* No size given */ break; /* FONT GROUP ... obsolete options */ @@ -9922,14 +9880,6 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha case GMTCASE_MAP_ANNOT_ORTHO: strncpy (GMT->current.setting.map_annot_ortho, lower_value, 5U); break; - case GMTCASE_MAP_AUTO_SCALE: - if (value[0] == '\0' || !strcmp (lower_value, "off")) /* Default */ - GMT->current.setting.map_auto_scale = false; - else if (!strcmp (lower_value, "on")) - GMT->current.setting.map_auto_scale = true; - else - error = true; - break; case GMTCASE_DEGREE_SYMBOL: GMT_COMPAT_TRANSLATE ("MAP_DEGREE_SYMBOL"); break; @@ -9975,7 +9925,6 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_MAP_FRAME_PEN: error = gmt_getpen (GMT, value, &GMT->current.setting.map_frame_pen); - if (gmt_M_is_zero (GMT->current.setting.map_frame_pen.width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_BASEMAP_TYPE: GMT_COMPAT_TRANSLATE ("MAP_FRAME_TYPE"); @@ -10053,14 +10002,12 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_MAP_GRID_PEN_PRIMARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_grid_pen[GMT_PRIMARY]); - if (gmt_M_is_zero (GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_GRID_PEN_SECONDARY: GMT_COMPAT_TRANSLATE ("MAP_GRID_PEN_SECONDARY"); break; case GMTCASE_MAP_GRID_PEN_SECONDARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_grid_pen[GMT_SECONDARY]); - if (gmt_M_is_zero (GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_MAP_HEADING_OFFSET: GMT->current.setting.map_heading_offset = gmt_M_to_inch (GMT, value); @@ -10177,11 +10124,9 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha break; case GMTCASE_MAP_TICK_PEN_PRIMARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_tick_pen[GMT_PRIMARY]); - if (gmt_M_is_zero (GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_MAP_TICK_PEN_SECONDARY: error = gmt_getpen (GMT, value, &GMT->current.setting.map_tick_pen[GMT_SECONDARY]); - if (gmt_M_is_zero (GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) updated = false; /* No pen width set so auto-scaling can still happen */ break; case GMTCASE_HEADER_OFFSET: GMT_COMPAT_TRANSLATE ("MAP_TITLE_OFFSET"); @@ -11415,12 +11360,6 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { case GMTCASE_MAP_ANNOT_ORTHO: strncpy (value, GMT->current.setting.map_annot_ortho, GMT_BUFSIZ-1); break; - case GMTCASE_MAP_AUTO_SCALE: - if (GMT->current.setting.map_auto_scale) - snprintf (value, GMT_LEN256, "on"); - else - snprintf (value, GMT_LEN256, "off"); - break; case GMTCASE_DEGREE_SYMBOL: if (gmt_M_compat_check (GMT, 4)) /* GMT4: */ GMT_COMPAT_WARN; diff --git a/src/gmt_keywords.txt b/src/gmt_keywords.txt index 463bac52b94..448d0ab7252 100644 --- a/src/gmt_keywords.txt +++ b/src/gmt_keywords.txt @@ -99,7 +99,6 @@ MAP_ANNOT_ORTHO # Specifies which axes should have orthogonal annotations [WES MAP_ANNOT_OBLIQUE # Bit-flags to control behavior of annotations for oblique projections MAP_ANNOT_MIN_ANGLE # Cut-off angle to eliminate very oblique annotations MAP_ANNOT_MIN_SPACING # Cut-off distance to eliminate crowding of annotations -MAP_AUTO_SCALE # Set font sizes, offsets, tick lengths, and pen widths relative to map size MAP_DEFAULT_PEN # Default for all pens MAP_DEGREE_SYMBOL # Symbol for "degree" to use on maps MAP_FRAME_AXES # Which axes should be plotted [WESNZ] diff --git a/src/gmt_plot.c b/src/gmt_plot.c index ddf3ee79261..2f12feb072c 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -7568,7 +7568,7 @@ struct PSL_CTRL *gmt_plotinit (struct GMT_CTRL *GMT, struct GMT_OPTION *options) PSL = GMT->PSL; /* Shorthand */ - gmt_auto_font_tick_sizes (GMT); /* if MAP_AUTO_SCALE is in effect we must change some defaults */ + gmt_auto_font_tick_sizes (GMT); /* We must change any undefined defaults */ PSL->internal.verbose = GMT->current.setting.verbose; /* Inherit verbosity level from GMT */ if (gmt_M_compat_check (GMT, 4) && GMT->current.setting.ps_copies > 1) PSL->init.copies = GMT->current.setting.ps_copies; From 5beab25cd7d98ea66d64c0b345b0f86275ef1cbc Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 16:46:28 -1000 Subject: [PATCH 036/109] Update docs --- doc/rst/source/cookbook/features.rst | 55 ++++++++++++++++++++++++++++ share/themes/modern.conf | 35 +++++++++--------- src/gmt_init.c | 19 +++------- 3 files changed, 78 insertions(+), 31 deletions(-) diff --git a/doc/rst/source/cookbook/features.rst b/doc/rst/source/cookbook/features.rst index d36c7852366..137a2bc3de0 100644 --- a/doc/rst/source/cookbook/features.rst +++ b/doc/rst/source/cookbook/features.rst @@ -224,6 +224,61 @@ placed in a separate parameter file: scenarios into separate ``gmt.conf`` files will minimize headaches associated with micro-editing of illustrations. +Automatic GMT settings +~~~~~~~~~~~~~~~~~~~~~~ + +In modern mode (as well as in classic when **GMT_THEME** is set to *modern*), a series of +dimensions for items affecting plots are set to *auto*. This flag signals that suitable +dimensions will be automatically computed when the plot dimensions are known. The items +affected by this mechanism are: + +================================== =============================================== +:term:`FONT_LOGO` Logo font [8p,Helvetica] +:term:`FONT_ANNOT_PRIMARY` Primary annotation font [10p,AvantGarde-Book] +:term:`FONT_ANNOT_SECONDARY` Secondary annotation font [12p,AvantGarde-Book] +:term:`FONT_LABEL` Axis label font [14p,AvantGarde-Book] +:term:`FONT_TAG` Tag/labeling font [18p,AvantGarde-Book] +:term:`FONT_TITLE` Plot title font [22p,AvantGarde-Demi] +:term:`FONT_HEADING` Subplot heading font [28p,AvantGarde-Demi] +:term:`MAP_ANNOT_OFFSET_PRIMARY` Primary annotation offset from axis [3p] +:term:`MAP_ANNOT_OFFSET_SECONDARY` Secondary annotation offset from axis [3p] +:term:`MAP_FRAME_WIDTH` Width of fancy frame [3p] +:term:`MAP_HEADING_OFFSET` Heading offset from subplot [16p] +:term:`MAP_LABEL_OFFSET` Label offset from annotations [6p] +:term:`MAP_TICK_LENGTH_PRIMARY` Length of primary tick marks [3p/1.5p] +:term:`MAP_TICK_LENGTH_SECONDARY` Length of secondary tick marks [12p/3p] +:term:`MAP_TITLE_OFFSET` Title offset from plot [12p] +:term:`MAP_FRAME_PEN` Pen width of plain frame [thicker] +:term:`MAP_TICK_PEN_PRIMARY` Pen width of primary tick marks [thinner] +:term:`MAP_TICK_PEN_SECONDARY` Pen width of secondary tick marks [thinner] +:term:`MAP_GRID_PEN_PRIMARY` Pen width of primary gridline [default] +:term:`MAP_GRID_PEN_SECONDARY` Pen width of secondary gridline [thinner] +================================== =============================================== + +The fonts and reference dimensions listed in brackets are the values you get for a plot +that has a maximum dimension of exactly 25 cm. Larger and smaller illustrations +will see a linear magnification or attenuation of these dimensions. The primary +annotation font size will be computed as:: + + size = (2/15) * (map_size_in_cm - 10) + 8 [in points] + +and all other items will have their reference sizes scaled by *scale = size / 10*. +If you do nothing then all of the above dimensions will be automatically set +based on your plot dimensions. However, you are free to override any of them +using the methods described in the next section. **Note**: The particular scaling +relationship is experimental in 6.1 and we reserve the right to adjust it pending +further experimentation and user feedback. + +A few default settings items have different values as well but are not subject +to any scaling: + +========================== ========================================= +:term:`FORMAT_GEO_MAP` Geographic annotation format [ddd:mm:ssF] +:term:`MAP_FRAME_AXES` Axes selection and draw mode [WrStZ] +:term:`MAP_FRAME_TYPE` Style of geographic map frame [plain] +:term:`MAP_VECTOR_SHAPE` Vector head shape parameter [0.5] +========================== ========================================= + Changing GMT defaults ~~~~~~~~~~~~~~~~~~~~~ diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 8aa6f3f643a..6c2366c10f9 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -1,15 +1,15 @@ # -# Defaults file for modern theme +# Defaults file for modern theme (under classic) # # FONT Parameters # -FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,black -FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,black -FONT_HEADING = 28p,AvantGarde-Demi,black -FONT_LABEL = 14p,AvantGarde-Book,black -FONT_LOGO = 8p,Helvetica,black -FONT_TAG = 18p,AvantGarde-Book,black -FONT_TITLE = 22p,AvantGarde-Demi,black +FONT_ANNOT_PRIMARY = auto,AvantGarde-Book,black +FONT_ANNOT_SECONDARY = auto,AvantGarde-Book,black +FONT_HEADING = auto,AvantGarde-Demi,black +FONT_LABEL = auto,AvantGarde-Book,black +FONT_LOGO = auto,Helvetica,black +FONT_TAG = auto,AvantGarde-Book,black +FONT_TITLE = auto,AvantGarde-Demi,black # # FORMAT Parameters # @@ -17,15 +17,14 @@ FORMAT_GEO_MAP = ddd:mm:ssF # # MAP Parameters # -MAP_AUTO_SCALE = on MAP_FRAME_AXES = WrStZ -MAP_ANNOT_OFFSET_PRIMARY = 3p -MAP_ANNOT_OFFSET_SECONDARY = 3p +MAP_ANNOT_OFFSET_PRIMARY = auto +MAP_ANNOT_OFFSET_SECONDARY = auto MAP_FRAME_TYPE = plain -MAP_FRAME_WIDTH = 3p -MAP_HEADING_OFFSET = 16p -MAP_LABEL_OFFSET = 6p -MAP_TICK_LENGTH_PRIMARY = 3p/1.5p -MAP_TICK_LENGTH_SECONDARY = 12p/3p -MAP_TITLE_OFFSET = 12p -MAP_VECTOR_SHAPE = 0.5 +MAP_FRAME_WIDTH = auto +MAP_HEADING_OFFSET = auto +MAP_LABEL_OFFSET = auto +MAP_TICK_LENGTH_PRIMARY = auto +MAP_TICK_LENGTH_SECONDARY = auto +MAP_TITLE_OFFSET = auto +MAP_VECTOR_SHAPE = auto diff --git a/src/gmt_init.c b/src/gmt_init.c index 6be73ac65da..445a8170820 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6116,8 +6116,6 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = GMT->session.d_NaN; /* 3p */ GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_PRIMARY] = 'p'; GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_SECONDARY] = 'p'; - /* MAP_DEGREE_SYMBOL (degree) */ - GMT->current.setting.map_degree_symbol = gmt_degree; /* MAP_FRAME_AXES */ strcpy (GMT->current.setting.map_frame_axes, "WrStZ"); for (i = 0; i < 5; i++) GMT->current.map.frame.side[i] = 0; /* Unset default settings */ @@ -9306,11 +9304,6 @@ char gmt_set_V (int mode) { return val; } -EXTERN_MSC int GMT_get_V (char arg); /* For backward compatibility in MEX for 5.2 */ -int GMT_get_V (char arg) { - return gmt_get_V (arg); -} - GMT_LOCAL int gmtinit_update_theme (struct GMT_CTRL *GMT); /* Must set this here since the next two functions call each other */ /*! . */ @@ -9447,17 +9440,17 @@ void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_PRIMARY].size)) GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_SECONDARY].size)) - GMT->current.setting.font_annot[GMT_SECONDARY].size = fontsize * (12.0/10.0); /* Modern 12p vs 10p */ + GMT->current.setting.font_annot[GMT_SECONDARY].size = scale * 12.0; /* Modern 12p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_label.size)) - GMT->current.setting.font_label.size = fontsize * (14.0/10.0); /* Modern 14p vs 10p */ + GMT->current.setting.font_label.size = scale * 14.0; /* Modern 14p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_heading.size)) - GMT->current.setting.font_heading.size = fontsize * (28.0/10.0); /* Modern 28p vs 10p */ + GMT->current.setting.font_heading.size = scale * 28.0; /* Modern 28p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_tag.size)) - GMT->current.setting.font_tag.size = fontsize * (18.0/10.0); /* Modern 18p vs 10p */ + GMT->current.setting.font_tag.size = scale * 18.0; /* Modern 18p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_title.size)) - GMT->current.setting.font_title.size = fontsize * (22.0/10.0); /* Modern 22p vs 10p */ + GMT->current.setting.font_title.size = scale * 22.0; /* Modern 22p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_logo.size)) - GMT->current.setting.font_logo.size = fontsize * (8.0/10.0); /* Classic 8p vs 10p */ + GMT->current.setting.font_logo.size = scale * 8.0; /* Classic 8p vs 10p */ /* Offsets */ From 07028a85c5bec4718deae43d58342f63b4d0ae83 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 18:31:29 -1000 Subject: [PATCH 037/109] Update subplot.c --- src/subplot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/subplot.c b/src/subplot.c index 06f736f4d4e..1fade973196 100644 --- a/src/subplot.c +++ b/src/subplot.c @@ -719,6 +719,8 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { bool add_annot, no_frame = false; FILE *fp = NULL; + gmt_auto_font_tick_sizes (GMT); /* Need to do any auto-scaling here since font-sizes are used below to compute heights */ + /* Determine if the subplot itself is an overlay of an existing plot */ sprintf (file, "%s/gmt_%d.ps-", API->gwf_dir, fig); if (!access (file, F_OK)) { /* Plot file already exists, so enter overlay mode if -X -Y nare ot set */ @@ -741,7 +743,7 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { GMT_Report (API, GMT_MSG_ERROR, "Please run 'gmt clear sessions' (or equivalent if from Julia, Matlab, Python, etc...) to solve this issue.\n"); Return (GMT_RUNTIME_ERROR); } - /* COmpute dimensions such as ticks and distance from tick to top of annotation etc */ + /* Compute dimensions such as ticks and distance from tick to top of annotation etc */ tick_height = MAX(0,GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER]); /* Allow for axis ticks */ annot_height = (GMT_LETTER_HEIGHT * GMT->current.setting.font_annot[GMT_PRIMARY].size / PSL_POINTS_PER_INCH) + MAX (0.0, GMT->current.setting.map_annot_offset[GMT_PRIMARY]); /* Allow for space between axis and annotations */ label_height = (GMT_LETTER_HEIGHT * GMT->current.setting.font_label.size / PSL_POINTS_PER_INCH) + MAX (0.0, GMT->current.setting.map_label_offset); From 28f3dc5d9276446a67566c5aa59aa7f47d5e2dab Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 19:46:37 -1000 Subject: [PATCH 038/109] Update psscale.c --- src/psscale.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/psscale.c b/src/psscale.c index 575acf0475a..4b98134aa01 100644 --- a/src/psscale.c +++ b/src/psscale.c @@ -1535,6 +1535,7 @@ EXTERN_MSC int GMT_psscale (void *V_API, int mode, void *args) { GMT->current.map.frame.draw = false; /* No -B parsed explicitly yet */ if (GMT_Parse_Common (API, THIS_MODULE_OPTIONS, options)) Return (API->error); Ctrl = New_Ctrl (GMT); /* Allocate and initialize a new control structure */ + gmt_auto_font_tick_sizes (GMT); /* We must change any undefined defaults */ if ((error = parse (GMT, Ctrl, options)) != 0) Return (error); /*---------------------------- This is the psscale main code ----------------------------*/ From 94c46b3de7bb71eb61775bfe9dd9ce53cb6f208a Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 14 Jun 2020 22:30:41 -1000 Subject: [PATCH 039/109] update undefined defaults at end of GMT_Parse_Common That is when we are done parsing any --PAR=value options --- src/gmt_init.c | 4 ++-- src/gmt_internals.h | 1 + src/gmt_parse.c | 1 + src/gmt_plot.c | 2 -- src/gmt_prototypes.h | 1 - src/pslegend.c | 2 -- src/psscale.c | 1 - src/subplot.c | 3 --- 8 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 445a8170820..181cf956e0b 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6080,7 +6080,7 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { * will be set based on map size. The user can override any of those with a specific * dimension (font size, length, etc.) with gmt set or --PAR=value. Below, all modern * font sizes are set to auto [->NaN] and all dimensions are set to NaN. If these remain - * NaN after reading gmt.conf then they are auto-scaled in gmt_auto_font_tick_sizes. */ + * NaN after reading gmt.conf then they are auto-scaled in gmtlib_set_undefined_defaults. */ /* FONT group */ @@ -9414,7 +9414,7 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) return (n_errors); } -void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT) { +void gmtlib_set_undefined_defaults (struct GMT_CTRL *GMT) { /* We must adjust all frame items with unspecified size according to plot size */ bool geo_frame = false; double fontsize, map_dim_cm, scale; diff --git a/src/gmt_internals.h b/src/gmt_internals.h index d78081c3280..32c238c75b0 100644 --- a/src/gmt_internals.h +++ b/src/gmt_internals.h @@ -52,6 +52,7 @@ struct GMT_XINGS { EXTERN_MSC char *dlerror (void); #endif +EXTERN_MSC void gmtlib_set_undefined_defaults (struct GMT_CTRL *GMT); EXTERN_MSC int gmtlib_file_is_jpeg2000_tile (struct GMTAPI_CTRL *API, char *file); EXTERN_MSC int gmtlib_download_remote_file (struct GMT_CTRL *GMT, const char* file_name, char *path, int k_data, unsigned int mode); EXTERN_MSC int gmtlib_get_serverfile_index (struct GMTAPI_CTRL *API, const char *file); diff --git a/src/gmt_parse.c b/src/gmt_parse.c index 59aa6de6963..39f7b5e6b3b 100644 --- a/src/gmt_parse.c +++ b/src/gmt_parse.c @@ -1067,6 +1067,7 @@ int GMT_Parse_Common (void *V_API, const char *given_options, struct GMT_OPTION API->GMT->current.options = options; if (n_errors) return_error (API, GMT_PARSE_ERROR); /* One or more options failed to parse */ if (gmt_M_is_geographic (API->GMT, GMT_IN)) API->GMT->current.io.warn_geo_as_cartesion = false; /* Don't need this warning */ + gmtlib_set_undefined_defaults (API->GMT); /* We must change any undefined defaults */ return (GMT_OK); } diff --git a/src/gmt_plot.c b/src/gmt_plot.c index 2f12feb072c..80dc98dc9b7 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -7568,8 +7568,6 @@ struct PSL_CTRL *gmt_plotinit (struct GMT_CTRL *GMT, struct GMT_OPTION *options) PSL = GMT->PSL; /* Shorthand */ - gmt_auto_font_tick_sizes (GMT); /* We must change any undefined defaults */ - PSL->internal.verbose = GMT->current.setting.verbose; /* Inherit verbosity level from GMT */ if (gmt_M_compat_check (GMT, 4) && GMT->current.setting.ps_copies > 1) PSL->init.copies = GMT->current.setting.ps_copies; PSL_setdefaults (PSL, GMT->current.setting.ps_magnify, GMT->current.setting.ps_page_rgb, GMT->current.setting.ps_encoding.name); diff --git a/src/gmt_prototypes.h b/src/gmt_prototypes.h index 92b80fb2705..998f1cfe272 100644 --- a/src/gmt_prototypes.h +++ b/src/gmt_prototypes.h @@ -45,7 +45,6 @@ EXTERN_MSC int gmt_examine_nc_cube (struct GMT_CTRL *GMT, char *file, uint64_t * /* gmt_init.c: */ -EXTERN_MSC void gmt_auto_font_tick_sizes (struct GMT_CTRL *GMT); EXTERN_MSC unsigned int gmt_parse_d_option (struct GMT_CTRL *GMT, char *arg); EXTERN_MSC int gmt_parse_g_option (struct GMT_CTRL *GMT, char *txt); EXTERN_MSC int gmt_parse_i_option (struct GMT_CTRL *GMT, char *arg); diff --git a/src/pslegend.c b/src/pslegend.c index 1823e78389a..a192089e6d7 100644 --- a/src/pslegend.c +++ b/src/pslegend.c @@ -496,8 +496,6 @@ EXTERN_MSC int GMT_pslegend (void *V_API, int mode, void *args) { gmt_M_memset (S, N_DAT, struct GMT_DATASEGMENT *); gmt_M_memset (krow, N_DAT, uint64_t); - gmt_auto_font_tick_sizes (GMT); /* Need to do any auto-scaling here since font-sizes are used below to compute heights */ - GMT_Report (API, GMT_MSG_INFORMATION, "Processing input text table data\n"); if (gmt_M_compat_check (GMT, 4)) { /* Since pslegend v4 used '>' to indicate a paragraph record we avoid confusion with multiple segment-headers by * diff --git a/src/psscale.c b/src/psscale.c index 4b98134aa01..575acf0475a 100644 --- a/src/psscale.c +++ b/src/psscale.c @@ -1535,7 +1535,6 @@ EXTERN_MSC int GMT_psscale (void *V_API, int mode, void *args) { GMT->current.map.frame.draw = false; /* No -B parsed explicitly yet */ if (GMT_Parse_Common (API, THIS_MODULE_OPTIONS, options)) Return (API->error); Ctrl = New_Ctrl (GMT); /* Allocate and initialize a new control structure */ - gmt_auto_font_tick_sizes (GMT); /* We must change any undefined defaults */ if ((error = parse (GMT, Ctrl, options)) != 0) Return (error); /*---------------------------- This is the psscale main code ----------------------------*/ diff --git a/src/subplot.c b/src/subplot.c index 1fade973196..e613d21b7c4 100644 --- a/src/subplot.c +++ b/src/subplot.c @@ -701,7 +701,6 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { if ((GMT = gmt_init_module (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_KEYS, THIS_MODULE_NEEDS, NULL, &options, &GMT_cpy)) == NULL) bailout (API->error); /* Save current state */ if (GMT_Parse_Common (API, THIS_MODULE_OPTIONS, options)) Return (API->error); - Ctrl = New_Ctrl (GMT); /* Allocate and initialize a new control structure */ if ((error = parse (GMT, Ctrl, options)) != 0) Return (error); @@ -719,8 +718,6 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { bool add_annot, no_frame = false; FILE *fp = NULL; - gmt_auto_font_tick_sizes (GMT); /* Need to do any auto-scaling here since font-sizes are used below to compute heights */ - /* Determine if the subplot itself is an overlay of an existing plot */ sprintf (file, "%s/gmt_%d.ps-", API->gwf_dir, fig); if (!access (file, F_OK)) { /* Plot file already exists, so enter overlay mode if -X -Y nare ot set */ From 0f0364f0af222738431b16692907df5a343d286f Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Tue, 16 Jun 2020 15:06:24 -1000 Subject: [PATCH 040/109] Fix subplot with WrStZ defaults under modern HEre, if we have W and a panel should not be annotated and w is not selected, then it should be l if either W or l is in the defaults. Some with b of S or b is in the default. --- doc/examples/ex42/ex42.sh | 8 ++++---- src/subplot.c | 4 ++-- test/movie/movie_indicator_f_hor.sh | 4 ++-- test/movie/movie_indicator_f_ver.sh | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/examples/ex42/ex42.sh b/doc/examples/ex42/ex42.sh index 0118ed3e56a..f15fd985e99 100755 --- a/doc/examples/ex42/ex42.sh +++ b/doc/examples/ex42/ex42.sh @@ -19,11 +19,11 @@ gmt begin ex42 gmt coast -Glightblue -Sroyalblue2 -X5c -Y12c gmt coast -Glightbrown -A+ag -Bafg gmt legend -DjLM+w3.5c+jRM+o1c/0 -F+p+i <<- EOF - H 18p,Times-Roman Legend + H 12 Legend D 0.25c 1p - S 0.4c s 0.5c blue 0.25p 0.75c Ocean - S 0.4c s 0.5c lightblue 0.25p 0.75c Ice front - S 0.4c s 0.5c lightbrown 0.25p 0.75c Grounding line + S 0.4c s 0.3c blue 0.25p 0.75c Ocean + S 0.4c s 0.3c lightblue 0.25p 0.75c Ice front + S 0.4c s 0.3c lightbrown 0.25p 0.75c Grounding line EOF # Fancy line gmt plot -R0/19/0/25 -Jx1c -B0 -W2p -X-6c -Y-13.5c <<- EOF diff --git a/src/subplot.c b/src/subplot.c index e613d21b7c4..fda58673fcc 100644 --- a/src/subplot.c +++ b/src/subplot.c @@ -966,7 +966,7 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { axes[k++] = 's'; /* Just needs ticks on south frame */ if (row < last_row) y -= tick_height; } - else if (strchr (Ctrl->S[GMT_X].axes, 'b')) + else if (strchr (Ctrl->S[GMT_X].axes, 'b') || strchr (Ctrl->S[GMT_X].axes, 'S')) /* If we have S and get here it means b */ axes[k++] = 'b'; /* Just draw line frame at south end */ By[row] = strdup (axes); /* Those are all the y-frame settings */ if (Ctrl->F.debug) { /* All rows share this lower y-coordinate */ @@ -1005,7 +1005,7 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { if (col) x += tick_height; axes[k++] = 'w'; /* Only ticks at west frame */ } - else if (strchr (Ctrl->S[GMT_Y].axes, 'l')) + else if (strchr (Ctrl->S[GMT_Y].axes, 'l') || strchr (Ctrl->S[GMT_Y].axes, 'W')) /* If we get here with W it means l */ axes[k++] = 'l'; /* Just draw west frame simple line */ px[col] = x; /* Now at correct x for left side or this subplot */ x += Ctrl->F.w[col]; /* Position x at the right side of subplot */ diff --git a/test/movie/movie_indicator_f_hor.sh b/test/movie/movie_indicator_f_hor.sh index c4584cf0a80..f0e0f850b89 100755 --- a/test/movie/movie_indicator_f_hor.sh +++ b/test/movie/movie_indicator_f_hor.sh @@ -9,5 +9,5 @@ gmt begin gmt plot -R0/9.2/0/5 -Jx1i -T -X0.2i -Y0.2i -B0 gmt end EOF -gmt movie map.sh -CHD -T1850/2010/5 -Fnone -M10,ps -Nmovie_indicator_f_hor -Pf+ap+jTC+o0/0.2i -Pf+w8i+af+jTC+o0/0.7i -Pf+w7i+ae+s60+jTC+o0/1.2i -Pf+w6i+ac0+jTC+o0/1.7i -Pf+w5i+ac0+jTC+o0/2.2i \ - -Pf+w4i+ac0+jTC+o0/2.7i -Pf+w3i+ac0+jTC+o0/3.2i -Pf+w2.5i+ae+s60+jTC+o0/3.7i -Pf+w2i+af+jTC+o0/4.2i -Pf+w1.5i+ap+jTC+o0/4.7i +gmt movie map.sh -CHD -T1850/2010/5 -Fnone -M10,ps -Nmovie_indicator_f_hor -Pf+ap+jTC+o0/0.5i -Pf+w8i+af+jTC+o0/1i -Pf+w7i+ae+s60+jTC+o0/1.5i -Pf+w6i+ac0+jTC+o0/2i -Pf+w5i+ac0+jTC+o0/2.5i \ + -Pf+w4i+ac0+jTC+o0/3i -Pf+w3i+ac0+jTC+o0/3.5i -Pf+w2.5i+ae+s60+jTC+o0/4i -Pf+w2i+af+jTC+o0/4.3i -Pf+w1.5i+ap+jTC+o0/4.7i diff --git a/test/movie/movie_indicator_f_ver.sh b/test/movie/movie_indicator_f_ver.sh index 3ae71330d06..d257dd26938 100755 --- a/test/movie/movie_indicator_f_ver.sh +++ b/test/movie/movie_indicator_f_ver.sh @@ -9,6 +9,6 @@ gmt begin gmt plot -R0/9.2/0/5 -Jx1i -T -X0.2i -Y0.2i -B0 gmt end EOF -gmt movie map.sh -CHD -T1850/2010/5 -Fnone -M10,ps -Nmovie_indicator_f_ver -Pf+ap+jML+o0.2i/0 -Pf+w4.5i+af+jML+o0.7i/0 -Pf+w4i+ae+s60+jML+o1.2i/0 -Pf+w4i+ac0+jML+o1.7i/0 -Pf+w2.5i+ac0+jML+o2.2i/0 \ - -Pf+w2i+ac0+jML+o2.7i/0 -Pf+w1.5i+ac0+jML+o3.2i/0 -Pf+ap+jMR+o0.2i/0 -Pf+w4.5i+af+jMR+o0.7i/0 -Pf+w4i+ae+s60+jMR+o1.2i/0 -Pf+w4i+ac0+jMR+o1.7i/0 -Pf+w2.5i+ac0+jMR+o2.2i/0 \ - -Pf+w2i+ac0+jMR+o2.7i/0 -Pf+w1.5i+ac0+jMR+o3.2i/0 +gmt movie map.sh -CHD -T1850/2010/5 -Fnone -M10,ps -Nmovie_indicator_f_ver -Pf+ap+jML+o0.5i/0 -Pf+w4.5i+af+jML+o1i/0 -Pf+w4i+ae+s60+jML+o1.5i/0 -Pf+w4i+ac0+jML+o2i/0 -Pf+w2.5i+ac0+jML+o2.5i/0 \ + -Pf+w2i+ac0+jML+o3i/0 -Pf+w1.5i+ac0+jML+o3.5i/0 -Pf+ap+jMR+o0.5i/0 -Pf+w4.5i+af+jMR+o1i/0 -Pf+w4i+ae+s60+jMR+o1.5i/0 -Pf+w4i+ac0+jMR+o2i/0 -Pf+w2.5i+ac0+jMR+o2.5i/0 \ + -Pf+w2i+ac0+jMR+o3i/0 -Pf+w1.5i+ac0+jMR+o3.5i/0 From ec2c3acd130d3de1b9d7293a58609ea02fda524e Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Tue, 16 Jun 2020 17:03:33 -1000 Subject: [PATCH 041/109] Let MAP_ANNOT_MIN_SPACING join the auto-scaled items Nominally 36p, it now is auto and will scale with the primary fontsize. --- doc/rst/source/cookbook/features.rst | 1 + doc/rst/source/gmt.conf.rst | 2 +- share/themes/modern.conf | 1 + src/gmt_init.c | 9 +++++++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/rst/source/cookbook/features.rst b/doc/rst/source/cookbook/features.rst index 137a2bc3de0..b5453e684cc 100644 --- a/doc/rst/source/cookbook/features.rst +++ b/doc/rst/source/cookbook/features.rst @@ -240,6 +240,7 @@ affected by this mechanism are: :term:`FONT_TAG` Tag/labeling font [18p,AvantGarde-Book] :term:`FONT_TITLE` Plot title font [22p,AvantGarde-Demi] :term:`FONT_HEADING` Subplot heading font [28p,AvantGarde-Demi] +:term:`MAP_ANNOT_MIN_SPACING` PMinimum spacing between annotations [36p] :term:`MAP_ANNOT_OFFSET_PRIMARY` Primary annotation offset from axis [3p] :term:`MAP_ANNOT_OFFSET_SECONDARY` Secondary annotation offset from axis [3p] :term:`MAP_FRAME_WIDTH` Width of fancy frame [3p] diff --git a/doc/rst/source/gmt.conf.rst b/doc/rst/source/gmt.conf.rst index b60b3d80614..33bb7b0da18 100644 --- a/doc/rst/source/gmt.conf.rst +++ b/doc/rst/source/gmt.conf.rst @@ -577,7 +577,7 @@ MAP Parameters **MAP_ANNOT_MIN_SPACING** If an annotation would be plotted less than this minimum distance from its closest neighbor, the annotation is not plotted (this may - occur for certain oblique projections.) [0p] + occur for certain oblique or polar projections.) [32p] **MAP_ANNOT_OBLIQUE** This argument is a comma-separated list of up to seven keywords: diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 6c2366c10f9..30cf2b858c0 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -18,6 +18,7 @@ FORMAT_GEO_MAP = ddd:mm:ssF # MAP Parameters # MAP_FRAME_AXES = WrStZ +MAP_ANNOT_MIN_SPACING = auto MAP_ANNOT_OFFSET_PRIMARY = auto MAP_ANNOT_OFFSET_SECONDARY = auto MAP_FRAME_TYPE = plain diff --git a/src/gmt_init.c b/src/gmt_init.c index a072bc4b769..a718683deb5 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -5798,7 +5798,7 @@ GMT_LOCAL void gmtinit_conf_classic (struct GMT_CTRL *GMT) { /* MAP_ANNOT_MIN_ANGLE */ GMT->current.setting.map_annot_min_angle = 20; /* MAP_ANNOT_MIN_SPACING */ - GMT->current.setting.map_annot_min_spacing = 0; /* 0p */ + GMT->current.setting.map_annot_min_spacing = 0; /* p */ GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_MIN_SPACING] = 'p'; /* MAP_ANNOT_ORTHO */ strcpy (GMT->current.setting.map_annot_ortho, "we"); @@ -6112,6 +6112,9 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { /* MAP group */ + /* MAP_ANNOT_MIN_SPACING */ + GMT->current.setting.map_annot_min_spacing = GMT->session.d_NaN; /* 36p */ + GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_MIN_SPACING] = 'p'; /* MAP_ANNOT_OFFSET_PRIMARY, MAP_ANNOT_OFFSET_SECONDARY */ GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = GMT->session.d_NaN; /* 3p */ GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_PRIMARY] = 'p'; @@ -9464,6 +9467,8 @@ void gmtlib_set_undefined_defaults (struct GMT_CTRL *GMT) { GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ if (gmt_M_is_dnan (GMT->current.setting.map_heading_offset)) GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ + if (gmt_M_is_dnan (GMT->current.setting.map_annot_min_spacing)) + GMT->current.setting.map_annot_min_spacing = 36 * pt * scale; /* 36p */ /* Tick lengths */ @@ -11343,7 +11348,7 @@ char *gmtlib_getparameter (struct GMT_CTRL *GMT, const char *keyword) { else { error = gmtinit_badvalreport (GMT, keyword); break; } /* Not recognized so give error message */ /* Intentionally fall through */ case GMTCASE_MAP_ANNOT_MIN_SPACING: - snprintf (value, GMT_LEN256, "%g%c", GMT->current.setting.map_annot_min_spacing * GMT_def_scale(GMTCASE_MAP_ANNOT_MIN_SPACING), GMT_def_unit(GMTCASE_MAP_ANNOT_MIN_SPACING)); + gmtinit_place_value (GMT, GMT->current.setting.map_annot_min_spacing, GMTCASE_MAP_ANNOT_MIN_SPACING, value); break; case GMTCASE_Y_AXIS_TYPE: if (gmt_M_compat_check (GMT, 4)) /* GMT4: */ From c22b2d278a8cdec3ee13f5c6c08cf052fd9d36a5 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Wed, 17 Jun 2020 17:21:10 -1000 Subject: [PATCH 042/109] Do not let gmtset expand auto to anything --- src/gmt_init.c | 27 ++++++++++++++++++++------- src/gmt_internals.h | 1 - src/gmt_map.c | 2 ++ src/gmt_parse.c | 1 - src/gmt_plot.c | 2 ++ src/gmt_prototypes.h | 1 + src/gmt_support.c | 6 +++++- src/pslegend.c | 9 +++++++-- src/psscale.c | 2 +- src/subplot.c | 31 +++++++++++++++++++++++++++---- 10 files changed, 65 insertions(+), 17 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index a718683deb5..c56264387f7 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6080,7 +6080,7 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { * will be set based on map size. The user can override any of those with a specific * dimension (font size, length, etc.) with gmt set or --PAR=value. Below, all modern * font sizes are set to auto [->NaN] and all dimensions are set to NaN. If these remain - * NaN after reading gmt.conf then they are auto-scaled in gmtlib_set_undefined_defaults. */ + * NaN after reading gmt.conf then they are auto-scaled in gmt_set_undefined_defaults. */ /* FONT group */ @@ -9417,12 +9417,15 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) return (n_errors); } -void gmtlib_set_undefined_defaults (struct GMT_CTRL *GMT) { - /* We must adjust all frame items with unspecified size according to plot size */ +void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { + /* We must adjust all frame items with unspecified size according to plot dimension */ bool geo_frame = false; - double fontsize, map_dim_cm, scale; + double fontsize, scale; double const pt = 1.0/72.0; /* points to inch */ + /* Refuse to do this in gmtset */ + if (!strcmp (GMT->init.module_name, "gmtset")) {fprintf (stderr, "Not doing it\n"); return; } + /* If a geographic map frame is fancy then we cannot have lrbt regardless of mode */ geo_frame = (gmt_M_is_geographic (GMT, GMT_IN) && (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED)); @@ -9433,9 +9436,16 @@ void gmtlib_set_undefined_defaults (struct GMT_CTRL *GMT) { /* Use this equation for fontsize to compute the primary annotation font size given map max dimension */ - map_dim_cm = MAX (GMT->current.map.width, GMT->current.map.height) * GMT->session.u2u[GMT_INCH][GMT_CM]; - fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; /* Gives result in points for plot dimension in cm */ - scale = fontsize / 10.0; /* scaling for offsets, pen widths and lengths normalized to the modern 10p size */ + if (gmt_M_is_zero (plot_dim)) { /* Get nominal reference values */ + fontsize = 10; + scale = 1.0; + } + else { /* Use map dimensions to get scale */ + double map_dim_cm = plot_dim * GMT->session.u2u[GMT_INCH][GMT_CM]; + fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; /* Gives result in points for plot dimension in cm */ + scale = fontsize / 10.0; /* scaling for offsets, pen widths and lengths normalized to the modern 10p size */ + } + GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Computed primary annotation font size: %g p Dimension scaling: %g\n", fontsize, scale); /* Only apply the automatic scaling to items NOT specifically set via a --PAR=value option */ @@ -17815,6 +17825,8 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j double GMT_LETTER_HEIGHT = 0.736; FILE *fp = NULL; /* Initialize the default settings before considering any -B history */ + gmt_set_undefined_defaults (GMT, 0.0); /* Must set undefined to their reference values for now */ + offset[GMT_OUT] = GMT->current.setting.map_label_offset + GMT->current.setting.map_frame_width; offset[GMT_IN] = GMT->current.setting.map_label_offset; @@ -17856,6 +17868,7 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Adding label space\n"); offset[GMT_OUT] += (GMT_LETTER_HEIGHT * GMT->current.setting.font_label.size / PSL_POINTS_PER_INCH) + MAX (0.0, GMT->current.setting.map_label_offset); } + gmtinit_conf_modern_override (GMT); /* Reset */ } unsigned int gmt_count_char (struct GMT_CTRL *GMT, char *txt, char it) { diff --git a/src/gmt_internals.h b/src/gmt_internals.h index 32c238c75b0..d78081c3280 100644 --- a/src/gmt_internals.h +++ b/src/gmt_internals.h @@ -52,7 +52,6 @@ struct GMT_XINGS { EXTERN_MSC char *dlerror (void); #endif -EXTERN_MSC void gmtlib_set_undefined_defaults (struct GMT_CTRL *GMT); EXTERN_MSC int gmtlib_file_is_jpeg2000_tile (struct GMTAPI_CTRL *API, char *file); EXTERN_MSC int gmtlib_download_remote_file (struct GMT_CTRL *GMT, const char* file_name, char *path, int k_data, unsigned int mode); EXTERN_MSC int gmtlib_get_serverfile_index (struct GMTAPI_CTRL *API, const char *file); diff --git a/src/gmt_map.c b/src/gmt_map.c index 07c11812493..48b5871068a 100644 --- a/src/gmt_map.c +++ b/src/gmt_map.c @@ -9336,6 +9336,8 @@ int gmt_map_setup (struct GMT_CTRL *GMT, double wesn[]) { if ((i = gmt_proj_setup (GMT, wesn)) != GMT_NOERROR) return (i); + gmt_set_undefined_defaults (GMT, MAX (GMT->current.map.width, GMT->current.map.height)); /* We must change any undefined defaults given max plot dimension */ + search = GMT->current.proj.search; /* If intervals are not set specifically, round them to some "nice" values diff --git a/src/gmt_parse.c b/src/gmt_parse.c index 6c0dc64945a..815cf048f87 100644 --- a/src/gmt_parse.c +++ b/src/gmt_parse.c @@ -1067,7 +1067,6 @@ int GMT_Parse_Common (void *V_API, const char *given_options, struct GMT_OPTION API->GMT->current.options = options; if (n_errors) return_error (API, GMT_PARSE_ERROR); /* One or more options failed to parse */ if (gmt_M_is_geographic (API->GMT, GMT_IN)) API->GMT->current.io.warn_geo_as_cartesion = false; /* Don't need this warning */ - gmtlib_set_undefined_defaults (API->GMT); /* We must change any undefined defaults */ return (GMT_OK); } diff --git a/src/gmt_plot.c b/src/gmt_plot.c index 2ee6d59a6f7..11fd2581599 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -7569,6 +7569,8 @@ struct PSL_CTRL *gmt_plotinit (struct GMT_CTRL *GMT, struct GMT_OPTION *options) PSL = GMT->PSL; /* Shorthand */ + gmt_set_undefined_defaults (GMT, MAX (GMT->current.map.width, GMT->current.map.height)); /* We must change any undefined defaults given max plot dimension */ + if (GMT->current.map.frame.paint) { /* Must squirrel this away for now since we may call psbasemap during the movie-indicators below */ do_paint = true; gmt_M_memcpy (&fill, &GMT->current.map.frame.fill, 1U, struct GMT_FILL); diff --git a/src/gmt_prototypes.h b/src/gmt_prototypes.h index 998f1cfe272..5d90f1f4236 100644 --- a/src/gmt_prototypes.h +++ b/src/gmt_prototypes.h @@ -45,6 +45,7 @@ EXTERN_MSC int gmt_examine_nc_cube (struct GMT_CTRL *GMT, char *file, uint64_t * /* gmt_init.c: */ +EXTERN_MSC void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim); EXTERN_MSC unsigned int gmt_parse_d_option (struct GMT_CTRL *GMT, char *arg); EXTERN_MSC int gmt_parse_g_option (struct GMT_CTRL *GMT, char *txt); EXTERN_MSC int gmt_parse_i_option (struct GMT_CTRL *GMT, char *arg); diff --git a/src/gmt_support.c b/src/gmt_support.c index c583a2232fa..b002f935655 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -994,6 +994,8 @@ GMT_LOCAL int gmtsupport_getpenwidth (struct GMT_CTRL *GMT, char *line, struct G /* Pen thickness with optional unit at end */ P->width = gmt_convert_units (GMT, line, GMT_PT, GMT_PT); } + else if (!strcmp (line, "auto")) + P->width = GMT->session.d_NaN; else { /* Pen name was given - these refer to fixed widths in points */ if ((n = gmtsupport_name2pen (line)) < 0) { GMT_Report (GMT->parent, GMT_MSG_ERROR, "Pen name %s not recognized!\n", line); @@ -6497,7 +6499,9 @@ char *gmt_putfont (struct GMT_CTRL *GMT, struct GMT_FONT *F) { static char text[GMT_BUFSIZ]; char size[GMT_LEN32] = {""}; - if (!gmt_M_is_dnan (F->size)) + if (gmt_M_is_dnan (F->size)) + snprintf (size, GMT_LEN32, "auto,"); + else snprintf (size, GMT_LEN32, "%gp,", F->size); if (F->form & 2) { diff --git a/src/pslegend.c b/src/pslegend.c index a192089e6d7..8a2a2ab0305 100644 --- a/src/pslegend.c +++ b/src/pslegend.c @@ -528,6 +528,13 @@ EXTERN_MSC int GMT_pslegend (void *V_API, int mode, void *args) { do_width = true; } + if (!(GMT->common.R.active[RSET] && GMT->common.J.active)) /* When no projection specified (i.e, -Dx is used), we cannot autoscale so set to nominal sizes */ + gmt_set_undefined_defaults (GMT, 0.0); /* Must set undefined to their reference values */ + else { + if (gmt_M_err_pass (GMT, gmt_map_setup (GMT, GMT->common.R.wesn), "")) + Return (GMT_PROJECTION_ERROR); + } + /* First attempt to compute the legend height */ one_line_spacing = Ctrl->D.spacing * GMT->current.setting.font_annot[GMT_PRIMARY].size / PSL_POINTS_PER_INCH; @@ -797,8 +804,6 @@ EXTERN_MSC int GMT_pslegend (void *V_API, int mode, void *args) { GMT_Report (API, GMT_MSG_INFORMATION, "Disabling your -B option since -R -J were not set\n"); } } - else if (gmt_M_err_pass (GMT, gmt_map_setup (GMT, GMT->common.R.wesn), "")) - Return (GMT_PROJECTION_ERROR); if ((PSL = gmt_plotinit (GMT, options)) == NULL) Return (GMT_RUNTIME_ERROR); diff --git a/src/psscale.c b/src/psscale.c index 575acf0475a..6dc51a5850c 100644 --- a/src/psscale.c +++ b/src/psscale.c @@ -1557,7 +1557,6 @@ EXTERN_MSC int GMT_psscale (void *V_API, int mode, void *args) { if (Ptrunc == NULL) Return (EXIT_FAILURE); P = Ptrunc; - //GMT_Write_Data (API, GMT_IS_PALETTE, GMT_IS_FILE, GMT_IS_NONE, 0, NULL, "chop.cpt", P); } if (Ctrl->W.active) /* Scale all z values */ gmt_scale_cpt (GMT, P, Ctrl->W.scale); @@ -1600,6 +1599,7 @@ EXTERN_MSC int GMT_psscale (void *V_API, int mode, void *args) { gmt_M_memset (wesn, 4, double); if (!(GMT->common.R.active[RSET] && GMT->common.J.active)) { /* When no projection specified, use fake linear projection */ + gmt_set_undefined_defaults (GMT, 0.0); /* Must set undefined to their reference values */ GMT->common.R.active[RSET] = true; GMT->common.J.active = false; gmt_parse_common_options (GMT, "J", 'J', text); diff --git a/src/subplot.c b/src/subplot.c index fda58673fcc..09a1388e362 100644 --- a/src/subplot.c +++ b/src/subplot.c @@ -711,13 +711,39 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { if (Ctrl->In.mode == SUBPLOT_BEGIN) { /* Determine and save subplot attributes once */ unsigned int row, col, k, panel, nx, ny, factor, last_row, last_col, *Lx = NULL, *Ly = NULL; uint64_t seg; - double x, y, width = 0.0, height = 0.0, tick_height, annot_height, label_height, title_height, y_header_off = 0.0; + double PD = 0.0, x, y, width = 0.0, height = 0.0, tick_height, annot_height, label_height, title_height, y_header_off = 0.0; 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; char **Bx = NULL, **By = NULL, *cmd = NULL, axes[3] = {""}, Bopt[GMT_LEN256] = {""}; char vfile[GMT_VF_LEN] = {""}, xymode = 'r'; bool add_annot, no_frame = false; FILE *fp = NULL; + /* Need an approximate panel dimension here to set the undefined quantities */ + + if (Ctrl->F.mode == SUBPLOT_FIGURE) { /* Got figure dimension, compute subplot dimensions */ + for (col = 0; col < Ctrl->N.dim[GMT_X]; col++) PD = MAX (PD, Ctrl->F.w[col] * Ctrl->F.dim[GMT_X]); + for (row = 0; row < Ctrl->N.dim[GMT_Y]; row++) PD = MAX (PD, Ctrl->F.h[row] * Ctrl->F.dim[GMT_Y]); + } + else { /* Already got subplot dimension, compute total figure dimension */ + if (Ctrl->F.reset_h) { /* Update h based on map aspect ratio and width of a constant column */ + for (row = 0; row < Ctrl->N.dim[GMT_Y]; row++) Ctrl->F.h[row] = Ctrl->F.w[0] * (GMT->current.map.height / GMT->current.map.width); + } + /* Sum up individual widths or heights and add the fluff space */ + for (col = 0; col < Ctrl->N.dim[GMT_X]; col++) PD = MAX (PD, Ctrl->F.w[col]); + for (row = 0; row < Ctrl->N.dim[GMT_Y]; row++) PD = MAX (PD, Ctrl->F.h[row]); + } + GMT_Report (API, GMT_MSG_NOTICE, "Subplot max panel dimension estimated: %g inch\n", PD); + + gmt_set_undefined_defaults (GMT, PD); /* We must change any undefined defaults given max panel dimension */ + /* Update defaults settings that depend on fonts etc */ + if (gmt_M_is_dnan (Ctrl->A.off[GMT_X])) + Ctrl->A.off[GMT_X] = Ctrl->A.off[GMT_Y] = 0.01 * GMT_TEXT_OFFSET * GMT->current.setting.font_tag.size / PSL_POINTS_PER_INCH; /* 20% */ + if (gmt_M_is_dnan (Ctrl->A.clearance[GMT_X])) + Ctrl->A.clearance[GMT_X] = Ctrl->A.clearance[GMT_Y] = 0.01 * GMT_TEXT_CLEARANCE * GMT->current.setting.font_tag.size / PSL_POINTS_PER_INCH; /* 15% */ + if (gmt_M_is_dnan (Ctrl->M.margin[XLO])) { + for (unsigned int k = 0; k < 4; k++) Ctrl->M.margin[k] = 0.5 * GMT->current.setting.font_annot[GMT_PRIMARY].size / PSL_POINTS_PER_INCH; /* Split annot font across two sides */ + } + /* Determine if the subplot itself is an overlay of an existing plot */ sprintf (file, "%s/gmt_%d.ps-", API->gwf_dir, fig); if (!access (file, F_OK)) { /* Plot file already exists, so enter overlay mode if -X -Y nare ot set */ @@ -841,9 +867,6 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { for (row = 0; row < Ctrl->N.dim[GMT_Y]; row++) Ctrl->F.h[row] *= (Ctrl->F.dim[GMT_Y] - fluff[GMT_Y]); } else { /* Already got subplot dimension, compute total figure dimension */ - if (Ctrl->F.reset_h) { /* Update h based on map aspect ratio and width of a constant column */ - for (row = 0; row < Ctrl->N.dim[GMT_Y]; row++) Ctrl->F.h[row] = Ctrl->F.w[0] * (GMT->current.map.height / GMT->current.map.width); - } /* Sum up individual widths or heights and add the fluff space */ for (col = 0, Ctrl->F.dim[GMT_X] = fluff[GMT_X]; col < Ctrl->N.dim[GMT_X]; col++) Ctrl->F.dim[GMT_X] += Ctrl->F.w[col]; for (row = 0, Ctrl->F.dim[GMT_Y] = fluff[GMT_Y]; row < Ctrl->N.dim[GMT_Y]; row++) Ctrl->F.dim[GMT_Y] += Ctrl->F.h[row]; From e7c399eb449d6f7ab4fed79f0a4beec76b7a62f9 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Fri, 19 Jun 2020 13:07:02 -1000 Subject: [PATCH 043/109] Fix vector shape init --- src/gmt_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gmt_init.c b/src/gmt_init.c index 95c4b69b09b..6edd1e745e0 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -12834,6 +12834,9 @@ GMT_LOCAL struct GMT_CTRL *gmtinit_begin_module_sub (struct GMTAPI_CTRL *API, co GMT->init.module_name = mod_name; GMT->init.module_lib = lib_name; + if (gmt_M_is_dnan (GMT->current.setting.map_vector_shape)) /* Do it here since independent on map size */ + GMT->current.setting.map_vector_shape = 0.5; + return (GMT); } From 9fdad4649e4ca42f31943e94e6859ab72f8ed1c6 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Fri, 19 Jun 2020 15:18:10 -1000 Subject: [PATCH 044/109] protect sides in psscale. The resetting interfered with auto-annotation of colorbars. --- src/gmt_init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 6edd1e745e0..9369be2d35e 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -17822,7 +17822,7 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j char side, axis, B_delim[2] = {30, 0}, p[GMT_BUFSIZ] = {""}; /* Use ASCII 30 RS Record Separator between -B strings */ char file[PATH_MAX] = {""}; - unsigned int pos = 0; + unsigned int pos = 0, sides[5]; bool add_label = false, add_annot = false, axis_set = false; double GMT_LETTER_HEIGHT = 0.736; FILE *fp = NULL; @@ -17870,7 +17870,10 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Adding label space\n"); offset[GMT_OUT] += (GMT_LETTER_HEIGHT * GMT->current.setting.font_label.size / PSL_POINTS_PER_INCH) + MAX (0.0, GMT->current.setting.map_label_offset); } + /* Because the next call will reset frame sides i will make a copy and override the override here */ + gmt_M_memcpy (sides, GMT->current.map.frame.side, 5U, unsigned int); gmtinit_conf_modern_override (GMT); /* Reset */ + gmt_M_memcpy (GMT->current.map.frame.side, sides, 5U, unsigned int); } unsigned int gmt_count_char (struct GMT_CTRL *GMT, char *txt, char it) { From 73caced9df323a9d1e690e5974d9778df9b85414 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Fri, 19 Jun 2020 16:24:23 -1000 Subject: [PATCH 045/109] Update gmt_init.c --- src/gmt_init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gmt_init.c b/src/gmt_init.c index 9369be2d35e..ed97ad772d7 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -17874,6 +17874,7 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j gmt_M_memcpy (sides, GMT->current.map.frame.side, 5U, unsigned int); gmtinit_conf_modern_override (GMT); /* Reset */ gmt_M_memcpy (GMT->current.map.frame.side, sides, 5U, unsigned int); + GMT->current.map.frame.draw = false; } unsigned int gmt_count_char (struct GMT_CTRL *GMT, char *txt, char it) { From 1d6483cf3fdc79eb71cfd7098a1a453b3548d859 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Fri, 19 Jun 2020 17:30:50 -1000 Subject: [PATCH 046/109] Fix pstext to initialize default font --- src/gmt_init.c | 5 +++-- src/pstext.c | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index ed97ad772d7..5bb9958ec2e 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -17823,7 +17823,7 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j char side, axis, B_delim[2] = {30, 0}, p[GMT_BUFSIZ] = {""}; /* Use ASCII 30 RS Record Separator between -B strings */ char file[PATH_MAX] = {""}; unsigned int pos = 0, sides[5]; - bool add_label = false, add_annot = false, axis_set = false; + bool add_label = false, add_annot = false, axis_set = false, was; double GMT_LETTER_HEIGHT = 0.736; FILE *fp = NULL; /* Initialize the default settings before considering any -B history */ @@ -17872,9 +17872,10 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j } /* Because the next call will reset frame sides i will make a copy and override the override here */ gmt_M_memcpy (sides, GMT->current.map.frame.side, 5U, unsigned int); + was = GMT->current.map.frame.draw; gmtinit_conf_modern_override (GMT); /* Reset */ gmt_M_memcpy (GMT->current.map.frame.side, sides, 5U, unsigned int); - GMT->current.map.frame.draw = false; + GMT->current.map.frame.draw = was; } unsigned int gmt_count_char (struct GMT_CTRL *GMT, char *txt, char it) { diff --git a/src/pstext.c b/src/pstext.c index 717dbd15f21..7da54e7a481 100644 --- a/src/pstext.c +++ b/src/pstext.c @@ -796,14 +796,11 @@ EXTERN_MSC int GMT_pstext (void *V_API, int mode, void *args) { /*---------------------------- This is the pstext main code ----------------------------*/ GMT_Report (API, GMT_MSG_INFORMATION, "Processing input text table data\n"); - pstext_load_parameters_pstext (GMT, &T, Ctrl); /* Pass info from Ctrl to T */ tcol = 2 + Ctrl->Z.active; n_expected_cols = 2 + Ctrl->Z.active + Ctrl->F.nread + GMT->common.t.variable; /* Normal number of columns to read, plus any text. This includes x,y */ if (Ctrl->M.active) n_expected_cols += 3; no_in_txt = (Ctrl->F.get_text > 1); /* No text in the input record */ - add = !(T.x_offset == 0.0 && T.y_offset == 0.0); - if (add && Ctrl->D.justify) T.boxflag |= 64; if (gmt_M_err_pass (GMT, gmt_map_setup (GMT, GMT->common.R.wesn), "")) Return (GMT_PROJECTION_ERROR); @@ -816,6 +813,13 @@ EXTERN_MSC int GMT_pstext (void *V_API, int mode, void *args) { if (Ctrl->G.mode) gmt_map_basemap (GMT); /* Must lay down basemap before text clipping is activated, otherwise we do it at the end */ + if (gmt_M_is_dnan (Ctrl->F.font.size)) + Ctrl->F.font.size = GMT->current.setting.font_annot[GMT_PRIMARY].size; + + pstext_load_parameters_pstext (GMT, &T, Ctrl); /* Pass info from Ctrl to T */ + add = !(T.x_offset == 0.0 && T.y_offset == 0.0); + if (add && Ctrl->D.justify) T.boxflag |= 64; + if (!(Ctrl->N.active || Ctrl->Z.active)) { gmt_BB_clip_on (GMT, GMT->session.no_rgb, 3); clip_set = true; From c75890d0cc7e2316cd87cb6428103fb807d2abcf Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 20 Jun 2020 11:27:39 -1000 Subject: [PATCH 047/109] Forgot to update the theme in gmtinit_conf_modern_override (#3508) This function is called when modern theme is selected in classic or always in modern. But it failed to actually set the GMT_THEME variable so in classic mode it reverted to classic before writing out the theme. --- src/gmt_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gmt_init.c b/src/gmt_init.c index df716c0597c..c5759fd5d57 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6110,6 +6110,9 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { strcpy (GMT->current.setting.format_geo_map, "ddd:mm:ssF"); gmtlib_plot_C_format (GMT); /* Update format statements */ + /* GMT_THEME */ + strcpy (GMT->current.setting.theme, "modern"); + /* MAP group */ /* MAP_ANNOT_MIN_SPACING */ From 0ec026da8e4a038a284a43f49767eff8822beee1 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 21 Jun 2020 15:05:17 -1000 Subject: [PATCH 048/109] Lengthen ticks and slightly increase font size --- src/gmt_init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index c5759fd5d57..e43c63d0661 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6139,8 +6139,8 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { GMT->current.setting.map_label_offset = GMT->session.d_NaN; /* 6p */ GMT->current.setting.given_unit[GMTCASE_MAP_LABEL_OFFSET] = 'p'; /* MAP_TICK_LENGTH_PRIMARY */ - GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = GMT->session.d_NaN; /* 3p */ - GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = GMT->session.d_NaN; /* 1.5p */ + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = GMT->session.d_NaN; /* 4p */ + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = GMT->session.d_NaN; /* 2p */ GMT->current.setting.given_unit[GMTCASE_MAP_TICK_LENGTH_PRIMARY] = 'p'; /* MAP_TICK_LENGTH_SECONDARY */ GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = GMT->session.d_NaN; /* 12p */ @@ -9445,7 +9445,7 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { } else { /* Use map dimensions to get scale */ double map_dim_cm = plot_dim * GMT->session.u2u[GMT_INCH][GMT_CM]; - fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 8; /* Gives result in points for plot dimension in cm */ + fontsize = (2.0/15.0) * (map_dim_cm - 10.0) + 9; /* Gives result in points for plot dimension in cm */ scale = fontsize / 10.0; /* scaling for offsets, pen widths and lengths normalized to the modern 10p size */ } @@ -9486,8 +9486,8 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { /* Tick lengths */ if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) { - GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 3 * pt * scale; /* 3p */ - GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1.5 * pt * scale; /* 1.5p */ + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 4 * pt * scale; /* 4p */ + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 2 * pt * scale; /* 2p */ } if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ From 2a2996eda43b3d77f6fc83a39ec04d2270aa2714 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 21 Jun 2020 15:53:41 -1000 Subject: [PATCH 049/109] Fix multiple addition of frame width --- src/gmt_init.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index e43c63d0661..e9663ce2014 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -9486,12 +9486,26 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { /* Tick lengths */ if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER])) { - GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 4 * pt * scale; /* 4p */ - GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 2 * pt * scale; /* 2p */ + if (geo_frame && GMT->current.setting.run_mode == GMT_MODERN) { + /* Use 50% lengths but extend ticks by the width of the fancy frame */ + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 2 * pt * scale + GMT->current.setting.map_frame_width; + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 1 * pt * scale + GMT->current.setting.map_frame_width; + } + else { + GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 4 * pt * scale; /* 4p */ + GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 2 * pt * scale; /* 2p */ + } } if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { - GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ - GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ + if (geo_frame && GMT->current.setting.run_mode == GMT_MODERN) { + /* Use 50% lengths but extend ticks by the width of the fancy frame */ + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 6 * pt * scale + GMT->current.setting.map_frame_width; + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 1.5 * pt * scale + GMT->current.setting.map_frame_width; + } + else { + GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ + GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ + } } /* Frame, tick and gridline pens */ @@ -9511,14 +9525,6 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { if (gmt_M_is_dnan (GMT->current.setting.map_vector_shape)) GMT->current.setting.map_vector_shape = 0.5; - - if (geo_frame && GMT->current.setting.run_mode == GMT_MODERN) { - /* Extend ticks by the width of the fancy frame */ - GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] += GMT->current.setting.map_frame_width; - GMT->current.setting.map_tick_length[GMT_TICK_UPPER] += GMT->current.setting.map_frame_width; - GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] += GMT->current.setting.map_frame_width; - GMT->current.setting.map_tick_length[GMT_TICK_LOWER] += GMT->current.setting.map_frame_width; - } } GMT_LOCAL unsigned int gmtinit_parse_map_annot_oblique (struct GMT_CTRL *GMT, char *text) { From de284d6b97edc957293dce792655ddb05ca1ab21 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sun, 28 Jun 2020 10:20:56 -1000 Subject: [PATCH 050/109] Update gmt_init.c --- src/gmt_init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 32651fdeb50..b1cf05cb3c3 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -3004,7 +3004,7 @@ void gmt_reload_history (struct GMT_CTRL *GMT) { } void gmt_reload_settings (struct GMT_CTRL *GMT) { - gmt_conf (GMT); /* Get the original system defaults */ + gmt_conf_SI(GMT); /* Get the original system defaults */ gmt_getdefaults (GMT, NULL); /* Overload user defaults */ } @@ -6116,6 +6116,8 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { * font sizes are set to auto [->NaN] and all dimensions are set to NaN. If these remain * NaN after reading gmt.conf then they are auto-scaled in gmt_set_undefined_defaults. */ + return; /* Not make default action for 6.1 yet */ + /* FONT group */ /* FONT_ANNOT_PRIMARY */ @@ -17743,7 +17745,7 @@ int gmt_manage_workflow (struct GMTAPI_CTRL *API, unsigned int mode, char *text) } } if (error) return (error); /* Bail at this point */ - gmt_conf (API->GMT); /* Get the original system defaults */ + gmt_conf_SI (API->GMT); /* Get the original system defaults */ if (!clean_start) gmt_getdefaults (API->GMT, NULL); /* Overload user defaults */ snprintf (dir, PATH_MAX, "%s/%s", API->gwf_dir, GMT_SETTINGS_FILE); /* Reuse dir string for saving gmt.conf to this dir */ API->GMT->current.setting.run_mode = GMT_MODERN; /* Enable modern mode here so putdefaults can skip writing PS_MEDIA if not PostScript output */ From f47bef18098a0b2625012d54c1f312621657ba59 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 26 Oct 2020 21:19:04 -1000 Subject: [PATCH 051/109] Update gmt_init.c --- src/gmt_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index ea9e7ee4f63..2cb5d0415e3 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -18103,7 +18103,7 @@ int gmt_manage_workflow (struct GMTAPI_CTRL *API, unsigned int mode, char *text) if (error) return (error); /* Bail at this point */ gmt_reset_history (API->GMT); /* No old classic history shall affect a new modern mode session */ - gmt_conf (API->GMT); /* Get the original system defaults */ + gmt_conf_SI (API->GMT); /* Get the original system defaults */ if (!clean_start) gmt_getdefaults (API->GMT, NULL); /* Overload user defaults */ snprintf (dir, PATH_MAX, "%s/%s", API->gwf_dir, GMT_SETTINGS_FILE); /* Reuse dir string for saving gmt.conf to this dir */ API->GMT->current.setting.run_mode = GMT_MODERN; /* Enable modern mode here so putdefaults can skip writing PS_MEDIA if not PostScript output */ From 518f0f0da5f13041e785a7982fd1bf2c02f05485 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Tue, 24 Nov 2020 09:44:10 -1000 Subject: [PATCH 052/109] Update inverse.conf --- share/themes/inverse.conf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/share/themes/inverse.conf b/share/themes/inverse.conf index 458448cbab1..38b33adeda3 100644 --- a/share/themes/inverse.conf +++ b/share/themes/inverse.conf @@ -3,13 +3,13 @@ # # FONT Parameters # -FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,black -FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,black -FONT_HEADING = 28p,AvantGarde-Demi,black -FONT_LABEL = 14p,AvantGarde-Book,black -FONT_LOGO = 8p,Helvetica,black -FONT_TAG = 18p,AvantGarde-Book,black -FONT_TITLE = 22p,AvantGarde-Demi,black +FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,white +FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,white +FONT_HEADING = 28p,AvantGarde-Demi,white +FONT_LABEL = 14p,AvantGarde-Book,white +FONT_LOGO = 8p,Helvetica,white +FONT_TAG = 18p,AvantGarde-Book,white +FONT_TITLE = 22p,AvantGarde-Demi,white # # MAP Parameters # From fdf1278e22ba6d06524666caa34b638de7fb341c Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Thu, 17 Dec 2020 10:36:11 -1000 Subject: [PATCH 053/109] Update gmt_init.c --- src/gmt_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 85f846e4854..ae273674209 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -2669,7 +2669,7 @@ GMT_LOCAL int gmtinit_savedefaults (struct GMT_CTRL *GMT, char *file) { fprintf (fpo, "#\n# %s\n#\n", GMT_keyword_active[current_group].name); header = true; } - fprintf (fpo, "%-30s = %s\n", GMT_keyword_active[k].name, gmtlib_putparameter (GMT, GMT_keyword_active[k].name)); + fprintf (fpo, "%-30s = %s\n", GMT_keyword_active[k].name, gmtlib_getparameter (GMT, GMT_keyword_active[k].name)); k++; } From 90fe9b3040b08f53ababf02b97304d0980b58193 Mon Sep 17 00:00:00 2001 From: Meghan Jones Date: Fri, 18 Dec 2020 14:37:32 -1000 Subject: [PATCH 054/109] Fix auto setting for MAP_FRAME_WIDTH --- src/gmt_init.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index ae273674209..a09adb7c87c 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -10267,11 +10267,7 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha GMT_COMPAT_TRANSLATE ("MAP_FRAME_WIDTH"); break; case GMTCASE_MAP_FRAME_WIDTH: - dval = gmt_M_to_inch (GMT, value); - if (dval > 0.0) - GMT->current.setting.map_frame_width = dval; - else - error = true; + GMT->current.setting.map_frame_width = gmt_M_to_inch (GMT, value); break; case GMTCASE_GRID_CROSS_SIZE_PRIMARY: GMT_COMPAT_TRANSLATE ("MAP_GRID_CROSS_SIZE_PRIMARY"); From 21645b91dbcfca4a0f55eac319dc38725ecc4125 Mon Sep 17 00:00:00 2001 From: Meghan Jones Date: Mon, 21 Dec 2020 20:36:04 -0500 Subject: [PATCH 055/109] Update modern theme and add minimal theme (#4596) * Change modern default MAP_FRAME_TYPE to fancy * Make Helvetica default font for modern theme * Remove return from gmtinit_conf_modern_override * Fix typo * Add minimal theme * Make modern font heading and title bold --- share/themes/minimal.conf | 32 ++++++++++++++++++++++++++++++++ share/themes/modern.conf | 14 +++++++------- src/gmt_init.c | 16 +++++++--------- 3 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 share/themes/minimal.conf diff --git a/share/themes/minimal.conf b/share/themes/minimal.conf new file mode 100644 index 00000000000..663404c5984 --- /dev/null +++ b/share/themes/minimal.conf @@ -0,0 +1,32 @@ +# +# Defaults file for minimal theme +# +# FONT Parameters +# +FONT_ANNOT_PRIMARY = auto,AvantGarde-Book,black +FONT_ANNOT_SECONDARY = auto,AvantGarde-Book,black +FONT_HEADING = auto,AvantGarde-Book,black +FONT_LABEL = auto,AvantGarde-Book,black +FONT_LOGO = auto,Helvetica,black +FONT_TAG = auto,AvantGarde-Book,black +FONT_TITLE = auto,AvantGarde-Book,black +# +# FORMAT Parameters +# +FORMAT_GEO_MAP = ddd:mm:ssF +# +# MAP Parameters +# +MAP_FRAME_AXES = WrStZ +MAP_ANNOT_MIN_SPACING = auto +MAP_ANNOT_OFFSET_PRIMARY = auto +MAP_ANNOT_OFFSET_SECONDARY = auto +MAP_FRAME_TYPE = plain +MAP_HEADING_OFFSET = auto +MAP_LABEL_OFFSET = auto +MAP_TICK_LENGTH_PRIMARY = auto +MAP_TICK_LENGTH_SECONDARY = auto +MAP_TITLE_OFFSET = auto +MAP_VECTOR_SHAPE = auto +MAP_GRID_PEN_PRIMARY = thinner,lightgrey +MAP_GRID_PEN_SECONDARY = thinnest,lightgrey diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 30cf2b858c0..321bda5ffc5 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -3,13 +3,13 @@ # # FONT Parameters # -FONT_ANNOT_PRIMARY = auto,AvantGarde-Book,black -FONT_ANNOT_SECONDARY = auto,AvantGarde-Book,black -FONT_HEADING = auto,AvantGarde-Demi,black -FONT_LABEL = auto,AvantGarde-Book,black +FONT_ANNOT_PRIMARY = auto,Helvetica,black +FONT_ANNOT_SECONDARY = auto,Helvetica,black +FONT_HEADING = auto,Helvetica-Bold,black +FONT_LABEL = auto,Helvetica,black FONT_LOGO = auto,Helvetica,black -FONT_TAG = auto,AvantGarde-Book,black -FONT_TITLE = auto,AvantGarde-Demi,black +FONT_TAG = auto,Helvetica,black +FONT_TITLE = auto,Helvetica-Bold,black # # FORMAT Parameters # @@ -21,7 +21,7 @@ MAP_FRAME_AXES = WrStZ MAP_ANNOT_MIN_SPACING = auto MAP_ANNOT_OFFSET_PRIMARY = auto MAP_ANNOT_OFFSET_SECONDARY = auto -MAP_FRAME_TYPE = plain +MAP_FRAME_TYPE = fancy MAP_FRAME_WIDTH = auto MAP_HEADING_OFFSET = auto MAP_LABEL_OFFSET = auto diff --git a/src/gmt_init.c b/src/gmt_init.c index c02fdbeed76..753ee0d74af 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6309,28 +6309,26 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { * dimension (font size, length, etc.) with gmt set or --PAR=value. Below, all modern * font sizes are set to auto [->NaN] and all dimensions are set to NaN. If these remain * NaN after reading gmt.conf then they are auto-scaled in gmt_set_undefined_defaults. */ - - return; /* Not make default action for 6.1 yet */ /* FONT group */ /* FONT_ANNOT_PRIMARY */ - error += gmt_getfont (GMT, "auto,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_PRIMARY]); + error += gmt_getfont (GMT, "auto,Helvetica,black", &GMT->current.setting.font_annot[GMT_PRIMARY]); GMT->current.setting.given_unit[GMTCASE_FONT_ANNOT_PRIMARY] = 'p'; /* FONT_ANNOT_SECONDARY */ - error += gmt_getfont (GMT, "auto,AvantGarde-Book,black", &GMT->current.setting.font_annot[GMT_SECONDARY]); + error += gmt_getfont (GMT, "auto,Helvetica,black", &GMT->current.setting.font_annot[GMT_SECONDARY]); GMT->current.setting.given_unit[GMTCASE_FONT_ANNOT_SECONDARY] = 'p'; /* FONT_HEADING */ - error += gmt_getfont (GMT, "auto,AvantGarde-Demi,black", &GMT->current.setting.font_heading); + error += gmt_getfont (GMT, "auto,Helvetica-Bold,black", &GMT->current.setting.font_heading); GMT->current.setting.given_unit[GMTCASE_FONT_HEADING] = 'p'; /* FONT_TITLE */ - error += gmt_getfont (GMT, "auto,AvantGarde-Demi,black", &GMT->current.setting.font_title); + error += gmt_getfont (GMT, "auto,Helvetica-Bold,black", &GMT->current.setting.font_title); GMT->current.setting.given_unit[GMTCASE_FONT_TITLE] = 'p'; /* FONT_LABEL */ - error += gmt_getfont (GMT, "auto,AvantGarde-Book,black", &GMT->current.setting.font_label); + error += gmt_getfont (GMT, "auto,Helvetica,black", &GMT->current.setting.font_label); GMT->current.setting.given_unit[GMTCASE_FONT_LABEL] = 'p'; /* FONT_TAG */ - error += gmt_getfont (GMT, "auto,AvantGarde-Book,black", &GMT->current.setting.font_tag); + error += gmt_getfont (GMT, "auto,Helvetica,black", &GMT->current.setting.font_tag); GMT->current.setting.given_unit[GMTCASE_FONT_TAG] = 'p'; /* FONT_LOGO */ error += gmt_getfont (GMT, "auto,Helvetica,black", &GMT->current.setting.font_logo); @@ -6358,7 +6356,7 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { GMT->current.map.frame.draw_box = false; error += gmtinit_decode5_wesnz (GMT, GMT->current.setting.map_frame_axes, false); /* MAP_FRAME_TYPE (plain) */ - GMT->current.setting.map_frame_type = GMT_IS_PLAIN; + GMT->current.setting.map_frame_type = GMT_IS_FANCY; /* MAP_FRAME_WIDTH */ GMT->current.setting.map_frame_width = GMT->session.d_NaN; /* 3p */ GMT->current.setting.given_unit[GMTCASE_MAP_FRAME_WIDTH] = 'p'; From 44231d2da81c702b6825be5f5ed7aadf833f2566 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Wed, 30 Dec 2020 08:31:39 -1000 Subject: [PATCH 056/109] Remove unfinished themes darkmode, inverse, movie --- share/themes/darkmode.conf | 25 ------------------------- share/themes/inverse.conf | 25 ------------------------- share/themes/movie.conf | 12 ------------ 3 files changed, 62 deletions(-) delete mode 100644 share/themes/darkmode.conf delete mode 100644 share/themes/inverse.conf delete mode 100644 share/themes/movie.conf diff --git a/share/themes/darkmode.conf b/share/themes/darkmode.conf deleted file mode 100644 index 1998273bd29..00000000000 --- a/share/themes/darkmode.conf +++ /dev/null @@ -1,25 +0,0 @@ -# -# Defaults file for darkmode theme -# -# FONT Parameters -# -FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,gray92 -FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,gray86 -FONT_HEADING = 28p,AvantGarde-Demi,gray92 -FONT_LABEL = 14p,AvantGarde-Book,black -FONT_LOGO = 8p,Helvetica,gray92 -FONT_TAG = 18p,AvantGarde-Book,gray92 -FONT_TITLE = 22p,AvantGarde-Demi,gray92 -# -# MAP Parameters -# -MAP_DEFAULT_PEN = default,gray92 -MAP_FRAME_PEN = thicker,gray92 -MAP_GRID_PEN_PRIMARY = default,gray92 -MAP_GRID_PEN_SECONDARY = thinner,gray86 -MAP_TICK_PEN_PRIMARY = thinner,gray92 -MAP_TICK_PEN_SECONDARY = thinner,gray86 -# -# PostScript Parameters -# -PS_PAGE_COLOR = 5/5/35 diff --git a/share/themes/inverse.conf b/share/themes/inverse.conf deleted file mode 100644 index 38b33adeda3..00000000000 --- a/share/themes/inverse.conf +++ /dev/null @@ -1,25 +0,0 @@ -# -# Defaults file for inverse theme -# -# FONT Parameters -# -FONT_ANNOT_PRIMARY = 10p,AvantGarde-Book,white -FONT_ANNOT_SECONDARY = 12p,AvantGarde-Book,white -FONT_HEADING = 28p,AvantGarde-Demi,white -FONT_LABEL = 14p,AvantGarde-Book,white -FONT_LOGO = 8p,Helvetica,white -FONT_TAG = 18p,AvantGarde-Book,white -FONT_TITLE = 22p,AvantGarde-Demi,white -# -# MAP Parameters -# -MAP_DEFAULT_PEN = default,white -MAP_FRAME_PEN = thicker,white -MAP_GRID_PEN_PRIMARY = default,white -MAP_GRID_PEN_SECONDARY = thinner,white -MAP_TICK_PEN_PRIMARY = thinner,white -MAP_TICK_PEN_SECONDARY = thinner,white -# -# PostScript Parameters -# -PS_PAGE_COLOR = black diff --git a/share/themes/movie.conf b/share/themes/movie.conf deleted file mode 100644 index b4fdce8bcee..00000000000 --- a/share/themes/movie.conf +++ /dev/null @@ -1,12 +0,0 @@ -# -# Defaults file for movie theme -# -# COLOR Parameters -# -COLOR_HSV_MAX_S = 0 -COLOR_HSV_MIN_V = 0 -# -# MAP Parameters -# -MAP_ORIGIN_X = 0 -MAP_ORIGIN_Y = 0 From f40741526831355d6aa9cd25e0b9c386132e4ae7 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 2 Jan 2021 11:56:46 -1000 Subject: [PATCH 057/109] Update doc/rst/source/gmt.conf.rst Co-authored-by: Meghan Jones --- doc/rst/source/gmt.conf.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/rst/source/gmt.conf.rst b/doc/rst/source/gmt.conf.rst index 2da04fb0e71..24ddd208fac 100644 --- a/doc/rst/source/gmt.conf.rst +++ b/doc/rst/source/gmt.conf.rst @@ -452,10 +452,9 @@ GMT Miscellaneous Parameters **GMT_THEME** Override GMT default settings with those of the selected theme. Choose from *classic* [Default for classic mode], *modern* [Default for modern mode], - *inverse* (white on black), *movie* (suitable for movie making) and *darkmode*. - You can also create and use your own themes by compiling files of desired settings - and place them in your GMT user themes directory (usually ~/.gmt/themes) and name - them *theme*.conf. + and *minimal*. You can also create and use your own themes by compiling + files of desired settings and place them in your GMT user themes directory + (usually ~/.gmt/themes) and name them *theme*.conf. **GMT_TRIANGULATE** Determines if we use the **Watson** [Default] or **Shewchuk** From fc1c7700e67639c0fc509a7ed64c125eb089c109 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 2 Jan 2021 11:56:59 -1000 Subject: [PATCH 058/109] Update src/gmt_init.c Co-authored-by: Meghan Jones --- src/gmt_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 1eb869cf01e..bbb28fa73b6 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -9742,7 +9742,7 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { if (gmt_M_is_dnan (GMT->current.setting.font_heading.size)) GMT->current.setting.font_heading.size = scale * 28.0; /* Modern 28p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_tag.size)) - GMT->current.setting.font_tag.size = scale * 18.0; /* Modern 18p vs 10p */ + GMT->current.setting.font_tag.size = scale * 16.0; /* Modern 16p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_title.size)) GMT->current.setting.font_title.size = scale * 22.0; /* Modern 22p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_logo.size)) From c8edc3d2a25c7ac635e2ff21af2138fb3e852fb5 Mon Sep 17 00:00:00 2001 From: Meghan Jones Date: Wed, 20 Jan 2021 14:57:18 -0500 Subject: [PATCH 059/109] Update doc/rst/source/cookbook/features.rst Co-authored-by: Dongdong Tian --- doc/rst/source/cookbook/features.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/rst/source/cookbook/features.rst b/doc/rst/source/cookbook/features.rst index 2e6e1ac7d75..c5ccd7f961a 100644 --- a/doc/rst/source/cookbook/features.rst +++ b/doc/rst/source/cookbook/features.rst @@ -286,7 +286,7 @@ affected by this mechanism are: :term:`FONT_TAG` Tag/labeling font [18p,AvantGarde-Book] :term:`FONT_TITLE` Plot title font [22p,AvantGarde-Demi] :term:`FONT_HEADING` Subplot heading font [28p,AvantGarde-Demi] -:term:`MAP_ANNOT_MIN_SPACING` PMinimum spacing between annotations [36p] +:term:`MAP_ANNOT_MIN_SPACING` Minimum spacing between annotations [36p] :term:`MAP_ANNOT_OFFSET_PRIMARY` Primary annotation offset from axis [3p] :term:`MAP_ANNOT_OFFSET_SECONDARY` Secondary annotation offset from axis [3p] :term:`MAP_FRAME_WIDTH` Width of fancy frame [3p] From a303ef7f7809ec6be953cb8eb75341f4ddb243aa Mon Sep 17 00:00:00 2001 From: Meghan Jones Date: Wed, 20 Jan 2021 14:57:53 -0500 Subject: [PATCH 060/109] Update doc/examples/ex41/ex41.sh Co-authored-by: Dongdong Tian --- doc/examples/ex41/ex41.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/ex41/ex41.sh b/doc/examples/ex41/ex41.sh index e80a5d8bf73..214fb85ffbe 100755 --- a/doc/examples/ex41/ex41.sh +++ b/doc/examples/ex41/ex41.sh @@ -5,7 +5,7 @@ # GMT modules: set, coast, legend, plot, makecpt # gmt begin ex41 - gmt set MAP_AUTO_SCALE off FONT_ANNOT_PRIMARY 12p,Helvetica FONT_LABEL 12p,Helvetica + gmt set FONT_ANNOT_PRIMARY 12p,Helvetica FONT_LABEL 12p,Helvetica gmt makecpt -Cred,orange,yellow,green,bisque,cyan,magenta,white,gray -T1/10/1 -N gmt coast -R130W/50W/8N/56N -JM14c -Glightgray -Sazure1 -A1000 -Wfaint gmt coast -EUS+glightyellow+pfaint -ECU+glightred+pfaint -EMX+glightgreen+pfaint -ECA+glightblue+pfaint From c1b22e6255b02009cc59cabded9fd50f877568da Mon Sep 17 00:00:00 2001 From: Meghan Jones Date: Mon, 25 Jan 2021 18:43:30 -0500 Subject: [PATCH 061/109] Remove MAP_ANNOT_MIN_SPACING auto-scaling (#4704) --- share/themes/minimal.conf | 1 - share/themes/modern.conf | 1 - src/gmt_init.c | 5 ----- 3 files changed, 7 deletions(-) diff --git a/share/themes/minimal.conf b/share/themes/minimal.conf index 663404c5984..3ff407b06d3 100644 --- a/share/themes/minimal.conf +++ b/share/themes/minimal.conf @@ -18,7 +18,6 @@ FORMAT_GEO_MAP = ddd:mm:ssF # MAP Parameters # MAP_FRAME_AXES = WrStZ -MAP_ANNOT_MIN_SPACING = auto MAP_ANNOT_OFFSET_PRIMARY = auto MAP_ANNOT_OFFSET_SECONDARY = auto MAP_FRAME_TYPE = plain diff --git a/share/themes/modern.conf b/share/themes/modern.conf index 321bda5ffc5..387df2b05c1 100644 --- a/share/themes/modern.conf +++ b/share/themes/modern.conf @@ -18,7 +18,6 @@ FORMAT_GEO_MAP = ddd:mm:ssF # MAP Parameters # MAP_FRAME_AXES = WrStZ -MAP_ANNOT_MIN_SPACING = auto MAP_ANNOT_OFFSET_PRIMARY = auto MAP_ANNOT_OFFSET_SECONDARY = auto MAP_FRAME_TYPE = fancy diff --git a/src/gmt_init.c b/src/gmt_init.c index c033449952e..6ff9532ae4b 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6345,9 +6345,6 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { /* MAP group */ - /* MAP_ANNOT_MIN_SPACING */ - GMT->current.setting.map_annot_min_spacing = GMT->session.d_NaN; /* 36p */ - GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_MIN_SPACING] = 'p'; /* MAP_ANNOT_OFFSET_PRIMARY, MAP_ANNOT_OFFSET_SECONDARY */ GMT->current.setting.map_annot_offset[GMT_PRIMARY] = GMT->current.setting.map_annot_offset[GMT_SECONDARY] = GMT->session.d_NaN; /* 3p */ GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_PRIMARY] = 'p'; @@ -9761,8 +9758,6 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ if (gmt_M_is_dnan (GMT->current.setting.map_heading_offset)) GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ - if (gmt_M_is_dnan (GMT->current.setting.map_annot_min_spacing)) - GMT->current.setting.map_annot_min_spacing = 36 * pt * scale; /* 36p */ /* Tick lengths */ From 9b20b763a8f5b269c925cfe8c35b3f08d90a0fba Mon Sep 17 00:00:00 2001 From: Meghan Jones Date: Mon, 25 Jan 2021 18:44:13 -0500 Subject: [PATCH 062/109] Update doc/scripts/GMT_TM.sh --- doc/scripts/GMT_TM.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/scripts/GMT_TM.sh b/doc/scripts/GMT_TM.sh index 8ebbc0cdb5e..efc3c03758a 100755 --- a/doc/scripts/GMT_TM.sh +++ b/doc/scripts/GMT_TM.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -gmt coast -R0/360/-80/80 -JT330/-45/10c -Ba30g -BWSne -Dc -A2000 -Slightblue -G0 -ps GMT_TM --MAP_ANNOT_OBLIQUE=2 +gmt coast -R0/360/-80/80 -JT330/-45/10c -Ba30g -BWSne -Dc -A2000 -Slightblue -G0 --MAP_ANNOT_OBLIQUE=lon_horizontal -ps GMT_TM From 53350c5aa00a4c7b390db98806c602c991bf8147 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Thu, 28 Jan 2021 12:27:59 -1000 Subject: [PATCH 063/109] Add auto-scaling for new subtitle font as well --- src/gmt_init.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gmt_init.c b/src/gmt_init.c index de62b9b2348..6988cdaadb1 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -6326,6 +6326,9 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { /* FONT_TITLE */ error += gmt_getfont (GMT, "auto,Helvetica-Bold,black", &GMT->current.setting.font_title); GMT->current.setting.given_unit[GMTCASE_FONT_TITLE] = 'p'; + /* FONT_SUBTITLE */ + error += gmt_getfont (GMT, "auto,Helvetica-Bold,black", &GMT->current.setting.font_subtitle); + GMT->current.setting.given_unit[GMTCASE_FONT_SUBTITLE] = 'p'; /* FONT_LABEL */ error += gmt_getfont (GMT, "auto,Helvetica,black", &GMT->current.setting.font_label); GMT->current.setting.given_unit[GMTCASE_FONT_LABEL] = 'p'; @@ -9743,6 +9746,8 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { GMT->current.setting.font_tag.size = scale * 16.0; /* Modern 16p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_title.size)) GMT->current.setting.font_title.size = scale * 22.0; /* Modern 22p vs 10p */ + if (gmt_M_is_dnan (GMT->current.setting.font_subtitle.size)) + GMT->current.setting.font_subtitle.size = scale * 18.0; /* Modern 18p vs 10p */ if (gmt_M_is_dnan (GMT->current.setting.font_logo.size)) GMT->current.setting.font_logo.size = scale * 8.0; /* Classic 8p vs 10p */ From 8014b272db475bae2cded2c8e271b5fa5db96d22 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Thu, 28 Jan 2021 16:15:05 -1000 Subject: [PATCH 064/109] Testing a GMT_THEME off solution (#4710) * Testing a GMT_THEME off solution Goal is to allow suers to override specifics in the theme settings without having the THEME be parsed again and overwrite the changes * Update gmt_init.c --- src/gmt_init.c | 6 +++--- src/gmtset.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index a888c3a0a41..47aad2b56e7 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -9643,6 +9643,7 @@ GMT_LOCAL int gmtinit_update_theme (struct GMT_CTRL *GMT) { char theme_file[PATH_MAX] = {""}; if (!GMT->current.setting.update_theme) return GMT_NOERROR; /* Nothing to do */ + if (!strcmp (GMT->current.setting.theme, "off")) return GMT_NOERROR; /* Nothing to do */ /* Got a GMT_THEME setting, take delayed action now */ GMT->current.setting.update_theme = false; @@ -11297,9 +11298,8 @@ unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, cha case GMTCASE_GMT_THEME: if (strlen (value) < GMT_LEN64) { strncpy (GMT->current.setting.theme, value, GMT_LEN64-1); - GMT->current.setting.update_theme = true; - if (core == false) /* Must deal with this right away */ - error = gmtinit_update_theme (GMT); + GMT->current.setting.update_theme = (strcmp (GMT->current.setting.theme, "off") != 0); + error = gmtinit_update_theme (GMT); } else { GMT_Report (GMT->parent, GMT_MSG_ERROR, "GMT_THEME must be less than %d characters\n", GMT_LEN64); diff --git a/src/gmtset.c b/src/gmtset.c index 72389dcb50b..d7f6e32e982 100644 --- a/src/gmtset.c +++ b/src/gmtset.c @@ -173,6 +173,8 @@ EXTERN_MSC int GMT_gmtset (void *V_API, int mode, void *args) { if (gmt_setdefaults (GMT, options)) Return (GMT_PARSE_ERROR); /* Process command line arguments, return error if failures */ + strcpy (GMT->current.setting.theme, "off"); /* To preserve changes the user may have set */ + gmt_putdefaults (GMT, Ctrl->G.file); /* Write out the revised settings */ Return (GMT_NOERROR); From 73e226300bb1551f7eb6cbdf7d3fb7ab7b16bd61 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Fri, 29 Jan 2021 08:33:18 -1000 Subject: [PATCH 065/109] Themes autoaxes (#4715) * Aadd auto mode for GMT_MAP_AXES The default choice may need to depend on view-angle, if azimuthal or cylindrical, etc. * Handle polar and rotated schemes * Update gmt_init.c --- src/gmt_init.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 47aad2b56e7..f85a213dbfb 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -3983,6 +3983,8 @@ GMT_LOCAL int gmtinit_decode5_wesnz (struct GMT_CTRL *GMT, const char *in, bool unsigned int k, error = 0, f_side[5] = {0, 0, 0, 0, 0}, z_axis[4] = {0, 0, 0, 0}; bool s_given = false; + + if (!strcmp (GMT->current.setting.map_frame_axes, "auto")) return GMT_NOERROR; /* Not ready yet */ if (check) { /* true if coming via -B, false if parsing gmt.conf */ GMT->current.map.frame.set_frame[GMT_PRIMARY]++, GMT->current.map.frame.set_frame[GMT_SECONDARY]++; if (GMT->current.map.frame.set_frame[GMT_PRIMARY] > 1 || GMT->current.map.frame.set_frame[GMT_SECONDARY] > 1) { @@ -6353,10 +6355,7 @@ GMT_LOCAL void gmtinit_conf_modern_override (struct GMT_CTRL *GMT) { GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_PRIMARY] = 'p'; GMT->current.setting.given_unit[GMTCASE_MAP_ANNOT_OFFSET_SECONDARY] = 'p'; /* MAP_FRAME_AXES */ - strcpy (GMT->current.setting.map_frame_axes, "WrStZ"); - for (i = 0; i < 5; i++) GMT->current.map.frame.side[i] = 0; /* Unset default settings */ - GMT->current.map.frame.draw_box = false; - error += gmtinit_decode5_wesnz (GMT, GMT->current.setting.map_frame_axes, false); + strcpy (GMT->current.setting.map_frame_axes, "auto"); /* MAP_FRAME_TYPE (plain) */ GMT->current.setting.map_frame_type = GMT_IS_FANCY; /* MAP_FRAME_WIDTH */ @@ -9711,6 +9710,29 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { /* Refuse to do this in gmtset */ if (!strcmp (GMT->init.module_name, "gmtset")) {fprintf (stderr, "Not doing it\n"); return; } + if (!strcmp (GMT->current.setting.map_frame_axes, "auto")) { /* Determine suitable MAP_FRAME_AXES for plot */ + double az = (gmt_M_is_zero (GMT->common.p.z_rotation)) ? GMT->current.proj.z_project.view_azimuth : GMT->common.p.z_rotation; + if (GMT->current.proj.projection == GMT_POLAR) { /* May need to switch what is south and north */ + strcpy (GMT->current.setting.map_frame_axes, GMT->current.proj.flip ? "WrStZ" : "WrbNZ"); + GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Given polar projection flip = %d, set MAP_FRAME_AXES = %s\n", + GMT->current.proj.flip, GMT->current.setting.map_frame_axes); + } + else if (!doubleAlmostEqual (az, 180.0)) { /* Rotated, so must adjust */ + unsigned int quadrant = urint (floor (az / 90.0)) + 1; + switch (quadrant) { + case 1: strcpy (GMT->current.setting.map_frame_axes, "lEbNZ"); break; + case 2: strcpy (GMT->current.setting.map_frame_axes, "lEStZ"); break; + case 3: strcpy (GMT->current.setting.map_frame_axes, "WrStZ"); break; + case 4: strcpy (GMT->current.setting.map_frame_axes, "WrbNZ"); break; + } + GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Given view angle = %g, set MAP_FRAME_AXES = %s\n", + az, GMT->current.setting.map_frame_axes); + } + else /* Default modern mode setting */ + strcpy (GMT->current.setting.map_frame_axes, "WrStZ"); + (void)gmtinit_decode5_wesnz (GMT, GMT->current.setting.map_frame_axes, false); + } + /* If a geographic map frame is fancy then we cannot have lrbt regardless of mode */ geo_frame = (gmt_M_is_geographic (GMT, GMT_IN) && (GMT->current.setting.map_frame_type == GMT_IS_FANCY || GMT->current.setting.map_frame_type == GMT_IS_ROUNDED)); @@ -18489,6 +18511,7 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j char side, axis, B_delim[2] = {30, 0}, p[GMT_BUFSIZ] = {""}; /* Use ASCII 30 RS Record Separator between -B strings */ char file[PATH_MAX] = {""}; + char *frame_axes = (!strcmp (GMT->current.setting.map_frame_axes, "auto")) ? "WrStZ" : GMT->current.setting.map_frame_axes; unsigned int pos = 0, sides[5]; bool add_label = false, add_annot = false, axis_set = false, was; double GMT_LETTER_HEIGHT = 0.736; @@ -18525,7 +18548,7 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j } } /* If -BWE.. was not set we must rely on MAP_FRAME_AXES default setting */ - if (!axis_set && strchr (GMT->current.setting.map_frame_axes, side)) add_annot = true; + if (!axis_set && strchr (frame_axes, side)) add_annot = true; if (add_label && gmt_M_is_geographic (GMT, GMT_IN)) add_label = false; /* Not allowed anyway */ /* Time to make updates, if any */ if (add_annot) { From e974773561364bad59751fdf24f6ffaca1c6327f Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Fri, 29 Jan 2021 14:11:59 -1000 Subject: [PATCH 066/109] Subplot axes (#4720) * Better interplay between -S and MAP_FRAME_AXES WHen -S is used for rows or cols then we should let it do its thing, not parse MAP_FRAME_AXES. If not set then we do. * Deal with subplot-specific gmt.conf settings Must create a gmt.conf for a subplot if modern theme so that all fonts etc will be the same across all panels. * Progress on auto axes and subplots * COmments --- src/gmt_init.c | 157 ++++++++++++++++++++++++++++++------------- src/gmt_map.c | 2 +- src/gmt_plot.c | 2 +- src/gmt_prototypes.h | 3 +- src/pslegend.c | 2 +- src/psscale.c | 3 +- src/subplot.c | 52 ++++++++++---- 7 files changed, 156 insertions(+), 65 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index f85a213dbfb..6f700bd9865 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -3976,6 +3976,21 @@ void gmt_handle5_plussign (struct GMT_CTRL *GMT, char *in, char *mods, unsigned gmt_strrepc (in, 1, '+'); } +GMT_LOCAL void gmtinit_sides2axes (struct GMT_CTRL *GMT) { + /* Convert GMT->current.map.frame.side to corresponding MAP_FRAME_AXES string */ + unsigned int k, i = 0; + char *all = {"WESNZ"}, *tick = {"wesnz"}, *draw = {"lrbtu"}; + for (k = 0; k <= Z_SIDE; k++) { + if (GMT->current.map.frame.side[k] & GMT_AXIS_ALL) + GMT->current.setting.map_frame_axes[i++] = all[k]; + else if (GMT->current.map.frame.side[k] & GMT_AXIS_BARB) + GMT->current.setting.map_frame_axes[i++] = tick[k]; + else if (GMT->current.map.frame.side[k] & GMT_AXIS_DRAW) + GMT->current.setting.map_frame_axes[i++] = draw[k]; + } + GMT->current.setting.map_frame_axes[i] = '\0'; +} + /*! Scans the WESNZ[1234]wesnz[1234]lrbtu flags and sets the side/drawbox parameters * and returns the length of the remaining string. */ @@ -3984,7 +3999,6 @@ GMT_LOCAL int gmtinit_decode5_wesnz (struct GMT_CTRL *GMT, const char *in, bool unsigned int k, error = 0, f_side[5] = {0, 0, 0, 0, 0}, z_axis[4] = {0, 0, 0, 0}; bool s_given = false; - if (!strcmp (GMT->current.setting.map_frame_axes, "auto")) return GMT_NOERROR; /* Not ready yet */ if (check) { /* true if coming via -B, false if parsing gmt.conf */ GMT->current.map.frame.set_frame[GMT_PRIMARY]++, GMT->current.map.frame.set_frame[GMT_SECONDARY]++; if (GMT->current.map.frame.set_frame[GMT_PRIMARY] > 1 || GMT->current.map.frame.set_frame[GMT_SECONDARY] > 1) { @@ -3992,8 +4006,10 @@ GMT_LOCAL int gmtinit_decode5_wesnz (struct GMT_CTRL *GMT, const char *in, bool return (1); } } - else + else { GMT->current.map.frame.draw_box = GMT_3D_NONE; + if (!strcmp (GMT->current.setting.map_frame_axes, "auto")) return GMT_NOERROR; /* Not ready to parse yet */ + } for (k = 0; in[k]; k++) { switch (in[k]) { /* Draw, Annotate, and Tick */ @@ -4044,6 +4060,8 @@ GMT_LOCAL int gmtinit_decode5_wesnz (struct GMT_CTRL *GMT, const char *in, bool GMT->current.map.frame.no_frame = false; GMT->current.map.frame.draw = true; if (check && f_side[Z_SIDE]) GMT->current.map.frame.drawz = true; + if (check) /* Update MAP_FRAME_AXES from sides */ + gmtinit_sides2axes (GMT); } if (GMT->current.map.frame.no_frame) gmt_M_memset (GMT->current.map.frame.side, 5, unsigned int); /* Set all to nothing */ if (z_axis[0] || z_axis[1] || z_axis[2] || z_axis[3]) gmt_M_memcpy (GMT->current.map.frame.z_axis, z_axis, 4, unsigned int); /* Overwrite the GMT defaults */ @@ -9701,7 +9719,33 @@ unsigned int gmt_setdefaults (struct GMT_CTRL *GMT, struct GMT_OPTION *options) return (n_errors); } -void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { +void gmt_set_undefined_axes (struct GMT_CTRL *GMT, bool conf_update) { + char axes[GMT_LEN32] = {""}; + double az = (gmt_M_is_zero (GMT->common.p.z_rotation)) ? GMT->current.proj.z_project.view_azimuth : GMT->common.p.z_rotation; + if (strcmp (GMT->current.setting.map_frame_axes, "auto")) return; + + /* Determine suitable MAP_FRAME_AXES for plot */ + if (GMT->current.proj.projection == GMT_POLAR) { /* May need to switch what is south and north */ + strcpy (axes, GMT->current.proj.flip ? "WrStZ" : "WrbNZ"); + GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Given polar projection flip = %d, set MAP_FRAME_AXES = %s\n", GMT->current.proj.flip, axes); + } + else if (!doubleAlmostEqual (az, 180.0)) { /* Rotated, so must adjust */ + unsigned int quadrant = urint (floor (az / 90.0)) + 1; + switch (quadrant) { + case 1: strcpy (axes, "lEbNZ"); break; + case 2: strcpy (axes, "lEStZ"); break; + case 3: strcpy (axes, "WrStZ"); break; + case 4: strcpy (axes, "WrbNZ"); break; + } + GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Given view angle = %g, set MAP_FRAME_AXES = %s\n", az, axes); + } + else /* Default modern mode setting */ + strcpy (axes, "WrStZ"); + gmtlib_setparameter (GMT, "MAP_FRAME_AXES", axes, conf_update); + (void)gmtinit_decode5_wesnz (GMT, axes, false); +} + +void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim, bool conf_update) { /* We must adjust all frame items with unspecified size according to plot dimension */ bool geo_frame = false; double fontsize, scale; @@ -9710,28 +9754,7 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { /* Refuse to do this in gmtset */ if (!strcmp (GMT->init.module_name, "gmtset")) {fprintf (stderr, "Not doing it\n"); return; } - if (!strcmp (GMT->current.setting.map_frame_axes, "auto")) { /* Determine suitable MAP_FRAME_AXES for plot */ - double az = (gmt_M_is_zero (GMT->common.p.z_rotation)) ? GMT->current.proj.z_project.view_azimuth : GMT->common.p.z_rotation; - if (GMT->current.proj.projection == GMT_POLAR) { /* May need to switch what is south and north */ - strcpy (GMT->current.setting.map_frame_axes, GMT->current.proj.flip ? "WrStZ" : "WrbNZ"); - GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Given polar projection flip = %d, set MAP_FRAME_AXES = %s\n", - GMT->current.proj.flip, GMT->current.setting.map_frame_axes); - } - else if (!doubleAlmostEqual (az, 180.0)) { /* Rotated, so must adjust */ - unsigned int quadrant = urint (floor (az / 90.0)) + 1; - switch (quadrant) { - case 1: strcpy (GMT->current.setting.map_frame_axes, "lEbNZ"); break; - case 2: strcpy (GMT->current.setting.map_frame_axes, "lEStZ"); break; - case 3: strcpy (GMT->current.setting.map_frame_axes, "WrStZ"); break; - case 4: strcpy (GMT->current.setting.map_frame_axes, "WrbNZ"); break; - } - GMT_Report (GMT->parent, GMT_MSG_NOTICE, "Given view angle = %g, set MAP_FRAME_AXES = %s\n", - az, GMT->current.setting.map_frame_axes); - } - else /* Default modern mode setting */ - strcpy (GMT->current.setting.map_frame_axes, "WrStZ"); - (void)gmtinit_decode5_wesnz (GMT, GMT->current.setting.map_frame_axes, false); - } + gmt_set_undefined_axes (GMT, conf_update); /* Determine suitable MAP_FRAME_AXES for plot if still auto */ /* If a geographic map frame is fancy then we cannot have lrbt regardless of mode */ @@ -9757,35 +9780,61 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { /* Only apply the automatic scaling to items NOT specifically set via a --PAR=value option */ - if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_PRIMARY].size)) + if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_PRIMARY].size)) { GMT->current.setting.font_annot[GMT_PRIMARY].size = fontsize; - if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_SECONDARY].size)) + if (conf_update) GMT_keyword_updated[GMTCASE_FONT_ANNOT_PRIMARY] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.font_annot[GMT_SECONDARY].size)) { GMT->current.setting.font_annot[GMT_SECONDARY].size = scale * 12.0; /* Modern 12p vs 10p */ - if (gmt_M_is_dnan (GMT->current.setting.font_label.size)) + if (conf_update) GMT_keyword_updated[GMTCASE_FONT_ANNOT_SECONDARY] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.font_label.size)) { GMT->current.setting.font_label.size = scale * 14.0; /* Modern 14p vs 10p */ - if (gmt_M_is_dnan (GMT->current.setting.font_heading.size)) + if (conf_update) GMT_keyword_updated[GMTCASE_FONT_LABEL] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.font_heading.size)) { GMT->current.setting.font_heading.size = scale * 28.0; /* Modern 28p vs 10p */ - if (gmt_M_is_dnan (GMT->current.setting.font_tag.size)) + if (conf_update) GMT_keyword_updated[GMTCASE_FONT_HEADING] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.font_tag.size)) { GMT->current.setting.font_tag.size = scale * 16.0; /* Modern 16p vs 10p */ - if (gmt_M_is_dnan (GMT->current.setting.font_title.size)) + if (conf_update) GMT_keyword_updated[GMTCASE_FONT_TAG] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.font_title.size)) { GMT->current.setting.font_title.size = scale * 22.0; /* Modern 22p vs 10p */ - if (gmt_M_is_dnan (GMT->current.setting.font_subtitle.size)) + if (conf_update) GMT_keyword_updated[GMTCASE_FONT_TITLE] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.font_subtitle.size)) { GMT->current.setting.font_subtitle.size = scale * 18.0; /* Modern 18p vs 10p */ - if (gmt_M_is_dnan (GMT->current.setting.font_logo.size)) + if (conf_update) GMT_keyword_updated[GMTCASE_FONT_SUBTITLE] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.font_logo.size)) { GMT->current.setting.font_logo.size = scale * 8.0; /* Classic 8p vs 10p */ + if (conf_update) GMT_keyword_updated[GMTCASE_FONT_LOGO] = true; + } /* Offsets */ - if (gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_PRIMARY])) + if (gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_PRIMARY])) { GMT->current.setting.map_annot_offset[GMT_PRIMARY] = 3 * pt * scale; /* 3p */ - if (gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_SECONDARY])) + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_ANNOT_OFFSET_PRIMARY] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.map_annot_offset[GMT_SECONDARY])) { GMT->current.setting.map_annot_offset[GMT_SECONDARY] = 3 * pt * scale; /* 3p */ - if (gmt_M_is_dnan (GMT->current.setting.map_label_offset)) + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_ANNOT_OFFSET_SECONDARY] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.map_label_offset)) { GMT->current.setting.map_label_offset = 6 * pt * scale; /* 6p */ - if (gmt_M_is_dnan (GMT->current.setting.map_title_offset)) + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_LABEL_OFFSET] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.map_title_offset)) { GMT->current.setting.map_title_offset = 12 * pt * scale; /* 12p */ - if (gmt_M_is_dnan (GMT->current.setting.map_heading_offset)) + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TITLE_OFFSET] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.map_heading_offset)) { GMT->current.setting.map_heading_offset = 16 * pt * scale; /* 16p */ + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_HEADING_OFFSET] = true; + } /* Tick lengths */ @@ -9799,6 +9848,7 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { GMT->current.setting.map_tick_length[GMT_ANNOT_UPPER] = 4 * pt * scale; /* 4p */ GMT->current.setting.map_tick_length[GMT_TICK_UPPER] = 2 * pt * scale; /* 2p */ } + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TICK_LENGTH_PRIMARY] = true; } if (gmt_M_is_dnan (GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER])) { if (geo_frame && GMT->current.setting.run_mode == GMT_MODERN) { @@ -9810,25 +9860,40 @@ void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim) { GMT->current.setting.map_tick_length[GMT_ANNOT_LOWER] = 12 * pt * scale; /* 12p */ GMT->current.setting.map_tick_length[GMT_TICK_LOWER] = 3 * pt * scale; /* 3p */ } + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TICK_LENGTH_SECONDARY] = true; } /* Frame, tick and gridline pens */ - if (gmt_M_is_dnan (GMT->current.setting.map_frame_width)) + if (gmt_M_is_dnan (GMT->current.setting.map_frame_width)) { GMT->current.setting.map_frame_width = 3 * pt * scale; /* 3p */ - if (gmt_M_is_dnan (GMT->current.setting.map_frame_pen.width)) + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_FRAME_WIDTH] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.map_frame_pen.width)) { GMT->current.setting.map_frame_pen.width = 1.5 * scale; /* 1.5p (thicker) */ - if (gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_FRAME_PEN] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_PRIMARY].width)) { GMT->current.setting.map_tick_pen[GMT_PRIMARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TICK_PEN_PRIMARY] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.map_tick_pen[GMT_SECONDARY].width)) { GMT->current.setting.map_tick_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ - if (gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_TICK_PEN_SECONDARY] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_PRIMARY].width)) { GMT->current.setting.map_grid_pen[GMT_PRIMARY].width = 0.25 * scale; /* 0.25p (default) */ - if (gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_GRID_PEN_PRIMARY] = true; + } + if (gmt_M_is_dnan (GMT->current.setting.map_grid_pen[GMT_SECONDARY].width)) { GMT->current.setting.map_grid_pen[GMT_SECONDARY].width = 0.5 * scale; /* 0.5p (thinner) */ + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_GRID_PEN_SECONDARY] = true; + } - if (gmt_M_is_dnan (GMT->current.setting.map_vector_shape)) + if (gmt_M_is_dnan (GMT->current.setting.map_vector_shape)) { GMT->current.setting.map_vector_shape = 0.5; + if (conf_update) GMT_keyword_updated[GMTCASE_MAP_VECTOR_SHAPE] = true; + } } GMT_LOCAL unsigned int gmtinit_parse_map_annot_oblique (struct GMT_CTRL *GMT, char *text) { @@ -18517,7 +18582,7 @@ void gmt_auto_offsets_for_colorbar (struct GMT_CTRL *GMT, double offset[], int j double GMT_LETTER_HEIGHT = 0.736; FILE *fp = NULL; /* Initialize the default settings before considering any -B history */ - gmt_set_undefined_defaults (GMT, 0.0); /* Must set undefined to their reference values for now */ + gmt_set_undefined_defaults (GMT, 0.0, false); /* Must set undefined to their reference values for now */ offset[GMT_OUT] = GMT->current.setting.map_label_offset + GMT->current.setting.map_frame_width; offset[GMT_IN] = GMT->current.setting.map_label_offset; diff --git a/src/gmt_map.c b/src/gmt_map.c index 4b13623fa94..6b9b5309ab4 100644 --- a/src/gmt_map.c +++ b/src/gmt_map.c @@ -9517,7 +9517,7 @@ int gmt_map_setup (struct GMT_CTRL *GMT, double wesn[]) { if ((error = gmt_proj_setup (GMT, wesn)) != GMT_NOERROR) goto gmt_map_setup_end; - gmt_set_undefined_defaults (GMT, MAX (GMT->current.map.width, GMT->current.map.height)); /* We must change any undefined defaults given max plot dimension */ + gmt_set_undefined_defaults (GMT, MAX (GMT->current.map.width, GMT->current.map.height), false); /* We must change any undefined defaults given max plot dimension */ search = GMT->current.proj.search; diff --git a/src/gmt_plot.c b/src/gmt_plot.c index adfa4bd3e93..aa5dae042b0 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -8374,7 +8374,7 @@ struct PSL_CTRL *gmt_plotinit (struct GMT_CTRL *GMT, struct GMT_OPTION *options) PSL = GMT->PSL; /* Shorthand */ - gmt_set_undefined_defaults (GMT, MAX (GMT->current.map.width, GMT->current.map.height)); /* We must change any undefined defaults given max plot dimension */ + gmt_set_undefined_defaults (GMT, MAX (GMT->current.map.width, GMT->current.map.height), false); /* We must change any undefined defaults given max plot dimension */ if (GMT->current.map.frame.paint[GMT_Z]) { /* Must squirrel this away for now since we may call psbasemap during the movie-indicators below */ do_paint = true; diff --git a/src/gmt_prototypes.h b/src/gmt_prototypes.h index 9fead6c4659..438752e64cc 100644 --- a/src/gmt_prototypes.h +++ b/src/gmt_prototypes.h @@ -46,7 +46,8 @@ EXTERN_MSC int gmt_nc_read_cube_info (struct GMT_CTRL *GMT, char *file, double * /* gmt_init.c: */ -EXTERN_MSC void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim); +EXTERN_MSC void gmt_set_undefined_axes (struct GMT_CTRL *GMT, bool conf_update); +EXTERN_MSC void gmt_set_undefined_defaults (struct GMT_CTRL *GMT, double plot_dim, bool conf_update); EXTERN_MSC bool gmt_parse_s_option (struct GMT_CTRL *GMT, char *item); EXTERN_MSC unsigned int gmt_parse_d_option (struct GMT_CTRL *GMT, char *arg); EXTERN_MSC int gmt_parse_g_option (struct GMT_CTRL *GMT, char *txt); diff --git a/src/pslegend.c b/src/pslegend.c index 5e3c5c9d684..1ecedda6c1c 100644 --- a/src/pslegend.c +++ b/src/pslegend.c @@ -529,7 +529,7 @@ EXTERN_MSC int GMT_pslegend (void *V_API, int mode, void *args) { } if (!(GMT->common.R.active[RSET] && GMT->common.J.active)) /* When no projection specified (i.e, -Dx is used), we cannot autoscale so set to nominal sizes */ - gmt_set_undefined_defaults (GMT, 0.0); /* Must set undefined to their reference values */ + gmt_set_undefined_defaults (GMT, 0.0, false); /* Must set undefined to their reference values */ else { if (gmt_M_err_pass (GMT, gmt_map_setup (GMT, GMT->common.R.wesn), "")) Return (GMT_PROJECTION_ERROR); diff --git a/src/psscale.c b/src/psscale.c index ac23eb6b97c..615f6ac7830 100644 --- a/src/psscale.c +++ b/src/psscale.c @@ -1603,6 +1603,7 @@ EXTERN_MSC int GMT_psscale (void *V_API, int mode, void *args) { if ((GMT = gmt_init_module (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_KEYS, THIS_MODULE_NEEDS, NULL, &options, &GMT_cpy)) == NULL) bailout (API->error); /* Save current state */ /* Overrule GMT settings of MAP_FRAME_AXES. Use WESN */ + strcpy (GMT->current.setting.map_frame_axes, "WESN"); GMT->current.map.frame.side[S_SIDE] = GMT->current.map.frame.side[E_SIDE] = GMT->current.map.frame.side[N_SIDE] = GMT->current.map.frame.side[W_SIDE] = GMT_AXIS_ALL; GMT->current.map.frame.draw = false; /* No -B parsed explicitly yet */ if (GMT_Parse_Common (API, THIS_MODULE_OPTIONS, options)) Return (API->error); @@ -1677,7 +1678,7 @@ EXTERN_MSC int GMT_psscale (void *V_API, int mode, void *args) { gmt_M_memset (wesn, 4, double); if (!(GMT->common.R.active[RSET] && GMT->common.J.active)) { /* When no projection specified, use fake linear projection */ - gmt_set_undefined_defaults (GMT, 0.0); /* Must set undefined to their reference values */ + gmt_set_undefined_defaults (GMT, 0.0, false); /* Must set undefined to their reference values */ GMT->common.R.active[RSET] = true; GMT->common.J.active = false; gmt_parse_common_options (GMT, "J", 'J', text); diff --git a/src/subplot.c b/src/subplot.c index 1984a46f683..3ae5dec86df 100644 --- a/src/subplot.c +++ b/src/subplot.c @@ -84,6 +84,8 @@ #define SUBPLOT_PLACE_AT_MAX 2 #define SUBPLOT_PLACE_AT_BOTH 3 +EXTERN_MSC unsigned int gmtlib_setparameter (struct GMT_CTRL *GMT, const char *keyword, char *value, bool core); + struct SUBPLOT_CTRL { struct SUBPLOT_In { /* begin | end | set */ bool active; @@ -387,7 +389,7 @@ static int parse (struct GMT_CTRL *GMT, struct SUBPLOT_CTRL *Ctrl, struct GMT_OP } break; - case 'B': /* Get a handle on -B args if any */ + case 'B': /* Get a handle on -B args, if any */ B_args = true; if (strstr (opt->arg, "+n")) noB = true; /* Turn off all annotations */ if (opt->arg[0] == 'x') Bx = opt; /* Got options for x-axis only */ @@ -654,18 +656,35 @@ static int parse (struct GMT_CTRL *GMT, struct SUBPLOT_CTRL *Ctrl, struct GMT_OP } } if (!Bframe) { /* No override, examine the default frame setting instead */ - if (strchr (GMT->current.setting.map_frame_axes, 'S')) Ctrl->S[GMT_X].axes[px++] = 'S'; - else if (strchr (GMT->current.setting.map_frame_axes, 's')) Ctrl->S[GMT_X].axes[px++] = 's'; - else if (strchr (GMT->current.setting.map_frame_axes, 'b')) Ctrl->S[GMT_X].axes[px++] = 'b'; - if (strchr (GMT->current.setting.map_frame_axes, 'N')) Ctrl->S[GMT_X].axes[px++] = 'N'; - else if (strchr (GMT->current.setting.map_frame_axes, 'n')) Ctrl->S[GMT_X].axes[px++] = 'n'; - else if (strchr (GMT->current.setting.map_frame_axes, 't')) Ctrl->S[GMT_X].axes[px++] = 't'; - if (strchr (GMT->current.setting.map_frame_axes, 'W')) Ctrl->S[GMT_Y].axes[py++] = 'W'; - else if (strchr (GMT->current.setting.map_frame_axes, 'w')) Ctrl->S[GMT_Y].axes[py++] = 'w'; - else if (strchr (GMT->current.setting.map_frame_axes, 'l')) Ctrl->S[GMT_Y].axes[py++] = 'l'; - if (strchr (GMT->current.setting.map_frame_axes, 'E')) Ctrl->S[GMT_Y].axes[py++] = 'E'; - else if (strchr (GMT->current.setting.map_frame_axes, 'e')) Ctrl->S[GMT_Y].axes[py++] = 'e'; - else if (strchr (GMT->current.setting.map_frame_axes, 'r')) Ctrl->S[GMT_Y].axes[py++] = 'r'; + gmt_set_undefined_axes (GMT, true); /* We cannot have MAP_FRAME_AXES=auto in subplot during -B parsing, so do the update now */ + if (Ctrl->S[GMT_X].active) /* Automatic selection of row sides via -SR, so set to SN */ + strcpy (Ctrl->S[GMT_X].axes, "SN"); + else { /* Extract what the MAP_FRAME_AXES has for this axis instead */ + if (strchr (GMT->current.setting.map_frame_axes, 'S')) Ctrl->S[GMT_X].axes[px++] = 'S'; + else if (strchr (GMT->current.setting.map_frame_axes, 's')) Ctrl->S[GMT_X].axes[px++] = 's'; + else if (strchr (GMT->current.setting.map_frame_axes, 'b')) Ctrl->S[GMT_X].axes[px++] = 'b'; + if (strchr (GMT->current.setting.map_frame_axes, 'N')) Ctrl->S[GMT_X].axes[px++] = 'N'; + else if (strchr (GMT->current.setting.map_frame_axes, 'n')) Ctrl->S[GMT_X].axes[px++] = 'n'; + else if (strchr (GMT->current.setting.map_frame_axes, 't')) Ctrl->S[GMT_X].axes[px++] = 't'; + } + if (Ctrl->S[GMT_Y].active) /* Automatic selection of column sides via -SC, so set to WE */ + strcpy (Ctrl->S[GMT_Y].axes, "WE"); + else { /* Extract what the MAP_FRAME_AXES has for this axis instead */ + if (strchr (GMT->current.setting.map_frame_axes, 'W')) Ctrl->S[GMT_Y].axes[py++] = 'W'; + else if (strchr (GMT->current.setting.map_frame_axes, 'w')) Ctrl->S[GMT_Y].axes[py++] = 'w'; + else if (strchr (GMT->current.setting.map_frame_axes, 'l')) Ctrl->S[GMT_Y].axes[py++] = 'l'; + if (strchr (GMT->current.setting.map_frame_axes, 'E')) Ctrl->S[GMT_Y].axes[py++] = 'E'; + else if (strchr (GMT->current.setting.map_frame_axes, 'e')) Ctrl->S[GMT_Y].axes[py++] = 'e'; + else if (strchr (GMT->current.setting.map_frame_axes, 'r')) Ctrl->S[GMT_Y].axes[py++] = 'r'; + } + /* Update MAP_FRAME_AXES for this subplot settings */ + if (!strcmp (GMT->current.setting.map_frame_axes, "auto")) { + char axes[GMT_LEN32] = {""}; + strcpy (axes, Ctrl->S[GMT_X].axes); + strcat (axes, Ctrl->S[GMT_Y].axes); + strcat (axes, "Z"); + gmtlib_setparameter (GMT, "MAP_FRAME_AXES", axes, true); + } } if (Ctrl->S[GMT_X].b == NULL) Ctrl->S[GMT_X].b = strdup ("af"); /* Default is -Baf if not set */ if (Ctrl->S[GMT_Y].b == NULL) Ctrl->S[GMT_Y].b = strdup ("af"); @@ -783,7 +802,10 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { } GMT_Report (API, GMT_MSG_NOTICE, "Subplot max panel dimension estimated: %g inch\n", PD); - gmt_set_undefined_defaults (GMT, PD); /* We must change any undefined defaults given max panel dimension */ + /* We must change any undefined defaults given max panel dimension now so that font sizes and dimensions + * can be written to this subplot's gmt.conf file and thus give the same settings for all panels. */ + gmt_set_undefined_defaults (GMT, PD, true); + /* Update defaults settings that depend on fonts etc */ if (gmt_M_is_dnan (Ctrl->A.off[GMT_X])) Ctrl->A.off[GMT_X] = Ctrl->A.off[GMT_Y] = 0.01 * GMT_TEXT_OFFSET * GMT->current.setting.font_tag.size / PSL_POINTS_PER_INCH; /* 20% */ @@ -1306,6 +1328,8 @@ EXTERN_MSC int GMT_subplot (void *V_API, int mode, void *args) { GMT->init.history[RG_id] = strdup (GMT->init.history[RP_id]); else if (GMT->init.history[RG_id] && !GMT->init.history[RP_id]) /* History for -RP but not -RG, duplicate*/ GMT->init.history[RP_id] = strdup (GMT->init.history[RG_id]); + + gmt_putdefaults (GMT, NULL); /* Finalize the gmt.conf file with settings that will apply to all panels in the subplot */ } else if (Ctrl->In.mode == SUBPLOT_SET) { /* SUBPLOT_SET */ char legend_justification[4] = {""}, pen[GMT_LEN32] = {""}, fill[GMT_LEN32] = {""}, off[GMT_LEN32] = {""}; From c42796f216b6d73d70cb4c260988500e4d60a29a Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Fri, 29 Jan 2021 16:46:44 -1000 Subject: [PATCH 067/109] Fix delayed get_scale calls --- src/psbasemap.c | 11 ++++++++++- src/pscoast.c | 11 ++++++++++- src/pslegend.c | 2 +- src/pswiggle.c | 11 ++++++++++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/psbasemap.c b/src/psbasemap.c index e4cd005a71d..f375fab4266 100644 --- a/src/psbasemap.c +++ b/src/psbasemap.c @@ -52,6 +52,7 @@ struct PSBASEMAP_CTRL { } F; struct PSBASEMAP_L { /* -L[g|j|n|x]+c[/]+w[e|f|M|n|k|u][+a][+f][+l[