Index: /trunk/SophyaPI/PI/pigraphgen.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphgen.cc	(revision 2425)
+++ /trunk/SophyaPI/PI/pigraphgen.cc	(revision 2426)
@@ -163,4 +163,25 @@
 //--
 
+inline void compstring_swapcoord( unsigned long txtdir, PIGrCoord& x, PIGrCoord& y)
+{
+  if (txtdir != PI_TextDirectionHorizontal) {
+    PIGrCoord tmp = x;
+    x = y; y = tmp;
+  }
+  return;
+}
+
+inline void compstring_chksgn_dyud( unsigned long txtdir, int & dyu, int & dyd)
+{
+  if (txtdir == PI_TextDirectionVerticalDown) {
+    dyu = -dyu;
+    dyd = -dyd;
+  }
+}
+inline void compstring_chksgn_dx( unsigned long txtdir, int & dx)
+{
+  if (txtdir == PI_TextDirectionVerticalUp)  dx = -dx;
+}
+
 /* --Methode-- */
 void 
@@ -188,7 +209,8 @@
   if (s_dn != NULL) sw_sdn = fnt_ss.GetStringWidth(s_dn);
 
-  PIGrCoord xs,ys; 
+  PIGrCoord xs,ys,xss,yss; 
   int posh = pos & PI_HorizontalPosition;
   int posv = pos & PI_VerticalPosition;
+  unsigned long txtdir = pos&PI_TextDirection;
 
   int dyu, dyd;
@@ -209,47 +231,74 @@
   int deltaposx = ((fh/8) > 0) ? fh/8 : 1;
 
+  // Pour gerer les traces de texte verticaux 
+  compstring_swapcoord(txtdir, x, y);
+  compstring_chksgn_dyud( txtdir, dyu, dyd);
+  compstring_chksgn_dx( txtdir, deltaposx); 
+  compstring_chksgn_dx( txtdir, sw_s); 
+  compstring_chksgn_dx( txtdir, sw_sup); 
+  compstring_chksgn_dx( txtdir, sw_sdn); 
 
   if ((pos == 0) || ((posh == PI_HorizontalLeft) && (posv == PI_VerticalBaseLine))) {
     xs = (int)x+sw_s;
-    if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight);
+    ys = y;
+    compstring_swapcoord(txtdir, xs, ys);    
+    if (s != NULL)  DrawString(xs, ys, s, txtdir | PI_HorizontalRight);
     xs = (int)x+sw_s+deltaposx;
     ys = (int)y+dyu;
     SelFont(fnt_ss);
-    if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft);
+    compstring_swapcoord(txtdir, xs, ys);    
+    if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft);
+    xs = (int)x+sw_s+deltaposx;
     ys = (int)y+dyd;
-    if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft);
+    compstring_swapcoord(txtdir, xs, ys);    
+    if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft);
   }
   else {
     if (posh == PI_HorizontalRight) {
       int sw_ss_max = ( sw_sup > sw_sdn ) ? sw_sup : sw_sdn;
-      xs = (int)x-sw_ss_max-deltaposx;
-      if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight | posv);
+      xss = xs = (int)x-sw_ss_max-deltaposx;
+      ys = y;
+      compstring_swapcoord(txtdir, xs, ys);    
+      if (s != NULL)  DrawString(xs, ys, s, txtdir | PI_HorizontalRight | posv);
       SelFont(fnt_ss);
-      xs = (int)xs+deltaposx;
+      xs = (int)xss+deltaposx;
       ys = (int)y+dyu;
-      if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft);
+      compstring_swapcoord(txtdir, xs, ys);    
+      if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft);
+      xs = (int)xss+deltaposx;
       ys = (int)y+dyd;
