FAUST compiler  0.9.9.6b8
Public Member Functions | List of all members
SVGDev Class Reference

#include <SVGDev.h>

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

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)
 
- Public Member Functions inherited from device
virtual ~device ()
 

Additional Inherited Members

- Protected Attributes inherited from device
FILE * fic_repr
 

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.

55 {
56  double gScale = 0.5;
57  if ((fic_repr = fopen(ficName,"w+")) == NULL) {
58  cout<<"Impossible de creer ou d'ouvrir "<<ficName<<endl;
59  }
60 
61  // representation file:
62  fprintf(fic_repr,"<?xml version=\"1.0\"?>\n");
63  // + DTD ...
64  // viewBox:
65  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);
66 
67  if (gShadowBlur) {
68  fprintf(fic_repr,
69  "<defs>\n"
70  " <filter id=\"filter\" filterRes=\"18\" x=\"0\" y=\"0\">\n"
71  " <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"1.55\" result=\"blur\"/>\n"
72  " <feOffset in=\"blur\" dx=\"3\" dy=\"3\"/>\n"
73  " </filter>\n"
74  "</defs>\n"
75  );
76  }
77 
78 }
bool gShadowBlur
Definition: main.cpp:117
FILE * fic_repr
Definition: device.h:49
SVGDev::~SVGDev ( )

Definition at line 80 of file SVGDev.cpp.

81 {
82  fprintf(fic_repr,"</svg>\n");
83  fclose(fic_repr);
84 }
FILE * fic_repr
Definition: device.h:49

Member Function Documentation

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

Implements device.

Definition at line 158 of file SVGDev.cpp.

159 {
160  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);
161 }
FILE * fic_repr
Definition: device.h:49
void SVGDev::dasharray ( double  x1,
double  y1,
double  x2,
double  y2 
)
virtual

Implements device.

Definition at line 168 of file SVGDev.cpp.

169 {
170  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);
171 }
FILE * fic_repr
Definition: device.h:49
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.

201 {
202  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);
203  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);
204 }
FILE * fic_repr
Definition: device.h:49
void SVGDev::fleche ( double  x,
double  y,
double  rotation,
int  sens 
)
virtual

Implements device.

Definition at line 141 of file SVGDev.cpp.

142 {
143  double dx = 3;
144  double dy = 1;
145 
146  if(sens == 1)
147  {
148  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);
149  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);
150  }
151  else //for recursion
152  {
153  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);
154  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);
155  }
156 }
FILE * fic_repr
Definition: device.h:49
void SVGDev::label ( double  x,
double  y,
const char *  name 
)
virtual

Implements device.

Definition at line 188 of file SVGDev.cpp.

References xmlcode().

189 {
190  char name2[256];
191  fprintf(fic_repr,"<text x=\"%f\" y=\"%f\" font-family=\"Arial\" font-size=\"7\">%s</text>\n",x,y+2,xmlcode(name,name2));
192 }
FILE * fic_repr
Definition: device.h:49
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
static char * xmlcode(const char *name, char *name2)
Definition: SVGDev.cpp:33

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.

195 {
196  int offset = (sens == 1) ? 2 : -2;
197  fprintf(fic_repr,"<circle cx=\"%f\" cy=\"%f\" r=\"1\"/>\n", x+offset, y+offset);
198 }
FILE * fic_repr
Definition: device.h:49
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().

87 {
88  char buf[512];
89  if (link != 0 && link[0]!=0) {
90  // open the optional link tag
91  fprintf(fic_repr,"<a xlink:href=\"%s\">\n", xmlcode(link, buf));
92  }
93  // draw the shadow
94  if (gShadowBlur) {
95  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);
96  } else {
97  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);
98  }
99 
100  // draw the rectangle
101  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);
102  if (link != 0 && link[0]!=0) {
103  // close the optional link tag
104  fprintf(fic_repr,"</a>\n");
105  }
106 
107 }
bool gShadowBlur
Definition: main.cpp:117
FILE * fic_repr
Definition: device.h:49
static char * xmlcode(const char *name, char *name2)
Definition: SVGDev.cpp:33

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.

137 {
138  fprintf(fic_repr,"<circle cx=\"%f\" cy=\"%f\" r=\"%f\"/>\n",x,y,rayon);
139 }
FILE * fic_repr
Definition: device.h:49
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().

174 {
175  char buf[512];
176  if (link != 0 && link[0]!=0) {
177  // open the optional link tag
178  fprintf(fic_repr,"<a xlink:href=\"%s\">\n", xmlcode(link, buf));
179  }
180  char name2[256];
181  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));
182  if (link != 0 && link[0]!=0) {
183  // close the optional link tag
184  fprintf(fic_repr,"</a>\n");
185  }
186 }
FILE * fic_repr
Definition: device.h:49
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
static char * xmlcode(const char *name, char *name2)
Definition: SVGDev.cpp:33

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.

164 {
165  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);
166 }
FILE * fic_repr
Definition: device.h:49
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().

114 {
115  char buf[512];
116  if (link != 0 && link[0]!=0) {
117  // open the optional link tag
118  fprintf(fic_repr,"<a xlink:href=\"%s\">\n", xmlcode(link, buf));
119  }
120  // draw triangle+circle
121  float r = 1.5; // circle radius
122  float x0, x1, x2;
123  if (leftright) {
124  x0 = (float)x;
125  x1 = (float)(x+l-2*r);
126  x2 = (float)(x+l-r);
127  } else {
128  x0 = (float)(x+l);
129  x1 = (float)(x+2*r);
130  x2 = (float)(x+r);
131  }
132  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);
133  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);
134 }
FILE * fic_repr
Definition: device.h:49
static char * xmlcode(const char *name, char *name2)
Definition: SVGDev.cpp:33

Here is the call graph for this function:


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