FAUST compiler  0.9.9.6b8
Public Member Functions
SVGDev Class Reference

#include <SVGDev.h>

Inheritance diagram for SVGDev:
Inheritance graph
[legend]
Collaboration diagram for SVGDev:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SVGDev (const char *, double, double)
 ~SVGDev ()
void rect (double x, double y, double l, double h, const char *color, const char *link)
void triangle (double x, double y, double l, double h, const char *color, const char *link, bool leftright)
void rond (double x, double y, double rayon)
void carre (double x, double y, double cote)
void fleche (double x, double y, double rotation, int sens)
void trait (double x1, double y1, double x2, double y2)
void dasharray (double x1, double y1, double x2, double y2)
void text (double x, double y, const char *name, const char *link)
void label (double x, double y, const char *name)
void markSens (double x, double y, int sens)
void Error (const char *message, const char *reason, int nb_error, double x, double y, double largeur)

Detailed Description

Definition at line 31 of file SVGDev.h.


Constructor & Destructor Documentation

SVGDev::SVGDev ( const char *  ficName,
double  largeur,
double  hauteur 
)

Definition at line 54 of file SVGDev.cpp.

References gShadowBlur.

{
    double gScale = 0.5;
    if ((fic_repr = fopen(ficName,"w+")) == NULL) {
        cout<<"Impossible de creer ou d'ouvrir "<<ficName<<endl;
    }

    // representation file:
    fprintf(fic_repr,"<?xml version=\"1.0\"?>\n");
    // + DTD ...
    // viewBox:
    fprintf(fic_repr,"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 %f %f\" width=\"%fmm\" height=\"%fmm\" version=\"1.1\">\n", largeur, hauteur, largeur*gScale, hauteur*gScale);

    if (gShadowBlur) {
         fprintf(fic_repr,
            "<defs>\n"
            "   <filter id=\"filter\" filterRes=\"18\" x=\"0\" y=\"0\">\n"
            "     <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"1.55\" result=\"blur\"/>\n"
            "     <feOffset in=\"blur\" dx=\"3\" dy=\"3\"/>\n"
            "   </filter>\n"
            "</defs>\n"
            );
    }

}

Definition at line 80 of file SVGDev.cpp.

{
    fprintf(fic_repr,"</svg>\n");
    fclose(fic_repr);
}

Member Function Documentation

void SVGDev::carre ( double  x,
double  y,
double  cote 
) [virtual]

Implements device.

Definition at line 158 of file SVGDev.cpp.

{
    fprintf(fic_repr,"<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\" style=\"stroke: black;stroke-width:0.5;fill:none;\"/>\n",x-0.5*cote,y-cote,cote,cote);
}
void SVGDev::dasharray ( double  x1,
double  y1,
double  x2,
double  y2 
) [virtual]

Implements device.

Definition at line 168 of file SVGDev.cpp.

{
    fprintf(fic_repr,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\"  style=\"stroke: black; stroke-linecap:round; stroke-width:0.25; stroke-dasharray:3,3;\"/>\n",x1,y1,x2,y2);
}
void SVGDev::Error ( const char *  message,
const char *  reason,
int  nb_error,
double  x,
double  y,
double  largeur 
) [virtual]

Implements device.

Definition at line 200 of file SVGDev.cpp.

{
    fprintf(fic_repr,"<text x=\"%f\" y=\"%f\"  textLength=\"%f\" lengthAdjust=\"spacingAndGlyphs\" style=\"stroke: red; stroke-width:0.3; fill:red; text-anchor:middle;\">%d : %s</text>\n",x,y-7,largeur,nb_error,message);
    fprintf(fic_repr,"<text x=\"%f\" y=\"%f\"  textLength=\"%f\" lengthAdjust=\"spacingAndGlyphs\" style=\"stroke: red; stroke-width:0.3; fill:none; text-anchor:middle;\">%s</text>\n",x,y+7,largeur,reason);
}
void SVGDev::fleche ( double  x,
double  y,
double  rotation,
int  sens 
) [virtual]

Implements device.

Definition at line 141 of file SVGDev.cpp.

{
    double dx = 3;
    double dy = 1;

    if(sens == 1)
    {
        fprintf(fic_repr,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\"  transform=\"rotate(%f,%f,%f)\" style=\"stroke: black; stroke-width:0.25;\"/>\n",x-dx,y-dy,x,y,rotation,x,y);
        fprintf(fic_repr,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\"  transform=\"rotate(%f,%f,%f)\" style=\"stroke: black; stroke-width:0.25;\"/>\n",x-dx,y+dy,x,y,rotation,x,y);
    }
    else //for recursion
    {
        fprintf(fic_repr,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\"  transform=\"rotate(%f,%f,%f)\" style=\"stroke: black; stroke-width:0.25;\"/>\n",x+dx,y-dy,x,y,rotation,x,y);
        fprintf(fic_repr,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\"  transform=\"rotate(%f,%f,%f)\" style=\"stroke: black; stroke-width:0.25;\"/>\n",x+dx,y+dy,x,y,rotation,x,y);
    }
}
void SVGDev::label ( double  x,
double  y,
const char *  name 
) [virtual]

