MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / gmt_plotend

Function gmt_plotend

src/gmt_plot.c:9565–9657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9563}
9564
9565void gmt_plotend (struct GMT_CTRL *GMT) {
9566 unsigned int i;
9567 bool K_active = (GMT->current.setting.run_mode == GMT_MODERN) ? true : GMT->common.K.active;
9568 struct PSL_CTRL *PSL= GMT->PSL;
9569 PSL_endlayer (GMT->PSL);
9570 if (GMT->common.t.active) PSL_command (PSL, "1 1 /Normal PSL_transp\n"); /* Reset transparency to fully opaque, if required */
9571
9572 if (GMT->common.p.do_z_rotation) { /* Need a undo the rotation about z of the whole page */
9573 double x0 = 0.0, y0 = 0.0; /* Default is to rotate around plot origin */
9574 if (GMT->current.proj.z_project.view_given) { /* Rotation is about another z-axis than through the origin */
9575 x0 = GMT->current.proj.z_project.view_x;
9576 y0 = GMT->current.proj.z_project.view_y;
9577 }
9578 else if (GMT->current.proj.z_project.world_given) /* Rotation is about another lon/lat pole than the origin */
9579 gmt_geo_to_xy (GMT, GMT->current.proj.z_project.world_x, GMT->current.proj.z_project.world_y, &x0, &y0);
9580 GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Transrot: Unrotating plot by %g degrees about (%g, %g)\n", -GMT->common.p.z_rotation, x0, y0);
9581 PSL_comment (GMT->PSL, "Possibly translate then unrotate rotate whole page\n");
9582 PSL_setorigin (PSL, x0, y0, -GMT->common.p.z_rotation, PSL_FWD);
9583 PSL_setorigin (PSL, -x0, -y0, 0.0, PSL_FWD);
9584 }
9585
9586 if (GMT->current.setting.map_logo)
9587 gmtplot_timestamp (GMT, PSL, GMT->current.setting.map_logo_pos[GMT_X], GMT->current.setting.map_logo_pos[GMT_Y], GMT->current.setting.map_logo_justify, GMT->current.ps.map_logo_label);
9588
9589 /* Check expected change of clip level to achieved one. Update overall clip level. Check for pending clips. */
9590
9591 if (abs (GMT->current.ps.nclip) == PSL_ALL_CLIP) /* Special case where we reset all polygon clip levels */
9592 GMT->current.ps.clip_level = GMT->current.ps.nclip = PSL->current.nclip = 0;
9593 else
9594 GMT->current.ps.clip_level += GMT->current.ps.nclip;
9595
9596 if (GMT->current.ps.nclip != PSL->current.nclip)
9597 GMT_Report (GMT->parent, GMT_MSG_INFORMATION,
9598 "Module was expected to change clip level by %d, but clip level changed by %d\n", GMT->current.ps.nclip, PSL->current.nclip);
9599
9600 if (!K_active) {
9601 if (GMT->current.ps.clip_level > 0)
9602 GMT_Report (GMT->parent, GMT_MSG_WARNING, "%d external clip operations were not terminated!\n", GMT->current.ps.clip_level);
9603 if (GMT->current.ps.clip_level < 0)
9604 GMT_Report (GMT->parent, GMT_MSG_WARNING, "%d extra terminations of external clip operations!\n", -GMT->current.ps.clip_level);
9605 GMT->current.ps.clip_level = 0; /* Reset to zero, so it will no longer show up in gmt.history */
9606 }
9607 for (i = 0; i < 3; i++) gmt_M_str_free (GMT->current.map.frame.axis[i].file_custom);
9608 PSL_endplot (PSL, !K_active);
9609
9610 if (GMT->current.setting.run_mode == GMT_MODERN) { /* Reset file pointer and name */
9611 struct stat buf;
9612 char file[PATH_MAX] = {""};
9613 FILE *fp = NULL;
9614 if (stat (GMT->current.ps.filename, &buf))
9615 GMT_Report (GMT->parent, GMT_MSG_WARNING, "Could not determine size of file %s\n", GMT->current.ps.filename);
9616 else
9617 GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Current size of half-baked PS file %s = %" PRIuS ".\n", GMT->current.ps.filename, buf.st_size);
9618 GMT->current.ps.fp = NULL;
9619 GMT->current.ps.filename[0] = '\0';
9620 /* Write layer size to gmt.layers.<fig> in case of revert calls */
9621 snprintf (file, PATH_MAX, "%s/gmt.layers.%d", GMT->parent->gwf_dir, GMT->current.ps.figure);
9622 if ((fp = fopen (file, "a")) == NULL) {

Callers 15

GMT_pswiggleFunction · 0.85
GMT_pssolarFunction · 0.85
GMT_grdviewFunction · 0.85
GMT_psternaryFunction · 0.85
GMT_insetFunction · 0.85
GMT_gmtlogoFunction · 0.85
GMT_psmaskFunction · 0.85
GMT_pshistogramFunction · 0.85
GMT_pstextFunction · 0.85
GMT_pscoastFunction · 0.85
GMT_psscaleFunction · 0.85
GMT_grdimageFunction · 0.85

Calls 15

PSL_endlayerFunction · 0.85
PSL_commandFunction · 0.85
gmt_geo_to_xyFunction · 0.85
GMT_ReportFunction · 0.85
PSL_commentFunction · 0.85
PSL_setoriginFunction · 0.85
gmtplot_timestampFunction · 0.85
PSL_endplotFunction · 0.85
gmt_get_postscriptFunction · 0.85
gmt_get_P_hiddenFunction · 0.85
strdupFunction · 0.85
PSL_getplotFunction · 0.85

Tested by

no test coverage detected