ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/tgraph.c
(Generate patch)

Comparing ray/src/meta/tgraph.c (file contents):
Revision 1.1 by greg, Sat Feb 22 02:07:26 2003 UTC vs.
Revision 1.4 by schorsch, Fri Aug 1 14:14:24 2003 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   *   1/20/85
8   */
9  
10 #include  "tgraph.h"
11
10   #include  <ctype.h>
11 + #include  <string.h>
12  
13 + #include  "tgraph.h"
14  
15 +
16   #define  isfloat(a)  (isdigit(a) || (a) == '-' || (a) == '.' ||  \
17                       (a) == 'E' || (a) == '+' || (a) == 'e')
18  
# Line 47 | Line 48 | char  *s;
48   short  userror = 0;
49   int  i;
50  
51 < if (s[0] == '-')
51 > if (s[0] == '-') {
52  
53      switch(s[1])  {
54      
# Line 91 | Line 92 | char  *s;
92            userror = *sp;
93            break;
94         }
95 < else
95 > } else {
96  
97      switch (s[1])  {
98  
# Line 110 | Line 111 | char  *s;
111               usecurve[*sp-'@'] = 1;
112            userror = *sp;
113         }
114 +    }
115  
116   if (userror)
117      error(USER, "options are [-sSYMRAD][-g][-lx][-ly][-p{dr}][-xXMIN][+xXMAX][-yYMIN][+yYMAX][-C..|+C..]");
# Line 180 | Line 182 | int  flag;
182   char   *format, stemp[32];
183  
184                                          /* set limits */
185 < if (polar)
185 > if (polar) {
186      if (xmax-xmin < ymax-ymin)                  /* null aspect for polar */
187          xmax = xmin + ymax-ymin;
188      else
189          ymax = ymin + xmax-xmin;
190 < else {
191 <    if (xmnset > -FHUGE)
190 > } else {
191 >    if (xmnset > -FHUGE) {
192         if (logx) {
193            if (xmnset > FTINY)
194               xmin = log10(xmnset);
195 <          }
194 <       else
195 >          } else
196            xmin = xmnset;
197 <    if (xmxset < FHUGE)
197 >        }
198 >    if (xmxset < FHUGE) {
199         if (logx) {
200            if (xmxset > FTINY)
201               xmax = log10(xmxset);
202 <          }
201 <       else
202 >          } else
203            xmax = xmxset;
204 <    if (ymnset > -FHUGE)
204 >        }
205 >    if (ymnset > -FHUGE) {
206         if (logy) {
207            if (ymnset > FTINY)
208               ymin = log10(ymnset);
209 <          }
208 <       else
209 >          } else
210            ymin = ymnset;
211 <    if (ymxset < FHUGE)
211 >        }
212 >    if (ymxset < FHUGE) {
213         if (logy) {
214            if (ymxset > FTINY)
215               ymax = log10(ymxset);
216 <          }
215 <       else
216 >          } else
217            ymax = ymxset;
218 +        }
219      }
220                                          /* set step */
221   if (logx) {
# Line 233 | Line 235 | int  flag;
235   xsize = xmax - xmin;
236   ysize = ymax - ymin;
237  
238 < if (polar)                             /* null aspect again */
238 > if (polar) {                           /* null aspect again */
239       if (xsize < ysize)
240          xmax = xmin + (xsize = ysize);
241       else
242          ymax = ymin + (ysize = xsize);
243 + }
244  
245   if (xmin > 0.0)
246      xorg = XBEG;
# Line 259 | Line 262 | int  flag;
262   if (flag & ORIGIN)
263      plseg(010, XBEG, yorg, XBEG+XSIZ-1, yorg);
264  
262 #if  CPM || MAC
263 if (xstep > 1.0)
264    format = "%5.0f";
265 else
266    format = "%5.3f";
267 #else
265   format = "%5g";
269 #endif
266   if (logx)
267      format = "1e%-3.0f";
268  
269   for (pos = xmin; pos < xmax+xstep/2; pos += xstep) {
270 <    if (flag & XTICS)
270 >    if (flag & XTICS) {
271         if (polar)
272            plseg(010, XCONV(pos), yorg-TSIZ/2, XCONV(pos), yorg+TSIZ/2);
273         else {
274            plseg(010, XCONV(pos), YBEG, XCONV(pos), YBEG-TSIZ);
275            plseg(010, XCONV(pos), YBEG+YSIZ-1, XCONV(pos), YBEG+YSIZ-1+TSIZ);
276            }
277 +        }
278      if (flag & XNUMS) {
279         sprintf(stemp, format, pos);
280         if (polar)
# Line 298 | Line 295 | int  flag;
295   if (flag & ORIGIN)
296      plseg(010, xorg, YBEG, xorg, YBEG+YSIZ-1);
297  
301 #if  CPM || MAC
302 if (ystep > 1.0)
303    format = "%5.0f";
304 else
305    format = "%5.3f";
306 #else
298   format = "%5g";
308 #endif
299   if (logy)
300      format = "1e%-3.0f";
301  
302   for (pos = ymin; pos < ymax+ystep/2; pos += ystep) {
303 <    if (flag & YTICS)
303 >    if (flag & YTICS) {
304         if (polar)
305            plseg(010, xorg-TSIZ/2, YCONV(pos), xorg+TSIZ/2, YCONV(pos));
306         else {
307            plseg(010, XBEG, YCONV(pos), XBEG-TSIZ, YCONV(pos));
308            plseg(010, XBEG+XSIZ-1, YCONV(pos), XBEG+XSIZ-1+TSIZ, YCONV(pos));
309            }
310 +        }
311      if (flag & YNUMS) {
312         sprintf(stemp, format, pos);
313         if (polar)
# Line 515 | Line 506 | register char  *s;
506      register char  *rval = NULL;
507  
508      for ( ; *s; s++)
509 <        if (*s == '"')
509 >        if (*s == '"') {
510              if (rval == NULL)
511                  rval = s+1;
512              else {
513                  *s = '\0';
514                  return(rval);
515              }
516 +        }
517      
518      return(NULL);
519   }
# Line 535 | Line 527 | char  *s;
527   double  *xp, *yp;
528  
529   {
538    char  *index();
530      double  sin(), cos();
531      int  oobounds = 0;
532      double  a;
533      register char  *cp;
534      
535 <    if ((cp = index(s, ',')) != NULL)
535 >    if ((cp = strchr(s, ',')) != NULL)
536          *cp = ' ';
537  
538      if (sscanf(s, "%lf %lf", xp, yp) != 2)
# Line 552 | Line 543 | double  *xp, *yp;
543      if (*yp < ymnset || *yp > ymxset)
544          oobounds++;
545  
546 <    if (logx)
546 >    if (logx) {
547          if (*xp < FTINY)
548              oobounds++;
549          else
550              *xp = log10(*xp);
551 +        }
552  
553 <    if (logy)
553 >    if (logy) {
554          if (*yp < FTINY)
555              oobounds++;
556          else
557              *yp = log10(*yp);
558 +        }
559  
560      if (polar) {
561          a = *xp;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines