Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fcd7956
Add option to not create a temporary EPS file but instead edit the or…
joa-quim Mar 27, 2024
0634753
Apparently unix doesn't deal with gmt_M_toc(GMT); in the Return macro.
joa-quim Mar 27, 2024
b409cff
Try gmt_M_toc(GMT,"") again.
joa-quim Mar 27, 2024
f571a71
f
joa-quim Mar 27, 2024
76e0140
Fix dumb error in typing the "/dev/null" file name.
joa-quim Apr 1, 2024
b680e9c
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jul 22, 2024
724b01a
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 4, 2024
330e078
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 13, 2024
cdd0a17
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 14, 2024
946b9de
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 17, 2024
441dd11
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 18, 2024
29f0aa5
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 19, 2024
7e2a38d
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 20, 2024
077dbb2
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 22, 2024
f18c1c0
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 26, 2024
b436425
Merge branch 'master' into psconvert-no-file-dup
joa-quim Nov 28, 2024
53beb8e
Make the -! option active by default if GMT is build with /DPS_NO_DUP
joa-quim Nov 29, 2024
86de8d4
Some rework on how the no-dup is set. Now it is a compile time parame…
joa-quim Nov 30, 2024
f572a56
Just force the build and CI again.
joa-quim Dec 1, 2024
0e5bb4b
Fix logic on when not scan the first ~700 lines.
joa-quim Dec 4, 2024
f50322c
One more fix when looking for transparency and GeoTIFF production.
joa-quim Dec 13, 2024
b07866b
Merge branch 'master' into psconvert-no-file-dup
joa-quim Dec 16, 2024
30a0941
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jan 1, 2025
ed88283
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jan 3, 2025
2520d94
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jan 4, 2025
4e5a2c4
Be more specific on the -N variations that disable -!
joa-quim Jan 5, 2025
ae5b221
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jan 5, 2025
b23a985
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jan 22, 2025
6806636
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jan 27, 2025
eb46b7c
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jan 30, 2025
c7a3c3b
Merge branch 'master' into psconvert-no-file-dup
joa-quim Feb 12, 2025
6dbd384
Merge branch 'master' into psconvert-no-file-dup
joa-quim Feb 12, 2025
246d54e
Merge branch 'master' into psconvert-no-file-dup
joa-quim Mar 10, 2025
d8cf120
Merge branch 'master' into psconvert-no-file-dup
joa-quim Mar 25, 2025
9807bba
Merge branch 'master' into psconvert-no-file-dup
joa-quim Mar 27, 2025
2ecc7c8
Merge branch 'master' into psconvert-no-file-dup
joa-quim Apr 11, 2025
a812460
Merge branch 'master' into psconvert-no-file-dup
joa-quim Apr 26, 2025
a71ba5b
Merge branch 'master' into psconvert-no-file-dup
joa-quim May 16, 2025
6e307bc
Merge branch 'master' into psconvert-no-file-dup
joa-quim May 16, 2025
50baea8
Merge branch 'master' into psconvert-no-file-dup
joa-quim May 28, 2025
7941eeb
Merge branch 'master' into psconvert-no-file-dup
joa-quim May 30, 2025
c303fe9
Fix the case where psimage had imported another PS file.
joa-quim Jun 1, 2025
9088b49
When -Tp (keep postscript) do not remove the 'setpagedevice' lines.
joa-quim Jun 2, 2025
b016ce3
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jun 2, 2025
dbfe0ea
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jun 3, 2025
2e00aef
Let it now also be able to process PS files and remain as PS
joa-quim Jun 4, 2025
34431a1
Add the possibility of also cropping a pure PS file (Classic mode only).
joa-quim Jun 4, 2025
cd46469
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jun 10, 2025
c87b373
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jun 11, 2025
7e0e45d
Merge branch 'master' into psconvert-no-file-dup
joa-quim Jun 11, 2025
4beadeb
Fix the situation where Landscape files worked well on first run but …
joa-quim Jun 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/gmt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -19567,7 +19567,7 @@ GMT_LOCAL int gmtinit_process_figures (struct GMTAPI_CTRL *API, char *show) {
char pen[GMT_LEN32] = {""}, fill[GMT_LEN32] = {""}, off[GMT_LEN32] = {""}, device_extra[GMT_LEN8] = {""}, *do_gray[2] = {"", "+m"};
char *copy = NULL, *ptr = NULL, *format = NULL, *c = NULL;
struct GMT_FIGURE *fig = NULL;
bool not_PS, auto_size;
bool not_PS = true, auto_size;
int error, k, f, nf, n_figs, n_orig, gcode[GMT_LEN16], jpeg_quality = GMT_JPEG_DEF_QUALITY, monochrome = 0;
unsigned int pos = 0;
double legend_width = 0.0, legend_scale = 1.0;
Expand All @@ -19581,6 +19581,7 @@ GMT_LOCAL int gmtinit_process_figures (struct GMTAPI_CTRL *API, char *show) {
GMT_Report (API, GMT_MSG_ERROR, "Unable to open gmt.figures for reading\n");
return GMT_ERROR_ON_FOPEN;
}

if ((n_figs = gmtinit_read_figures (API->GMT, 2, &fig)) == GMT_NOTSET) { /* Auto-insert the hidden gmt_0.ps- file which may not have been used */
GMT_Report (API, GMT_MSG_ERROR, "Unable to open gmt.figures for reading\n");
return GMT_ERROR_ON_FOPEN;
Expand All @@ -19591,6 +19592,7 @@ GMT_LOCAL int gmtinit_process_figures (struct GMTAPI_CTRL *API, char *show) {
for (k = 0; k < n_figs; k++) {
if (!strcmp (fig[k].prefix, "-")) continue; /* Unnamed outputs are left for manual psconvert calls by external APIs */
GMT_Report (API, GMT_MSG_INFORMATION, "Processing GMT figure #%d [%s %s %s]\n", fig[k].ID, fig[k].prefix, fig[k].formats, fig[k].options);

/* Go through the format list and build array for -T arguments */
nf = gmtinit_get_graphics_formats (API->GMT, fig[k].formats, fmt, gcode, &jpeg_quality, &monochrome);
if (n_orig && k) { /* Specified one or more figs via gmt figure so must switch to the current figure and update the history */
Expand All @@ -19601,22 +19603,27 @@ GMT_LOCAL int gmtinit_process_figures (struct GMTAPI_CTRL *API, char *show) {
}
gmtinit_get_history (API->GMT); /* Make sure we have the latest history for this figure */
}

copy = strdup (fig[k].formats); ptr = copy;
for (f = 0; f < nf; f++) { /* Loop over all desired output formats */
format = strsep (&ptr, ","); /* Name of next format as user specified it */
device_extra[0] = '\0'; /* Reset device arguments */
if (fmt[f] == 'j' && jpeg_quality != GMT_JPEG_DEF_QUALITY)
sprintf (device_extra, "+q%d", jpeg_quality); /* Need to pass quality modifier */

mark = '-'; /* This is the last char in extension for a half-baked GMT PostScript file */
snprintf (cmd, GMT_BUFSIZ, "%s/gmt_%d.ps%c", API->gwf_dir, fig[k].ID, mark); /* Check if the file exists */

if (access (cmd, F_OK)) { /* No such file, check if the fully baked file is there instead */
mark = '+'; /* This is the last char in extension for a fully-baked GMT PostScript file */
snprintf (cmd, GMT_BUFSIZ, "%s/gmt_%d.ps%c", API->gwf_dir, fig[k].ID, mark); /* Check if the file exists */
if (access (cmd, F_OK)) { /* No such file ether, give up; warn if a fig set via gmt figure (k > 0) and it is not the movie_background case which may not have a plot to go with it */
if (k && strcmp (fig[k].prefix, "movie_background")) GMT_Report (API, GMT_MSG_WARNING, "Figure # %d (%s) was registered but no matching PostScript-|+ file found - skipping\n", fig[k].ID, fig[k].prefix);
if (k && strcmp (fig[k].prefix, "movie_background"))
GMT_Report (API, GMT_MSG_WARNING, "Figure # %d (%s) was registered but no matching PostScript-|+ file found - skipping\n", fig[k].ID, fig[k].prefix);
continue;
}
}

if (gmt_get_legend_info (API, &legend_width, &legend_scale, legend_justification, pen, fill, off)) { /* Unplaced legend file */
/* Default to white legend with 1p frame offset 0.2 cm from selected justification point [TR] */
bool active = API->GMT->common.l.active; /* Must temporarily turn off -l since should not be passed to legend and plot */
Expand All @@ -19641,11 +19648,14 @@ GMT_LOCAL int gmtinit_process_figures (struct GMTAPI_CTRL *API, char *show) {
}
else /* Place products in current directory */
snprintf (cmd, GMT_BUFSIZ, "'%s/gmt_%d.ps-' -T%c%s%s -F%s", API->gwf_dir, fig[k].ID, fmt[f], device_extra, do_gray[monochrome], fig[k].prefix);

gmt_filename_get (fig[k].prefix);
not_PS = (fmt[f] != 'p'); /* Do not add convert options if plain PS */
/* Append psconvert optional settings */
auto_size = gmtinit_check_if_autosize (API, fig[k].ID); /* Determine if the PostScript file has auto size (32767x32767) enabled */
/* Next line is risky. See comments on line #9014 of gmt_plot.c/gmt_plotinit() */
if (!auto_size) not_PS = (fmt[f] != 'p'); /* Do not add convert options if plain PS and a explicit paper size was set. */

dir[0] = '\0'; /* No directory via D<dir> convert option */
auto_size = gmtinit_check_if_autosize (API, fig[k].ID); /* Determine if the PostScript file has auto size enabled */
if (fig[k].options[0]) { /* Append figure-specific psconvert settings */
pos = 0; /* Reset position counter */
while ((gmt_strtok (fig[k].options, ",", &pos, p))) {
Expand Down Expand Up @@ -19678,13 +19688,15 @@ GMT_LOCAL int gmtinit_process_figures (struct GMTAPI_CTRL *API, char *show) {
}
else if (not_PS && auto_size) /* No specific settings but must always add -A if not PostScript unless when media size is given */
strcat (cmd, " -A");

GMT_Report (API, GMT_MSG_DEBUG, "psconvert: %s\n", cmd);
if ((error = GMT_Call_Module (API, "psconvert", GMT_MODULE_CMD, cmd))) {
GMT_Report (API, GMT_MSG_ERROR, "Failed to call psconvert\n");
gmt_M_free (API->GMT, fig);
gmt_M_str_free (copy);
return error;
}

if (!strncmp (format, "jpeg", 4U) || !strncmp (format, "tiff", 4U)) { /* Must rename file to have .jpeg or .tiff extensions */
/* Since psconvert cannot tell from j and t if the extensions should be 3 or 4 characters... */
char old_name[PATH_MAX] = {""}, new_name[PATH_MAX] = {""}, ext[GMT_LEN8] = {""};
Expand Down
10 changes: 8 additions & 2 deletions src/gmt_plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -8995,7 +8995,7 @@ struct PSL_CTRL *gmt_plotinit (struct GMT_CTRL *GMT, struct GMT_OPTION *options)
GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Running in PS mode %s\n", ps_mode[GMT->current.setting.run_mode]);
if (GMT->current.setting.run_mode == GMT_MODERN) { /* Write PS to hidden gmt_#.ps- file. No -O -K allowed */
char *verb[2] = {"Create", "Append to"};
bool wants_PS;
bool wants_PS = false;
double paper_margin = GMT_PAPER_MARGIN_AUTO;

if (gmtlib_fixed_paper_size (GMT->parent)) { /* Must honor paper size and regular margin */
Expand All @@ -9014,9 +9014,15 @@ struct PSL_CTRL *gmt_plotinit (struct GMT_CTRL *GMT, struct GMT_OPTION *options)
GMT->parent->error = GMT_ERROR_ON_FOPEN;
return NULL;
}
O_active = (k) ? true : false; /* -O is determined by presence or absence of hidden PS file */

/* Determine paper size */
wants_PS = gmtlib_fig_is_ps (GMT); /* True if we have requested a PostScript output format */
/* Next line would let modern mode use "auto" paper size (the 11 m wall-size) to correctly crop also a PS
file (currently it sets the A4 size as default), but that breaks all modern mode tests. It also terribly
slows down the tests when the -! option is built in to be the default (The /DPS_NO_DUP) */
//if (!auto_media) wants_PS = gmtlib_fig_is_ps (GMT); /* True if we have requested a PostScript output AND set paper size. */

O_active = (k) ? true : false; /* -O is determined by presence or absence of hidden PS file */
if (wants_PS && !O_active) { /* Requesting a new PostScript file in modern mode */
if (auto_media) { /* Cannot use "auto" if requesting a PostScript file */
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "You should specify a paper size when requesting a PostScript file.\n");
Expand Down
6 changes: 4 additions & 2 deletions src/postscriptlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -4742,9 +4742,11 @@ int PSL_beginplot (struct PSL_CTRL *PSL, FILE *fp, int orientation, int overlay,
PSL_command (PSL, "PSLevel 1 gt { << /WhiteIsOpaque true >> setpagedevice } if\n");
if (manual_feed) /* Manual media feed requested */
PSL_command (PSL, "PSLevel 1 gt { << /ManualFeed true >> setpagedevice } if\n");
else if (PSL->internal.p_width > 0.0 && PSL->internal.p_height > 0.0) /* Specific media selected */
PSL_command (PSL, "PSLevel 1 gt { << /PageSize [%.12g %.12g] /ImagingBBox null >> setpagedevice } if \n",
else if (PSL->internal.p_width > 0.0 && PSL->internal.p_height > 0.0) { /* Specific media selected */
PSL_command (PSL, "PSLevel 1 gt { << /PageSize [%.12g %.12g] /ImagingBBox null >> setpagedevice } if \n",
PSL->internal.p_width, PSL->internal.p_height); /* Leave some space for eventual PageSize change by psconvert */
PSL_command (PSL, "%% \n"); /* Space for eventual rot/translation by psconvert*/
}
if (PSL->init.copies > 1) PSL_command (PSL, "/#copies %d def\n", PSL->init.copies);
PSL_command (PSL, "%%%%EndSetup\n\n");

Expand Down
Loading
Loading