src/shstr.c

00001 
00006 /*
00007  *  PROGRAM NAME:  sh
00008  *
00009  *  (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES
00010  *  CORPORATION 12/1/2001.  ALL RIGHTS RESERVED.
00011  *
00012  *  Please refer to the LICENSE file in the top directory
00013  *
00014  *      author: Mike Henderson mhender@watson.ibm.com
00015  */
00016 
00017 static char *id="@(#) $Id: shstr.c,v 1.2 2006/08/17 19:28:17 mhender Exp $";
00018 
00019 #include <shInternal.h>
00020 
00023 int SHnstr=0;
00024 char **SHstr=(char**)NULL;
00025 int *SHxstr=(int*)NULL;
00026 int *SHystr=(int*)NULL;
00027 double *SHzstr=(double*)NULL;
00028 
00039 void shstr(float x,float y,float z,char *str)
00040  {
00041   float xx=0.;
00042   float yy=0.;
00043   float zz=0.;
00044 
00045   SHstr=(char**)realloc(SHstr,(SHnstr+1)*sizeof(char*));
00046   SHxstr=(int*)realloc(SHxstr,(SHnstr+1)*sizeof(int));
00047   SHystr=(int*)realloc(SHystr,(SHnstr+1)*sizeof(int));
00048   SHzstr=(double*)realloc(SHzstr,(SHnstr+1)*sizeof(double));
00049 
00050   shpers(&x,&y,&z,&xx,&yy,&zz);
00051 
00052   SHxstr[SHnstr]=xx*shMax+.5;
00053   SHystr[SHnstr]=yy*shMax+.5;
00054   SHzstr[SHnstr]=zz;
00055   SHstr[SHnstr]=(char*)malloc((strlen(str)+1)*sizeof(char));
00056   strcpy(SHstr[SHnstr],str);
00057   SHnstr++;
00058 
00059   return;
00060  }
00061 
00069 void shdoStrings(FILE *fid,float x,float y)
00070  {
00071   int i;
00072   int ix,iy;
00073 
00074   fprintf(fid,"initclip\n");
00075   fprintf(fid,"/Helvetica findfont %f scalefont setfont\n",20.*shIMax/1024);
00076   fprintf(fid,"0. setgray\n");
00077   for(i=0;i<SHnstr;i++)
00078    {
00079     ix=SHxstr[i]/x;
00080     iy=SHystr[i]/y;
00081     fflush(stdout);
00082     if((SHstr[i])[0]!='/')
00083       fprintf(fid,"%d %d moveto (%s) show\n",ix,iy,SHstr[i]);
00084      else
00085       fprintf(fid,"%s\n",SHstr[i]);
00086    }
00087   return;
00088  }
00089 
00093 void shfreeStrings()
00094  {
00095   int i;
00096 
00097   for(i=0;i<SHnstr;i++)
00098     if(SHstr[i]!=(char*)NULL)free(SHstr[i]);
00099   if(SHxstr!=(int*)NULL)free(SHxstr);
00100   if(SHystr!=(int*)NULL)free(SHystr);
00101   if(SHzstr!=(double*)NULL)free(SHzstr);
00102   
00103   return;
00104  }

Generated on Thu Aug 17 15:29:43 2006 for sh by  doxygen 1.4.6