SVGDev Class Reference

#include <SVGDev.h>

Inherits device.

Collaboration diagram for SVGDev:
[legend]

List of all members.

Public Member Functions

 SVGDev (const char *, double, double)
 ~SVGDev ()
void rect (double, double, double, double, const char *, const char *)
void rond (double, double, double)
void carre (double, double, double)
void fleche (double, double, double, int)
void trait (double, double, double, double)
void dasharray (double, double, double, double)
void text (double, double, const char *)
void label (double, double, const char *)
void markSens (double, double, int)
void Error (const char *, const char *, int, double, double, double)

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 device::fic_repr, and gShadowBlur.

00055 {
00056     double gScale = 0.5;
00057 //  if ((fic_repr = fopen(addFileNum(ficName),"w+")) == NULL) {
00058     if ((fic_repr = fopen(ficName,"w+")) == NULL) {
00059     //if((fic_repr = fopen(ficName,"w+")) == NULL) {
00060         cout<<"Impossible de creer ou d'ouvrir "<<ficName<<endl;
00061     }
00062 
00063     // representation file:
00064     fprintf(fic_repr,"<?xml version=\"1.0\"?>\n");
00065     // + DTD ...
00066     // viewBox:
00067     //fprintf(fic_repr,"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 %f %f\" width=\"200mm\" height=\"150mm\" >\n",largeur,hauteur);
00068     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);
00069 
00070     if (gShadowBlur) {
00071      fprintf(fic_repr,
00072         "<defs>\n"
00073         "   <filter id=\"filter\" filterRes=\"50\" x=\"0\" y=\"0\">\n"
00074         "     <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"1.5\"/>\n"
00075         "     <feOffset dx=\"1\" dy=\"1\"/>\n"
00076         "   </filter>\n"
00077         "</defs>\n"
00078         );
00079     }
00080 
00081 }

SVGDev::~SVGDev (  ) 

Definition at line 83 of file SVGDev.cpp.

References device::fic_repr.

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


Member Function Documentation

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

Implements device.

Definition at line 136 of file SVGDev.cpp.

References device::fic_repr.

00137 {
00138     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);
00139 }

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

Implements device.

Definition at line 147 of file SVGDev.cpp.

References device::fic_repr.

00148 {
00149     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);
00150 }

void SVGDev::Error ( const char *  message,
const char *  reason,
int  nb_error,
double  x,
double  y,
double  largeur 
) [virtual]

Implements device.

Definition at line 173 of file SVGDev.cpp.

References device::fic_repr.

00174 {
00175     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);
00176     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);
00177 }

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

Implements device.

Definition at line 119 of file SVGDev.cpp.

References device::fic_repr.

00120 {
00121     double dx = 3;
00122     double dy = 1;
00123 
00124     if(sens == 1)
00125     {
00126         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);
00127         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);
00128     }
00129     else //for recursion
00130     {
00131         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);
00132         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);
00133     }
00134 }

void SVGDev::label ( double  x,
double  y,
const char *  name 
) [virtual]

Implements device.

Definition at line 159 of file SVGDev.cpp.

References device::fic_repr, and xmlcode().

00160 {
00161     char name2[256];
00162 //  fprintf(fic_repr,"<text x=\"%f\" y=\"%f\" style=\"font-family:Courier;font-weight:normal;font-style:normal;font-size:7\">%s</text>\n",x,y+2,xmlcode(name,name2));
00163     fprintf(fic_repr,"<text x=\"%f\" y=\"%f\" font-family=\"Arial\" font-size=\"7\">%s</text>\n",x,y+2,xmlcode(name,name2));
00164 //  fprintf(fic_repr,"<text x=\"%f\" y=\"%f\" font-family=\"Courier\" font-size=\"7\" fill=\"#000000\">%s</text>\n",x,y+2,xmlcode(name,name2));
00165 }

Here is the call graph for this function:

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

Implements device.

Definition at line 167 of file SVGDev.cpp.

References device::fic_repr.

00168 {
00169     int offset = (sens == 1) ? 2 : -2;
00170     fprintf(fic_repr,"<circle cx=\"%f\" cy=\"%f\" r=\"1\"/>\n", x+offset, y+offset);
00171 }

void SVGDev::rect ( double  x,
double  y,
double  l,
double  h,
const char *  color,
const char *  link 
) [virtual]

Implements device.

Definition at line 89 of file SVGDev.cpp.

References device::fic_repr, gShadowBlur, and xmlcode().

00090 {
00091     char buf[512];
00092     if (link != 0 && link[0]!=0) {
00093         // open the optional link tag
00094         fprintf(fic_repr,"<a xlink:href=\"%s\">\n", xmlcode(link, buf));
00095     }
00096     // draw the shadow
00097     if (gShadowBlur) {
00098         fprintf(fic_repr,"<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\" rx=\"0\" ry=\"0\" style=\"stroke:none;fill:#888888;;filter:url(#filter);\"/>\n",x+1,y+1,l,h);
00099     } else {
00100         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);
00101     }
00102 
00103     // draw the rectangle
00104     //fprintf(fic_repr,"<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\" rx=\"0\" ry=\"0\" style=\"shape-rendering: crispEdges; stroke: black;stroke-width:0.25;fill:%s;\"/>\n", x, y, l, h, color);
00105     //fprintf(fic_repr,"<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\" rx=\"0\" ry=\"0\" style=\"stroke: black;stroke-width:0.25;fill:%s;\"/>\n", x, y, l, h, color);
00106     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);
00107     if (link != 0 && link[0]!=0) {
00108         // close the optional link tag
00109         fprintf(fic_repr,"</a>\n");
00110     }
00111 
00112 }

Here is the call graph for this function:

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

Implements device.

Definition at line 114 of file SVGDev.cpp.

References device::fic_repr.

00115 {
00116     fprintf(fic_repr,"<circle cx=\"%f\" cy=\"%f\" r=\"%f\"/>\n",x,y,rayon);
00117 }

void SVGDev::text ( double  x,
double  y,
const char *  name 
) [virtual]

Implements device.

Definition at line 152 of file SVGDev.cpp.

References device::fic_repr, and xmlcode().

00153 {
00154     char name2[256];
00155     //fprintf(fic_repr,"<text x=\"%f\" y=\"%f\" font-family=\"Courier\" font-size=\"8\" text-anchor=\"middle\">%s</text>\n",x,y+3,xmlcode(name,name2));
00156     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));
00157 }

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 141 of file SVGDev.cpp.

References device::fic_repr.

00142 {
00143     //fprintf(fic_repr,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\"  style=\"shape-rendering: crispEdges; stroke:black; stroke-linecap:round; stroke-width:0.25;\"/>\n",x1,y1,x2,y2);
00144     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);
00145 }


The documentation for this class was generated from the following files:
Generated on Thu Apr 29 00:00:24 2010 for FAUST compiler by  doxygen 1.6.3