Changeset 1893 in Sophya


Ignore:
Timestamp:
Feb 7, 2002, 10:11:55 AM (24 years ago)
Author:
ansari
Message:

Implementation du trace de fleches et programme test associe - Reza 7 Fev 2002

Location:
trunk/SophyaPI/PI
Files:
1 added
3 edited

Legend:

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

    r1887 r1893  
    66
    77#include "pigraphgen.h"
     8#include <math.h>
    89
    910//++
     
    247248/* --Methode-- */
    248249void
    249 PIGraphicGen::DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
    250 {
    251   // AFAIREREZA012002
     250PIGraphicGen::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);
    252348}
    253349
  • trunk/SophyaPI/PI/pigraphgen.h

    r1890 r1893  
    6161  inline PIGrCoord() { iv = 0; dv = 0.;}
    6262  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;}
    6565  inline PIGrCoord(PIGrCoord const & gc) { iv = gc.iv;  dv = gc.dv; }
    6666  inline operator int() { return(iv); }
     
    7171  inline operator double() { return(dv); }
    7272  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); }
    7577  inline PIGrCoord& operator= (PIGrCoord const & gc) { iv = gc.iv; dv = gc.dv;  return(*this); }
     78protected:
    7679  int iv;
    7780  double dv;
     
    172175  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0)                            = 0;
    173176  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);
    175179
    176180  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
  • trunk/SophyaPI/PI/psfile.cc

    r1887 r1893  
    11191119    for(int i = 1; i<n; i++)
    11201120      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");
    11221122}
    11231123
Note: See TracChangeset for help on using the changeset viewer.