Implements device.

Definition at line 188 of file SVGDev.cpp.

References xmlcode().

{
    char name2[256];
    fprintf(fic_repr,"<text x=\"%f\" y=\"%f\" font-family=\"Arial\" font-size=\"7\">%s</text>\n",x,y+2,xmlcode(name,name2));
}

Here is the call graph for this function:

void SVGDev::markSens ( double  x,
double  y,
int  sens 
) [virtual]

Implements device.

Definition at line 194 of file SVGDev.cpp.

{
    int offset = (sens == 1) ? 2 : -2;
    fprintf(fic_repr,"<circle cx=\"%f\" cy=\"%f\" r=\"1\"/>\n", x+offset, y+offset);
}
void SVGDev::rect ( double  x,
double  y,
double  l,
double  h,
const char *  color,
const char *  link 
) [virtual]

Implements device.

Definition at line 86 of file SVGDev.cpp.

References gShadowBlur, and xmlcode().

{
    char buf[512];
    if (link != 0 && link[0]!=0) {
        // open the optional link tag
        fprintf(fic_repr,"<a xlink:href=\"%s\">\n", xmlcode(link, buf));
    }
    // draw the shadow
    if (gShadowBlur) {
        fprintf(fic_repr,"<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\" rx=\"0.1\" ry=\"0.1\" style=\"stroke:none;fill:#aaaaaa;;filter:url(#filter);\"/>\n",x+1,y+1,l,h);
    } else {
        fprintf(fic_repr,"<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\" rx=\"0\" ry=\"0\" style=\"stroke:none;fill:#cccccc;\"/>\n",x+1,y+1,l,h);
    }

    // draw the rectangle
    fprintf(fic_repr,"<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\" rx=\"0\" ry=\"0\" style=\"stroke:none;fill:%s;\"/>\n", x, y, l, h, color);
    if (link != 0 && link[0]!=0) {
        // close the optional link tag
        fprintf(fic_repr,"</a>\n");
    }

}

Here is the call graph for this function:

void SVGDev::rond ( double  x,
double  y,
double  rayon 
) [virtual]

Implements device.

Definition at line 136 of file SVGDev.cpp.

{
    fprintf(fic_repr,"<circle cx=\"%f\" cy=\"%f\" r=\"%f\"/>\n",x,y,rayon);
}
void SVGDev::text ( double  x,
double  y,
const char *  name,
const char *  link 
) [virtual]

Implements device.

Definition at line 173 of file SVGDev.cpp.

References xmlcode().

{
    char buf[512];
    if (link != 0 && link[0]!=0) {
        // open the optional link tag
        fprintf(fic_repr,"<a xlink:href=\"%s\">\n", xmlcode(link, buf));
    }
    char name2[256];
    fprintf(fic_repr,"<text x=\"%f\" y=\"%f\" font-family=\"Arial\" font-size=\"7\" text-anchor=\"middle\" fill=\"#FFFFFF\">%s</text>\n",x,y+2,xmlcode(name,name2));
    if (link != 0 && link[0]!=0) {
        // close the optional link tag
        fprintf(fic_repr,"</a>\n");
    }
}

Here is the call graph for this function:

void SVGDev::trait ( double  x1,
double  y1,
double  x2,
double  y2 
) [virtual]

Implements device.

Definition at line 163 of file SVGDev.cpp.

{
    fprintf(fic_repr,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\"  style=\"stroke:black; stroke-linecap:round; stroke-width:0.25;\"/>\n",x1,y1,x2,y2);
}
void SVGDev::triangle ( double  x,
double  y,
double  l,
double  h,
const char *  color,
const char *  link,
bool  leftright 
) [virtual]

Implements device.

Definition at line 113 of file SVGDev.cpp.

References xmlcode().

{
    char buf[512];
    if (link != 0 && link[0]!=0) {
        // open the optional link tag
        fprintf(fic_repr,"<a xlink:href=\"%s\">\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,"<polygon fill=\"%s\" stroke=\"black\" stroke-width=\".25\" points=\"%f,%f %f,%f %f,%f\"/>\n", color, x0,y, x1,y+h/2.0, x0,y+h);
    fprintf(fic_repr,"<circle  fill=\"%s\" stroke=\"black\" stroke-width=\".25\" cx=\"%f\" cy=\"%f\" r=\"%f\"/>\n", color, x2, y+h/2.0, r);
}

Here is the call graph for this function:


The documentation for this class was generated from the following files: