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

Function gmtplot_prog_indicator_E

src/gmt_plot.c:8830–8887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8828}
8829
8830GMT_LOCAL void gmtplot_prog_indicator_E (struct GMT_CTRL *GMT, double x, double y, double t, double w, int justify, char *P1, char *P2, char *label, char kind, double fsize) {
8831 /* Place solid line indicator with optional start/end labels */
8832 int text_justify, just_p;
8833 double fx, fy, dy, dy2, xt, xp, del_x = 0.0, del_y = 0.0, angle = 0.0;
8834 struct GMT_PEN pen;
8835
8836 gmtplot_just_f_xy (justify, &fx, &fy);
8837 gmt_M_memset (&pen, 1, struct GMT_PEN);
8838 gmt_getpen (GMT, P2, &pen); /* Pen for the background fixed line */
8839 dy = pen.width / PSL_POINTS_PER_INCH; /* Pen width in inches */
8840 dy2 = dy / 2.0; /* Half pen-width */
8841 x += fx * (w + dy2); y += fy * dy; /* Adjust center (x,y) depending on justification */
8842 xt = w * (t - 0.5); /* Point of current time on axis */
8843 w /= 2; /* From here on, w is half-length of fixed line length */
8844 if (kind == 'E') { /* Want a label at the current crossmark */
8845 if (fsize == 0.0) fsize = 2.0 * dy * PSL_POINTS_PER_INCH; /* Set a scaled font size */
8846 switch (justify) { /* Deal with justification of text and possibly rotation */
8847 case PSL_BL: case PSL_BC: case PSL_BR:
8848 text_justify = PSL_BC; del_y = dy; break;
8849 case PSL_TL: case PSL_TC: case PSL_TR: case PSL_MC:
8850 text_justify = PSL_TC; del_y = -dy; break;
8851 case PSL_ML: text_justify = PSL_ML; angle = 90.0; x -= w; del_y = -dy; break;
8852 case PSL_MR: text_justify = PSL_MR; angle = 90.0; x += w; del_y = +dy; break;
8853 default:
8854 text_justify = PSL_BC; del_y = dy; break;
8855 }
8856 }
8857 PSL_setorigin (GMT->PSL, x, y, angle, PSL_FWD); /* Origin is now mid-point of rounded line and we have possibly rotated 90 degrees */
8858 if (kind == 'E') { /* Place the two labels */
8859 char *c = strchr (label, ';'), *p = NULL;
8860 if (c) c[0] = '\0'; /* Chop of label at t == 1 and place the first at t == 0 */
8861 if ((p = strchr (label, '%'))) /* Watch for percentage sign; if found place 0 and add % to axis label */
8862 PSL_plottext (GMT->PSL, del_x-w, del_y, fsize, "0", -angle, text_justify, 0);
8863 else
8864 PSL_plottext (GMT->PSL, del_x-w, del_y, fsize, label, -angle, text_justify, 0);
8865 if ((p = strchr (&c[1], '%'))) /* Watch for percentage sign; if found place 100 and add % to axis label */
8866 PSL_plottext (GMT->PSL, del_x+w, del_y, fsize, "100", -angle, text_justify, 0);
8867 else
8868 PSL_plottext (GMT->PSL, del_x+w, del_y, fsize, &c[1], -angle, text_justify, 0);
8869 if (p) { /* Since we found percentage we add it as an axis label */
8870 if (justify == PSL_ML || justify == PSL_MR)
8871 just_p = PSL_BC, xp = w + dy;
8872 else {
8873 just_p = (justify % 4 == 3) ? PSL_MR : PSL_ML;
8874 xp = (just_p == PSL_MR) ? -dy-w : w+dy;
8875 }
8876 PSL_plottext (GMT->PSL, xp, 0.0, fsize, "%", -angle, just_p, 0);
8877 }
8878 c[0] = ';'; /* Restore the semi-colon separator */
8879 }
8880 gmt_setpen (GMT, &pen);
8881 PSL_plotsegment (GMT->PSL, -w, 0.0, +w, 0.0); /* Draw thick rounded line */
8882 gmt_M_memset (&pen, 1, struct GMT_PEN);
8883 gmt_getpen (GMT, P1, &pen); /* Pen for time-variable line */
8884 gmt_setpen (GMT, &pen);
8885 PSL_plotsegment (GMT->PSL, w, 0.0, xt, 0.0);
8886 PSL_setorigin (GMT->PSL, -x, -y, -angle, PSL_INV); /* Undo coordinate transformation */
8887}

Callers 1

gmt_plotinitFunction · 0.85

Calls 6

gmtplot_just_f_xyFunction · 0.85
gmt_getpenFunction · 0.85
PSL_setoriginFunction · 0.85
PSL_plottextFunction · 0.85
gmt_setpenFunction · 0.85
PSL_plotsegmentFunction · 0.85

Tested by

no test coverage detected