Changeset 2257 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Nov 12, 2002, 1:10:20 PM (23 years ago)
Author:
ansari
Message:

Correction/implementation trace Arc, en particulier par 3 points - Reza 12/11/2002

Location:
trunk/SophyaPI/PI
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pigraphgen.cc

    r2242 r2257  
    317317int PIGraphicGen::ComputeArcFrom3Pt(double x1, double y1, double x2, double y2,
    318318                                    double x3, double y3, double& x0, double& y0,
    319                                     double& dx, double& dy, double& degdeb, double& degfin)
     319                                    double& dx, double& dy, double& degdeb, double& deltadeg)
    320320{
    321321  x0 = y0 = dx = dy = 0.;
    322   degdeb = degfin = 0.;
     322  degdeb = deltadeg = 0.;
    323323  double px[2], py[2];
    324324  cout << "DBG - Arc3Pt" << x1 << "," << y1 << " - "
     
    389389  double r = sqrt(delx*delx+dely*dely);
    390390  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  }
    394423  x0 = (xc-r);
    395424  y0 = (yc-r);
    396425  dx = dy = 2.*r;
    397   degdeb = -ang1*180./M_PI;
    398   degfin = -ang2*180./M_PI;
    399426  cout << "DBG - Arc3Pt-2  " << xc << "," << yc << " R=" << r << " deg= "
    400        << degdeb << " :: " << degfin << endl;
     427       << degdeb << " Delta= " << deltadeg << endl;
    401428  return(0);
    402429}
  • trunk/SophyaPI/PI/pigraphgen.h

    r2242 r2257  
    100100  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)   = 0; 
    101101  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    102                              double degdeb, double degfin)                             = 0;
     102                             double degdeb, double deltadeg)                           = 0;
    103103  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    104                               double degdeb, double degfin)                            = 0;
     104                              double degdeb, double deltadeg)                          = 0;
    105105
    106106  virtual void       Draw3PtArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
  • trunk/SophyaPI/PI/pigraphmac.cc

    r1890 r2257  
    164164/* --Methode-- */
    165165void PIGraphicMac::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    166                          double degdeb, double degfin)
     166                         double degdeb, double deltadeg)
    167167{
    168168  if (mPane->FocusDraw()) {
     
    170170    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
    171171    if (rr.left > rr.right)  swap(rr.left, rr.right);
    172     ::FrameArc(&rr, degdeb, degfin-degdeb);
     172    ::FrameArc(&rr, degdeb, deltadeg);
    173173  }
    174174}
     
    176176/* --Methode-- */
    177177void PIGraphicMac::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    178                          double degdeb, double degfin)
     178                         double degdeb, double deltadeg)
    179179{
    180180  if (mPane->FocusDraw()) {
     
    182182    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
    183183    if (rr.left > rr.right)  swap(rr.left, rr.right);
    184     ::PaintArc(&rr, degdeb, degfin-degdeb);
     184    ::PaintArc(&rr, degdeb, deltadeg);
    185185  }
    186186}
  • trunk/SophyaPI/PI/pigraphmac.h

    r1890 r2257  
    3030  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
    3131  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    32                              double degdeb, double degfin);
     32                             double degdeb, double deltadeg);
    3333  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    34                               double degdeb, double degfin);
     34                              double degdeb, double deltadeg);
    3535  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    3636  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
  • trunk/SophyaPI/PI/pigraphps.cc

    r1899 r2257  
    197197{
    198198if(mPSOut)
    199   mPSOut->DrawFCircle((double)x0,(double)y0,(double)r,mFCol,mFCol,mLAtt);
     199  mPSOut->DrawFCircle((double)x0,(double)y0,(double)r,mFCol,mFCol);
    200200return;
    201201}
     
    204204void PIGraphicPS::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
    205205{
    206 // $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
     206if(mPSOut)
     207  mPSOut->DrawArc((double)x0,(double)y0,(double)dx,(double)dy,0.,360.,mFCol,mLAtt);
     208return;
    207209}
    208210
     
    210212void PIGraphicPS::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
    211213{
    212 // $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
     214if(mPSOut)
     215  mPSOut->DrawFArc((double)x0,(double)y0,(double)dx,(double)dy,0.,360.,mFCol,mFCol);
     216return;
     217
    213218}
    214219
     
    271276
    272277/* --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
     278void PIGraphicPS::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double deltadeg)
     279{
     280if(mPSOut)
     281  mPSOut->DrawArc((double)x0,(double)y0,(double)dx,(double)dy,degdeb,deltadeg,mFCol,mLAtt);
     282return;
     283}
     284
     285/* --Methode-- */
     286void PIGraphicPS::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double deltadeg)
     287{
     288if(mPSOut)
     289  mPSOut->DrawFArc((double)x0,(double)y0,(double)dx,(double)dy,degdeb,deltadeg,mFCol,mFCol);
     290return;
    282291}
    283292
     
    287296if(mPSOut)
    288297  mPSOut->DrawMarker((double)x0,(double)y0,mMrk,mFCol,mMrkSz);
    289 // $CHECK$ Ajouter starmarker
    290 // /* 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 externe
    295 // double ri = 0.5; //  rayon interne pour rext=1.2
    296 // 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 
    303298return;
    304299}
  • trunk/SophyaPI/PI/pigraphps.h

    r1898 r2257  
    3333  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
    3434  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    35                              double degdeb, double degfin);
     35                             double degdeb, double deltadeg);
    3636  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    37                               double degdeb, double degfin);
     37                              double degdeb, double deltadeg);
    3838  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    3939  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
  • trunk/SophyaPI/PI/pigraphuc.cc

    r2242 r2257  
    631631/* --Methode-- */
    632632void PIGraphicUC::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    633                           double degdeb, double degfin)
     633                          double degdeb, double deltadeg)
    634634{
    635635  if (!mGrC) return;
     
    638638  UC2GrC(x0, y0, xf, yf);
    639639  DUC2GrC(dx, dy, dxf, dyf);
    640   mGrC->DrawArc(xf, yf, dxf, dyf, degdeb, degfin);
     640  mGrC->DrawArc(xf, yf, dxf, dyf, degdeb, deltadeg);
    641641}
    642642/* --Methode-- */
    643643void PIGraphicUC::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    644                            double degdeb, double degfin)
     644                           double degdeb, double deltadeg)
    645645{
    646646  if (!mGrC) return;
     
    649649  UC2GrC(x0, y0, xf, yf);
    650650  DUC2GrC(dx, dy, dxf, dyf);
    651   mGrC->DrawFArc(xf, yf, dxf, dyf, degdeb, degfin);
     651  mGrC->DrawFArc(xf, yf, dxf, dyf, degdeb, deltadeg);
    652652}
    653653
  • trunk/SophyaPI/PI/pigraphuc.h

    r2247 r2257  
    6565  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);
    6666  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    67                              double degdeb, double degfin);
     67                             double degdeb, double deltadeg);
    6868  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    69                               double degdeb, double degfin);
     69                              double degdeb, double deltadeg);
    7070  virtual void       Draw3PtArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
    7171                                PIGrCoord x3, PIGrCoord y3);
    7272  virtual void       Draw3PtFArc(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
    7373                                 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);
    8074 
    8175  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
  • trunk/SophyaPI/PI/pigraphx.cc

    r1977 r2257  
    261261/* --Methode-- */
    262262void 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
     266degdeb = 360. - (degdeb+deltadeg);
    265267XDrawArc(mDisp, mWId, DefGC(),
    266          (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(degfin*64.));
     268         (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(deltadeg*64.));
    267269return;
    268270}
     
    270272/* --Methode-- */
    271273void PIGraphicX::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    272                          double degdeb, double degfin)
    273 {
     274                         double degdeb, double deltadeg)
     275{
     276degdeb = 360. - (degdeb+deltadeg);
    274277XFillArc(mDisp, mWId, DefGC(),
    275          (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(degfin*64.));
     278         (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(deltadeg*64.));
    276279return;
    277280}
  • trunk/SophyaPI/PI/pigraphx.h

    r1898 r2257  
    3333  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
    3434  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    35                              double degdeb, double degfin);
     35                             double degdeb, double deltadeg);
    3636  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
    37                               double degdeb, double degfin);
     37                              double degdeb, double deltadeg);
    3838  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    3939  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
  • trunk/SophyaPI/PI/psfile.cc

    r1904 r2257  
    11121112}
    11131113
     1114void  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
     1136void  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
    11141163
    11151164// Les coordonnees sont supposees etre en mode incremental .
  • trunk/SophyaPI/PI/psfile.h

    r1898 r2257  
    134134                               PIColors FillColor  = PI_NotDefColor,
    135135                               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);
    136145    virtual void  DrawPolygon (double *x, double *y, int n,
    137146                               PIColors DrawColor  = PI_NotDefColor,
Note: See TracChangeset for help on using the changeset viewer.