Changeset 2426 in Sophya


Ignore:
Timestamp:
Sep 5, 2003, 5:32:47 PM (22 years ago)
Author:
ansari
Message:

1/ Ajouter caractere d'echappement \ pour les parentheses dans les
chaines de caracteres postscript (fichier psfile.cc)
2/ Ajout variable d'environnement PIXKBMODMASK pour choix touche Alt1
et/ou Alt2 (fichier pixtbase.cc)
3) Correction/implementation trace CompString en vertical (pigraphgen.cc)

Reza - 5 Septembre 2003

Location:
trunk/SophyaPI/PI
Files:
4 edited

Legend:

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

    r2394 r2426  
    163163//--
    164164
     165inline void compstring_swapcoord( unsigned long txtdir, PIGrCoord& x, PIGrCoord& y)
     166{
     167  if (txtdir != PI_TextDirectionHorizontal) {
     168    PIGrCoord tmp = x;
     169    x = y; y = tmp;
     170  }
     171  return;
     172}
     173
     174inline void compstring_chksgn_dyud( unsigned long txtdir, int & dyu, int & dyd)
     175{
     176  if (txtdir == PI_TextDirectionVerticalDown) {
     177    dyu = -dyu;
     178    dyd = -dyd;
     179  }
     180}
     181inline void compstring_chksgn_dx( unsigned long txtdir, int & dx)
     182{
     183  if (txtdir == PI_TextDirectionVerticalUp)  dx = -dx;
     184}
     185
    165186/* --Methode-- */
    166187void
     
    188209  if (s_dn != NULL) sw_sdn = fnt_ss.GetStringWidth(s_dn);
    189210
    190   PIGrCoord xs,ys;
     211  PIGrCoord xs,ys,xss,yss;
    191212  int posh = pos & PI_HorizontalPosition;
    192213  int posv = pos & PI_VerticalPosition;
     214  unsigned long txtdir = pos&PI_TextDirection;
    193215
    194216  int dyu, dyd;
     
    209231  int deltaposx = ((fh/8) > 0) ? fh/8 : 1;
    210232
     233  // Pour gerer les traces de texte verticaux
     234  compstring_swapcoord(txtdir, x, y);
     235  compstring_chksgn_dyud( txtdir, dyu, dyd);
     236  compstring_chksgn_dx( txtdir, deltaposx);
     237  compstring_chksgn_dx( txtdir, sw_s);
     238  compstring_chksgn_dx( txtdir, sw_sup);
     239  compstring_chksgn_dx( txtdir, sw_sdn);
    211240
    212241  if ((pos == 0) || ((posh == PI_HorizontalLeft) && (posv == PI_VerticalBaseLine))) {
    213242    xs = (int)x+sw_s;
    214     if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight);
     243    ys = y;
     244    compstring_swapcoord(txtdir, xs, ys);   
     245    if (s != NULL)  DrawString(xs, ys, s, txtdir | PI_HorizontalRight);
    215246    xs = (int)x+sw_s+deltaposx;
    216247    ys = (int)y+dyu;
    217248    SelFont(fnt_ss);
    218     if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft);
     249    compstring_swapcoord(txtdir, xs, ys);   
     250    if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft);
     251    xs = (int)x+sw_s+deltaposx;
    219252    ys = (int)y+dyd;
    220     if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft);
     253    compstring_swapcoord(txtdir, xs, ys);   
     254    if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft);
    221255  }
    222256  else {
    223257    if (posh == PI_HorizontalRight) {
    224258      int sw_ss_max = ( sw_sup > sw_sdn ) ? sw_sup : sw_sdn;
    225       xs = (int)x-sw_ss_max-deltaposx;
    226       if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight | posv);
     259      xss = xs = (int)x-sw_ss_max-deltaposx;
     260      ys = y;
     261      compstring_swapcoord(txtdir, xs, ys);   
     262      if (s != NULL)  DrawString(xs, ys, s, txtdir | PI_HorizontalRight | posv);
    227263      SelFont(fnt_ss);
    228       xs = (int)xs+deltaposx;
     264      xs = (int)xss+deltaposx;
    229265      ys = (int)y+dyu;
    230       if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft);
     266      compstring_swapcoord(txtdir, xs, ys);   
     267      if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft);
     268      xs = (int)xss+deltaposx;
    231269      ys = (int)y+dyd;
    232       if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft);     
     270      compstring_swapcoord(txtdir, xs, ys);   
     271      if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft);     
    233272    }
    234273    else if (posh == PI_HorizontalCenter) {
    235274      int sw_tot = sw_sup+sw_sdn+sw_s+deltaposx;
    236       xs = (int)x-sw_tot/2+sw_s;
    237       if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight | posv);
     275      xss = xs = (int)x-sw_tot/2+sw_s;
     276      ys = y;
     277      compstring_swapcoord(txtdir, xs, ys);   
     278      if (s != NULL)  DrawString(xs, ys, s, txtdir | PI_HorizontalRight | posv);
    238279      SelFont(fnt_ss);
    239       xs = (int)xs+deltaposx;
     280      xs = (int)xss+deltaposx;
    240281      ys = (int)y+dyu;
    241       if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft);
     282      compstring_swapcoord(txtdir, xs, ys);   
     283      if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft);
     284      xs = (int)xss+deltaposx;
    242285      ys = (int)y+dyd;
    243       if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft);           
     286      compstring_swapcoord(txtdir, xs, ys);   
     287      if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft);           
    244288    }
    245289    else {
    246290      xs = (int)x+sw_s;
    247       if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight | posv);
     291      ys = y;
     292      compstring_swapcoord(txtdir, xs, ys);   
     293      if (s != NULL)  DrawString(xs, ys, s, txtdir | PI_HorizontalRight | posv);
    248294      SelFont(fnt_ss);
    249295      xs = (int)x+sw_s+deltaposx;
    250296      ys = (int)y+dyu;
    251       if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft);
     297      compstring_swapcoord(txtdir, xs, ys);   
     298      if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft);
     299      xs = (int)x+sw_s+deltaposx;
    252300      ys = (int)y+dyd;
    253       if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft);
     301      compstring_swapcoord(txtdir, xs, ys);   
     302      if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft);
    254303    }
    255304  }
  • trunk/SophyaPI/PI/piversion.h

    r2374 r2426  
    22#define PIVERSION_H_SEEN
    33
    4 #define PI_VERSIONNUMBER  3.95
     4#define PI_VERSIONNUMBER  3.96
    55
    66#endif
  • trunk/SophyaPI/PI/pixtbase.cc

    r2410 r2426  
     1#include "machdefs.h"
     2#include <stdlib.h>
    13#include <stdio.h>
    24
     
    110112{ st = last_state_xevt;  t = last_time_xevt; }
    111113
     114/* Gestion de variable d'environnement pour choix Mod1Mask ou Mod2Mask */
     115static bool fgenv_kb_modmasks = false;
     116static int  sel_kb_modmasks = 1;
     117
    112118/* Nouvelle-Fonction */
    113119static void init_class_pixtbase()
    114120{
     121// Pour le choix Mod1Mask OU Mod2mask OU ( Mod1Mask | Mod2mask )
     122// Il faut en particulier Mod2Mask sur serveur X11/MacOSX (touche pomme)
     123//                      Reza / Septembre 2003
     124// Var. Env  PIXKBMODMASK   =2 -> Mod2Mask
     125//                          =3 -> Mod1Mask | Mod2Mask
     126//                          =0 -> Pas de ModMask
     127//                          =autre -> Mod1Mask (defaut)
     128if ( !fgenv_kb_modmasks ) {
     129  char *envmodmask = getenv("PIXKBMODMASK");
     130  if (envmodmask) {
     131    if (envmodmask[0] == '0')  sel_kb_modmasks = 0;
     132    else if (envmodmask[0] == '2')  sel_kb_modmasks = 2;
     133    else if (envmodmask[0] == '3')  sel_kb_modmasks = 3;
     134    else sel_kb_modmasks = 1;
     135  }
     136}
    115137#ifdef DEBUG_PIXTB
    116138puts("Debug_init_class_pixtbase() ");
     
    288310    if  (evt->xkey.state & ControlMask)
    289311      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
    290     // sur MacOSX, la touche Alt correspond a la touche pomme
    291     // et la masque associe est Mod2Mask   -    Reza 02/2002
    292     // Pour eviter les problemes, on va confondre Mod1Mask et Mod2mask
    293     //                      Reza / Juillet 2003
    294     if  ((evt->xkey.state & Mod1Mask) || (evt->xkey.state & Mod2Mask))   
     312    // Choix Mod1Mask Et/Ou Mod2Mask par variable sel_kb_modmasks
     313    //                      Reza / Septembre 2003
     314    if ((sel_kb_modmasks == 1) && (evt->xkey.state & Mod1Mask) )
    295315      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
     316    if ((sel_kb_modmasks == 2) && (evt->xkey.state & Mod2Mask) )
     317      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
     318    if ((sel_kb_modmasks == 3) &&
     319        ((evt->xkey.state & Mod1Mask) || (evt->xkey.state & Mod2Mask)) )
     320      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
     321
    296322    switch (key) {
    297323      case XK_Return :
  • trunk/SophyaPI/PI/psfile.cc

    r2394 r2426  
    893893
    894894
     895/* fonction pour rajouter \ devant ( ) et \ pour string postscript */
     896static char * EscapePSString(const char *s)
     897{
     898  int nce = 0;
     899  int ls = strlen(s);
     900  int i,j,k;
     901  for(int k=0; k<ls; k++)
     902    if ( (s[k] == '(') || (s[k] == ')') || (s[k] == '\\') ) nce++;
     903  if (nce == 0) return NULL;
     904  char * es = new char[ls+nce+1];
     905  j = 0;
     906  for(int k=0; k<ls; k++) {
     907    if ( (s[k] == '(') || (s[k] == ')') || (s[k] == '\\') ) {
     908      es[j] = '\\';  j++;
     909    }
     910    es[j] = s[k];  j++;
     911  }
     912  es[j] = '\0';
     913  return es;
     914}
     915
    895916void  PSFile::DrawString  (double x,  double y, const char *s,
    896917                           PIColors DrawColor,
     
    964985      setFontDone = true ;   // $CHECK$ - doit etre fait uniquement a ce moment
    965986    }
     987    /* Les () et \ doivent avoir le caractere escape \ dans les chaines postscript */
     988    char * es = EscapePSString(s);
     989    const char * epss = s;
     990    if (es != NULL) epss = es;
    966991    if (pos == 0)
    967       fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ;
     992      fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, epss) ;
    968993    else {
    969994      unsigned long txtdir = pos & PI_TextDirection;
     
    9781003        if (angle == 0)
    9791004          fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) hlshstr gr\n",
    980                   x, y, s) ;
     1005                  x, y, epss) ;
    9811006        else
    9821007          fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) hlshstr gr\n",
    983                   x, y, angle, s) ;
     1008                  x, y, angle, epss) ;
    9841009      }
    9851010      else {
     
    9941019          if (angle == 0)
    9951020            fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cshstr gr\n",
    996                     x, y, s, sshp) ;
     1021                    x, y, epss, sshp) ;
    9971022          else fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cshstr gr\n",
    998                        x, y, angle, s, sshp) ;
     1023                       x, y, angle, epss, sshp) ;
    9991024        }
    10001025        else {
     
    10051030        if (angle == 0)
    10061031          fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cv%cshstr gr\n",
    1007                   x, y, s, sshp, ssvp) ;
     1032                  x, y, epss, sshp, ssvp) ;
    10081033        else
    10091034          fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cv%cshstr gr\n",
    1010                   x, y, angle, s, sshp, ssvp) ;
     1035                  x, y, angle, epss, sshp, ssvp) ;
    10111036      }
    10121037    }
    10131038
     1039    if (es) delete[] es;  /* chaine modifiee avec des \( \) ou \\ */   
     1040    return;
    10141041}
    10151042
Note: See TracChangeset for help on using the changeset viewer.