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

Function gmtplot_prog_indicator_D

src/gmt_plot.c:8771–8828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8769}
8770
8771GMT_LOCAL void gmtplot_prog_indicator_D (struct GMT_CTRL *GMT, double x, double y, double t, double w, int justify, char *P1, char *P2, char *label, char kind, double fsize) {
8772 /* Place rounded line indicator with a single crossmark line and optional label.
8773 * If label is in percent then we strip off the percent and place it at end of line insteadl */
8774 int text_justify, just_p;
8775 char *p = NULL;
8776 double fx, fy, dy, dy2, xt, del_x = 0.0, del_y = 0.0, angle = 0.0, xp;
8777 struct GMT_PEN pen;
8778
8779 gmtplot_just_f_xy (justify, &fx, &fy);
8780 gmt_M_memset (&pen, 1, struct GMT_PEN);
8781 gmt_getpen (GMT, P2, &pen); /* Pen for the background fixed line */
8782 dy = pen.width / PSL_POINTS_PER_INCH; /* Pen width in inches */
8783 dy2 = dy / 2.0; /* Half pen-width */
8784 x += fx * (w + dy); y += fy * dy; /* Adjust center (x,y) depending on justification */
8785 xt = w * (t - 0.5); /* Location of label and tick along x-axis */
8786 w /= 2; /* From here on, w is half-length of fixed line */
8787 if (kind == 'D') { /* Want a label at the current crossmark */
8788 if (fsize == 0.0) fsize = 2.0 * dy * PSL_POINTS_PER_INCH; /* Set a scaled font size */
8789 if ((p = strchr (label, '%'))) p[0] = '\0'; /* Remove % here and add separately later */
8790 switch (justify) { /* Deal with justification of text and possibly rotation */
8791 case PSL_BL: case PSL_BC: case PSL_BR:
8792 text_justify = PSL_BC; del_y = dy; break;
8793 case PSL_TL: case PSL_TC: case PSL_TR: case PSL_MC:
8794 text_justify = PSL_TC; del_y = -dy; break;
8795 case PSL_ML: text_justify = PSL_ML; angle = 90.0; x -= w; del_y = -dy; break;
8796 case PSL_MR: text_justify = PSL_MR; angle = 90.0; x += w; del_y = +dy; break;
8797 default:
8798 text_justify = PSL_BC; del_y = dy; break;
8799 }
8800 if (p) { /* Got percentages; must plot it separately */
8801 if (justify == PSL_ML || justify == PSL_MR)
8802 just_p = PSL_BC, xp = w + dy;
8803 else {
8804 just_p = (justify % 4 == 3) ? PSL_MR : PSL_ML;
8805 xp = (just_p == PSL_MR) ? -dy-w : w+dy;
8806 }
8807 }
8808 }
8809 PSL_setorigin (GMT->PSL, x, y, angle, PSL_FWD); /* Origin is now mid-point of rounded line */
8810 if (kind == 'D') {
8811 PSL_plottext (GMT->PSL, xt+del_x, del_y, fsize, label, -angle, text_justify, 0);
8812 if (p) {
8813 PSL_plottext (GMT->PSL, xp, 0.0, fsize, "%", -angle, just_p, 0);
8814 p[0] = '%'; /* Restore it */
8815 }
8816 }
8817 PSL_command (GMT->PSL, "V\n"); /* Do a save/restore around the line cap change */
8818 gmt_setpen (GMT, &pen);
8819 PSL_setlinecap (GMT->PSL, PSL_ROUND_CAP); /* Want the rounded line effect */
8820 PSL_plotsegment (GMT->PSL, -w, 0.0, +w, 0.0); /* Draw thick rounded line */
8821 PSL_command (GMT->PSL, "U\n"); /* grestore to restore to whatever line cap was set to before */
8822 gmt_M_memset (&pen, 1, struct GMT_PEN); /* Wipe pen */
8823 gmt_getpen (GMT, P1, &pen); /* Get pen for crossmark */
8824 gmt_setpen (GMT, &pen);
8825 PSL_plotsegment (GMT->PSL, xt, -dy2, xt, dy2); /* Draw foreground crossmark at label time */
8826 PSL_setorigin (GMT->PSL, -x, -y, -angle, PSL_INV); /* Undo coordinate transformation */
8827 PSL_setlinecap (GMT->PSL, PSL_BUTT_CAP); /* Want the rounded line effect */
8828}

Callers 1

gmt_plotinitFunction · 0.85

Calls 8

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

Tested by

no test coverage detected