Changeset 2257 in Sophya for trunk/SophyaPI
- Timestamp:
- Nov 12, 2002, 1:10:20 PM (23 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pigraphgen.cc
r2242 r2257 317 317 int PIGraphicGen::ComputeArcFrom3Pt(double x1, double y1, double x2, double y2, 318 318 double x3, double y3, double& x0, double& y0, 319 double& dx, double& dy, double& degdeb, double& de gfin)319 double& dx, double& dy, double& degdeb, double& deltadeg) 320 320 { 321 321 x0 = y0 = dx = dy = 0.; 322 degdeb = de gfin= 0.;322 degdeb = deltadeg = 0.; 323 323 double px[2], py[2]; 324 324 cout << "DBG - Arc3Pt" << x1 << "," << y1 << " - " … … 389 389 double r = sqrt(delx*delx+dely*dely); 390 390 double ang1 = atan2(dely, delx); 391 delx = x3-xc; 392 dely = y3-yc; 393 double ang2 = atan2(dely, delx); 391 double delx2 = x3-xc; 392 double dely2 = y3-yc; 393 double ang2 = atan2(dely2, delx2); 394 // angle M1-O-M3 : Produit scalaire OM1 . OM3 395 double cda = (delx*delx2+dely*dely2)/sqrt(delx*delx+dely*dely)/sqrt(delx2*delx2+dely2*dely2); 396 double dang = acos(cda); 397 // angle M1-O-M3 : Produit vectoriel OM1 X OM3 - Signe de l'angle deltaAngle 398 double sda = (delx*dely2-dely*delx2); 399 // Produit scalaire (OM1 + OM3) . OM2 : deltaAngle ou 2*PI-DeltaAngle 400 delx = (x1+x3)-xc; 401 dely = (y1+y3)-yc; 402 double daopi = (delx*delx2+dely*dely2)/sqrt(delx*delx+dely*dely)/sqrt(delx2*delx2+dely2*dely2); 403 if (sda >= 0.) { 404 if (daopi < 0.) { 405 degdeb = ang2*180./M_PI; 406 deltadeg = (360.-dang*180./M_PI); 407 } 408 else { 409 degdeb = ang1*180./M_PI; 410 deltadeg = dang*180./M_PI; 411 } 412 } 413 else { 414 if (daopi < 0.) { 415 degdeb = ang1*180./M_PI; 416 deltadeg = (360.-dang*180./M_PI); 417 } 418 else { 419 degdeb = ang2*180./M_PI; 420 deltadeg = dang*180./M_PI; 421 } 422 } 394 423 x0 = (xc-r); 395 424 y0 = (yc-r); 396 425 dx = dy = 2.*r; 397 degdeb = -ang1*180./M_PI;398 degfin = -ang2*180./M_PI;399 426 cout << "DBG - Arc3Pt-2 " << xc << "," << yc << " R=" << r << " deg= " 400 << degdeb << " :: " << degfin<< endl;427 << degdeb << " Delta= " << deltadeg << endl; 401 428 return(0); 402 429 } -
trunk/SophyaPI/PI/pigraphgen.h
r2242 r2257 100 100 virtual void DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true) = 0; 101 101 virtual void DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 102 double degdeb, double de gfin)= 0;102 double degdeb, double deltadeg) = 0; 103 103 virtual void DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 104 double degdeb, double de gfin)= 0;104 double degdeb, double deltadeg) = 0; 105 105 106 106 virtual void Draw3PtArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, -
trunk/SophyaPI/PI/pigraphmac.cc
r1890 r2257 164 164 /* --Methode-- */ 165 165 void PIGraphicMac::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 166 double degdeb, double de gfin)166 double degdeb, double deltadeg) 167 167 { 168 168 if (mPane->FocusDraw()) { … … 170 170 if (rr.top > rr.bottom) swap(rr.top, rr.bottom); 171 171 if (rr.left > rr.right) swap(rr.left, rr.right); 172 ::FrameArc(&rr, degdeb, de gfin-degdeb);172 ::FrameArc(&rr, degdeb, deltadeg); 173 173 } 174 174 } … … 176 176 /* --Methode-- */ 177 177 void PIGraphicMac::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 178 double degdeb, double de gfin)178 double degdeb, double deltadeg) 179 179 { 180 180 if (mPane->FocusDraw()) { … … 182 182 if (rr.top > rr.bottom) swap(rr.top, rr.bottom); 183 183 if (rr.left > rr.right) swap(rr.left, rr.right); 184 ::PaintArc(&rr, degdeb, de gfin-degdeb);184 ::PaintArc(&rr, degdeb, deltadeg); 185 185 } 186 186 } -
trunk/SophyaPI/PI/pigraphmac.h
r1890 r2257 30 30 virtual void DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 31 31 virtual void DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 32 double degdeb, double de gfin);32 double degdeb, double deltadeg); 33 33 virtual void DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 34 double degdeb, double de gfin);34 double degdeb, double deltadeg); 35 35 virtual void DrawMarker(PIGrCoord x0, PIGrCoord y0); 36 36 virtual void DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n); -
trunk/SophyaPI/PI/pigraphps.cc
r1899 r2257 197 197 { 198 198 if(mPSOut) 199 mPSOut->DrawFCircle((double)x0,(double)y0,(double)r,mFCol,mFCol ,mLAtt);199 mPSOut->DrawFCircle((double)x0,(double)y0,(double)r,mFCol,mFCol); 200 200 return; 201 201 } … … 204 204 void PIGraphicPS::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) 205 205 { 206 // $CHECK$ Reza/ Nicolas 12 Nov 98 - A faire 206 if(mPSOut) 207 mPSOut->DrawArc((double)x0,(double)y0,(double)dx,(double)dy,0.,360.,mFCol,mLAtt); 208 return; 207 209 } 208 210 … … 210 212 void PIGraphicPS::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) 211 213 { 212 // $CHECK$ Reza/ Nicolas 12 Nov 98 - A faire 214 if(mPSOut) 215 mPSOut->DrawFArc((double)x0,(double)y0,(double)dx,(double)dy,0.,360.,mFCol,mFCol); 216 return; 217 213 218 } 214 219 … … 271 276 272 277 /* --Methode-- */ 273 void PIGraphicPS::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double degfin) 274 { 275 // $CHECK$ Reza/ Nicolas 12 Nov 98 - A faire 276 } 277 278 /* --Methode-- */ 279 void PIGraphicPS::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double degfin) 280 { 281 // $CHECK$ Reza/ Nicolas 12 Nov 98 - A faire 278 void PIGraphicPS::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double deltadeg) 279 { 280 if(mPSOut) 281 mPSOut->DrawArc((double)x0,(double)y0,(double)dx,(double)dy,degdeb,deltadeg,mFCol,mLAtt); 282 return; 283 } 284 285 /* --Methode-- */ 286 void PIGraphicPS::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double deltadeg) 287 { 288 if(mPSOut) 289 mPSOut->DrawFArc((double)x0,(double)y0,(double)dx,(double)dy,degdeb,deltadeg,mFCol,mFCol); 290 return; 282 291 } 283 292 … … 287 296 if(mPSOut) 288 297 mPSOut->DrawMarker((double)x0,(double)y0,mMrk,mFCol,mMrkSz); 289 // $CHECK$ Ajouter starmarker290 // /* Coordonnees pour une etoile a 5 branches */291 // double pio5 = M_PI/2.5;292 // double pio52 = pio5/2.;293 // double cpi2 = M_PI/2.-pio5;294 // double re = 1.2; // Rayon externe295 // double ri = 0.5; // rayon interne pour rext=1.2296 // for(int k=0; k<5; k++) {297 // starcoordx[2*k] = cos(k*pio5+cpi2)*re;298 // starcoordy[2*k] = -sin(k*pio5+cpi2)*re;299 // starcoordx[2*k+1] = cos(k*pio5+pio52+cpi2)*ri;300 // starcoordy[2*k+1] = -sin(k*pio5+pio52+cpi2)*ri;301 // }302 303 298 return; 304 299 } -
trunk/SophyaPI/PI/pigraphps.h
r1898 r2257 33 33 virtual void DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 34 34 virtual void DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 35 double degdeb, double de gfin);35 double degdeb, double deltadeg); 36 36 virtual void DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 37 double degdeb, double de gfin);37 double degdeb, double deltadeg); 38 38 virtual void DrawMarker(PIGrCoord x0, PIGrCoord y0); 39 39 virtual void DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n); -
trunk/SophyaPI/PI/pigraphuc.cc
r2242 r2257 631 631 /* --Methode-- */ 632 632 void PIGraphicUC::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 633 double degdeb, double de gfin)633 double degdeb, double deltadeg) 634 634 { 635 635 if (!mGrC) return; … … 638 638 UC2GrC(x0, y0, xf, yf); 639 639 DUC2GrC(dx, dy, dxf, dyf); 640 mGrC->DrawArc(xf, yf, dxf, dyf, degdeb, de gfin);640 mGrC->DrawArc(xf, yf, dxf, dyf, degdeb, deltadeg); 641 641 } 642 642 /* --Methode-- */ 643 643 void PIGraphicUC::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 644 double degdeb, double de gfin)644 double degdeb, double deltadeg) 645 645 { 646 646 if (!mGrC) return; … … 649 649 UC2GrC(x0, y0, xf, yf); 650 650 DUC2GrC(dx, dy, dxf, dyf); 651 mGrC->DrawFArc(xf, yf, dxf, dyf, degdeb, de gfin);651 mGrC->DrawFArc(xf, yf, dxf, dyf, degdeb, deltadeg); 652 652 } 653 653 -
trunk/SophyaPI/PI/pigraphuc.h
r2247 r2257 65 65 virtual void DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 66 66 virtual void DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 67 double degdeb, double de gfin);67 double degdeb, double deltadeg); 68 68 virtual void DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 69 double degdeb, double de gfin);69 double degdeb, double deltadeg); 70 70 virtual void Draw3PtArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, 71 71 PIGrCoord x3, PIGrCoord y3); 72 72 virtual void Draw3PtFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, 73 73 PIGrCoord x3, PIGrCoord y3); 74 static int ComputeArcFrom3Pt(PIGrCoord& x1, PIGrCoord& y1,75 PIGrCoord& x2, PIGrCoord& y2,76 PIGrCoord& x3, PIGrCoord& y3,77 PIGrCoord& x0, PIGrCoord& y0,78 PIGrCoord& dx, PIGrCoord& dy,79 double& degdeb, double& degfin);80 74 81 75 virtual void DrawMarker(PIGrCoord x0, PIGrCoord y0); -
trunk/SophyaPI/PI/pigraphx.cc
r1977 r2257 261 261 /* --Methode-- */ 262 262 void PIGraphicX::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 263 double degdeb, double degfin) 264 { 263 double degdeb, double deltadeg) 264 { 265 // Convention X est ds le sens trigo inverse 266 degdeb = 360. - (degdeb+deltadeg); 265 267 XDrawArc(mDisp, mWId, DefGC(), 266 (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(de gfin*64.));268 (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(deltadeg*64.)); 267 269 return; 268 270 } … … 270 272 /* --Methode-- */ 271 273 void PIGraphicX::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 272 double degdeb, double degfin) 273 { 274 double degdeb, double deltadeg) 275 { 276 degdeb = 360. - (degdeb+deltadeg); 274 277 XFillArc(mDisp, mWId, DefGC(), 275 (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(de gfin*64.));278 (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(deltadeg*64.)); 276 279 return; 277 280 } -
trunk/SophyaPI/PI/pigraphx.h
r1898 r2257 33 33 virtual void DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 34 34 virtual void DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 35 double degdeb, double de gfin);35 double degdeb, double deltadeg); 36 36 virtual void DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 37 double degdeb, double de gfin);37 double degdeb, double deltadeg); 38 38 virtual void DrawMarker(PIGrCoord x0, PIGrCoord y0); 39 39 virtual void DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n); -
trunk/SophyaPI/PI/psfile.cc
r1904 r2257 1112 1112 } 1113 1113 1114 void PSFile::DrawArc (double x0, double y0, double dx, double dy, 1115 double degdeb, double deltadeg, 1116 PIColors DrawColor, 1117 PILineAtt LineAtt) { 1118 1119 /* Line Att */ 1120 if ( (LineAtt != PI_NotDefLineAtt) && (LineAtt != mLineAtt) ) 1121 SelectLine(LineAtt); 1122 1123 /* Couleurs */ 1124 if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) { 1125 mDrawColor = DrawColor; 1126 fprintf(mPSFile, "C%d ", mDrawColor); 1127 } 1128 1129 1130 /* Dessin */ 1131 fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy %.2f %.2f ellipse s gr\n", 1132 x0+dx/2, y0+dy/2, dx/2, dy/2, degdeb, deltadeg) ; 1133 } 1134 1135 1136 void PSFile::DrawFArc (double x0, double y0, double dx, double dy, 1137 double degdeb, double deltadeg, 1138 PIColors DrawColor, 1139 PIColors FillColor, 1140 PILineAtt LineAtt) { 1141 1142 /* Line Att */ 1143 if ( (LineAtt != PI_NotDefLineAtt) && (LineAtt != mLineAtt) ) 1144 SelectLine(LineAtt); 1145 1146 /* Dessin du fond */ 1147 if ( (FillColor != PI_NotDefColor) || (FillColor != mDrawColor) ){ 1148 mDrawColor = FillColor; 1149 fprintf(mPSFile, "C%d ", mDrawColor) ; 1150 } 1151 fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy %.2f %.2f ellipse f gr\n", 1152 x0+dx/2, y0+dy/2, dx/2, dy/2, degdeb, deltadeg); 1153 1154 /* Dessin du contour (s'il y a lieu) */ 1155 if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) ) { 1156 mDrawColor = DrawColor; 1157 fprintf(mPSFile, "C%d ", mDrawColor); 1158 fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy %.2f %.2f ellipse s gr\n", 1159 x0+dx/2, y0+dy/2, dx/2, dy/2, degdeb, deltadeg) ; 1160 } 1161 } 1162 1114 1163 1115 1164 // Les coordonnees sont supposees etre en mode incremental . -
trunk/SophyaPI/PI/psfile.h
r1898 r2257 134 134 PIColors FillColor = PI_NotDefColor, 135 135 PILineAtt LineAtt = PI_NotDefLineAtt); 136 virtual void DrawArc (double x0, double y0, double dx, double dy, 137 double degdeb, double deltadeg, 138 PIColors DrawColor = PI_NotDefColor, 139 PILineAtt LineAtt = PI_NotDefLineAtt); 140 virtual void DrawFArc (double x0, double y0, double dx, double dy, 141 double degdeb, double deltadeg, 142 PIColors DrawColor = PI_NotDefColor, 143 PIColors FillColor = PI_NotDefColor, 144 PILineAtt LineAtt = PI_NotDefLineAtt); 136 145 virtual void DrawPolygon (double *x, double *y, int n, 137 146 PIColors DrawColor = PI_NotDefColor,
Note:
See TracChangeset
for help on using the changeset viewer.