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

Function gmt_contlabel_plot

src/gmt_plot.c:7966–8009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7964}
7965
7966void gmt_contlabel_plot (struct GMT_CTRL *GMT, struct GMT_CONTOUR *G) {
7967 unsigned int i, mode;
7968 bool no_labels;
7969 struct PSL_CTRL *PSL= GMT->PSL;
7970
7971 if (!G->n_segments) return; /* Northing to do here */
7972
7973 /* See if there are labels at all */
7974 for (i = 0, no_labels = true; i < G->n_segments && no_labels; i++)
7975 if (G->segment[i]->n_labels) no_labels = false;
7976
7977 if (!G->delay) PSL_command (GMT->PSL, "V\n"); /* Plotting something, so protect current graphics state */
7978
7979 if (G->debug) gmtplot_contlabel_debug (GMT, PSL, G); /* Debugging lines and points */
7980
7981 if (no_labels) { /* No labels, just draw lines; no clipping required */
7982 gmtplot_contlabel_drawlines (GMT, PSL, G, 0);
7983 PSL_command (GMT->PSL, "U\n"); /* Restore to where we were */
7984 return;
7985 }
7986
7987 PSL_settextmode (PSL, PSL_TXTMODE_MINUS); /* Replace hyphens with minus signs */
7988 gmt_setfont (GMT, &G->font_label);
7989
7990 if (G->must_clip) { /* Transparent boxes means we must set up plot text, then set up clip paths, then draw lines, then deactivate clipping */
7991 /* Place PSL variables, plot labels, set up clip paths, draw lines */
7992 mode = PSL_TXT_INIT | PSL_TXT_SHOW | PSL_TXT_CLIP_ON;
7993 if (G->draw) mode |= PSL_TXT_DRAW;
7994 if (!G->delay) mode |= PSL_TXT_CLIP_OFF; /* Also turn off clip path when done */
7995 gmtplot_contlabel_plotlabels (GMT, PSL, G, mode); /* Take the above actions */
7996 }
7997 else { /* Opaque text boxes */
7998 mode = PSL_TXT_INIT; /* Plot text */
7999 if (G->draw) mode |= PSL_TXT_DRAW; /* Draw lines */
8000 gmtplot_contlabel_plotlabels (GMT, PSL, G, mode); /* Place PSL variables and draw lines */
8001 mode = PSL_TXT_SHOW; /* Plot text */
8002 if (G->delay) mode |= PSL_TXT_CLIP_ON; /* Also turn on clip path after done */
8003 gmtplot_contlabel_plotlabels (GMT, PSL, G, mode); /* Plot labels and possibly turn on clipping if delay */
8004 }
8005 PSL_command (GMT->PSL, "[] 0 B\n"); /* Ensure no pen textures remain in effect */
8006 PSL_settextmode (PSL, PSL_TXTMODE_HYPHEN); /* Back to leave as is */
8007
8008 if (!G->delay) PSL_command (GMT->PSL, "U\n"); /* Restore to where we were */
8009}
8010
8011#if 0 // We have no current need for this anymore
8012GMT_LOCAL void gmtplot_wipe_substr(char *str1, char *str2) {

Callers 4

GMT_psxyFunction · 0.85
GMT_psxyzFunction · 0.85
GMT_grdcontourFunction · 0.85
GMT_pscontourFunction · 0.85

Calls 6

PSL_commandFunction · 0.85
gmtplot_contlabel_debugFunction · 0.85
PSL_settextmodeFunction · 0.85
gmt_setfontFunction · 0.85

Tested by

no test coverage detected