#include <PSDev.h>
Inherits device.
Public Member Functions | |
PSDev (const char *, double, double) | |
~PSDev () | |
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) |
Definition at line 31 of file PSDev.h.
PSDev::PSDev | ( | const char * | ficName, | |
double | largeur, | |||
double | hauteur | |||
) |
Definition at line 54 of file PSDev.cpp.
References addFileNum(), and device::fic_repr.
00055 { 00056 if ((fic_repr = fopen(addFileNum(ficName),"w+")) == NULL) { 00057 //if ((fic_repr = fopen(ficName,"w+")) == NULL) { 00058 cout<<"Impossible de creer ou d'ouvrir "<<ficName<<endl; 00059 } 00060 00061 if(largeur<hauteur) 00062 largeur=hauteur; 00063 00064 fprintf(fic_repr,"%%!PS-Adobe-3.0 \n"); 00065 //fprintf(fic_repr,"%%%%Pages: (atend) \n"); 00066 fprintf(fic_repr,"%%%%BoundingBox: 0 0 450 %d\n",(int)floor((hauteur*450/largeur)+1)); 00067 00068 fprintf(fic_repr,"/unit {%f mul} def\n\n",450/largeur); 00069 fprintf(fic_repr,"0 %f unit translate\n",hauteur); 00070 fprintf(fic_repr,"1 -1 scale\n\n"); // postscript's origin = lower left corner (SVG:upper left) 00071 fprintf(fic_repr,"0.6 unit setlinewidth\n"); // lines' width 00072 00073 fprintf(fic_repr,"/Times-Roman findfont %% Get the basic font for text\n"); 00074 //fprintf(fic_repr,"15 unit scalefont %% Scale the font to 15 units\n"); 00075 fprintf(fic_repr,"10 unit scalefont %% Scale the font to 10 units\n"); 00076 fprintf(fic_repr,"setfont %% Make it the current font\n\n"); 00077 }
PSDev::~PSDev | ( | ) |
Definition at line 79 of file PSDev.cpp.
References device::fic_repr.
void PSDev::carre | ( | double | x, | |
double | y, | |||
double | cote | |||
) | [virtual] |
Implements device.
Definition at line 145 of file PSDev.cpp.
References device::fic_repr.
00146 { 00147 fprintf(fic_repr,"gsave\n"); 00148 fprintf(fic_repr,"newpath\n"); 00149 fprintf(fic_repr,"0.3 setgray\n"); 00150 fprintf(fic_repr,"%f unit %f unit moveto\n",x-cote/2,y); 00151 fprintf(fic_repr,"0 unit %f unit rlineto\n",-cote); 00152 fprintf(fic_repr,"%f unit 0 unit rlineto\n",cote); 00153 fprintf(fic_repr,"0 unit %f unit rlineto\n",cote); 00154 fprintf(fic_repr,"closepath\n"); 00155 fprintf(fic_repr,"stroke\n"); 00156 fprintf(fic_repr,"grestore\n"); 00157 }
void PSDev::dasharray | ( | double | x1, | |
double | y1, | |||
double | x2, | |||
double | y2 | |||
) | [virtual] |
Implements device.
Definition at line 170 of file PSDev.cpp.
References device::fic_repr.
00171 { 00172 fprintf(fic_repr,"gsave\n"); 00173 fprintf(fic_repr,"newpath\n"); 00174 fprintf(fic_repr,"0.6 setgray\n"); 00175 fprintf(fic_repr,"0.8 unit setlinewidth\n"); 00176 fprintf(fic_repr,"%f unit %f unit moveto\n",x1,y1); 00177 fprintf(fic_repr,"%f unit %f unit lineto\n",x2,y2); 00178 fprintf(fic_repr,"stroke\n"); 00179 fprintf(fic_repr,"grestore\n"); 00180 }
void PSDev::Error | ( | const char * | message, | |
const char * | reason, | |||
int | nb_error, | |||
double | x, | |||
double | y, | |||
double | largeur | |||
) | [virtual] |
Implements device.
Definition at line 225 of file PSDev.cpp.
References device::fic_repr.
00226 { 00227 fprintf(fic_repr,"gsave\n"); 00228 fprintf(fic_repr,"/Times-Roman findfont %% Get the basic font for text\n"); 00229 fprintf(fic_repr,"17 unit scalefont %% Scale the font to 10 points\n"); 00230 fprintf(fic_repr,"setfont %% Make it the current font\n\n"); 00231 fprintf(fic_repr,"newpath\n"); 00232 fprintf(fic_repr,"%f unit %f unit moveto\n",(x-8)-(strlen(message)-1)*3.8,y-10); 00233 fprintf(fic_repr,"1 -1 scale\n"); 00234 fprintf(fic_repr,"(%s) show\n",message); 00235 fprintf(fic_repr,"1 -1 scale\n"); 00236 fprintf(fic_repr,"%f unit %f unit moveto\n",(x-8)-(strlen(reason)-1)*3.8,y+10); 00237 fprintf(fic_repr,"1 -1 scale\n"); 00238 fprintf(fic_repr,"(%s) show\n",reason); 00239 fprintf(fic_repr,"grestore\n"); 00240 00241 }
void PSDev::fleche | ( | double | x, | |
double | y, | |||
double | rotation, | |||
int | sens | |||
) | [virtual] |
Implements device.
Definition at line 109 of file PSDev.cpp.
References device::fic_repr.
00110 { 00111 if(sens == 1) 00112 { 00113 fprintf(fic_repr,"gsave\n"); 00114 fprintf(fic_repr,"newpath\n"); 00115 fprintf(fic_repr,"0.3 setgray\n"); 00116 fprintf(fic_repr,"%f unit %f unit moveto\n",x,y); 00117 fprintf(fic_repr,"%f rotate\n",rotation); 00118 fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)-4,(double)-2); 00119 fprintf(fic_repr,"%f rotate\n",(double)-rotation); 00120 fprintf(fic_repr,"%f unit %f unit moveto\n",x,y); 00121 fprintf(fic_repr,"%f rotate\n",rotation); 00122 fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)-4,(double)+2); 00123 fprintf(fic_repr,"closepath\n"); 00124 fprintf(fic_repr,"stroke\n"); 00125 fprintf(fic_repr,"grestore\n"); 00126 } 00127 else //for the recursion 00128 { 00129 fprintf(fic_repr,"gsave\n"); 00130 fprintf(fic_repr,"newpath\n"); 00131 fprintf(fic_repr,"0.3 setgray\n"); 00132 fprintf(fic_repr,"%f unit %f unit moveto\n",x,y); 00133 fprintf(fic_repr,"%f rotate\n",rotation); 00134 fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)4,(double)-2); 00135 fprintf(fic_repr,"%f rotate\n",(double)-rotation); 00136 fprintf(fic_repr,"%f unit %f unit moveto\n",x,y); 00137 fprintf(fic_repr,"%f rotate\n",rotation); 00138 fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)4,(double)+2); 00139 fprintf(fic_repr,"closepath\n"); 00140 fprintf(fic_repr,"stroke\n"); 00141 fprintf(fic_repr,"grestore\n"); 00142 } 00143 }
void PSDev::label | ( | double | x, | |
double | y, | |||
const char * | label | |||
) | [virtual] |
Implements device.
Definition at line 193 of file PSDev.cpp.
References device::fic_repr.
00194 { 00195 fprintf(fic_repr,"gsave\n"); 00196 fprintf(fic_repr,"/Times-Roman findfont %% Get the basic font for text\n"); 00197 fprintf(fic_repr,"7 unit scalefont %% Scale the font to 10 points\n"); 00198 fprintf(fic_repr,"setfont %% Make it the current font\n\n"); 00199 fprintf(fic_repr,"newpath\n"); 00200 fprintf(fic_repr,"%f unit %f unit moveto\n",(x+2),y+1.2); 00201 fprintf(fic_repr,"1 -1 scale\n"); 00202 fprintf(fic_repr,"(%s) show\n",label); 00203 fprintf(fic_repr,"grestore\n"); 00204 }
void PSDev::markSens | ( | double | x, | |
double | y, | |||
int | sens | |||
) | [virtual] |
Implements device.
Definition at line 206 of file PSDev.cpp.
References device::fic_repr.
00207 { 00208 if (sens==1) 00209 { 00210 fprintf(fic_repr,"newpath\n"); 00211 fprintf(fic_repr,"%f unit %f unit moveto\n",x,y+4); 00212 fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)4,(double)-4); 00213 fprintf(fic_repr,"closepath\n"); 00214 } 00215 else //for the recursion 00216 { 00217 fprintf(fic_repr,"newpath\n"); 00218 fprintf(fic_repr,"%f unit %f unit moveto\n",x,y-4); 00219 fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)-4,(double)4); 00220 fprintf(fic_repr,"closepath\n"); 00221 } 00222 fprintf(fic_repr,"stroke\n"); 00223 }
void PSDev::rect | ( | double | x, | |
double | y, | |||
double | l, | |||
double | h, | |||
const char * | , | |||
const char * | ||||
) | [virtual] |
Implements device.
Definition at line 85 of file PSDev.cpp.
References device::fic_repr.
00086 { 00087 fprintf(fic_repr,"gsave\n"); 00088 fprintf(fic_repr,"newpath\n"); 00089 //fprintf(fic_repr,"1.5 unit setlinewidth\n"); 00090 fprintf(fic_repr,"1.0 unit setlinewidth\n"); 00091 fprintf(fic_repr,"%f unit %f unit moveto\n",x,y); 00092 fprintf(fic_repr,"0 unit %f unit rlineto\n",h); 00093 fprintf(fic_repr,"%f unit 0 unit rlineto\n",l); 00094 fprintf(fic_repr,"0 unit %f unit rlineto\n",-h); 00095 fprintf(fic_repr,"closepath\n"); 00096 fprintf(fic_repr,"stroke\n"); 00097 fprintf(fic_repr,"grestore\n"); 00098 }
void PSDev::rond | ( | double | x, | |
double | y, | |||
double | rayon | |||
) | [virtual] |
void PSDev::text | ( | double | x, | |
double | y, | |||
const char * | nom | |||
) | [virtual] |
Implements device.
Definition at line 182 of file PSDev.cpp.
References device::fic_repr.
00183 { 00184 fprintf(fic_repr,"newpath\n"); 00185 //fprintf(fic_repr,"%f unit %f unit moveto\n",(x-4)-(strlen(nom)-1)*3.8,y+2); 00186 fprintf(fic_repr,"%f unit %f unit moveto\n",(x-0)-(strlen(nom)-1)*3.8,y+2); 00187 fprintf(fic_repr,"gsave\n"); 00188 fprintf(fic_repr,"1 -1 scale\n\n"); 00189 fprintf(fic_repr,"(%s) show\n",nom); 00190 fprintf(fic_repr,"grestore\n"); 00191 }
void PSDev::trait | ( | double | x1, | |
double | y1, | |||
double | x2, | |||
double | y2 | |||
) | [virtual] |
Implements device.
Definition at line 159 of file PSDev.cpp.
References device::fic_repr.
00160 { 00161 fprintf(fic_repr,"gsave\n"); 00162 fprintf(fic_repr,"0.3 setgray\n"); 00163 fprintf(fic_repr,"newpath\n"); 00164 fprintf(fic_repr,"%f unit %f unit moveto\n",x1,y1); 00165 fprintf(fic_repr,"%f unit %f unit lineto\n",x2,y2); 00166 fprintf(fic_repr,"stroke\n"); 00167 fprintf(fic_repr,"grestore\n"); 00168 }