-      if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft);      
+      compstring_swapcoord(txtdir, xs, ys);    
+      if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft);      
     }
     else if (posh == PI_HorizontalCenter) {
       int sw_tot = sw_sup+sw_sdn+sw_s+deltaposx;
-      xs = (int)x-sw_tot/2+sw_s; 
-      if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight | posv);
+      xss = xs = (int)x-sw_tot/2+sw_s; 
+      ys = y;
+      compstring_swapcoord(txtdir, xs, ys);    
+      if (s != NULL)  DrawString(xs, ys, s, txtdir | PI_HorizontalRight | posv);
       SelFont(fnt_ss);
-      xs = (int)xs+deltaposx;
+      xs = (int)xss+deltaposx;
       ys = (int)y+dyu;
-      if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft);
+      compstring_swapcoord(txtdir, xs, ys);    
+      if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft);
+      xs = (int)xss+deltaposx;
       ys = (int)y+dyd;
-      if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft);            
+      compstring_swapcoord(txtdir, xs, ys);    
+      if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft);            
     }
     else {
       xs = (int)x+sw_s;
-      if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight | posv);
+      ys = y;
+      compstring_swapcoord(txtdir, xs, ys);    
+      if (s != NULL)  DrawString(xs, ys, s, txtdir | PI_HorizontalRight | posv);
       SelFont(fnt_ss);
       xs = (int)x+sw_s+deltaposx;
       ys = (int)y+dyu;
-      if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft);
+      compstring_swapcoord(txtdir, xs, ys);    
+      if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft);
+      xs = (int)x+sw_s+deltaposx;
       ys = (int)y+dyd;
-      if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft);
+      compstring_swapcoord(txtdir, xs, ys);    
+      if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft);
     }
   }
Index: /trunk/SophyaPI/PI/piversion.h
===================================================================
--- /trunk/SophyaPI/PI/piversion.h	(revision 2425)
+++ /trunk/SophyaPI/PI/piversion.h	(revision 2426)
@@ -2,5 +2,5 @@
 #define PIVERSION_H_SEEN
 
-#define PI_VERSIONNUMBER  3.95
+#define PI_VERSIONNUMBER  3.96
 
 #endif
Index: /trunk/SophyaPI/PI/pixtbase.cc
===================================================================
--- /trunk/SophyaPI/PI/pixtbase.cc	(revision 2425)
+++ /trunk/SophyaPI/PI/pixtbase.cc	(revision 2426)
@@ -1,2 +1,4 @@
+#include "machdefs.h"
+#include <stdlib.h>
 #include <stdio.h>
 
@@ -110,7 +112,27 @@
 { st = last_state_xevt;  t = last_time_xevt; }
 
