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

Function PSL_endplot

src/postscriptlight.c:4533–4583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4531}
4532
4533int PSL_endplot (struct PSL_CTRL *PSL, int lastpage) {
4534 /* Finalizes the current plot layer; see PSL_endsession for terminating PSL session. */
4535
4536 if (PSL->init.runmode == 0) {
4537 psl_pattern_cleanup (PSL);
4538 memset (PSL->internal.pattern, 0, 2*PSL_N_PATTERNS*sizeof (struct PSL_PATTERN)); /* Reset all pattern info since the file is now closed */
4539 }
4540 PSL_setdash (PSL, NULL, 0.0);
4541 if (!PSL_eq (PSL->current.rgb[PSL_IS_STROKE][3], 0.0)) PSL_command (PSL, "1 1 /Normal PSL_transp\n");
4542
4543 if (lastpage) {
4544 PSL_command (PSL, "\ngrestore\n"); /* End encapsulation of main body for this plot */
4545 PSL_comment (PSL, "Run PSL movie label completion function, if defined\n");
4546 PSL_command (PSL, "PSL_movie_label_completion /PSL_movie_label_completion {} def\n"); /* Run then make it a null function */
4547 PSL_comment (PSL, "Run PSL movie progress indicator completion function, if defined\n");
4548 PSL_command (PSL, "PSL_movie_prog_indicator_completion /PSL_movie_prog_indicator_completion {} def\n"); /* Run then make it a null function */
4549 PSL_command (PSL, "%%PSL_Begin_Trailer\n");
4550 PSL_command (PSL, "%%%%PageTrailer\n");
4551 if (PSL->init.runmode) {
4552 psl_pattern_cleanup (PSL);
4553 memset (PSL->internal.pattern, 0, 2*PSL_N_PATTERNS*sizeof (struct PSL_PATTERN)); /* Reset all pattern info since the file is now closed */
4554 }
4555 PSL_comment (PSL, "Reset transformations and call showpage\n");
4556 PSL_command (PSL, "U\nshowpage\n");
4557 PSL_command (PSL, "\n%%%%Trailer\n");
4558 PSL_command (PSL, "\nend\n");
4559 PSL_command (PSL, "%%%%EOF\n");
4560 }
4561 else if (PSL->internal.origin[0] == 'a' || PSL->internal.origin[1] == 'a') { /* Restore the origin of the plotting */
4562 if (PSL->internal.comments) PSL_command (PSL, "%% Reset plot origin:\n");
4563 PSL_command (PSL, "%d %d TM\n", PSL->internal.origin[0] == 'a' ? -psl_iz(PSL, PSL->internal.offset[0]) : 0,
4564 PSL->internal.origin[1] == 'a' ? -psl_iz(PSL, PSL->internal.offset[1]) : 0);
4565 }
4566 if (PSL->internal.memory) { /* Finalize memory buffer allocation */
4567 memset (&PSL->internal.buffer[PSL->internal.n], 0, (PSL->internal.n_alloc-PSL->internal.n)*sizeof (char)); /* Wipe the unused stuff */
4568 PSL->internal.n_alloc = PSL->internal.n; /* Shrink allocated memory to what is needed to hold the PS */
4569 PSL->internal.buffer = PSL_memory (PSL, PSL->internal.buffer, PSL->internal.n_alloc, char);
4570 if (lastpage) PSL->internal.pmode |= 2; /* We provided a trailer */
4571 }
4572 else { /* Dealing with files or stdout */
4573 if (PSL->internal.fp != stdout && PSL->internal.call_level == 1) {
4574 fclose (PSL->internal.fp); /* Only level 1 can close the file (if not stdout) */
4575 PSL->internal.fp = NULL;
4576 }
4577 }
4578 PSL->internal.offset[0] = PSL->internal.prev_offset[0];
4579 PSL->internal.offset[1] = PSL->internal.prev_offset[1];
4580
4581 PSL->internal.call_level--; /* Done with this module call */
4582 return (PSL_NO_ERROR);
4583}
4584
4585char * PSL_getplot (struct PSL_CTRL *PSL) {
4586 /* Simply pass the plot back to caller */

Callers 4

gmt_plotendFunction · 0.85
PSL_endplot_Function · 0.85
mainFunction · 0.85
GMT_psconvertFunction · 0.85

Calls 5

psl_pattern_cleanupFunction · 0.85
PSL_setdashFunction · 0.85
PSL_commandFunction · 0.85
PSL_commentFunction · 0.85
psl_izFunction · 0.85

Tested by

no test coverage detected