1 /* pwrit.f -- translated by f2c (version 19961017).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 /* #include "f2c.h" */
7 #include "coxplot.h"
8 
9 /* Common Block Declarations */
10 
11 /* get these structs from coxplot.h    [13 Aug 2021 rickr] */
12 #if 0
13 extern struct {
14     real xpgmin, ypgmin, xpgmax, ypgmax, xclbot, yclbot, xcltop, ycltop, xbot,
15 	     ybot, xtop, ytop, xmin, ymin, xmax, ymax;
16     integer ixcoor, iycoor;
17     real alphxx, betaxx, alphyy, betayy, tmajx, tminx, tmajy, tminy;
18     integer majrx, minrx, majry, minry, isizx, isizy;
19     real xphold, yphold;
20 } zzzplt_;
21 
22 extern struct {
23     real xphmax, yphmax;
24     integer ixpmax, iypmax;
25     real xpscal, ypscal;
26     integer iflip, nplotr;
27     char cfile[64];
28 } zzpltr_;
29 #endif
30 
31 #define zzzplt_1 zzzplt_
32 #define zzpltr_1 zzpltr_
33 
34 
35 
pwrit_(real * x,real * y,char * ch,integer * nch,integer * isiz,integer * ior,integer * icent,ftnlen ch_len)36 /* Subroutine */ int pwrit_(real *x, real *y, char *ch, integer *nch, integer
37 	*isiz, integer *ior, integer *icent, ftnlen ch_len)
38 {
39     /* System generated locals */
40     integer i__1;
41 
42     /* Local variables */
43     static integer i__, nchar;
44     static real width;
45     static integer isize;
46     static real ct, dx, dy, oor, st, xx, yy;
47     extern /* Subroutine */ int zzchar_(char *, real *, real *, real *, real *
48 	    , ftnlen), zzphys_(real *, real *);
49 
50 
51 /*  Additional options besides NCAR's choices: */
52 
53 /*    NCH < 0    ==> use absolute coordinates rather than user coords. */
54 /*                   [this is because the use of integer absolute   ] */
55 /*                   [coordinates is not implemented in this package] */
56 
57 /*    ABS(NCH) = 999 ==> find length of string by looking for a 0 byte. */
58 
59 /*    ICENT = -2 ==> (X,Y) is lower left corner of string to plot. */
60 
61 /* .......................................................................
62  */
63 
64 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
65  */
66 /*  Calculate character width in terms of 1/1000 of the x-width. */
67 
68 
69 /*  Internal Data for PLOTPAK */
70 
71     /* Parameter adjustments */
72     --ch;
73 
74     /* Function Body */
75     isize = *isiz;
76     if (isize <= 0) {
77 	isize = 8;
78     } else if (isize == 1) {
79 	isize = 12;
80     } else if (isize == 2) {
81 	isize = 16;
82     } else if (isize == 3) {
83 	isize = 24;
84     }
85 
86     width = isize * .001f * (zzzplt_1.xpgmax - zzzplt_1.xpgmin);
87 
88 /*  Rotation/scaling factors for digitization.  Include factor of 1/6 */
89 /*  to allow for digitization scale in ZZCHAR. */
90 
91     oor = *ior * .017453292f;
92     dx = width * cos(oor);
93     dy = width * sin(oor);
94     ct = dx * .1666667f;
95     st = dy * .1666667f;
96 
97 /*  Starting location for first character. */
98 
99     xx = *x;
100     yy = *y;
101     if (*nch > 0) {
102 	zzphys_(&xx, &yy);
103     }
104 
105 /*  Get no. of characters in string.  Special option 999 must be checked.
106 */
107 
108     nchar = abs(*nch);
109     if (nchar == 999) {
110 	i__1 = nchar;
111 	for (i__ = 1; i__ <= i__1; ++i__) {
112 	    if (*(unsigned char *)&ch[i__] == '\0') {
113 		goto L20;
114 	    }
115 /* L10: */
116 	}
117 L20:
118 	nchar = i__ - 1;
119     }
120 
121 /*  If centering option is not lower-left corner, must calculate */
122 /*  location of lower left corner. */
123 
124     if (*icent != -2) {
125 /*  Move from center of character down to bottom (aspect ratio = 7/6)
126 */
127 	xx += dy * .5833333f;
128 	yy -= dx * .5833333f;
129 	if (*icent == 0) {
130 	    xx -= nchar * .5f * dx;
131 	    yy -= nchar * .5f * dy;
132 	} else if (*icent == 1) {
133 	    xx -= nchar * dx;
134 	    yy -= nchar * dy;
135 	}
136     }
137 /* .......................................................................
138  */
139     i__1 = nchar;
140     for (i__ = 1; i__ <= i__1; ++i__) {
141 	zzchar_(ch + i__, &xx, &yy, &ct, &st, 1L);
142 	xx += dx;
143 	yy += dy;
144 /* L100: */
145     }
146 /* .......................................................................
147  */
148     zzzplt_1.xphold = xx;
149     zzzplt_1.yphold = yy;
150     return 0;
151 } /* pwrit_ */
152 
153