+/* Gestion de variable d'environnement pour choix Mod1Mask ou Mod2Mask */
+static bool fgenv_kb_modmasks = false;
+static int  sel_kb_modmasks = 1;
+
 /* Nouvelle-Fonction */
 static void init_class_pixtbase()
 {
+// Pour le choix Mod1Mask OU Mod2mask OU ( Mod1Mask | Mod2mask )
+// Il faut en particulier Mod2Mask sur serveur X11/MacOSX (touche pomme)
+//                      Reza / Septembre 2003
+// Var. Env  PIXKBMODMASK   =2 -> Mod2Mask
+//                          =3 -> Mod1Mask | Mod2Mask
+//                          =0 -> Pas de ModMask
+//                          =autre -> Mod1Mask (defaut) 
+if ( !fgenv_kb_modmasks ) {
+  char *envmodmask = getenv("PIXKBMODMASK");
+  if (envmodmask) {
+    if (envmodmask[0] == '0')  sel_kb_modmasks = 0;
+    else if (envmodmask[0] == '2')  sel_kb_modmasks = 2;
+    else if (envmodmask[0] == '3')  sel_kb_modmasks = 3;
+    else sel_kb_modmasks = 1;
+  }
+}
 #ifdef DEBUG_PIXTB
 puts("Debug_init_class_pixtbase() ");
@@ -288,10 +310,14 @@
     if  (evt->xkey.state & ControlMask) 
       kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
-    // sur MacOSX, la touche Alt correspond a la touche pomme 
-    // et la masque associe est Mod2Mask   -    Reza 02/2002
-    // Pour eviter les problemes, on va confondre Mod1Mask et Mod2mask
-    //                      Reza / Juillet 2003
-    if  ((evt->xkey.state & Mod1Mask) || (evt->xkey.state & Mod2Mask))   
+    // Choix Mod1Mask Et/Ou Mod2Mask par variable sel_kb_modmasks
+    //                      Reza / Septembre 2003
+    if ((sel_kb_modmasks == 1) && (evt->xkey.state & Mod1Mask) )
       kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    if ((sel_kb_modmasks == 2) && (evt->xkey.state & Mod2Mask) )
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    if ((sel_kb_modmasks == 3) && 
+	((evt->xkey.state & Mod1Mask) || (evt->xkey.state & Mod2Mask)) )
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+
     switch (key) {
       case XK_Return :
Index: /trunk/SophyaPI/PI/psfile.cc
===================================================================
--- /trunk/SophyaPI/PI/psfile.cc	(revision 2425)
+++ /trunk/SophyaPI/PI/psfile.cc	(revision 2426)
@@ -893,4 +893,25 @@
 
 
+/* fonction pour rajouter \ devant ( ) et \ pour string postscript */
+static char * EscapePSString(const char *s)
+{
+  int nce = 0;
+  int ls = strlen(s);
+  int i,j,k;
+  for(int k=0; k<ls; k++) 
+    if ( (s[k] == '(') || (s[k] == ')') || (s[k] == '\\') ) nce++;
+  if (nce == 0) return NULL;
+  char * es = new char[ls+nce+1];
+  j = 0;
+  for(int k=0; k<ls; k++) {
+    if ( (s[k] == '(') || (s[k] == ')') || (s[k] == '\\') ) {
+      es[j] = '\\';  j++; 
+    }
+    es[j] = s[k];  j++;
+  }
+  es[j] = '\0';
+  return es;
+}
+
 void  PSFile::DrawString  (double x,  double y, const char *s, 
 			   PIColors DrawColor, 
@@ -964,6 +985,10 @@
       setFontDone = true ;   // $CHECK$ - doit etre fait uniquement a ce moment
     }
+    /* Les () et \ doivent avoir le caractere escape \ dans les chaines postscript */
+    char * es = EscapePSString(s);
+    const char * epss = s;
+    if (es != NULL) epss = es;
     if (pos == 0) 
-      fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 
+      fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, epss) ; 
     else {
       unsigned long txtdir = pos & PI_TextDirection;
@@ -978,8 +1003,8 @@
 	if (angle == 0) 
 	  fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) hlshstr gr\n", 
-		  x, y, s) ;
+		  x, y, epss) ;
 	else 
 	  fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) hlshstr gr\n", 
-		  x, y, angle, s) ;
+		  x, y, angle, epss) ;
       }
       else {
@@ -994,7 +1019,7 @@
 	  if (angle == 0) 
 	    fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cshstr gr\n", 
-		    x, y, s, sshp) ;
+		    x, y, epss, sshp) ;
 	  else fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cshstr gr\n", 
-		       x, y, angle, s, sshp) ;
+		       x, y, angle, epss, sshp) ;
 	}
 	else {
@@ -1005,11 +1030,13 @@
 	if (angle == 0) 
 	  fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cv%cshstr gr\n", 
-		  x, y, s, sshp, ssvp) ; 
+		  x, y, epss, sshp, ssvp) ; 
 	else 
 	  fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cv%cshstr gr\n", 
-		  x, y, angle, s, sshp, ssvp) ; 
+		  x, y, angle, epss, sshp, ssvp) ; 
       }
     }
 
+    if (es) delete[] es;  /* chaine modifiee avec des \( \) ou \\ */    
+    return;
 }
 
