Changeset 1893 in Sophya
- Timestamp:
- Feb 7, 2002, 10:11:55 AM (24 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pigraphgen.cc
r1887 r1893 6 6 7 7 #include "pigraphgen.h" 8 #include <math.h> 8 9 9 10 //++ … … 247 248 /* --Methode-- */ 248 249 void 249 PIGraphicGen::DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2) 250 { 251 // AFAIREREZA012002 250 PIGraphicGen::DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool fgline) 251 { 252 double dx = (double)x2-(double)x1; 253 double dy = (double)y2-(double)y1; 254 double theta = atan2(dy, dx); 255 256 PIGrCoord x[5], y[5]; 257 PIGrCoord x2l, y2l; 258 bool fgfill = false; 259 int npt = 3; 260 double t0,tp,tm,asz; 261 262 switch (myArrowMrk) { 263 264 case PI_BasicArrowMarker : 265 t0 = M_PI/4.; 266 asz = (double)myArrowMrkSz/cos(t0); 267 tp = theta+0.75*M_PI; 268 tm = theta-0.75*M_PI; 269 x[0] = (double)x2 + cos(tp)*asz; 270 y[0] = (double)y2 + sin(tp)*asz; 271 x[1] = x2; 272 y[1] = y2; 273 x[2] = (double)x2 + cos(tm)*asz; 274 y[2] = (double)y2 + sin(tm)*asz; 275 x2l = x2; y2l =y2; 276 fgfill = false; 277 npt = 3; 278 break; 279 280 case PI_TriangleArrowMarker : 281 case PI_FTriangleArrowMarker : 282 t0 = M_PI/6.; 283 asz = (double)myArrowMrkSz/cos(t0); 284 tp = theta+5.*M_PI/6.; 285 tm = theta-5.*M_PI/6.; 286 x[0] = (double)x2 + cos(tp)*asz; 287 y[0] = (double)y2 + sin(tp)*asz; 288 x[1] = x2; 289 y[1] = y2; 290 x[2] = (double)x2 + cos(tm)*asz; 291 y[2] = (double)y2 + sin(tm)*asz; 292 x[3] = x[0]; 293 y[3] = y[0]; 294 x2l = (double)x2 - cos(theta)*myArrowMrkSz; 295 y2l = (double)y2 - sin(theta)*myArrowMrkSz; 296 npt = 4; 297 if (myArrowMrk == PI_FTriangleArrowMarker) fgfill = true; 298 else fgfill = false; 299 break; 300 301 case PI_ArrowShapedArrowMarker : 302 case PI_FArrowShapedArrowMarker : 303 t0 = M_PI/8.; 304 asz = 2.*(double)myArrowMrkSz*cos(t0); 305 tp = theta+7.*M_PI/8.; 306 tm = theta-7.*M_PI/8.; 307 x2l = (double)x2 - cos(theta)*myArrowMrkSz; 308 y2l = (double)y2 - sin(theta)*myArrowMrkSz; 309 x[0] = x2; 310 y[0] = y2; 311 x[1] = (double)x2 + cos(tp)*asz; 312 y[1] = (double)y2 + sin(tp)*asz; 313 x[2] = x2l; 314 y[2] = y2l; 315 x[3] = (double)x2 + cos(tm)*asz; 316 y[3] = (double)y2 + sin(tm)*asz; 317 x[4] = x[0]; 318 y[4] = y[0]; 319 npt = 5; 320 if (myArrowMrk == PI_FArrowShapedArrowMarker) fgfill = true; 321 else fgfill = false; 322 break; 323 324 default: 325 t0 = M_PI/4.; 326 asz = (double)myArrowMrkSz/cos(t0); 327 tp = theta+5.*M_PI/4.; 328 tm = theta-5.*M_PI/4.; 329 330 x[0] = (double)x2 + cos(tp)*asz; 331 y[0] = (double)y2 + sin(tp)*asz; 332 x[1] = x2; 333 y[1] = y2; 334 x[2] = (double)x2 + cos(tm)*asz; 335 y[2] = (double)y2 + sin(tm)*asz; 336 x[3] = x[0]; 337 y[3] = y[0]; 338 x2l = x2; y2l =y2; 339 fgfill = false; 340 npt = 3; 341 break; 342 } 343 344 if (fgline) DrawLine(x1, y1, x2l, y2l); 345 346 if (fgfill) DrawFPolygon(x, y, npt, false); 347 else DrawPolygon(x, y, npt, false); 252 348 } 253 349 -
trunk/SophyaPI/PI/pigraphgen.h
r1890 r1893 61 61 inline PIGrCoord() { iv = 0; dv = 0.;} 62 62 inline PIGrCoord(int a) { iv = a; dv = (double)a;} 63 inline PIGrCoord(float a) { iv = ( int)a; dv = (double)a;}64 inline PIGrCoord(double a) { iv = ( int)a; dv = a;}63 inline PIGrCoord(float a) { iv = (a>=0.)?(int)(a+0.5):(int)(a-0.5); dv = (double)a;} 64 inline PIGrCoord(double a) { iv = (a>=0.)?(int)(a+0.5):(int)(a-0.5); dv = a;} 65 65 inline PIGrCoord(PIGrCoord const & gc) { iv = gc.iv; dv = gc.dv; } 66 66 inline operator int() { return(iv); } … … 71 71 inline operator double() { return(dv); } 72 72 inline PIGrCoord& operator= (int a) { iv = a; dv = (double)a; return(*this); } 73 inline PIGrCoord& operator= (float a) { iv = (int)a; dv = (double)a; return(*this); } 74 inline PIGrCoord& operator= (double a) { iv = (int)a; dv = a; return(*this); } 73 inline PIGrCoord& operator= (float a) 74 { iv = (a>=0.)?(int)(a+0.5):(int)(a-0.5); dv = (double)a; return(*this); } 75 inline PIGrCoord& operator= (double a) 76 { iv = (a>=0.)?(int)(a+0.5):(int)(a-0.5); dv = a; return(*this); } 75 77 inline PIGrCoord& operator= (PIGrCoord const & gc) { iv = gc.iv; dv = gc.dv; return(*this); } 78 protected: 76 79 int iv; 77 80 double dv; … … 172 175 virtual void DrawMarker(PIGrCoord x0, PIGrCoord y0) = 0; 173 176 virtual void DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n) = 0; 174 virtual void DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2); 177 virtual void DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, 178 bool fgline=true); 175 179 176 180 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, -
trunk/SophyaPI/PI/psfile.cc
r1887 r1893 1119 1119 for(int i = 1; i<n; i++) 1120 1120 fprintf(mPSFile, cmd, x[i], y[i]); 1121 fprintf(mPSFile, " c s\n");1121 fprintf(mPSFile, " s\n"); // On ne ferme pas le path - Reza 02/2002 - fprintf(mPSFile, "c s\n"); 1122 1122 } 1123 1123
Note:
See TracChangeset
for help on using the changeset viewer.