Changeset 1899 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Feb 13, 2002, 12:03:15 PM (24 years ago)
Author:
ansari
Message:

Fin implementation trace texte vertical (PIGraphX, PIGraphPS, PSFile)
Debut de modification de gestion des Drawer (AutoDeleteOndetach, ...)

Reza 13/02/2002

Location:
trunk/SophyaPI/PI
Files:
11 edited

Legend:

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

    r1898 r1899  
    334334
    335335if (mTxtDir != PI_TextDirectionHorizontal) {
    336   xpos = 50;  ypos = 350;
     336  xpos = 50;  ypos = 450;
    337337  s1 = "V_Top-H_Left-TxDUp";
    338338  g->SelForeground(PI_Red);
     
    343343                PI_HorizontalLeft|PI_VerticalTop|PI_TextDirectionVerticalUp); 
    344344
    345   xpos = 100;  ypos = 300;
     345  xpos = 100;  ypos = 400;
    346346  s1 = "V_Top-H_Center-TxDUp";
    347347  g->SelForeground(PI_Red);
     
    352352                PI_HorizontalCenter|PI_VerticalTop|PI_TextDirectionVerticalUp);
    353353
    354   xpos = 150;  ypos = 250;
     354  xpos = 150;  ypos = 350;
    355355  s1 = "V_Top-H_Right-TxDUp";
    356356  g->SelForeground(PI_Red);
     
    361361                PI_HorizontalRight|PI_VerticalTop|PI_TextDirectionVerticalUp);
    362362
    363   xpos = 200;  ypos = 50;
     363  xpos = 50;  ypos = 250;
     364  s1 = "V_Center-H_Left-TxDUp";
     365  g->SelForeground(PI_Red);
     366  g->DrawLine(xpos-10, ypos, xpos+10, ypos);
     367  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
     368  g->SelForeground(PI_Black);
     369  g->DrawString(xpos, ypos, s1,
     370                PI_HorizontalLeft|PI_VerticalCenter|PI_TextDirectionVerticalUp); 
     371
     372  xpos = 100;  ypos = 200;
     373  s1 = "V_Base-H_Center-TxDUp";
     374  g->SelForeground(PI_Red);
     375  g->DrawLine(xpos-10, ypos, xpos+10, ypos);
     376  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
     377  g->SelForeground(PI_Black);
     378  g->DrawString(xpos, ypos, s1,
     379                PI_HorizontalCenter|PI_VerticalBaseLine|PI_TextDirectionVerticalUp);
     380
     381  xpos = 150;  ypos = 150;
     382  s1 = "V_Bot-H_Right-TxDUp";
     383  g->SelForeground(PI_Red);
     384  g->DrawLine(xpos-10, ypos, xpos+10, ypos);
     385  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
     386  g->SelForeground(PI_Black);
     387  g->DrawString(xpos, ypos, s1,
     388                PI_HorizontalRight|PI_VerticalBottom|PI_TextDirectionVerticalUp);
     389
     390
     391  xpos = 200;  ypos = 100;
    364392  s1 = "V_Top-H_Left-TxDown";
    365393  g->SelForeground(PI_Red);
     
    370398                PI_HorizontalLeft|PI_VerticalTop|PI_TextDirectionVerticalDown); 
    371399
    372   xpos = 250;  ypos = 100;
     400  xpos = 250;  ypos = 150;
    373401  s1 = "V_Top-H_Center-TxDown";
    374402  g->SelForeground(PI_Red);
     
    379407                PI_HorizontalCenter|PI_VerticalTop|PI_TextDirectionVerticalDown);
    380408
    381   xpos = 300;  ypos = 150;
     409  xpos = 300;  ypos = 200;
    382410  s1 = "V_Top-H_Right-TxDown";
    383411  g->SelForeground(PI_Red);
     
    387415  g->DrawString(xpos, ypos, s1,
    388416                PI_HorizontalRight|PI_VerticalTop|PI_TextDirectionVerticalDown);
     417
     418  xpos = 200;  ypos = 300;
     419  s1 = "V_Center-H_Left-TxDown";
     420  g->SelForeground(PI_Red);
     421  g->DrawLine(xpos-10, ypos, xpos+10, ypos);
     422  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
     423  g->SelForeground(PI_Black);
     424  g->DrawString(xpos, ypos, s1,
     425                PI_HorizontalLeft|PI_VerticalCenter|PI_TextDirectionVerticalDown); 
     426
     427  xpos = 250;  ypos = 350;
     428  s1 = "V_Base-H_Center-TxDown";
     429  g->SelForeground(PI_Red);
     430  g->DrawLine(xpos-10, ypos, xpos+10, ypos);
     431  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
     432  g->SelForeground(PI_Black);
     433  g->DrawString(xpos, ypos, s1,
     434                PI_HorizontalCenter|PI_VerticalBaseLine|PI_TextDirectionVerticalDown);
     435
     436  xpos = 300;  ypos = 400;
     437  s1 = "V_Bot-H_Right-TxDown";
     438  g->SelForeground(PI_Red);
     439  g->DrawLine(xpos-10, ypos, xpos+10, ypos);
     440  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
     441  g->SelForeground(PI_Black);
     442  g->DrawString(xpos, ypos, s1,
     443                PI_HorizontalRight|PI_VerticalBottom|PI_TextDirectionVerticalDown);
     444
    389445
    390446  return;
     
    443499// --------------- Vertical BaseLine -----------------
    444500xpos = 30;  ypos = 250;
    445 s1 = "V_Bottom-H_Left";
     501s1 = "V_Base-H_Left";
    446502g->SelForeground(PI_Red);
    447503g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     
    451507
    452508xpos = XSize()/2;  ypos = 250;
    453 s1 = "V_Bottom-H_Center";
     509s1 = "V_Base-H_Center";
    454510g->SelForeground(PI_Red);
    455511g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     
    459515
    460516xpos = XSize()-30;  ypos = 250;
    461 s1 = "V_Bottom-H_Center";
     517s1 = "V_Base-H_Center";
    462518g->SelForeground(PI_Red);
    463519g->DrawLine(xpos-50, ypos, xpos+50, ypos);
  • trunk/SophyaPI/PI/picolist.h

    r1640 r1899  
    1717                 PI_Violet = 16, PI_VioletRed = 17,
    1818                 PI_BlueViolet = 18, PI_DarkViolet = 19,
    19                  PI_ColorAllBits0 = 19, PI_ColorAllBits1 = 20 };
     19                 PI_HighlightBlue = 20,
     20                 PI_ColorAllBits0 = 21, PI_ColorAllBits1 = 22 };
    2021
    2122#endif
  • trunk/SophyaPI/PI/pidrawer.cc

    r1897 r1899  
    4242PIDrawer::PIDrawer()
    4343{
     44  mFgDeleteOnDetach = false;
    4445  mBWdg = NULL;
    4546  mGrUC = NULL;
     
    324325  for(it = mBWdgList.begin(); it != mBWdgList.end(); it++)
    325326     if ( ((*it).id == id) && ((*it).wdg == wdg) ) { mBWdgList.erase(it);  break; }
     327  if (mFgDeleteOnDetach && (mBWdgList.size() == 0))  delete this;
    326328  return;
    327329}
     
    332334  // On affiche par defaut la fenetre de gestion des attributs graphiques
    333335   PIDrwTools::ShowPIDrwTools(wdg);
     336}
     337
     338void
     339PIDrawer::DeactivateControlWindow(PIBaseWdgGen* wdg)
     340{
     341  // On affiche par defaut la fenetre de gestion des attributs graphiques
    334342}
    335343
  • trunk/SophyaPI/PI/pidrawer.h

    r1897 r1899  
    3030  virtual           ~PIDrawer();
    3131
     32  inline  void       SetAutoDeleteOnDetach(bool fg)
     33                       { mFgDeleteOnDetach = fg; }
     34
    3235  virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax,
    3336                               int axrl=kAxeDirSame, int ayud=kAxeDirSame);
     
    101104  virtual void       ShowControlWindow(PIBaseWdgGen* wdg);
    102105  inline  bool       HasSpecificControlWindow() const { return mFgSpecContWind; }
     106  virtual void       DeactivateControlWindow(PIBaseWdgGen* wdg);
    103107
    104108//   Methode permettant de decoder des options a partir de chaines
     
    135139  void DrawGrid(PIGraphicUC* g);
    136140
    137  
     141
     142  bool mFgDeleteOnDetach;         // si true -> delete drawer on detach
     143                                  // from last BaseWdg
     144
    138145  double xMin, xMax, yMin, yMax;  // Valeurs en unites user
    139146  int xW0, yW0, xWd, yWd;        // Origine/largeur ds la fenetre de trace
  • trunk/SophyaPI/PI/pigraphgen.cc

    r1898 r1899  
    127127myWdg = NULL;
    128128myGrb = NULL;
     129myLockFCol = false;
    129130SelArrowMarker();
    130131}
     
    135136myWdg = wdg;
    136137myGrb = NULL;
     138myLockFCol = false;
    137139SelArrowMarker();
    138140}
     
    143145myWdg = NULL;
    144146myGrb = grb;
     147myLockFCol = false;
    145148SelArrowMarker();
    146149}
     
    194197void
    195198PIGraphicGen::DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
    196                              const char* s_up, const char* s_dn, unsigned long pos)
     199                             const char* s_up, const char* s_dn,
     200                             PIFont const & fntss, unsigned long pos)
    197201{
    198202  if ((s_up == NULL) && (s_dn == NULL)) {
     
    207211
    208212  PIFont fnt_save(myFont);
    209   PIFont fnt_ss(myFont);
     213  PIFont fnt_ss(fntss);
    210214  fnt_ss.SetFontSzPt(2*myFont.GetFontSize()/3);
    211215
     
    272276    else {
    273277      xs = (int)x+sw_s;
    274       if (s != NULL)  DrawString(x, y, s, PI_HorizontalRight | posv);
     278      if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight | posv);
    275279      SelFont(fnt_ss);
    276280      xs = (int)x+sw_s+deltaposx;
  • trunk/SophyaPI/PI/pigraphgen.h

    r1898 r1899  
    164164  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, unsigned long pos = 0) = 0;
    165165  virtual void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
    166                                     const char* s_up, const char* s_dn, unsigned long pos = 0);
     166                                    const char* s_up, const char* s_dn,
     167                                    PIFont const & fntss, unsigned long pos = 0);
     168  inline  void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
     169                                    const char* s_up, const char* s_dn,
     170                                    unsigned long pos = 0)
     171                     { DrawCompString(x, y, s, s_up, s_dn, GetFont(), pos); }
    167172
    168173  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)  = 0;
     
    200205  virtual void       SelArrowMarker(int arrsz=5,
    201206                                    PIArrowMarker arrmrk=PI_BasicArrowMarker);
     207
     208  inline  void       LockForegroundColor() { myLockFCol = true; }
     209  inline  void       UnLockForegroundColor() { myLockFCol = false; }
     210
    202211// Modifications de fonte
    203212  virtual void       SelFont(PIFont & fnt)                                     = 0;
     
    248257  PIArrowMarker sArrowMrk;
    249258  int sArrowMrkSz;
    250 
     259  bool myLockFCol;
    251260};
    252261
  • trunk/SophyaPI/PI/pigraphps.cc

    r1898 r1899  
    115115{
    116116if(mPSOut) {
    117   int posh = pos & PI_HorizontalPosition;
    118   int posv = pos & PI_VerticalPosition;
     117  unsigned long txtdir = pos&PI_TextDirection;
     118  unsigned long posh = pos & PI_HorizontalPosition;
     119  unsigned long posv = pos & PI_VerticalPosition;
    119120  int dx,dy;
    120121  double xd = x;
    121122  double yd = y;
    122   if ( CalcStringPositionShift(s, posv, dx, dy) ) yd -= dy;
     123  bool fgcsps = CalcStringPositionShift(s, posv, dx, dy);
     124  if (txtdir == PI_TextDirectionHorizontal) {
     125    if (fgcsps) yd -= dy;
     126  }
     127  else {
     128    if (txtdir == PI_TextDirectionVerticalDown) xd += dy;
     129    else xd -= dy;
     130  }
    123131  mPSOut->DrawString(xd, yd, s, mFCol, myFont.GetFontName(), myFont.GetFontAtt(),
    124                      myFont.GetFontSize(), posh);
     132                     myFont.GetFontSize(), posh|txtdir);
    125133}
    126134return;
     
    131139{
    132140if(mPSOut) {
    133   int posh = pos & PI_HorizontalPosition;
    134   int posv = pos & PI_VerticalPosition;
     141  unsigned long txtdir = pos&PI_TextDirection;
     142  unsigned long posh = pos & PI_HorizontalPosition;
     143  unsigned long posv = pos & PI_VerticalPosition;
    135144  int dx,dy;
    136145  double xd = x;
    137146  double yd = y;
    138   if ( CalcStringPositionShift(s, posv, dx, dy) ) yd -= dy;
     147  bool fgcsps = CalcStringPositionShift(s, posv, dx, dy);
     148  if (txtdir == PI_TextDirectionHorizontal) {
     149    if (fgcsps) yd -= dy;
     150  }
     151  else {
     152    if (txtdir == PI_TextDirectionVerticalDown) xd += dy;
     153    else xd -= dy;
     154  }
    139155  mPSOut->DrawString(xd, yd, s, mFCol, myFont.GetFontName(), myFont.GetFontAtt(),
    140                      myFont.GetFontSize(), posh);
     156                     myFont.GetFontSize(), posh|txtdir);
    141157}
    142158return;
  • trunk/SophyaPI/PI/pigraphuc.cc

    r1898 r1899  
    154154                         int axrl, int ayud)
    155155{
    156 
    157156  if (axrl == kAxeDirAuto) {
    158157    double ff;
     
    411410/* --Methode-- */
    412411void PIGraphicUC::DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
    413                                  const char* s_up, const char* s_dn, unsigned long pos)
     412                                 const char* s_up, const char* s_dn,
     413                                 PIFont const & fntss, unsigned long pos)
    414414{
    415415  if (!mGrC) return;
    416416  double xf, yf;
    417417  UC2GrC(x, y, xf, yf);
    418   mGrC->DrawCompString(xf, yf, s, s_up, s_dn, pos);
     418  mGrC->DrawCompString(xf, yf, s, s_up, s_dn, fntss, pos);
    419419}
    420420
  • trunk/SophyaPI/PI/pigraphuc.h

    r1898 r1899  
    3333//  Definition des coordonnees utilisateur
    3434  virtual void       SetUCS(double xmin, double xmax, double ymin, double ymax,
    35                             int axrl=kAxeDirSame, int ayud=kAxeDirSame);    
     35                            int axrl=kAxeDirSame, int ayud=kAxeDirSame);
    3636// Echelle logarithmique
    3737  virtual void       SetLogScale(bool logx, bool logy);
     
    4646  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, unsigned long pos = 0);
    4747  virtual void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
    48                                     const char* s_up, const char* s_dn, unsigned long pos = 0);
     48                                    const char* s_up, const char* s_dn,
     49                                    PIFont const & fntss, unsigned long pos = 0);
     50  inline  void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
     51                                    const char* s_up, const char* s_dn,
     52                                    unsigned long pos = 0)
     53                     { DrawCompString(x, y, s, s_up, s_dn, GetFont(), pos); }
     54
    4955  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
    5056  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
  • trunk/SophyaPI/PI/pigraphx.cc

    r1898 r1899  
    1414
    1515/*  Variables globales pour modifier les GC  */
    16 #define NMAXCOL  24
     16#define NMAXCOL  32
    1717static  PIXColor colpix[NMAXCOL];
    1818
     
    491491  }
    492492  XPutImage(dsx, pxm2, gcbm, ximg2, 0, 0, 0, 0, fh, sw);
     493  GC gcvis;
    493494  GC gcvs = XCreateGC (dsx, mWId, GCFunction | GCPlaneMask, &xgv);
    494495  XCopyGC(dsx, DefGC(), ~0, gcvs);
    495496  XSetStipple(dsx, gcvs, pxm2);
    496497  XSetFillStyle(dsx, gcvs, FillStippled);
     498  if (imgs) {
     499    gcvis = XCreateGC (dsx, mWId, GCFunction | GCPlaneMask, &xgv);
     500    XCopyGC(dsx, DefGC(), ~0, gcvis);
     501    if (mBCol == PI_ColorFromMap)  XSetForeground(mDisp, gcvis, mBCfMap);
     502    else  XSetForeground(mDisp, gcvis, colpix[mBCol]);
     503  }
    497504  if (fgdown) {
    498     XSetTSOrigin(dsx, gcvs, x, y);
    499     XFillRectangle(dsx, mWId, gcvs, x, y, fh, sw);
     505    XSetTSOrigin(dsx, gcvs, x-fdes, y);
     506    if (imgs)  XFillRectangle(dsx, mWId, gcvis, x-fdes, y, fh, sw);
     507    XFillRectangle(dsx, mWId, gcvs, x-fdes, y, fh, sw);
    500508  }
    501509  else {
    502     XSetTSOrigin(dsx, gcvs, x-fh, y-sw);
    503     XFillRectangle(dsx, mWId, gcvs, x-fh, y-sw, fh, sw);
     510    XSetTSOrigin(dsx, gcvs, x-fasc, y-sw);
     511    if (imgs) XFillRectangle(dsx, mWId, gcvis, x-fasc, y-sw, fh, sw);
     512    XFillRectangle(dsx, mWId, gcvs, x-fasc, y-sw, fh, sw);
    504513  }
    505514  // Cleaning 
    506515  XDestroyImage(ximg);
    507516  XDestroyImage(ximg2);
     517  XFreeGC(dsx, gcbm);
    508518  XFreeGC(dsx, gcvs);
    509   XFreeGC(dsx, gcbm);
     519  if (imgs) XFreeGC(dsx, gcvis);
    510520  XFreePixmap(dsx, pxm);                             
    511521  XFreePixmap(dsx, pxm2);                           
     
    517527void PIGraphicX::SelForeground(PIColors col)
    518528{
     529if (myLockFCol)  return;
    519530if (col == mFCol)  return;
    520531if ( (col < 0) || (col >= NMAXCOL))  return;
     
    537548void PIGraphicX::SelForeground(PIColorMap& cmap, int cid)
    538549{
     550if (myLockFCol)  return;
    539551SelectFCol(cmap.Color(cid));
    540552}
     
    849861  colpix[PI_DarkViolet] = mycol.pixel;
    850862
     863mycol.red = 0;
     864mycol.blue = 65000;
     865mycol.green = 45000;
     866if ( XAllocColor (mdsp, cmap, &mycol) )  colpix[PI_HighlightBlue] = mycol.pixel;
    851867
    852868/*  le GC pour DrawPixmap  */
  • trunk/SophyaPI/PI/psfile.cc

    r1898 r1899  
    946946      fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ;
    947947    else {
     948      unsigned long txtdir = pos & PI_TextDirection;
    948949      int posh = pos & PI_HorizontalPosition;
    949950      int posv = pos & PI_VerticalPosition;
     951      int angle = 0;
     952      if (txtdir == PI_TextDirectionVerticalUp) angle = -90;
     953      else if (txtdir == PI_TextDirectionVerticalDown) angle = 90;
     954
    950955      if ((posh == PI_HorizontalLeft)  &&
    951           ((posv == PI_VerticalBaseLine) || (posv == 0)) )
    952         fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) hlshstr gr\n",
    953                 x, y, s) ;
     956          ((posv == PI_VerticalBaseLine) || (posv == 0)) ) {
     957        if (angle == 0)
     958          fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) hlshstr gr\n",
     959                  x, y, s) ;
     960        else
     961          fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) hlshstr gr\n",
     962                  x, y, angle, s) ;
     963      }
    954964      else {
    955965        char ssvp = 'b';
     
    960970          else sshp = 'l';
    961971        }
    962         if (posv == 0)
    963           fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cshstr gr\n",
    964                   x, y, s, sshp) ;
     972        if (posv == 0) {
     973          if (angle == 0)
     974            fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cshstr gr\n",
     975                    x, y, s, sshp) ;
     976          else fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cshstr gr\n",
     977                       x, y, angle, s, sshp) ;
     978        }
    965979        else {
    966980          if (posv == PI_VerticalCenter)  ssvp = 'c';
     
    968982          else ssvp = 'b';
    969983        }
    970         fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cv%cshstr gr\n",
     984        if (angle == 0)
     985          fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cv%cshstr gr\n",
    971986                  x, y, s, sshp, ssvp) ;
     987        else
     988          fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cv%cshstr gr\n",
     989                  x, y, angle, s, sshp, ssvp) ;
    972990      }
    973991    }
Note: See TracChangeset for help on using the changeset viewer.