39 for (i=0, j=0; (name[i] != 0) && (j < 250); i++) {
41 case '<' : name2[j++] =
'&'; name2[j++] =
'l'; name2[j++] =
't'; name2[j++] =
';';
break;
42 case '>' : name2[j++] =
'&'; name2[j++] =
'g'; name2[j++] =
't'; name2[j++] =
';';
break;
43 case '\'' : name2[j++] =
'&'; name2[j++] =
'a'; name2[j++] =
'p'; name2[j++] =
'o'; name2[j++] =
's'; name2[j++] =
';';
break;
44 case '"' : name2[j++] =
'&'; name2[j++] =
'q'; name2[j++] =
'u'; name2[j++] =
'o'; name2[j++] =
't'; name2[j++] =
';';
break;
45 case '&' : name2[j++] =
'&'; name2[j++] =
'a'; name2[j++] =
'm'; name2[j++] =
'p'; name2[j++] =
';';
break;
46 default : name2[j++] = name[i];
57 if ((fic_repr = fopen(ficName,
"w+")) == NULL) {
58 cout<<
"Impossible de creer ou d'ouvrir "<<ficName<<endl;
62 fprintf(fic_repr,
"<?xml version=\"1.0\"?>\n");
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);
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"
82 fprintf(fic_repr,
"</svg>\n");
86 void SVGDev::rect(
double x,
double y,
double l,
double h,
const char* color,
const char* link)
89 if (link != 0 && link[0]!=0) {
91 fprintf(fic_repr,
"<a xlink:href=\"%s\">\n",
xmlcode(link, buf));
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);
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);
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) {
104 fprintf(fic_repr,
"</a>\n");
113 void SVGDev::triangle(
double x,
double y,
double l,
double h,
const char* color,
const char* link,
bool leftright)
116 if (link != 0 && link[0]!=0) {
118 fprintf(fic_repr,
"<a xlink:href=\"%s\">\n",
xmlcode(link, buf));
125 x1 = (float)(x+l-2*r);
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);
138 fprintf(fic_repr,
"<circle cx=\"%f\" cy=\"%f\" r=\"%f\"/>\n",x,y,rayon);
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);
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);
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);
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);
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);
176 if (link != 0 && link[0]!=0) {
178 fprintf(fic_repr,
"<a xlink:href=\"%s\">\n",
xmlcode(link, buf));
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) {
184 fprintf(fic_repr,
"</a>\n");
191 fprintf(fic_repr,
"<text x=\"%f\" y=\"%f\" font-family=\"Arial\" font-size=\"7\">%s</text>\n",x,y+2,
xmlcode(name,name2));
196 int offset = (sens == 1) ? 2 : -2;
197 fprintf(fic_repr,
"<circle cx=\"%f\" cy=\"%f\" r=\"1\"/>\n", x+offset, y+offset);
200 void SVGDev::Error(
const char* message,
const char* reason,
int nb_error,
double x,
double y,
double largeur)
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);
void fleche(double x, double y, double rotation, int sens)
void Error(const char *message, const char *reason, int nb_error, double x, double y, double largeur)
void text(double x, double y, const char *name, const char *link)
void rond(double x, double y, double rayon)
void label(double x, double y, const char *name)
void rect(double x, double y, double l, double h, const char *color, const char *link)
void carre(double x, double y, double cote)
const char * name(Symbol *sym)
Returns the name of a symbol.
void trait(double x1, double y1, double x2, double y2)
static char * xmlcode(const char *name, char *name2)
void markSens(double x, double y, int sens)
void triangle(double x, double y, double l, double h, const char *color, const char *link, bool leftright)
SVGDev(const char *, double, double)
void dasharray(double x1, double y1, double x2, double y2)