X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/c7f552fd8888da2f0d8cfb228fe0f28d3df3a12c..b4b6f2ea75b9f0f3ca918f5b84016610bf7a4d4f:/interpretor/faust-0.9.47mr3/compiler/draw/device/SVGDev.cpp diff --git a/interpretor/faust-0.9.47mr3/compiler/draw/device/SVGDev.cpp b/interpretor/faust-0.9.47mr3/compiler/draw/device/SVGDev.cpp deleted file mode 100755 index 12b5a66..0000000 --- a/interpretor/faust-0.9.47mr3/compiler/draw/device/SVGDev.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/************************************************************************ - ************************************************************************ - FAUST compiler - Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale - --------------------------------------------------------------------- - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - ************************************************************************ - ************************************************************************/ - - - -// SVGDev.cpp - -#include "SVGDev.h" -#include "stdio.h" -#include -using namespace std; - -extern bool gShadowBlur; - -static char* xmlcode(const char* name, char* name2) -{ - int i,j; - - // SUBSTITUTION DES CARACTeRES INTERDITS EN XML - - for (i=0, j=0; (name[i] != 0) && (j < 250); i++) { - switch (name[i]) { - case '<' : name2[j++] = '&'; name2[j++] = 'l'; name2[j++] = 't'; name2[j++] = ';'; break; - case '>' : name2[j++] = '&'; name2[j++] = 'g'; name2[j++] = 't'; name2[j++] = ';'; break; - case '\'' : name2[j++] = '&'; name2[j++] = 'a'; name2[j++] = 'p'; name2[j++] = 'o'; name2[j++] = 's'; name2[j++] = ';'; break; - case '"' : name2[j++] = '&'; name2[j++] = 'q'; name2[j++] = 'u'; name2[j++] = 'o'; name2[j++] = 't'; name2[j++] = ';'; break; - case '&' : name2[j++] = '&'; name2[j++] = 'a'; name2[j++] = 'm'; name2[j++] = 'p'; name2[j++] = ';'; break; - default : name2[j++] = name[i]; - } - } - name2[j] = 0; - - return name2; -} - -SVGDev::SVGDev(const char* ficName,double largeur, double hauteur) -{ - double gScale = 0.5; - if ((fic_repr = fopen(ficName,"w+")) == NULL) { - cout<<"Impossible de creer ou d'ouvrir "<\n"); - // + DTD ... - // viewBox: - fprintf(fic_repr,"\n", largeur, hauteur, largeur*gScale, hauteur*gScale); - - if (gShadowBlur) { - fprintf(fic_repr, - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - ); - } - -} - -SVGDev::~SVGDev() -{ - fprintf(fic_repr,"\n"); - fclose(fic_repr); -} - -void SVGDev::rect(double x,double y,double l,double h, const char* color, const char* link) -{ - char buf[512]; - if (link != 0 && link[0]!=0) { - // open the optional link tag - fprintf(fic_repr,"\n", xmlcode(link, buf)); - } - // draw the shadow - if (gShadowBlur) { - fprintf(fic_repr,"\n",x+1,y+1,l,h); - } else { - fprintf(fic_repr,"\n",x+1,y+1,l,h); - } - - // draw the rectangle - fprintf(fic_repr,"\n", x, y, l, h, color); - if (link != 0 && link[0]!=0) { - // close the optional link tag - fprintf(fic_repr,"\n"); - } - -} - -// - -void SVGDev::triangle(double x,double y,double l,double h, const char* color, const char* link, bool leftright) -{ - char buf[512]; - if (link != 0 && link[0]!=0) { - // open the optional link tag - fprintf(fic_repr,"\n", xmlcode(link, buf)); - } - // draw triangle+circle - float r = 1.5; // circle radius - float x0, x1, x2; - if (leftright) { - x0 = x; - x1 = x+l-2*r; - x2 = x+l-r; - } else { - x0 = x+l; - x1 = x+2*r; - x2 = x+r; - } - fprintf(fic_repr,"\n", color, x0,y, x1,y+h/2.0, x0,y+h); - fprintf(fic_repr,"\n", color, x2, y+h/2.0, r); -} - -void SVGDev::rond(double x,double y,double rayon) -{ - fprintf(fic_repr,"\n",x,y,rayon); -} - -void SVGDev::fleche(double x,double y,double rotation,int sens) -{ - double dx = 3; - double dy = 1; - - if(sens == 1) - { - fprintf(fic_repr,"\n",x-dx,y-dy,x,y,rotation,x,y); - fprintf(fic_repr,"\n",x-dx,y+dy,x,y,rotation,x,y); - } - else //for recursion - { - fprintf(fic_repr,"\n",x+dx,y-dy,x,y,rotation,x,y); - fprintf(fic_repr,"\n",x+dx,y+dy,x,y,rotation,x,y); - } -} - -void SVGDev::carre(double x,double y,double cote) -{ - fprintf(fic_repr,"\n",x-0.5*cote,y-cote,cote,cote); -} - -void SVGDev::trait(double x1,double y1,double x2,double y2) -{ - fprintf(fic_repr,"\n",x1,y1,x2,y2); -} - -void SVGDev::dasharray(double x1,double y1,double x2,double y2) -{ - fprintf(fic_repr,"\n",x1,y1,x2,y2); -} - -void SVGDev::text(double x,double y,const char* name, const char* link) -{ - char buf[512]; - if (link != 0 && link[0]!=0) { - // open the optional link tag - fprintf(fic_repr,"\n", xmlcode(link, buf)); - } - char name2[256]; - fprintf(fic_repr,"%s\n",x,y+2,xmlcode(name,name2)); - if (link != 0 && link[0]!=0) { - // close the optional link tag - fprintf(fic_repr,"\n"); - } -} - -void SVGDev::label(double x,double y,const char* name) -{ - char name2[256]; - fprintf(fic_repr,"%s\n",x,y+2,xmlcode(name,name2)); -} - -void SVGDev::markSens(double x,double y,int sens) -{ - int offset = (sens == 1) ? 2 : -2; - fprintf(fic_repr,"\n", x+offset, y+offset); -} - -void SVGDev::Error(const char* message, const char* reason,int nb_error,double x,double y,double largeur) -{ - fprintf(fic_repr,"%d : %s\n",x,y-7,largeur,nb_error,message); - fprintf(fic_repr,"%s\n",x,y+7,largeur,reason); -} - - -