Subversion Repositories wimsdev

Rev

Rev 10 | Rev 8076 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
  2.  *
  3.  *  This program is free software; you can redistribute it and/or modify
  4.  *  it under the terms of the GNU General Public License as published by
  5.  *  the Free Software Foundation; either version 2 of the License, or
  6.  *  (at your option) any later version.
  7.  *
  8.  *  This program is distributed in the hope that it will be useful,
  9.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.  *  GNU General Public License for more details.
  12.  *
  13.  *  You should have received a copy of the GNU General Public License
  14.  *  along with this program; if not, write to the Free Software
  15.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17.  
  18.  /* This file is a temporary patch to tex eps files with extra borders.
  19.   * It cuts the borders in the resulting gif file, so that the font
  20.   * fits tightly in the cadre. libgd is required. */
  21.  
  22. #include "flydraw.h"
  23. #include "../Lib/libwims.h"
  24.  
  25. char imagefilename[1024];
  26. char vimgfilename[1024];
  27. int sizex, sizey, saved;
  28. gdImagePtr image=NULL, brushimg=NULL, tileimg=NULL, wimg=NULL;
  29. int brushed=0,tiled=0,styled=0,width=1, savew=1, wcolor=-1;
  30. int color_white,color_black,color_bounder;
  31. int linecnt=-100000;
  32. int tranged=0;
  33. double xscale=1,yscale=1,xstart=0,ystart=0;
  34. double tstart=0,tend=1,tstep=100,plotjump=200;
  35. double animstep=0;
  36. double matrix[]={1,0,0,1};      /* transformation matrix */
  37. int transform=0;                /* transformation indicator */
  38. double transx=0,transy=0;       /* translation vector */
  39. int lstep=4;
  40. ev_variable vartab[MAX_VARS];
  41. char varnamebuf[MAX_VARNAMEBUF], *varnameptr=varnamebuf;
  42. int varcnt;
  43. int vimg=0;                     /* 0: no vector image output.
  44.                                  * 1: DXF vector output. */
  45. int vimg_enable=0;              /* 0: disable. 1: enable. */
  46. int vimg_ready=0;
  47. FILE *vimgf=NULL;
  48. double scale_buf[MAX_PARMS];
  49. /***** Les modifs a JC Fev 06 *****/
  50. /** les matrices suivantes sont initialisees par la commande setmatrix nummatrix,a11,a12,a21,a22 */
  51. /** elles sont remises a l'unite par resetmatrix nummatrix */
  52. double matrix01[] = {1,0,0,1};
  53. double matrix02[] = {1,0,0,1};
  54. double matrix03[] = {1,0,0,1};
  55. double matrix04[] = {1,0,0,1};
  56. double matrix05[] = {1,0,0,1};
  57. double matrix06[] = {1,0,0,1};
  58. double matrix07[] = {1,0,0,1};
  59. double matrix08[] = {1,0,0,1};
  60. double matrix09[] = {1,0,0,1};
  61. double matrix10[] = {1,0,0,1};
  62. double matrix11[] = {1,0,0,1};
  63. double matrix12[] = {1,0,0,1};
  64. double matrix13[] = {1,0,0,1};
  65. double matrix14[] = {1,0,0,1};
  66. double matrix15[] = {1,0,0,1};
  67. double matrix16[] = {1,0,0,1};
  68. double matrix17[] = {1,0,0,1};
  69. double matrix18[] = {1,0,0,1};
  70. double matrix19[] = {1,0,0,1};
  71. #define JC_NB_MATRICES 19
  72. /* la matrice fixant le systeme de coordonnees "mathematiques" dans l'image */
  73. double *matrices_pavage[] ={ matrix,
  74.                                 matrix01,matrix02,matrix03,matrix04,matrix05,matrix06,matrix07,matrix08,matrix09,
  75.                                 matrix10,matrix11,matrix12,matrix13,matrix14,matrix15,matrix16,matrix17,matrix18,matrix19
  76.  
  77. };
  78. /** les vecteurs suivants sont initialises par la commande setvector numvector,u_1,u_2 */
  79. /** ils sont remis a zero par resetvector numvector */
  80. double vector[] = {0,0};
  81. double vector01[] = {0,0};
  82. double vector02[] = {0,0};
  83. double vector03[] = {0,0};
  84. double vector04[] = {0,0};
  85. double vector05[] = {0,0};
  86. double vector06[] = {0,0};
  87. double vector07[] = {0,0};
  88. double vector08[] = {0,0};
  89. double vector09[] = {0,0};
  90. double vector10[] = {0,0};
  91. double vector11[] = {0,0};
  92. double vector12[] = {0,0};
  93. double vector13[] = {0,0};
  94. double vector14[] = {0,0};
  95. double vector15[] = {0,0};
  96. double vector16[] = {0,0};
  97. double vector17[] = {0,0};
  98. double vector18[] = {0,0};
  99. double vector19[] = {0,0};
  100.  
  101. double *vecteurs_pavage[] ={ vector,
  102.                                 vector01,vector02,vector03,vector04,vector05,vector06,vector07,vector08,vector09,
  103.                                 vector10,vector11,vector12,vector13,vector14,vector15,vector16,vector17,vector18,vector19
  104. };
  105.  
  106. /** les coordonnees du parallelograme de pavage = coordonnees "mathematiques" du parallelogramme contenant l'image a recopier **/
  107. /** on place ces coorodonnes avec setparallelogram xs,ys,xu,yu,xv,yu **/
  108. /* xs,ys=coordonnees math du point 0,0,
  109.  * xu,yu coordonnees math de l'horizontale
  110.  * xv,yv coordonnees math de la verticale
  111.  * ces coordonnees sont remises a leur valeur par defaut par resetparallelogram
  112.  */
  113. /** TODO serait-ce un moyen de definir la brush ?? **/
  114. double parallogram_fonda[]={0,0,100,0,0,100};
  115.  
  116. /**** Fin modifs JC Fev 06 ******/
  117.  
  118.         /* Write the image */
  119. void output(void)
  120. {
  121.     FILE *out;
  122.  
  123.     if(!image) return;
  124.     if(imagefilename[0]) {
  125.         out=fopen(imagefilename,"wb");
  126.         if(out!=NULL) {gdImageGif(image,out); fclose(out); }
  127.     }
  128.     else gdImageGif(image,stdout);
  129.     saved=1;
  130. }
  131.  
  132. #include "lines.c"
  133. #include "nametab.c"
  134. #include "evalue.c"
  135. #include "vimg.c"
  136. #include "objects.c"
  137.  
  138. void process(void)
  139. {
  140.     char buf[MAX_LINELEN+1];
  141.     int c;
  142.     do {
  143.         c=ggetline(buf); obj_main(buf);
  144.     }
  145.     while(c!=EOF);
  146. }
  147.  
  148. int verify_tables(void) {
  149.     return evaltab_verify();
  150. }
  151.  
  152. int main(int argc, char *argv[])
  153. {
  154.     error1=error; error2=error; error3=error;
  155.     substitute=substit;
  156.     ev_varcnt=&varcnt; ev_var=vartab;
  157.     if(argc==2 && strcasecmp(argv[1],"table")==0) {
  158.         if(verify_tables()) {
  159.             printf("Table disorder.\n"); return 1;
  160.         }
  161.         printf("Table orders OK.\n"); return 0;
  162.     }
  163.     vartab[0].name="animstep"; vartab[0].value=0;
  164.     varcnt=1;
  165.     if(argc>1) snprintf(imagefilename,sizeof(imagefilename),"%s",argv[1]);
  166.     else imagefilename[0]=0;
  167.     process();
  168.     if(!saved || imagefilename[0]!=0) output();
  169.     if(image) gdImageDestroy(image);
  170.     if(vimg_ready) vimg_close();
  171.     return 0;
  172. }
  173.  
  174.