Changeset 1887 in Sophya


Ignore:
Timestamp:
Jan 30, 2002, 5:44:39 PM (24 years ago)
Author:
ansari
Message:

Correction bugs suite a l'introduction de la classe PILineAtt -
Ajout de la fonction clip dans le fichier de sortie postscript

Corrections diverses ds le trace des lignes - Reza 30/01/2002

Location:
trunk/SophyaPI/PI
Files:
11 edited

Legend:

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

    r1884 r1887  
    559559
    560560  if (mFSz == PI_NotDefFontSize)
    561     g->SelFontSz(xMajTickLen*3., mFAtt);
     561    g->SelFontSz(xMajTickLen*4., mFAtt);  // Passage de x3. a x4. - Reza Janvier 2002
    562562
    563563  // Choix du bon format pour les labels des axes;
     
    590590
    591591  if (mFSz == PI_NotDefFontSize)
    592     g->SelFontSz(xMajTickLen*3., mFAtt);
     592    g->SelFontSz(xMajTickLen*4., mFAtt);    // Passage de x3. a x4. - Reza Janvier 2002
    593593
    594594  // Choix du bon format pour les labels des axes;
  • trunk/SophyaPI/PI/pidrwtools.cc

    r1877 r1887  
    227227mOpt[5]->AppendItem("Dotted-Line", 608);
    228228mOpt[5]->AppendItem("ThickDotted", 609);
     229mOpt[5]->AppendItem("ThinDashDott", 610);
     230mOpt[5]->AppendItem("DashDot-Line", 611);
     231mOpt[5]->AppendItem("ThickDashDott", 612);
    229232mOpt[5]->SetValue(600);
    230233mOpt[5]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
     
    335338                            PI_TriangleMarker, PI_FTriangleMarker,
    336339                            PI_StarMarker, PI_FStarMarker };
    337 static PILineAtt line[10] = { PI_NotDefLineAtt, PI_ThinLine, PI_NormalLine, PI_ThickLine,
     340static PILineTypes line[13] = { PI_NotDefLineAtt, PI_ThinLine, PI_NormalLine, PI_ThickLine,
    338341                              PI_ThinDashedLine, PI_DashedLine, PI_ThickDashedLine,
     342                              PI_ThinDashDottedLine, PI_DashDottedLine, PI_ThickDashDottedLine,
    339343                              PI_ThinDottedLine, PI_DottedLine, PI_ThickDottedLine };
    340344
     
    467471
    468472PILineAtt lat = dr->GetLineAtt();
    469 for(kk=0; kk<10; kk++)
     473for(kk=0; kk<13; kk++)
    470474  if (lat == line[kk])   { mOpt[5]->SetValue(600+kk);  break; }
    471475
     
    502506
    503507  k =  mOpt[5]->GetValue()-600;
    504   if ( (k < 0) || (k > 9) )  k = 0;
    505   drw->SetLineAtt(line[k]);
     508  if ( (k < 0) || (k > 12) )  k = 0;
     509  drw->SetLineAtt(PILineAtt(line[k]));
    506510  if (fgref)  mCurBW->Refresh();
    507511  else drw->Refresh();
  • trunk/SophyaPI/PI/pigraphgen.cc

    r1886 r1887  
    1414
    1515/* --Methode-- */
    16 PILineAtt::PILineAtt(PILineTyp ltyp)
    17 {
     16PILineAtt::PILineAtt(PILineTypes ltyp)
     17{
     18  _lwidth = 2*8;
     19  _ldash=PI_LineSolid;
    1820  _ljoincap = PI_JoinMiter*PI_CapButt*256;
    1921  switch (ltyp) {
     
    4749    case PI_ThickDottedLine :
    4850      _lwidth = 8*4; _ldash=PI_LineDotted;
     51      break;
     52    case PI_DashDottedLine :
     53      _lwidth = 2*8; _ldash=PI_LineDashDotted;
     54      break;
     55    case PI_ThinDashDottedLine :
     56      _lwidth = 8; _ldash=PI_LineDashDotted;
     57      break;
     58    case PI_ThickDashDottedLine :
     59      _lwidth = 8*4; _ldash=PI_LineDashDotted;
    4960      break;
    5061    default :
  • trunk/SophyaPI/PI/pigraphgen.h

    r1886 r1887  
    1919enum PILineCap  { PI_CapButt=0, PI_CapRound=1, PI_CapProjecting=2};
    2020enum PILineDash { PI_LineSolid, PI_LineDashed, PI_LineDotted,
    21                   PI_LineDashedDotted};
     21                  PI_LineDashDotted};
    2222// Predefined line types
    23 enum PILineTyp { PI_NotDefLineAtt = -1,
    24                  PI_NormalLine, PI_ThinLine, PI_ThickLine,
    25                  PI_DashedLine, PI_ThinDashedLine, PI_ThickDashedLine,
    26                  PI_DottedLine, PI_ThinDottedLine, PI_ThickDottedLine };
     23enum PILineTypes { PI_NotDefLineAtt,
     24                   PI_NormalLine, PI_ThinLine, PI_ThickLine,
     25                   PI_DashedLine, PI_ThinDashedLine, PI_ThickDashedLine,
     26                   PI_DottedLine, PI_ThinDottedLine, PI_ThickDottedLine,
     27                   PI_DashDottedLine, PI_ThinDashDottedLine, PI_ThickDashDottedLine};
    2728
    2829// Marker types
     
    8081class PILineAtt {
    8182public:
    82   inline PILineAtt(int width=1, PILineDash dash=PI_LineSolid,
    83                    PILineJoin join=PI_JoinMiter, PILineCap cap=PI_CapButt)
    84   { _lwidth = width*8; _ldash=dash; _ljoincap=join+cap*256; }   
    85   inline PILineAtt(double width, PILineDash dash=PI_LineSolid,
    86                    PILineJoin join=PI_JoinMiter, PILineCap cap=PI_CapButt)
    87   { _lwidth = (unsigned short)(width*8.); _ldash=dash; _ljoincap=join+cap*256; } 
     83  explicit inline PILineAtt(int width=1, PILineDash dash=PI_LineSolid,
     84                            PILineJoin join=PI_JoinMiter, PILineCap cap=PI_CapButt)
     85  {_lwidth = (width>0)?width*8:8; _ldash=dash; _ljoincap=join+cap*256; }
     86  explicit inline PILineAtt(double width, PILineDash dash=PI_LineSolid,
     87                            PILineJoin join=PI_JoinMiter, PILineCap cap=PI_CapButt)
     88  { _lwidth = (width>0)?(unsigned short)(width*8.):8; _ldash=dash; _ljoincap=join+cap*256; }
    8889  inline PILineAtt(PILineAtt const& b)
    89   { _lwidth=b._lwidth; _ldash=b._ldash; _ljoincap=b._ljoincap; } 
     90  { _lwidth=b._lwidth; _ldash=b._ldash; _ljoincap=b._ljoincap; }
    9091 
    91   PILineAtt(PILineTyp ltyp);
     92  explicit PILineAtt(PILineTypes ltyp);
    9293
    9394  inline ~PILineAtt() {}
    9495
    9596  inline PILineAtt& operator = (PILineAtt const& b)
    96   { _lwidth=b._lwidth; _ldash=b._ldash; _ljoincap=b._ljoincap; return(*this); }   
     97  { _lwidth=b._lwidth; _ldash=b._ldash; _ljoincap=b._ljoincap; return(*this); } 
     98  inline PILineAtt& operator = (PILineTypes ltyp)
     99  { *this=PILineAtt(ltyp);  return(*this); }
     100   
    97101  inline bool operator == (PILineAtt const& b)
    98102  { return ((_lwidth==b._lwidth)&&(_ldash==b._ldash)&&(_ljoincap==b._ljoincap)); }
    99   inline bool operator == (PILineTyp ltyp)
     103  inline bool operator == (PILineTypes ltyp)
    100104  { return ((*this) == PILineAtt(ltyp)); }
    101105  inline bool operator != (PILineAtt const& b)
    102   { return (!(_lwidth==b._lwidth)&&(_ldash==b._ldash)&&(_ljoincap==b._ljoincap)); }
    103   inline bool operator != (PILineTyp ltyp)
     106  { return ((_lwidth!=b._lwidth)||(_ldash!=b._ldash)||(_ljoincap!=b._ljoincap)); }
     107  inline bool operator != (PILineTypes ltyp)
    104108  { return ((*this) != PILineAtt(ltyp)); }
    105109
    106   inline int GetLineWidth() const { return (_lwidth/8); }
     110  inline int GetLineWidth() const { return ((_lwidth>0)?_lwidth/8:1); }
    107111  inline int GetLineWidthx8() const { return (_lwidth); }
    108   inline double GetLineWidthD() const { return ((double)_lwidth/8.); }
     112  inline double GetLineWidthD() const { return ((_lwidth>0)?(double)_lwidth/8.:1.); }
    109113  inline PILineDash GetLineDash() const { return _ldash; }
    110114  inline PILineJoin GetLineJoin() const { return (PILineJoin)(_ljoincap%256); }
     
    180184  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy)                         = 0;
    181185  virtual void       SelLine(PILineAtt att=PI_NormalLine)                      = 0;
    182   inline  void       SelLine(PILineTyp lt) { SelLine(PILineAtt(lt)); }
     186  inline  void       SelLine(PILineTypes lt) { SelLine(PILineAtt(lt)); }
    183187  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker)           = 0;
    184188  virtual void       SelArrowMarker(int arrsz=5,
  • trunk/SophyaPI/PI/pigraphps.cc

    r1851 r1887  
    413413
    414414/* --Methode-- */
    415 void PIGraphicPS::SetClipRectangle(PIGrCoord /*x0*/, PIGrCoord /*y0*/, PIGrCoord /*dx*/, PIGrCoord /*dy*/)
    416 {
    417 /*  $CHECK$  A FAIRE , voir Nicolas  */
    418 return;
     415void PIGraphicPS::SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     416{
     417  mPSOut->SetClipRectangle((double)x0, (double)y0, (double)dx, (double)dy);
    419418}
    420419
     
    422421void PIGraphicPS::ClearClipRectangle()
    423422{
    424 /*  $CHECK$  A FAIRE , voir Nicolas  */
    425 return;
     423  mPSOut->ClearClipRectangle();
    426424}
    427425
  • trunk/SophyaPI/PI/pigraphuc.cc

    r587 r1887  
    410410
    411411/* --Methode-- */
     412void PIGraphicUC::DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
     413                                 const char* s_up, const char* s_dn, int pos)
     414{
     415  if (!mGrC) return;
     416  double xf, yf;
     417  UC2GrC(x, y, xf, yf);
     418  mGrC->DrawCompString(xf, yf, s, s_up, s_dn, pos);
     419}
     420
     421/* --Methode-- */
    412422void PIGraphicUC::DrawLine(PIGrCoord xc1, PIGrCoord yc1, PIGrCoord xc2, PIGrCoord yc2)
    413423{
     
    683693
    684694/* --Methode-- */
     695void PIGraphicUC::DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
     696{
     697  if (!mGrC) return;
     698  double xf1, yf1, xf2, yf2;
     699  UC2GrC(x1, y1, xf1, yf1);
     700  UC2GrC(x2, y2, xf2, yf2);
     701  mGrC->DrawArrowMarker(xf1, yf1, xf2, yf2);
     702}
     703
     704/* --Methode-- */
    685705void PIGraphicUC::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    686706                        int sx, int sy, PIColorMap* cmap)
  • trunk/SophyaPI/PI/pigraphuc.h

    r535 r1887  
    4545  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
    4646  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
     47  virtual void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
     48                                    const char* s_up, const char* s_dn, int pos = 0);
    4749  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
    4850  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     
    6163  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    6264  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
     65  virtual void       DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
     66
    6367  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    6468                                int sx, int sy, PIColorMap* cmap);
  • trunk/SophyaPI/PI/pigraphx.cc

    r1886 r1887  
    6666SelForeground(PI_Black);
    6767SelBackground(PI_White);
    68 mLAtt = PI_ThinLine;
     68mLAtt = PI_NotDefLineAtt;
    6969 XSetFont(mDisp, DefGC(), myFont.GetXFontId());  // Pour initialiser la fonte ds le GC
    7070SelLine();
     
    482482
    483483switch (att.GetLineDash()) {
    484  case PI_LineSolid :
    485    lstyle = LineSolid;
    486    break;
    487  case PI_LineDashed :
    488    lstyle = LineOnOffDash;
    489    dash[0] = dash[1] = 6;     
    490    dashlen = 2;
    491    break;
    492  case PI_LineDotted :
    493    lstyle = LineOnOffDash;
    494    dash[0] = 2; dash[1] = 6; 
    495    dashlen = 2;
    496    break;
    497  case PI_LineDashedDotted :
    498    lstyle = LineOnOffDash;
    499    dash[0] = 2; dash[1] = 6; 
    500    dash[2] = 6; dash[1] = 6; 
    501    dashlen = 4;
    502    break;
    503  default :
    504    lstyle = LineSolid;
    505    break;
    506 }
     484  case PI_LineSolid :
     485    lstyle = LineSolid;
     486     break;
     487  case PI_LineDashed :
     488    lstyle = LineOnOffDash;
     489    dash[0] = dash[1] = 6;     
     490    dashlen = 2;
     491    break;
     492  case PI_LineDotted :
     493    lstyle = LineOnOffDash;
     494    dash[0] = 2; dash[1] = 6; 
     495    dashlen = 2;
     496    break;
     497  case PI_LineDashDotted :
     498    lstyle = LineOnOffDash;
     499    dash[0] = 2; dash[1] = 2; 
     500    dash[2] = 4; dash[3] = 6; 
     501    dashlen = 4;
     502    break;
     503  default :
     504    lstyle = LineSolid;
     505    break;
     506  }
     507if (lstyle != LineSolid)   
     508  XSetDashes( mDisp, DefGC(), 0, dash, dashlen);
     509
    507510
    508511int ljoin = JoinMiter;
     
    538541}
    539542
    540 if (lstyle != LineSolid)
    541   XSetDashes( mDisp, DefGC(), 0, dash, dashlen);
    542  
    543543XSetLineAttributes(mDisp, DefGC(), lw, lstyle, lcap, ljoin);
    544544mLAtt = att;
  • trunk/SophyaPI/PI/piversion.h

    r1879 r1887  
    22#define PIVERSION_H_SEEN
    33
    4 #define PI_VERSIONNUMBER  3.40
     4#define PI_VERSIONNUMBER  3.44
    55
    66#endif
  • trunk/SophyaPI/PI/psfile.cc

    r1886 r1887  
    133133/sldash {[6 6] 0 setdash} bind def %% Dashed-Line \n\
    134134/sldott {[2 6] 0 setdash} bind def %% Dotted-Line \n\
    135 /sldashdott {[2 6 6 6] 0 setdash} bind def %% Dash-Dotted-Line \n\
     135/sldashdott {[2 2 4 6] 0 setdash} bind def %% Dash-Dotted-Line \n\
    136136/ff {findfont} bind def   /sf {setfont} bind def /scf {scalefont} bind def\n\
    137137/rl {rlineto} bind def    /tr {translate} bind def\n\
     
    798798            currentBloc->Tx, currentBloc->Ty,
    799799            currentBloc->X0, currentBloc->Y0);
     800    // On redefinit la zone de clip
     801    fprintf(mPSFile, "%% Define clip region to the entire bloc area \n");
     802    fprintf(mPSFile, "initclip newpath 0 0 m %.2f Ux 0 rl 0 %.2f Uy rl %2f Ux 0 rl closepath clip \n",
     803            currentBloc->Dx, currentBloc->Dy, -currentBloc->Dx);
    800804    // On redefint la fonte par defaut - $CHECK$ Reza 11/12/99
    801805    mFontAtt = PI_RomanFont;
     
    804808    double scaledFontSize = (double)mFontSize*currentPage->FontScaleFactor;
    805809    fprintf(mPSFile, "/Courier ff %g FS /curfntsz %g def \n",
    806             scaledFontSize, scaledFontSize) ;
     810            scaledFontSize, scaledFontSize) ;
     811    mLineAtt = PI_NotDefLineAtt;
     812    SelectLine(PILineAtt(PI_NormalLine));
    807813    setFontDone = true;
    808814    currentBloc->tmp = ftell(mPSFile) ;
     
    830836    /* Flags */
    831837    currentBloc = NULL ;
     838}
     839
     840
     841void PSFile::SetClipRectangle(double x0, double y0, double dx, double dy)
     842{
     843  // On redefinit la zone de clip
     844  fprintf(mPSFile, "%% SetClipRectangle: Define clip region \n ");
     845  fprintf(mPSFile, "newpath %.2f Ux %.2f Uy m %.2f Ux 0 rl 0 %.2f Uy rl %.2f Ux 0 rl closepath clip \n",
     846          x0, y0, dx, dy, -dx);
     847}
     848
     849void PSFile::ClearClipRectangle()
     850{
     851  // On redefinit la zone de clip a l'ensemble du bloc
     852  fprintf(mPSFile, "%% Define clip region to the entire bloc area \n");
     853  fprintf(mPSFile, "initclip newpath 0 0 m %.2f Ux 0 rl 0 %.2f Uy rl %2f Ux 0 rl closepath clip \n",
     854          currentBloc->Dx, currentBloc->Dy, -currentBloc->Dx);
    832855}
    833856
     
    11501173    if (MrkType != PI_NotDefMarker)
    11511174        mMarker = MrkType;
    1152 
     1175    if ((MrkType == PI_DotMarker) && (MarkerSize<3)) MarkerSize=3;
    11531176    if(MarkerSize != mMarkerSize || setFontDone) {
    11541177        mMarkerSize = MarkerSize ;
     
    12341257{
    12351258   
    1236       fprintf(mPSFile, "%d slw ", att.GetLineWidth()) ;
     1259  //  if (att.GetLineWidth() != mLineAtt.GetLineWidth()) {
     1260  double scaledLineWidth = att.GetLineWidthD()*currentPage->FontScaleFactor;
     1261  fprintf(mPSFile, "%g slw ", scaledLineWidth) ;
     1262  if (att.GetLineDash() != mLineAtt.GetLineDash()) {
    12371263      switch (att.GetLineDash()) {
    12381264        case PI_LineSolid :
     
    12451271          fprintf(mPSFile, "sldott ");
    12461272          break;
    1247         case PI_LineDashedDotted :
     1273        case PI_LineDashDotted :
    12481274          fprintf(mPSFile, "sldashdott ");
    12491275          break;
     
    12521278          break;
    12531279      }
    1254 
     1280  }
     1281  if (att.GetLineJoin() != mLineAtt.GetLineJoin()) {
    12551282      switch (att.GetLineJoin()) {
    12561283        case PI_JoinMiter :
     
    12671294          break;
    12681295      }
    1269 
     1296  }
     1297  if (att.GetLineCap() != mLineAtt.GetLineCap()) {
    12701298      switch (att.GetLineCap()) {
    12711299        case PI_CapButt :
     
    12821310          break;
    12831311      }
     1312  }
    12841313      mLineAtt = att;
    12851314}
  • trunk/SophyaPI/PI/psfile.h

    r1886 r1887  
    104104    virtual void  EndBloc();
    105105
     106    virtual void  SetClipRectangle(double x0, double y0, double dx, double dy);
     107    virtual void  ClearClipRectangle();
     108
    106109    virtual void SelForeground(PIColorMap& cmap, int cid) ;
    107110    virtual void SelBackground(PIColorMap& cmap, int cid) ;
Note: See TracChangeset for help on using the changeset viewer.