Changeset 382 in Sophya


Ignore:
Timestamp:
Aug 12, 1999, 11:04:27 AM (26 years ago)
Author:
ercodmgr
Message:

Modifs PSFile,PSGraphic pour compatibilite PIFont (Nicolas - Reza 12/8/99

Location:
trunk/SophyaPI/PI
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/Tests/pit1.cc

    r323 r382  
    104104g->DrawFBox(10, 60, 120, 20);
    105105
     106PIFont f0;
     107g->SelFont(f0);
    106108g->SelForeground(PI_Black);
    107109g->DrawString(20, 110, str);
     110PIFont f(PI_TimesFont);
     111g->SelFont(f);
     112g->DrawString(20, 130, "Times-Font");
     113PIFont f2(14,PI_CourierFont,PI_BoldFont);
     114g->SelFont(f2);
     115g->DrawString(20, 150, "Courier-Font");
     116PIFont f3(14,PI_TimesFont,PI_BoldFont);
     117g->SelFont(f3);
     118g->DrawString(20, 170, "Times-Font");
     119PIFont f4(14,PI_HelveticaFont,PI_BoldFont);
     120g->SelFont(f4);
     121g->DrawString(20, 190, "Helvetica-Font");
     122PIFont f5(14,PI_SymbolFont,PI_BoldFont);
     123g->SelFont(f5);
     124g->DrawString(20, 210, "Symbol-Font");
     125
    108126
    109127g->SelLine(PI_ThinLine);
     
    118136g->SelForeground(PI_Grey);
    119137g->DrawFCircle(120, 60, 15);
     138
     139
     140
    120141
    121142PIGrCoord x[5] = { 20, 35, 50, 65, 80 };
     
    367388m[0]->AppendItem("New ExBwdg", 10102);
    368389m[0]->AppendItem("New ScSample", 10103);
     390m[0]->AppendItem("->eps", 10111);
    369391m[0]->AppendItem("Exit", 10105);
    370392// On accroche le menu au Menubar
     
    398420
    399421
     422static int numpsf = 0;
    400423static int nbwin = 0;
    401424/* --Methode-- */
     
    460483      break;
    461484
     485    case 10111:          // -> eps
     486      if (mcurwin) {
     487        char buff[64];
     488        sprintf(buff, "pit_%d.eps", numpsf);        numpsf++;
     489        printf("Creating EPS File %s (Encapsulated PostScript) \n", buff);
     490        PSFile *mps;
     491        mps = new PSFile(buff);
     492        mcurwin->PSPrint(mps,0,0);
     493        delete mps;
     494        }
     495      break;       
    462496    case 10105:          // Sortie d'application
    463497      Stop();
  • trunk/SophyaPI/PI/pigraphps.cc

    r316 r382  
    8282mLAtt = PI_ThinLine;
    8383SelLine();
    84 mFAtt = PI_BoldFont;  mFSize = 0;
     84// mFAtt = PI_BoldFont;  mFSize = 0;  $CHECK$ Plus besoin
    8585SelFont();
    8686SelMarker(1, PI_DotMarker);
     
    111111{
    112112if(mPSOut)
    113   mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
     113  //  mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
     114  mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(),
     115                     myFont.GetFontAtt(),  myFont.GetFontSize());
     116// Calculez la taille de la boite occupe par la fonte
     117//  myFont.GetFontHeight(int& asc, int& desc)  Tres proche de myFont.GetFontSize() en principe
     118//  myFont.GetStringWidth(char const* s)  Largeur occupe par la chaine
    114119return;
    115120}
     
    119124{
    120125if(mPSOut)
    121   mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
     126  //  mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
     127  mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(),
     128                     myFont.GetFontAtt(),  myFont.GetFontSize());
     129// Idem taille ici
    122130return;
    123131}
     
    251259if(mPSOut)
    252260  mPSOut->DrawMarker((double)x0,(double)y0,mMrk,mFCol,mMrkSz);
     261// $CHECK$ Ajouter starmarker
     262// /* Coordonnees pour une etoile a 5 branches */
     263// double pio5 = M_PI/2.5; 
     264// double pio52 = pio5/2.;
     265// double cpi2 = M_PI/2.-pio5; 
     266// double re = 1.2;  // Rayon externe
     267// double ri = 0.5; //  rayon interne pour rext=1.2
     268// for(int k=0; k<5; k++) {
     269//  starcoordx[2*k] = cos(k*pio5+cpi2)*re;
     270//  starcoordy[2*k] = -sin(k*pio5+cpi2)*re;
     271//  starcoordx[2*k+1] = cos(k*pio5+pio52+cpi2)*ri;
     272//  starcoordy[2*k+1] = -sin(k*pio5+pio52+cpi2)*ri;
     273//  }
     274
    253275return;
    254276}
     
    331353{
    332354//  $CHECK$   -  Reza 13/06/99
    333 SelFontSzPt(fnt.GetFontSize(), fnt.GetFontAtt());
     355if (myFont == fnt)  return;
     356myFont = fnt;
     357  // C'est peu-etre mieux
     358  // SelFontSzPt(fnt.GetFontSize(), fnt.GetFontAtt());
     359}
     360
     361
     362static int fntsz[5] = {8,10,12,14,16};
     363
     364/* --Methode-- */
     365void PIGraphicPS::SelFont(PIFontSize sz, PIFontAtt att)
     366{
     367//  $CHECK$   -  Reza 13/06/99
     368PIFont fnt(myFont.GetFontName());
     369fnt.SetFontAtt(att);
     370fnt.SetFontSz(sz);
     371SelFont(fnt);
     372return;
    334373}
    335374
     
    338377{
    339378//  $CHECK$   -  Reza 13/06/99
    340 myFont.SetFontSzPt(npt);
    341 myFont.SetFontAtt(att);
    342 mFSize = npt;
    343 mFAtt = att;
    344 return;
    345 }
    346 
    347 static int fntsz[5] = {8,10,12,14,16};
    348 
    349 /* --Methode-- */
    350 void PIGraphicPS::SelFont(PIFontSize sz, PIFontAtt att)
    351 {
    352 //  $CHECK$   -  Reza 13/06/99
    353 int i;
    354 switch (sz) {
    355   case PI_SmallSizeFont:
    356     i = 0;
    357     break;
    358   case PI_NormalSizeFont:
    359     i = 2;
    360     break;
    361   case PI_BigSizeFont:
    362     i = 4;
    363     break;
    364   default:
    365     i=2;
    366     break;
    367   }
    368 myFont.SetFontSz(sz);
    369 myFont.SetFontAtt(att);
    370 mFSize = fntsz[i];
    371 mFAtt = att;
    372 return;
     379PIFont fnt(npt, myFont.GetFontName(), att);
     380SelFont(fnt);
    373381}
    374382
  • trunk/SophyaPI/PI/pigraphps.h

    r316 r382  
    8383  PIColor  mFCfMap, mBCfMap;
    8484  PIGOMode mGOm;
    85   PIFontAtt mFAtt;
     85//  PIFontAtt mFAtt;  Plus besoin Reza + NR 07/08/99
    8686  PILineAtt mLAtt;
    87   int mFSize;
     87//  int mFSize;    Plus besoin Reza + NR 07/08/99
    8888  PIMarker mMrk;
    8989  int mMrkSz;
  • trunk/SophyaPI/PI/piwdggen.cc

    r329 r382  
    258258psf->DrawBox(0., 0., (double)XSize(), (double)YSize());
    259259sprintf(str,"PIWdgGen::PSPrint() Kind=%ld Name= %s", kind(), Nom().c_str());
    260 psf->DrawString(12., 12., str, PI_Black, PI_RomanFont, 10);
     260// N.R. 07/08/99 FontName specifie dans DrawString()
     261psf->DrawString(12., 12., str, PI_Black, PI_DefaultFont, PI_RomanFont, 10);
    261262psf->EndBloc();
    262263
  • trunk/SophyaPI/PI/psfile.cc

    r292 r382  
    66 *   Modification le 01/03/96
    77 *    - fusion psfile.cc - psdict.cc
     8 *
     9 *
     10 *   07/08/99 : Gestion des fontes ; ajout Times/Helvetica/Symbol
     11 *             
     12 *
     13 *
    814 *
    915 */
     
    7783/C%-2d  {0.195 0.800 0.195 setrgbcolor} bind def %% PI_LimeGreen\n\
    7884/C%-2d  {0.996 0.840 0.0   setrgbcolor} bind def %% PI_Gold\n\
    79 /F%-2d  {/Courier   findfont} bind def       %% PI_RomanFont\n\
    80 /F%-2d  {/Courier-Bold    findfont} bind def       %% PI_BoldFont\n\
    81 /F%-2d  {/Courier-Italic  findfont} bind def       %% PI_ItalicFont\n\
     85/F%-2d  {/Courier   findfont} bind def           %% PI_RomanFont\n\
     86/F%-2d  {/Courier-Bold    findfont} bind def     %% PI_BoldFont\n\
     87/F%-2d  {/Courier-Italic  findfont} bind def     %% PI_ItalicFont\n\
    8288/F%-2d  {}\
    8389                        bind def       %% PI_NotDefFontAtt\n\
     
    268274#define HEADER     "\
    269275%%%%Title: %s\n\
    270 %%%%Creator: PSFile\n\
     276%%%%Creator: PSFile (N.R. 07/08/99)\n\
    271277%%%%CreationDate: %s\
    272278%%%%Pages: (atend)\n\
     
    308314      mFillColor(PI_Black),
    309315      mFontAtt(PI_RomanFont),
    310       mFontSize(PI_NormalSizeFont),
     316      mFontSize(0),
     317      mFontName(PI_DefaultFont),
    311318      mLineAtt(PI_NormalLine),
    312319      mMarker(PI_DotMarker),
     
    370377    mFillColor(PI_Black),
    371378    mFontAtt(PI_RomanFont),
    372     mFontSize(PI_NormalSizeFont),
     379    mFontSize(0),
     380    mFontName(PI_DefaultFont),
    373381    mLineAtt(PI_NormalLine),
    374382    mMarker(PI_DotMarker),
     
    448456}
    449457
    450 PIFontSize PSFile::GetFontSize() {
     458// N.R. 07/08/99 return val PIFontSize --> int
     459int PSFile::GetFontSize() {
    451460
    452461    return(mFontSize);
     
    551560
    552561        if(currentPage->orientation == PI_Portrait) {
    553 //          if( (tw/Dx) < (th/Dy) )
    554 //              scale = tw/Dx ;
    555 //                scale = tw/Tw ;
    556 //          else
    557 //              scale = th/Dy;
    558 //                scale = th/Th;
    559 //          fprintf(mPSFile,
    560 //                  "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
    561 //                  Dx, Dy,
    562 //                  Dx*scale, Dy*scale,
    563 //                  Tw*scale, Th*scale,
    564 //                  0.5*(Tw-tw), -0.5*(Th+th)) ;
     562          //        if( (tw/Dx) < (th/Dy) )
     563          //            scale = tw/Dx ;
     564          //                scale = tw/Tw ;
     565          //        else
     566          //            scale = th/Dy;
     567          //                scale = th/Th;
     568          //        fprintf(mPSFile,
     569          //                "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
     570          //                Dx, Dy,
     571          //                Dx*scale, Dy*scale,
     572          //                Tw*scale, Th*scale,
     573          //                0.5*(Tw-tw), -0.5*(Th+th)) ;
    565574            scale = (tw/Dx)<(th/Dy) ? tw/Dx : th/Dy ;
    566575            tw = scale*Dx ; th = scale*Dy ;
     
    698707void  PSFile::DrawString  (double x,  double y, const char *s,
    699708                           PIColors DrawColor,
     709                           PIFontName FontName,
    700710                           PIFontAtt FontAtt,
    701711                           int FontSize) {
     
    703713
    704714    /* Couleurs */
    705     if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
     715    if ( (DrawColor != PI_NotDefColor) && (DrawColor != mDrawColor) ) {
    706716        mDrawColor = DrawColor;
    707717        fprintf(mPSFile, "C%d ", mDrawColor) ;
    708718    }
    709719    /* Choix des fontes */
    710     if ( (FontAtt != PI_NotDefFontAtt) || (FontAtt != mFontAtt) ) {
    711         mFontAtt = FontAtt;
    712         change = 1;}
    713     if ( (FontSize != PI_NotDefFontSize) || (FontSize != mFontSize) ) {
    714         mFontSize = (PIFontSize) FontSize;  // $CHECK$ EA ajoute le cast un peu au pif
    715         change = 1;}
    716     if (change)
    717         fprintf(mPSFile, "F%d %d FS ", mFontAtt, FontSize) ;
    718 
     720    if ( (FontAtt != PI_NotDefFontAtt) && (FontAtt != mFontAtt) ) {
     721      printf("PSFile::DrawString(%s) : FontAtt a change : %d %d \n", s, mFontAtt, FontAtt) ;
     722      mFontAtt = FontAtt;
     723      change = 1;
     724    }
     725    if ( (FontSize != PI_NotDefFontSize) && (FontSize != mFontSize) ) {
     726      printf("PSFile::DrawString(%s) : FontSize a change : %d %d \n", s, mFontSize, FontSize) ;
     727      mFontSize = (PIFontSize) FontSize;  // $CHECK$ EA ajoute le cast un peu au pif
     728      change = 1;
     729    }
     730    if( (FontName != mFontName) ) {
     731      printf("PSFile::DrawString(%s) : FontName a change : %d %d \n", s, mFontName, FontName) ;
     732      mFontName = (PIFontName) FontName ;
     733      change = 1 ;
     734    }
     735    if (change) {
     736      string fname ;
     737      switch(mFontName) {
     738      case PI_DefaultFont:
     739      case PI_CourierFont:
     740        fprintf(mPSFile, "/Courier") ;
     741        break ;
     742      case PI_HelveticaFont:
     743        fprintf(mPSFile, "/Helvetica") ;
     744        break ;
     745      case PI_TimesFont:
     746        fprintf(mPSFile, "/Times") ;
     747        break ;
     748      case PI_SymbolFont:
     749        fprintf(mPSFile, "/Symbol ") ;
     750        break ;
     751      } // endsw
     752     
     753      switch(mFontAtt) {
     754      case PI_NotDefFontAtt:
     755      case PI_RomanFont:
     756        fprintf(mPSFile, " ") ;
     757        break ;
     758      case PI_BoldFont:
     759        if(mFontName != PI_SymbolFont) fprintf(mPSFile, "-Bold ") ;
     760        break ;
     761      case PI_ItalicFont:
     762        if(mFontName != PI_SymbolFont) fprintf(mPSFile, "-Italic ") ;
     763        break ;
     764      } // endsw
     765      fprintf(mPSFile, " ff %d FS ", FontSize) ;
     766    }
     767   
     768   
    719769    fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ;
    720770    setFontDone = true ;
     
    723773
    724774void  PSFile::DrawLine    (double x1, double y1, double x2, double y2,
    725                    PIColors DrawColor,
    726                    PILineAtt LineAtt) {
     775                           PIColors DrawColor,
     776                           PILineAtt LineAtt) {
    727777
    728778  int lw = 0 ;
  • trunk/SophyaPI/PI/psfile.h

    r292 r382  
    2525#endif
    2626#include "pisysdep.h"
    27 
     27#include "pifontgen.h"
    2828
    2929#include "pigraphgen.h"      // Types enumeres repris de Peida:PIFontSize...
     
    9292    virtual PIColors    GetFillColor();
    9393    virtual PIFontAtt   GetFontAtt();
    94     virtual PIFontSize  GetFontSize();
     94    virtual int         GetFontSize();
    9595    virtual PILineAtt   GetLineAtt();
    9696    virtual PIMarker    GetMarker();
     
    108108    virtual void  DrawString  (double x,  double y, const char *s,
    109109                               PIColors DrawColor  = PI_NotDefColor,
     110                               PIFontName FontName = PI_DefaultFont,
    110111                               PIFontAtt FontAtt   = PI_NotDefFontAtt,
    111112                               int FontSize        = 8);
     
    196197    enum PIColors    mFillColor;  /* Couleur de remplissage courante */
    197198    enum PIFontAtt   mFontAtt;
    198     enum PIFontSize  mFontSize;
     199    //    enum PIFontSize  mFontSize;
     200    int              mFontSize;
     201    enum PIFontName  mFontName;
    199202    enum PILineAtt   mLineAtt;    /* Epaisseur d une ligne */
    200203    enum PIMarker    mMarker;     /* Marker courant */
Note: See TracChangeset for help on using the changeset viewer.