home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / disks / disk373.lzh / Multiplot / source / mplot_src / src.zoo / file.c < prev    next >
C/C++ Source or Header  |  1990-08-02  |  34KB  |  947 lines

  1. #include <graphics/display.h>
  2. #include <libraries/dosextens.h>
  3. #include <libraries/diskfont.h>
  4. #include <exec/exec.h>
  5. #include <intuition/intuitionbase.h>
  6. #include <graphics/regions.h>
  7. #include <devices/keymap.h>
  8. #include <stdio.h>
  9. #include <workbench/startup.h>
  10. #include <graphics/gfxmacros.h>
  11. #include <graphics/gfxbase.h>
  12. #include <math.h>
  13.  
  14. #include "diskicon.h"
  15. #include "struct.h"
  16. #include "plotlim.h"
  17. #include "ffp.h"
  18.  
  19. /*** PLOT TYPES ***/
  20. #define LINEPLOT 0
  21. #define POINTPLOT 1
  22. #define BOTHPLOT 2
  23. #define STEP 3
  24.  
  25. extern int MAXVERT;
  26. extern int MAXHORIZ;
  27. extern int CHARWIDTH;
  28. extern int CHARHEIGHT;
  29. extern struct TextFont *xf;
  30. extern struct TextFont *yf;
  31. extern struct TextFont *tf;
  32. extern struct TextFont *lf;
  33. extern int GetDat();
  34. extern void plot();
  35. extern struct Screen *screen;
  36. extern struct Window *window;
  37. extern int XMINP;      /* LMARGIN */
  38. extern int YMAXP;   /* MAXVERT - TMARGIN */
  39. extern int YMINP;    /* BMARGIN */
  40. extern int XMAXP;
  41.  
  42. #define QUIT 0
  43. #define GO 1
  44. extern int QuitFlag;
  45. extern long IconBase;
  46. extern FFP xtic[MAXTICS],ytic[MAXTICS];
  47. extern short xticp[MAXTICS],yticp[MAXTICS];
  48. extern char filename[150];
  49. extern struct RastPort *p;
  50. extern struct ViewPort *vp;
  51. extern struct TextBox *ExtraText;
  52.  
  53. #define P_X_TIC_SIZE X_TIC_SIZE*(P_YREG/MAXVERT)
  54. #define P_Y_TIC_SIZE Y_TIC_SIZE*(P_XREG/MAXHORIZ)
  55. #define P_ERR_DELIM ERR_DELIM*(P_XREG/MAXHORIZ)
  56.  
  57. #define P_CH_WID 115
  58. #define P_CH_HEI 100
  59.  
  60. int P_LMARGIN;
  61. int P_BMARGIN;
  62. int P_TMARGIN;
  63. int P_RMARGIN;
  64. int P_YREG;
  65. int P_XREG;
  66.  
  67. #define MCAD_ERR_DELIM ERR_DELIM*(
  68.  
  69. static FFP XScale, YScale, XOffset, YOffset;
  70. static FFP XFactor, YFactor;
  71.  
  72. void fWrtFFP(fp, ffpval)
  73. FILE *fp;
  74. FFP ffpval;
  75. {
  76.    fprintf(fp, "%d", (int)ffpval);
  77. }
  78.  
  79.  
  80. void WrtAxes(fp, Pict)
  81. FILE *fp;
  82. struct Pict *Pict;
  83. {
  84.    short n, tmpx, tmpy, i;
  85.    FFP *x, *y;
  86.    char tmpstr[20];
  87.    struct Plot *Plot;
  88.    struct TextBox *TempText;
  89.  
  90.    /*** DRAW TICS/GRID ***/
  91.    fprintf(fp,"SP2;");
  92.    x=Pict->Tics->x; y=Pict->Tics->y;
  93.    for (i=0; i < Pict->Tics->NX; i++) {
  94.       if (Pict->Grid==2) {              /* Plot Grid */
  95.          fprintf(fp,"PU"); fWrtFFP(fp,(XScale * (XOffset + x[i])));
  96.          fprintf(fp," %d;PD",P_BMARGIN);
  97.          fWrtFFP(fp,(XScale * (XOffset + x[i])));
  98.          fprintf(fp," %d;\n",P_YREG);
  99.       }
  100.       else {
  101.          if ((Pict->Grid==0)||(Pict->Grid==3)) {   /* Plot tics */
  102.            fprintf(fp,"PU"); fWrtFFP(fp,(XScale * (XOffset + x[i])));
  103.            fprintf(fp," %d;PD",P_BMARGIN);
  104.            fWrtFFP(fp,(XScale * (XOffset + x[i])));
  105.            fprintf(fp," %d;",P_BMARGIN + P_X_TIC_SIZE);
  106.            }
  107.          if (Pict->Grid==3) {
  108.            fprintf(fp,"PU"); fWrtFFP(fp,(XScale * (XOffset + x[i])));
  109.            fprintf(fp," %d;PD",P_YREG);
  110.            fWrtFFP(fp,(XScale * (XOffset + x[i])));
  111.            fprintf(fp," %d;\n",P_YREG - P_X_TIC_SIZE);
  112.            }
  113.       }
  114.    }
  115.    for (i=0; i < Pict->Tics->NY; i++) {
  116.       if (Pict->Grid==2) {
  117.          fprintf(fp,"PU%d ",P_LMARGIN);
  118.          fWrtFFP(fp,(YScale * (YOffset + y[i])));
  119.          fprintf(fp,"PD%d ",P_XREG);
  120.          fWrtFFP(fp,(YScale * (YOffset + y[i])));
  121.          fprintf(fp,";\n");
  122.       }
  123.       else {
  124.          if ((Pict->Grid==0)||(Pict->Grid==3)) {
  125.            fprintf(fp,"PU%d ",P_LMARGIN);
  126.            fWrtFFP(fp,(YScale * (YOffset + y[i])));
  127.            fprintf(fp,";PD%d ", P_LMARGIN + P_Y_TIC_SIZE);
  128.            fWrtFFP(fp,(YScale * (YOffset + y[i])));
  129.            fprintf(fp,";");
  130.            }
  131.          if (Pict->Grid==3) {
  132.            fprintf(fp,"PU%d ",P_XREG);
  133.            fWrtFFP(fp,(YScale * (YOffset + y[i])));
  134.            fprintf(fp,";PD%d ", P_XREG - P_Y_TIC_SIZE);
  135.            fWrtFFP(fp,(YScale * (YOffset + y[i])));
  136.            fprintf(fp,";\n");
  137.            }
  138.       }
  139.    }
  140.  
  141.    /*** DRAW BORDER ***/
  142.    if (Pict->Grid<5) {
  143.      fprintf(fp,"SP1;PU%d %d;",P_XREG,P_BMARGIN);
  144.      fprintf(fp,"PD%d %d %d %d",P_LMARGIN,P_BMARGIN,P_LMARGIN,P_YREG);
  145.      if (Pict->Grid>1) {
  146.        fprintf(fp," %d %d %d %d",P_XREG,P_YREG,P_XREG,P_BMARGIN);
  147.        if (Pict->RMargin) {fprintf(fp," %d %d %d %d %d %d",P_XREG+P_RMARGIN,P_BMARGIN,P_XREG+P_RMARGIN,P_YREG,P_XREG,P_YREG);}
  148.        }
  149.      fprintf(fp,";\n");
  150.    }
  151.  
  152.    /*** PRINT TIC VALUES ***/
  153.    if (lf) fprintf(fp,"SR%f %f;\n",(float)(lf->tf_XSize)*68.0/(float)MAXHORIZ,(float)(lf->tf_YSize)*60.0/(float)MAXVERT);
  154.    else fprintf(fp,"SR%f %f;\n",(float)CHARWIDTH*68.0/(float)MAXHORIZ,(float)CHARHEIGHT*60/MAXVERT);
  155.    if ((Pict->Grid==0)||(Pict->Grid==2)||(Pict->Grid==3)) {
  156.      fprintf(fp,"SP1;");
  157.      for (i=0; i < Pict->Tics->NX; i++) {
  158.         n=GetString(&tmpstr,Pict->Tics->x[i]);
  159.         tmpx = (short)((XScale * (XOffset + Pict->Tics->x[i])));
  160.         if (lf) tmpx -= (((n+1)/2)-.5) * (short)(lf->tf_XSize)*10000/MAXHORIZ;
  161.         else    tmpx -= (((n+1)/2)-.5) * CHARWIDTH*10000/MAXHORIZ;
  162.         if (lf) tmpy = P_BMARGIN - (2*(short)(lf->tf_YSize)*10000/MAXVERT) +1;
  163.         else    tmpy = P_BMARGIN - (2*CHARHEIGHT*10000/MAXVERT) +1;
  164.         fprintf(fp, "PU%d %d;", tmpx,tmpy);
  165.         fprintf(fp,"LB%s\003;\n", tmpstr);
  166.      }
  167.    }
  168.    if ((Pict->Grid==0)||(Pict->Grid==2)||(Pict->Grid==3)) {
  169.      for (i=0; i < Pict->Tics->NY; i++) {
  170.         n=GetString(&tmpstr,Pict->Tics->y[i]);
  171.         tmpy = (short)((YScale * (YOffset + Pict->Tics->y[i])));
  172.         if (lf) tmpy -=  (short)(lf->tf_YSize)*10000/MAXVERT/2;
  173.         else    tmpy -=  CHARHEIGHT*10000/MAXVERT/2;
  174.         if (lf) tmpx = P_LMARGIN-( (n+1) * (short)(lf->tf_XSize)*10000 / MAXHORIZ);
  175.         else    tmpx = P_LMARGIN-( (n+1) * CHARWIDTH*10000 / MAXHORIZ);
  176.         fprintf(fp, "PU%d %d;",tmpx, tmpy);
  177.         fprintf(fp,"LB%s\003;\n", tmpstr);
  178.      }
  179.    }
  180.  
  181.    /*** WRITE X LABEL ***/
  182.    if (xf) fprintf(fp,"SR%f %f;\n",(float)(xf->tf_XSize)*68.0/(float)MAXHORIZ,(float)(xf->tf_YSize)*60/MAXVERT);
  183.    else fprintf(fp,"SR%f %f;\n",(float)CHARWIDTH*68.0/(float)MAXHORIZ,(float)CHARHEIGHT*60/MAXVERT);
  184.    if (strlen(Pict->XLabel->String)){
  185.       tmpx = P_LMARGIN+(P_XREG-P_LMARGIN)/2;
  186.       if (xf) tmpx = tmpx - strlen(Pict->XLabel->String)*(short)(xf->tf_XSize)*10000/MAXHORIZ/2;
  187.       else tmpx = tmpx - strlen(Pict->XLabel->String) * CHARWIDTH*10000/MAXHORIZ/2;
  188.       if (lf) tmpy = P_BMARGIN - (4*(short)(lf->tf_YSize)*10000/MAXVERT) +1;
  189.       else    tmpy = P_BMARGIN - (4*CHARHEIGHT*10000/MAXVERT) +1;
  190.       fprintf(fp, "PU%d %d;", tmpx,tmpy);
  191.       fprintf(fp,"LB%s\003;\n", Pict->XLabel->String);
  192.    }
  193.  
  194.    /*** WRITE LEGEND ***/
  195.    if (lf) fprintf(fp,"SR%f %f;\n",(float)(lf->tf_XSize)*68.0/(float)MAXHORIZ,(float)(lf->tf_YSize)*60/MAXVERT);
  196.    else fprintf(fp,"SR%f %f;\n",(float)CHARWIDTH*68.0/(float)MAXHORIZ,(float)CHARHEIGHT*60/MAXVERT);
  197.    Plot=Pict->Plot;
  198.    while (Plot)
  199.      {
  200.          if ((Plot->Enabled)&&(strlen(Plot->Legend->String)))
  201.            {
  202.               fprintf(fp, "PU");
  203.               fWrtFFP(fp, (FFP)(P_LMARGIN+(Plot->Legend->x-XMINP)*XFactor +500));
  204.               fprintf(fp," ");
  205.               if (lf) fWrtFFP(fp, (FFP)(P_BMARGIN+(Plot->Legend->y-YMINP)*YFactor-(short)(lf->tf_YSize)*10000/MAXVERT/2));
  206.               else fWrtFFP(fp, (FFP)(P_BMARGIN+(Plot->Legend->y-YMINP)*YFactor-CHARHEIGHT*10000/MAXVERT/2));
  207.               fprintf(fp,"; LB%s\003;\n", Plot->Legend->String);
  208.             }
  209.          while (Plot->Continued) Plot=Plot->NextPlot;
  210.          Plot=Plot->NextPlot;
  211.      }
  212.  
  213.     /*** WRITE EXTRA TEXT ***/
  214.     TempText=ExtraText;
  215.     while (TempText)
  216.       {
  217.           fprintf(fp, "PU");
  218.           fWrtFFP(fp, (FFP)(P_LMARGIN+(TempText->x-XMINP)*XFactor +100));
  219.           fprintf(fp," ");
  220.           if (lf) fWrtFFP(fp, (FFP)(P_BMARGIN+(TempText->y-YMINP)*YFactor-(short)(lf->tf_YSize)*10000/MAXVERT/2));
  221.           else    fWrtFFP(fp, (FFP)(P_BMARGIN+(TempText->y-YMINP)*YFactor-CHARHEIGHT*10000/MAXVERT/2));
  222.           fprintf(fp,"; LB%s\003", TempText->String);
  223.           TempText=TempText->NextText;
  224.       }
  225.  
  226.    /*** WRITE TITLE ***/
  227.    if (tf) fprintf(fp,"SR%f %f;\n",(float)(tf->tf_XSize)*68.0/(float)MAXHORIZ,(float)(tf->tf_YSize)*60/MAXVERT);
  228.    else fprintf(fp,"SR%f %f;\n",(float)CHARWIDTH*68.0/(float)MAXHORIZ,(float)CHARHEIGHT*60/MAXVERT);
  229.    if (strlen(Pict->Title->String)) {
  230.       tmpx = 10000/2;
  231.       if (tf) tmpx -= strlen(Pict->Title) * (short)(tf->tf_XSize)*10000/MAXHORIZ/2;
  232.       else tmpx -= strlen(Pict->Title) * CHARWIDTH*10000/MAXHORIZ/2;
  233.       if (tf) tmpy= P_YREG + (short)(tf->tf_YSize)*10000/MAXVERT - 1;
  234.       else    tmpy= P_YREG + CHARHEIGHT*10000/MAXVERT - 1;
  235.       fprintf(fp, "PU%d %d;", tmpx,tmpy);
  236.       fprintf(fp,"LB%s\003;\n", Pict->Title->String);
  237.    }
  238.  
  239.    /*** WRITE YLABEL ***/
  240.    if (strlen(Pict->YLabel->String)) {
  241.       if (yf) fprintf(fp,"SR%f %f;\n",(float)(yf->tf_XSize)*86/MAXHORIZ,(float)(yf->tf_YSize)*43/MAXVERT);
  242.       else fprintf(fp,"SR%f %f;\n",(float)CHARWIDTH*86/MAXHORIZ,(float)CHARHEIGHT*43/MAXVERT);
  243.       tmpx = 1;
  244.       tmpy= P_BMARGIN+(P_YREG-P_BMARGIN)/2;
  245.       if (yf) tmpy -= strlen(Pict->YLabel->String) * (short)(yf->tf_XSize)*10000/MAXVERT/2;
  246.       else tmpy -= strlen(Pict->YLabel->String) * CHARWIDTH*10000/MAXVERT/2;
  247.       fprintf(fp, "DR0,1; PU%d %d;", tmpx,tmpy);
  248.       fprintf(fp,"LB%s\003", Pict->YLabel->String);
  249.    }
  250.  
  251. }
  252.  
  253. extern USHORT chip WaitSprite[];
  254. extern char *stpchr();
  255.  
  256. WrtPlt(Pict,Dest)
  257. USHORT Dest;
  258. struct Pict *Pict;
  259. {
  260. struct Process  *OurTask;
  261. struct Window   *old_pr_WindowPtr;
  262. FILE *fp;
  263. short i,n=3;
  264. struct Plot *Plot, *TempPlot;
  265. FFP *x, *y, *e, tempx1, tempx2, tempy1, tempy2;
  266. short xptsiz, yptsiz;
  267. static char plotname[150], def_drive[150]="PLT:", def_path[100], def_node[30],def_extn[20];
  268. static char PlotNum = 0;
  269. void PlotBox(), PlotTri(), PlotEggs(), PlotPlus(), PlotKite();
  270. struct Tics *Tics;
  271. char tmpstr[20];
  272.  
  273.    if (Dest)
  274.       {
  275.           strcpy(plotname,filename);
  276.           strsfn(plotname,def_drive,def_path,def_node,def_extn);
  277.           strcat(def_drive,def_path);
  278.           strcat(def_node,".plt");
  279.           strcat(def_node,PlotNum);
  280.  
  281.           OurTask = (struct Process *)FindTask(0L);
  282.           old_pr_WindowPtr = (struct Window *)OurTask->pr_WindowPtr;
  283.           OurTask->pr_WindowPtr = (APTR)window;
  284.           if (get_fname(window,screen,"Save File As...",def_node,def_drive)==NULL)
  285.                {
  286.                   OurTask->pr_WindowPtr = (APTR)old_pr_WindowPtr;
  287.                   return(TRUE);
  288.                 }
  289.  
  290.            OurTask->pr_WindowPtr = (APTR)old_pr_WindowPtr;
  291.            strmfp(plotname,def_drive,def_node);
  292.            PutDiskObject(plotname,&IconDiskObject);
  293.        }
  294.    else
  295.        {
  296.           if (!(fp = fopen("l:plt-handler","r") ))
  297.              {
  298.                 Message("Printing needs the PLT: Device"); return(FALSE);
  299.              }
  300.           fclose(fp);
  301.  
  302.           Execute("c:failat >Nil: <Nil: 20 \n c:mount >Nil: <Nil: plt:",0,0);
  303.           strcpy(plotname,"PLT:");
  304.        }
  305.    if (!(fp = fopen(plotname,"w") ))
  306.       {Message("  Can't write file to PLT:"); return(FALSE);}
  307.    if (strlen(Pict->XLabel->String))
  308.      {
  309.          if (xf) P_BMARGIN=4*(short)(xf->tf_YSize)*10000/MAXVERT;
  310.          else    P_BMARGIN=4*CHARHEIGHT*10000/MAXVERT;
  311.      }
  312.    else
  313.      {
  314.          if (xf) P_BMARGIN=2*(short)(xf->tf_YSize)*10000/MAXVERT;
  315.          else    P_BMARGIN=2*CHARHEIGHT*10000/MAXVERT;
  316.      }
  317.    if (strlen(Pict->Title->String))
  318.      {
  319.          if (tf) P_TMARGIN=2*(short)(tf->tf_YSize)*10000/MAXVERT;
  320.          else    P_TMARGIN=2*CHARHEIGHT*10000/MAXVERT;
  321.      }
  322.    else P_TMARGIN=0;
  323.    P_YREG = 10000-P_TMARGIN;
  324.  
  325.    Tics = Pict->Tics;
  326.    for (i=0; i < Tics->NY; i++) { n=max(n,GetString(&tmpstr,Tics->y[i]));}
  327.    if (lf) P_LMARGIN=(n+1)*(short)(lf->tf_XSize)*10000/MAXHORIZ;
  328.    else P_LMARGIN=(n+1)* CHARWIDTH*10000/MAXHORIZ;
  329.    if (strlen(Pict->YLabel->String))
  330.      {
  331.        if (yf) P_LMARGIN=P_LMARGIN+(short)(yf->tf_YSize)*10000/MAXVERT;
  332.        else    P_LMARGIN=P_LMARGIN+CHARHEIGHT*10000/MAXVERT;
  333.      }
  334.    P_RMARGIN = 0;
  335.    if (Pict->RMargin) {
  336.       Plot=Pict->Plot;
  337.       if (lf) {
  338.         while (Plot) {
  339.           P_RMARGIN= max(P_RMARGIN,(strlen(Plot->Legend->String)*
  340.                   (short)(lf->tf_XSize)*10000 / MAXHORIZ));
  341.           while (Plot->Continued) Plot=Plot->NextPlot;
  342.           Plot=Plot->NextPlot;
  343.         }
  344.       }
  345.       else {
  346.         while (Plot) {
  347.           P_RMARGIN= max(P_RMARGIN,(strlen(Plot->Legend->String)*
  348.                    CHARWIDTH*10000 / MAXHORIZ));
  349.           while (Plot->Continued) Plot=Plot->NextPlot;
  350.           Plot=Plot->NextPlot;
  351.         }
  352.       }
  353.       if (P_RMARGIN>0) {P_RMARGIN=P_RMARGIN+700;}
  354.    }
  355.    P_XREG = 10000-P_RMARGIN;
  356.  
  357.    XFactor=(FFP)(P_XREG-P_LMARGIN)/(XMAXP-XMINP);
  358.    YFactor=(FFP)(P_YREG-P_BMARGIN)/(YMAXP-YMINP);
  359.  
  360.    fprintf(fp,"IN;SC 0 %d 0 %d;\n", P_XREG+P_RMARGIN+100, P_YREG+100+P_TMARGIN);
  361.    fprintf(fp,"VS 20.0;\n");                /* VELOCITY cm/s */
  362.    fprintf(fp,"\033.N;19:\033.I81;;17:\n"); /* XON/XOFF */
  363.  
  364.    XScale = (FFP) (P_XREG - P_LMARGIN)/(Pict->CurrReg->XMax - Pict->CurrReg->XMin);
  365.    YScale = (P_YREG-P_BMARGIN)/ (Pict->CurrReg->YMax - Pict->CurrReg->YMin);
  366.    XOffset = (FFP)(P_LMARGIN) / XScale - Pict->CurrReg->XMin;
  367.    YOffset = (FFP)(P_BMARGIN) / YScale - Pict->CurrReg->YMin;
  368.  
  369.    Plot = Pict->Plot;
  370.    while (Plot) {
  371.       if (Plot->Enabled) {
  372.          fprintf(fp,"PU;SP%d;\n", 1+Plot->Color-PLOTCOLORBASE);
  373.          /* PLOT LINES */
  374.          if (Plot->Lines)
  375.             {
  376.                TempPlot=Plot;
  377.                tempx1=(XScale*(XOffset+Plot->x[0]));
  378.                tempy1=(YScale*(YOffset+Plot->y[0]));
  379.                if (Plot->Lines>1) fprintf(fp,"LT%d,2",Plot->Lines);
  380.  
  381.                /*** LINE OR LINE & POINT GRAPHS ***/
  382.                if (Plot->PlotType<STEP)  {
  383.                  do {
  384.                       for (i=0; i<TempPlot->NPts; i++) {
  385.                         tempx2=(XScale*(XOffset+TempPlot->x[i]));
  386.                         tempy2=(YScale*(YOffset+TempPlot->y[i]));
  387.                         if (FFPClip(&tempx1,&tempy1,&tempx2,&tempy2,(FFP)P_LMARGIN,(FFP)P_BMARGIN,(FFP)P_XREG,(FFP)P_YREG))
  388.                           {
  389.                             FFPPlotLines(fp,tempx1,tempy1,tempx2,tempy2);
  390.                           }
  391.                         tempx1=(XScale*(XOffset+TempPlot->x[i]));
  392.                         tempy1=(YScale*(YOffset+TempPlot->y[i]));
  393.                       }
  394.                     } while ((TempPlot->Continued)&&(TempPlot=TempPlot->NextPlot));
  395.                }
  396.  
  397.                /*** STEP GRAPHS ***/
  398.                else  {
  399.                  do {
  400.                       for (i=0; i<TempPlot->NPts; i++) {
  401.                         tempx2=(XScale*(XOffset+TempPlot->x[i]));
  402.                         tempy2=(YScale*(YOffset+TempPlot->y[i]));
  403.                         if (FFPClip(&tempx1,&tempy1,&tempx2,&tempy1,(FFP)P_LMARGIN,(FFP)P_BMARGIN,(FFP)P_XREG,(FFP)P_YREG))
  404.                           {
  405.                             FFPPlotLines(fp,tempx1,tempy1,tempx2,tempy1);
  406.                           }
  407.                         if (FFPClip(&tempx2,&tempy1,&tempx2,&tempy1,(FFP)P_LMARGIN,(FFP)P_BMARGIN,(FFP)P_XREG,(FFP)P_YREG))
  408.                           {
  409.                             FFPPlotLines(fp,tempx2,tempy1,tempx2,tempy2);
  410.                           }
  411.                         tempx1=(XScale*(XOffset+TempPlot->x[i]));
  412.                         tempy1=(YScale*(YOffset+TempPlot->y[i]));
  413.                       }
  414.                     } while ((TempPlot->Continued)&&(TempPlot=TempPlot->NextPlot));
  415.                }
  416.                fprintf(fp, ";\n");
  417.                if (strlen(Plot->Legend->String)) {
  418.                   fprintf(fp, "PU");
  419.                   fWrtFFP(fp, (FFP)(P_LMARGIN+(Plot->Legend->x-XMINP)*XFactor));
  420.                   fprintf(fp," ");
  421.                   fWrtFFP(fp,(FFP)(P_BMARGIN+(Plot->Legend->y-YMINP)*YFactor));
  422.                   fprintf(fp,";");
  423.                   fprintf(fp, "PD");
  424.                   fWrtFFP(fp, (FFP)(P_LMARGIN+(Plot->Legend->x-XMINP)*XFactor+400));
  425.                   fprintf(fp," ");
  426.                   fWrtFFP(fp,(FFP)(P_BMARGIN+(Plot->Legend->y-YMINP)*YFactor));
  427.                   fprintf(fp,";\n");
  428.                }
  429.                fprintf(fp,"LT;\n");
  430.             }
  431.  
  432.          /* PLOT POINTS */
  433.          if (Plot->PointSize != 0) {
  434.             xptsiz = abs(Plot->PointSize) * (P_XREG / 1100);
  435.             yptsiz = abs(Plot->PointSize) * (P_YREG / 850);
  436.             TempPlot=Plot;
  437.             do {
  438.                    x=TempPlot->x; y=TempPlot->y;
  439.                    for (i=0; i<TempPlot->NPts; i++, x++, y++) {
  440.                       tempx1=(XScale * (XOffset + *x));
  441.                       tempy1=(YScale * (YOffset + *y));
  442.                       if (FFPClipPoint(tempx1,tempy1,(FFP)P_LMARGIN,(FFP)P_BMARGIN,(FFP)P_XREG,(FFP)P_YREG))
  443.                         {
  444.                            FFPPlotPoint(fp,tempx1,tempy1,Plot->PointType,xptsiz,yptsiz);
  445.                         }
  446.                    }
  447.                } while ((TempPlot->Continued)&&(TempPlot=TempPlot->NextPlot));
  448.             if (strlen(Plot->Legend->String)>0)
  449.               {
  450.                  FFPPlotPoint(fp,(FFP)(P_LMARGIN+(Plot->Legend->x-XMINP)*XFactor),(FFP)(P_BMARGIN+(Plot->Legend->y-YMINP)*YFactor),Plot->PointType,xptsiz,yptsiz);
  451.                  FFPPlotPoint(fp,(FFP)(P_LMARGIN+(Plot->Legend->x-XMINP)*XFactor+400),(FFP)(P_BMARGIN+(Plot->Legend->y-YMINP)*YFactor),Plot->PointType,xptsiz,yptsiz);
  452.               }
  453.          }
  454.  
  455.          /* PLOT ERROR BARS */
  456.          if (Pict->ShowErr) {
  457.            TempPlot=Plot;
  458.            do {
  459.                  if (TempPlot->PlotType!=STEP) {
  460.                    x=TempPlot->x; y=TempPlot->y; e=TempPlot->e;
  461.                    for (i=0; i<TempPlot->NPts; i++, x++, y++, e++) {
  462.                       if ( (abs(*e)) > FFPSMALL)
  463.                         {
  464.                            tempy1=YScale * (YOffset + (*y - *e));
  465.                            tempy2=YScale * (YOffset + (*y + *e));
  466.                            tempx1=XScale * (XOffset + *x);
  467.  
  468.                            if (FFPQuickClip(tempx1,&tempy1,&tempy2,(FFP)P_LMARGIN,(FFP)P_BMARGIN,(FFP)P_XREG,(FFP)P_YREG))
  469.                              {
  470.                                 FFPPlotLines(fp,tempx1,tempy1,tempx1,tempy2);
  471.                                 fprintf(fp,";\n");
  472.                              }
  473.  
  474.                            /* PLOT DELIMITERS ON ERROR BARS */
  475.                            if (FFPClipPoint(tempx1,YScale*(YOffset+(*y-*e)),(FFP)P_LMARGIN,(FFP)P_BMARGIN,(FFP)P_XREG,(FFP)P_YREG))
  476.                              {
  477.                                 FFPPlotLines(fp,(XScale*(XOffset+*x)-P_ERR_DELIM),(YScale*(YOffset+(*y-*e))),
  478.                                                 (XScale*(XOffset+*x)+P_ERR_DELIM),(YScale*(YOffset+(*y-*e))));
  479.                                 fprintf(fp,";\n");
  480.                              }
  481.                            if (FFPClipPoint(tempx1,YScale*(YOffset+(*y+*e)),(FFP)P_LMARGIN,(FFP)P_BMARGIN,(FFP)P_XREG,(FFP)P_YREG))
  482.                              {
  483.                                 FFPPlotLines(fp,(XScale*(XOffset+*x)-P_ERR_DELIM),(YScale*(YOffset+(*y+*e))),
  484.                                                 (XScale*(XOffset+*x)+P_ERR_DELIM),(YScale*(YOffset+(*y+*e))));
  485.                                 fprintf(fp,";\n");
  486.                              }
  487.                         }
  488.                     }
  489.                  }
  490.            } while ((TempPlot->Continued)&&(TempPlot=TempPlot->NextPlot));
  491.          }
  492.       }
  493.       while (Plot->Continued) Plot=Plot->NextPlot;
  494.       Plot = Plot->NextPlot;
  495.    }
  496.  
  497.    WrtAxes(fp, Pict);
  498.  
  499.    fprintf(fp, "SP;");
  500.    (void) fclose(fp);
  501.    PlotNum++;
  502.    return(TRUE);
  503. }
  504.  
  505. FFPPlotLines(fp,x1,y1,x2,y2)
  506. FILE *fp;
  507. FFP x1,x2,y1,y2;
  508. {
  509. static FFP tempx=0, tempy=0;
  510.  
  511.   if ((x1==tempx)&&(y1==tempy))
  512.     {fprintf(fp, " %d %d",(int)x2,(int)y2);}
  513.   else
  514.     {fprintf(fp, "; PU%d %d; PD%d %d",(int)x1,(int)y1,(int)x2,(int)y2);}
  515.   tempx=x2; tempy=y2;
  516.   return(0);
  517. }
  518.  
  519.  
  520. FFPPlotPoint(fp,x,y,PointType,xptsiz,yptsiz)
  521. FILE *fp;
  522. FFP x,y,xptsiz,yptsiz;
  523. short PointType;
  524. {
  525.    fprintf(fp,"PU%d %d;",(int)x,(int)y);
  526.    switch (PointType) {
  527.    case 1:  PlotTri(fp,xptsiz/2,yptsiz/2);  break;
  528.    case 2:  PlotKite(fp,xptsiz/2,yptsiz/2); break;
  529.    case 3:  PlotEggs(fp,xptsiz/2,yptsiz/2); break;
  530.    case 4:  PlotEggs(fp,xptsiz/2,yptsiz/2); /* Fall through (fancy, huh?) */
  531.    case 5:  PlotPlus(fp,xptsiz/2,yptsiz/2); break;
  532.    case 6:
  533.    default: PlotBox(fp,xptsiz/2,yptsiz/2); break;
  534.    }
  535.    return(0);
  536. }
  537.  
  538. void PlotPlus(fp,x,y)
  539. FILE *fp;
  540. SHORT x,y;
  541. {
  542.    fprintf(fp,"PR%d 0;PD%d 0;PU%d %d;PD0 %d;PA;",-x,2*x,-x,-y,2*y);
  543. }
  544.  
  545. void PlotBox(fp,x,y)
  546. FILE *fp;
  547. SHORT x,y;
  548. {
  549.    fprintf(fp,"PR%d %d;PD%d 0 0 %d %d 0 0 %d;PA;\n",-x,-y,2*x,2*y, -2*x, -2*y);
  550. }
  551.  
  552. void PlotEggs(fp,x,y)
  553. FILE *fp;
  554. SHORT x,y;
  555. {
  556.    fprintf(fp,"PR%d %d;PD%d %d;PU0 %d;PD%d %d;PU%d %d;PA\n;",-x,-y,2*x,2*y,-2*y,-2*x,2*y,x,-y);
  557. }
  558.  
  559. void PlotKite(fp,x,y)
  560. FILE *fp;
  561. SHORT x,y;
  562. {
  563.    fprintf(fp,"PR%d 0;PD%d %d %d %d %d %d %d %d;PA;\n",-x,x,y,x,-y,-x,-y,-x,y);
  564. }
  565.  
  566.  
  567. void PlotTri(fp,x,y)
  568. FILE *fp;
  569. SHORT x,y;
  570. {
  571.    fprintf(fp,"PR%d %d;PD%d %d %d %d %d 0;PA;\n",-x,-y,x,2*y,x,-2*y,-2*x);
  572. }
  573.  
  574.  
  575.  
  576.  
  577. void header(n, c, t, fp)
  578. int n, c, t;
  579. FILE *fp;
  580. {
  581.    UBYTE bdummy;
  582.    bdummy = n;
  583.    fwrite((char *)&bdummy, 1, 1, fp);
  584.    bdummy = c;
  585.    fwrite((char *)&bdummy, 1, 1, fp);
  586.    bdummy = 0;
  587.    fwrite((char *)&bdummy, 1, 1, fp); /* LineType */
  588.    bdummy = t;
  589.    fwrite((char *)&bdummy, 1, 1, fp);
  590.    bdummy = 0;
  591.    fwrite((char *)&bdummy, 1, 1, fp); /* padding for future use */
  592.    fwrite((char *)&bdummy, 1, 1, fp);
  593. }
  594.  
  595. To_mCAD(Pict,Dest)
  596. struct Pict *Pict;
  597. USHORT Dest;
  598. {
  599.  
  600.    struct Process  *OurTask;
  601.    struct Window   *old_pr_WindowPtr;
  602.  
  603.    FILE *fp;
  604.    short i;
  605.    struct Plot *Plot, *TempPlot;
  606.    FFP *x, *y, *e, xtmp, ytmp, xtmp1, ytmp1, tempx1, tempx2, tempy1, tempy2;
  607.    FFP CADMaxX, CADMinX, CADMinY, CADMaxY, CADErrEnd;
  608.    FFP xptsiz, yptsiz, XReg, YReg, XScale, XOffset;
  609.    char plotname[150], def_drive[150], def_path[100], def_node[30],def_extn[20];
  610.    static char mPlotNum = 0;
  611.    void CADBox(), CADKite(), CADTri(), CADEggs(), CADPlus();
  612.  
  613.   if (Dest)
  614.     {
  615.      strcpy(plotname,filename);
  616.      strsfn(plotname,def_drive,def_path,def_node,def_extn);
  617.      strcat(def_drive,def_path);
  618.      strcat(def_node,".txt");
  619.      strcat(def_node,mPlotNum);
  620.  
  621.            OurTask = (struct Process *)FindTask(0L);
  622.            old_pr_WindowPtr = (struct Window *)OurTask->pr_WindowPtr;
  623.            OurTask->pr_WindowPtr = (APTR)window;
  624.            if (get_fname(window,screen,"Save File As...",def_node,def_drive)==NULL)
  625.                {
  626.                   OurTask->pr_WindowPtr = (APTR)old_pr_WindowPtr;
  627.                   return(TRUE);
  628.                 }
  629.  
  630.      OurTask->pr_WindowPtr = (APTR)old_pr_WindowPtr;
  631.      strmfp(plotname,def_drive,def_node);
  632.      PutDiskObject(plotname,&IconDiskObject);
  633.     }
  634.    else
  635.        {
  636.           if (!(fp = fopen("T:tempfile","w") ))
  637.              {
  638.                 Message("Save needs the T: Device"); return(FALSE);
  639.              }
  640.           fclose(fp);
  641.           strcpy(plotname,"T:tempfile");
  642.        }
  643.  
  644.    if (!(fp = fopen(plotname,"w") ))
  645.       {Message("   Can't write tempory file  "); return(FALSE);}
  646.  
  647.    XReg = Pict->CurrReg->XMax - Pict->CurrReg->XMin;
  648.    YReg = Pict->CurrReg->YMax - Pict->CurrReg->YMin;
  649.    XScale = YReg/XReg * 1.4434; XOffset = Pict->CurrReg->XMin;
  650.  
  651.    PToU(Pict, XMINP, YMINP, &CADMinX, &CADMinY);
  652.    CADMinX = XScale * (CADMinX - XOffset);
  653.    PToU(Pict, XMAXP, YMAXP, &CADMaxX, &CADMaxY);
  654.    CADMaxX = XScale * (CADMaxX - XOffset);
  655.  
  656.    Plot = Pict->Plot;
  657.    while (Plot) {
  658.       if (Plot->Enabled) {
  659.  
  660.          /* PLOT LINES */
  661.          if (Plot->Lines != FALSE) {
  662.            TempPlot=Plot;
  663.            tempx1 = XScale * (Plot->x[0] - XOffset);
  664.            tempy1=Plot->y[0];
  665.  
  666.            /*** LINE OR LINE & POINT GRAPHS ***/
  667.            if (Plot->PlotType<STEP)  {
  668.              do {
  669.                  for (i=0; i<TempPlot->NPts; i++) {
  670.                      tempx2 = XScale * (TempPlot->x[i] - XOffset);
  671.                      tempy2 = TempPlot->y[i];
  672.                      if ((FFPClip(&tempx1,&tempy1,&tempx2,&tempy2,CADMinX,CADMinY,CADMaxX,CADMaxY))
  673.                         && ( (tempx1!=tempx2)||(tempy1!=tempy2)))
  674.                        {
  675.                           fprintf(fp, "%f %f\n", tempx1,tempy1);
  676.                           fprintf(fp, "%f %f\n*>\n", tempx2,tempy2);
  677.                           if (Plot->Lines>1) fprintf(fp,"*L %d\n", Plot->Lines);
  678.                           fprintf(fp,"*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  679.                        }
  680.                      tempx1 = XScale * (TempPlot->x[i] - XOffset);
  681.                      tempy1 = TempPlot->y[i];
  682.                   }
  683.               } while ((TempPlot->Continued)&&(TempPlot=TempPlot->NextPlot));
  684.             }
  685.  
  686.            /*** STEP GRAPHS ***/
  687.            else  {
  688.              do {
  689.                  for (i=0; i<TempPlot->NPts; i++) {
  690.                      tempx2 = XScale * (TempPlot->x[i] - XOffset);
  691.                      tempy2 = TempPlot->y[i];
  692.                      if ((FFPClip(&tempx1,&tempy1,&tempx2,&tempy1,CADMinX,CADMinY,CADMaxX,CADMaxY))
  693.                         && (tempx1!=tempx2))
  694.                        {
  695.                           fprintf(fp, "%f %f\n", tempx1,tempy1);
  696.                           fprintf(fp, "%f %f\n*>\n", tempx2,tempy1);
  697.                           if (Plot->Lines>1) fprintf(fp,"*L %d\n", Plot->Lines);
  698.                           fprintf(fp,"*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  699.                        }
  700.                      if ((FFPClip(&tempx2,&tempy1,&tempx2,&tempy2,CADMinX,CADMinY,CADMaxX,CADMaxY))
  701.                         && (tempy1!=tempy2))
  702.                        {
  703.                           fprintf(fp, "%f %f\n", tempx2,tempy1);
  704.                           fprintf(fp, "%f %f\n*>\n", tempx2,tempy2);
  705.                           if (Plot->Lines>1) fprintf(fp,"*L %d\n", Plot->Lines);
  706.                           fprintf(fp,"*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  707.                        }
  708.                      tempx1 = XScale * (TempPlot->x[i] - XOffset);
  709.                      tempy1 = TempPlot->y[i];
  710.                   }
  711.               } while ((TempPlot->Continued)&&(TempPlot=TempPlot->NextPlot));
  712.             }
  713.          }
  714.  
  715.          /* PLOT POINTS */
  716.          if (Plot->PointSize != 0) {
  717.             TempPlot=Plot;
  718.             xptsiz = abs(Plot->PointSize) * (XReg / 582.);
  719.             xptsiz = XScale * xptsiz;
  720.             yptsiz = abs(Plot->PointSize) * (YReg / 360.);
  721.             do {
  722.                    x=TempPlot->x; y=TempPlot->y;
  723.                    for (i=0; i<TempPlot->NPts; i++, x++, y++) {
  724.                       tempx1=(XScale * (*x - XOffset));
  725.                       if (FFPClipPoint(tempx1,*y,CADMinX,CADMinY,CADMaxX,CADMaxY))
  726.                         {
  727.                            switch (Plot->PointType) {
  728.                            case 1:  CADTri(fp,Plot,tempx1,*y,xptsiz/2,yptsiz/2); break;
  729.                            case 2:  CADKite(fp,Plot,tempx1,*y,xptsiz/2,yptsiz/2); break;
  730.                            case 3:  CADEggs(fp,Plot,tempx1,*y,xptsiz/2,yptsiz/2); break;
  731.                            case 4:  CADEggs(fp,Plot,tempx1,*y,xptsiz/2,yptsiz/2);
  732.                            case 5:  CADPlus(fp,Plot,tempx1,*y,xptsiz/2,yptsiz/2); break;
  733.                            case 6:
  734.                            default: CADBox(fp,Plot,tempx1,*y,xptsiz/2,yptsiz/2); break;
  735.                            }
  736.                         }
  737.                     }
  738.                } while ((TempPlot->Continued)&&(TempPlot=TempPlot->NextPlot));
  739.          }
  740.  
  741.          /* PLOT ERROR BARS */
  742.          if (Pict->ShowErr) {
  743.             TempPlot=Plot;
  744.             CADErrEnd=XScale*(ERR_DELIM*(XReg/582));     /* SCALED ERROR DELIMITER */
  745.             do {
  746.                   if (TempPlot->PlotType!=STEP) {
  747.                     x=TempPlot->x; y=TempPlot->y; e=TempPlot->e;
  748.                     for (i=0; i<TempPlot->NPts; i++, x++, y++, e++) {
  749.                       if ((abs(*e)) > FFPSMALL)
  750.                         {
  751.                            tempx1 = XScale * (*x - XOffset);
  752.                            tempy1 = *y - *e;
  753.                            tempy2 = *y + *e;
  754.                            if (FFPClipPoint(tempx1,tempy1,CADMinX,CADMinY,CADMaxX,CADMaxY))
  755.                              {
  756.                                 fprintf(fp,"%f %f\n",tempx1-CADErrEnd,tempy1);
  757.                                 fprintf(fp,"%f %f\n*>\n*C %d\n\n",tempx1+CADErrEnd,tempy1,1+Plot->Color-PLOTCOLORBASE);
  758.                              }
  759.                            if (FFPClipPoint(tempx1,tempy2,CADMinX,CADMinY,CADMaxX,CADMaxY))
  760.                              {
  761.                                 fprintf(fp,"%f %f\n",tempx1-CADErrEnd,tempy2);
  762.                                 fprintf(fp,"%f %f\n*>\n*C %d\n\n",tempx1+CADErrEnd,tempy2,1+Plot->Color-PLOTCOLORBASE);
  763.                              }
  764.                            if (FFPQuickClip(tempx1,&tempy1,&tempy2,CADMinX,CADMinY,CADMaxX,CADMaxY))
  765.                              {
  766.                                 fprintf(fp,"%f %f\n", tempx1, tempy1);
  767.                                 fprintf(fp,"%f %f\n", tempx1, tempy2);
  768.                                 fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  769.                              }
  770.                         }
  771.                     }
  772.                   }
  773.                } while ((TempPlot->Continued)&&(TempPlot=TempPlot->NextPlot));
  774.          }
  775.       }
  776.       while (Plot->Continued) Plot=Plot->NextPlot;
  777.       Plot = Plot->NextPlot;
  778.    }
  779.  
  780.    /*** DRAW TICS/GRID ***/
  781.    x = Pict->Tics->x; y = Pict->Tics->y;
  782.    for (i=0; i < Pict->Tics->NX; i++) {
  783.       xtmp = XScale * (x[i] - XOffset);
  784.       if (Pict->Grid==2) {
  785.          PToU(Pict, 0, YMINP, &xtmp1, &ytmp);
  786.          PToU(Pict, 0, YMAXP, &xtmp1, &ytmp1);
  787.          fprintf(fp,"%f %f\n%f %f\n*>\n*C 2\n\n", xtmp, ytmp, xtmp, ytmp1);
  788.       }
  789.       else {
  790.         if ((Pict->Grid==0)||(Pict->Grid==3))
  791.           {
  792.              PToU(Pict, 0, YMINP, &xtmp1, &ytmp);
  793.              fprintf(fp,"%f %f\n", xtmp, ytmp);
  794.              PToU(Pict, 0, YMINP+X_TIC_SIZE, &xtmp1, &ytmp1);
  795.              fprintf(fp,"%f %f\n*>\n*C 3\n\n", xtmp, ytmp1);
  796.            }
  797.          if (Pict->Grid==3)
  798.            {
  799.              PToU(Pict, 0, YMAXP, &xtmp1, &ytmp);
  800.              fprintf(fp,"%f %f\n", xtmp, ytmp);
  801.              PToU(Pict, 0, YMAXP-X_TIC_SIZE, &xtmp1, &ytmp1);
  802.              fprintf(fp,"%f %f\n*>\n*C 3\n\n", xtmp, ytmp1);
  803.            }
  804.       }
  805.    }
  806.    for (i=0; i < Pict->Tics->NY; i++) {
  807.       if (Pict->Grid==2) {
  808.          PToU(Pict, XMINP, YMINP, &xtmp, &ytmp);
  809.          xtmp = XScale * (xtmp - XOffset);
  810.          PToU(Pict, XMAXP, YMAXP, &xtmp1, &ytmp1);
  811.          xtmp1 = XScale * (xtmp1 - XOffset);
  812.          fprintf(fp,"%f %f\n%f %f\n*>\n*C 2\n\n", xtmp, y[i], xtmp1, y[i]);
  813.       }
  814.       else {
  815.         if ((Pict->Grid==0)||(Pict->Grid==3))
  816.           {
  817.              PToU(Pict, XMINP, 0, &xtmp, &ytmp);
  818.              xtmp = XScale * (xtmp - XOffset);
  819.              fprintf(fp,"%f %f\n", xtmp, y[i]);
  820.              PToU(Pict, XMINP+Y_TIC_SIZE, 0, &xtmp1, &ytmp1);
  821.              xtmp1 = XScale * (xtmp1 - XOffset);
  822.              fprintf(fp,"%f %f\n*>\n*C 3\n\n", xtmp1, y[i]);
  823.           }
  824.         if (Pict->Grid==3)
  825.           {
  826.              PToU(Pict, XMAXP, 0, &xtmp, &ytmp);
  827.              xtmp = XScale * (xtmp - XOffset);
  828.              fprintf(fp,"%f %f\n", xtmp, y[i]);
  829.              PToU(Pict, XMAXP-Y_TIC_SIZE, 0, &xtmp1, &ytmp1);
  830.              xtmp1 = XScale * (xtmp1 - XOffset);
  831.              fprintf(fp,"%f %f\n*>\n*C 3\n\n", xtmp1, y[i]);
  832.           }
  833.       }
  834.    }
  835.  
  836.    /*** PRINT TIC VALUES ***/
  837. /*
  838. *   for (i=0; i < Pict->Tics->NX; i++) {
  839. *      n = sprintf(tmpstr, "%-.4f", Pict->Tics->x[i]);
  840. *      n = min(n, 7);
  841. *      while (tmpstr[n-1] == '0') n--;
  842. *      tmpstr[n]=0;
  843. *   }
  844. *   for (i=0; i < Pict->Tics->NY; i++) {
  845. *      n = sprintf(tmpstr, "%-.4f", Pict->Tics->y[i]);
  846. *      n = min(n, 7);
  847. *      while (tmpstr[n-1] == '0') n--;
  848. *      tmpstr[n]=0;
  849. *   }
  850. */
  851.  
  852.    /*** DRAW AXES ***/
  853.    if (Pict->Grid<5)
  854.      {
  855.         fprintf(fp, "%f %f\n", CADMinX, CADMaxY);
  856.         fprintf(fp, "%f %f\n", CADMinX, CADMinY);
  857.         fprintf(fp, "%f %f\n", CADMaxX, CADMinY);
  858.         if (Pict->Grid>1)
  859.           {
  860.              fprintf(fp, "%f %f\n", CADMaxX, CADMaxY);
  861.              fprintf(fp, "%f %f\n", CADMinX, CADMaxY);
  862.           }
  863.         fprintf(fp,"*>\n*C 1\n\n");
  864.       }
  865.    (void) fclose(fp);
  866.    mPlotNum++;
  867.    return(TRUE);
  868. }
  869.  
  870. void CADBox(fp,Plot,x,y,dx,dy)
  871. FILE *fp;
  872. struct Plot *Plot;
  873. FFP x,y,dx,dy;
  874. {
  875.    x = x - dx;
  876.    y = y - dy;
  877.    fprintf(fp,"%f %f\n", x, y); x += 2*dx;
  878.    fprintf(fp,"%f %f\n", x, y); y += 2*dy;
  879.    fprintf(fp,"%f %f\n", x, y); x -= 2*dx;
  880.    fprintf(fp,"%f %f\n", x, y); y -= 2*dy;
  881.    fprintf(fp,"%f %f\n", x, y);
  882.    fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  883.  
  884. }
  885.  
  886. void CADPlus(fp,Plot,x,y,dx,dy)
  887. FILE *fp;
  888. struct Plot *Plot;
  889. FFP x,y,dx,dy;
  890. {
  891.    x = x - dx;
  892.    fprintf(fp,"%f %f\n", x, y); x += 2*dx;
  893.    fprintf(fp,"%f %f\n", x, y);
  894.    fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  895.  
  896.    x -= dx; y -= dy;
  897.    fprintf(fp,"%f %f\n", x, y); y += 2*dy;
  898.    fprintf(fp,"%f %f\n", x, y);
  899.    fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  900. }
  901.  
  902. void CADEggs(fp,Plot,x,y,dx,dy)
  903. FILE *fp;
  904. struct Plot *Plot;
  905. FFP x,y,dx,dy;
  906. {
  907.    x = x - dx; y = y - dy;
  908.    fprintf(fp,"%f %f\n", x, y); x += 2*dx; y += 2*dy;
  909.    fprintf(fp,"%f %f\n", x, y);
  910.    fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  911.  
  912.    y -= 2*dy;
  913.    fprintf(fp,"%f %f\n", x, y); x -= 2*dx; y += 2*dy;
  914.    fprintf(fp,"%f %f\n", x, y);
  915.    fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  916. }
  917.  
  918.  
  919. void CADKite(fp,Plot,x,y,dx,dy)
  920. FILE *fp;
  921. struct Plot *Plot;
  922. FFP x,y,dx,dy;
  923. {
  924.    x = x - dx;
  925.    fprintf(fp,"%f %f\n", x, y); x += dx; y += dy;
  926.    fprintf(fp,"%f %f\n", x, y); x += dx; y -= dy;
  927.    fprintf(fp,"%f %f\n", x, y); x -= dx; y -= dy;
  928.    fprintf(fp,"%f %f\n", x, y); x -= dx; y += dy;
  929.    fprintf(fp,"%f %f\n", x, y);
  930.    fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  931. }
  932.  
  933. void CADTri(fp,Plot,x,y,dx,dy)
  934. FILE *fp;
  935. struct Plot *Plot;
  936. FFP x,y,dx,dy;
  937. {
  938.    x = x - dx;
  939.    y = y - dy;
  940.    fprintf(fp,"%f %f\n", x, y); x += dx; y += 2*dy;
  941.    fprintf(fp,"%f %f\n", x, y); x += dx; y -= 2*dy;
  942.    fprintf(fp,"%f %f\n", x, y); x -= 2*dy;
  943.    fprintf(fp,"%f %f\n", x, y);
  944.    fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  945. }
  946.  
  947.