Index: /trunk/SophyaPI/PI/pigraphgen.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphgen.cc	(revision 1847)
+++ /trunk/SophyaPI/PI/pigraphgen.cc	(revision 1848)
@@ -288,4 +288,38 @@
 }
 
+/* --Methode-- */
+bool PIGraphicGen::CalcStringPositionShift(char const* s, int pos, 
+					   int& dx, int& dy)
+{
+  dx = 0;
+  dy = 0;
+  cout << " PIGraphicGen::CalcStringPositionShift - DBG - pos= " 
+       << pos << endl;
+  if (pos == 0) return(false);
+  else {
+    int posh = pos & PI_HorizontalPosition;
+    int posv = pos & PI_VerticalPosition;
+    if ((posh == PI_HorizontalLeft)  && (posv == PI_VerticalBottom))
+      return(false);
+    if (posh != PI_HorizontalLeft) {
+      int wx = myFont.GetStringWidth(s);
+      if (posh == PI_HorizontalCenter)  dx = wx/2;
+      else if (posh == PI_HorizontalRight)  dx = wx;
+      else wx = 0;
+    }
+    if (posv != PI_VerticalBottom) {
+      int a,d;
+      int wy = myFont.GetFontHeight(a, d);
+      if (posv == PI_VerticalCenter)  dy = -wy/2;
+      else if (posv == PI_VerticalTop)  dy = -wy;
+      else dy = 0;
+    }
+    cout << " PIGraphicGen::CalcStringPositionShift - DBG2 - dx= " 
+	 << dx << " dy=" << dy << endl;
+    return(true);
+  }
+}
+
+
 //++
 // Titre	Sauvegarde et rappel des attributs graphiques
Index: /trunk/SophyaPI/PI/pigraphgen.h
===================================================================
--- /trunk/SophyaPI/PI/pigraphgen.h	(revision 1847)
+++ /trunk/SophyaPI/PI/pigraphgen.h	(revision 1848)
@@ -28,9 +28,16 @@
                  PI_StarMarker=9, PI_FStarMarker=10 };
 
-enum PIGrPosHorizontal { PI_HorizontalLeft = 0, PI_HorizontalCenter = 1, 
-			 PI_HorizontalRight = 2 };
-enum PIGrPosVertical { PI_VerticalBottom = 32, PI_VerticalCenter = 36, 
-		       PI_VerticalTop = 40 };
 
+enum PIGrPosHorizontal // Flags de positionnement horizontal
+// PI_HorizontalPosition regroupe l'ensemble des bits utilisables
+     { PI_HorizontalLeft = 0x1, PI_HorizontalCenter = 0x2, 		 
+       PI_HorizontalRight = 0x3, PI_HorizontalPosition = 0xF };
+
+enum PIGrPosVertical  // Flags de positionnement vertical
+// PI_VerticalPosition regroupe l'ensemble des bits utilisables
+     { PI_VerticalBottom = 0x10, PI_VerticalCenter = 0x20, 
+       PI_VerticalTop = 0x30, PI_VerticalPosition = 0xF0 };
+
+// Les differents modes de trace graphique disponible
 enum PIGOMode { PI_GOCopy = 0, PI_GOXOR = 1, PI_GOInvert = 2 }; 
 
@@ -130,4 +137,6 @@
   virtual PIGrCoord  GetFontHeight(PIGrCoord& asc, PIGrCoord& desc);
   virtual PIGrCoord  CalcStringWidth(char const* s);
+  virtual bool       CalcStringPositionShift(char const* s, int pos,  
+					     int& dx, int& dy);
 
 // Sauvegarde des attributs graphiques 
Index: /trunk/SophyaPI/PI/pigraphps.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphps.cc	(revision 1847)
+++ /trunk/SophyaPI/PI/pigraphps.cc	(revision 1848)
@@ -112,10 +112,11 @@
 
 /* --Methode-- */
-void PIGraphicPS::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+void PIGraphicPS::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
 {
 if(mPSOut)
   //  mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
   mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(),
-                     myFont.GetFontAtt(),  myFont.GetFontSize()*0.9); /* $CHECK$  x 0.9 - Reza 4/11/99 */
+                     myFont.GetFontAtt(),  myFont.GetFontSize(),
+		     pos); /* $CHECK$  x 0.9 - Reza 4/11/99  - enleve 3/01/2002 */
 // Calculez la taille de la boite occupe par la fonte
 //  myFont.GetFontHeight(int& asc, int& desc)  Tres proche de myFont.GetFontSize() en principe
@@ -125,10 +126,11 @@
 
 /* --Methode-- */
-void PIGraphicPS::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+void PIGraphicPS::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
 {
 if(mPSOut)
   //  mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
   mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(), 
-                     myFont.GetFontAtt(),  myFont.GetFontSize()*0.9);  /* $CHECK$  x 0.9 - Reza 4/11/99 */
+                     myFont.GetFontAtt(),  myFont.GetFontSize(),
+		     pos);  /* $CHECK$  x 0.9 - Reza 4/11/99 */
 // Idem taille ici 
 return;
Index: /trunk/SophyaPI/PI/pigraphx.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphx.cc	(revision 1847)
+++ /trunk/SophyaPI/PI/pigraphx.cc	(revision 1848)
@@ -103,16 +103,24 @@
 
 /* --Methode-- */
-void PIGraphicX::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
-{
+void PIGraphicX::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
+{
+int dx, dy, xi, yi;
+xi = x;  yi = y;
+if (CalcStringPositionShift(s, pos, dx, dy)) {
+  xi -= dx;  yi -= dy; }
 XDrawString (XtDisplay (MyWdg()),mWId, 
-                  DefGC(), (int)x, (int)y, s, strlen(s));
-return;
-}
-
-/* --Methode-- */
-void PIGraphicX::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
-{
+                  DefGC(), xi, yi, s, strlen(s));
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
+{
+int dx, dy, xi, yi;
+xi = x;  yi = y;
+if (CalcStringPositionShift(s, pos, dx, dy)) {
+  xi -= dx;  yi -= dy; }
 XDrawImageString (XtDisplay (MyWdg()),mWId, 
-                  DefGC(), (int)x, (int)y, s, strlen(s));
+                  DefGC(), xi, yi, s, strlen(s));
 return;
 }
Index: /trunk/SophyaPI/PI/psfile.cc
===================================================================
--- /trunk/SophyaPI/PI/psfile.cc	(revision 1847)
+++ /trunk/SophyaPI/PI/psfile.cc	(revision 1848)
@@ -130,4 +130,35 @@
 /ff {findfont} bind def   /sf {setfont} bind def /scf {scalefont} bind def\n\
 /rl {rlineto} bind def    /tr {translate} bind def\n\
+/rmv {rmoveto} bind def \n\
+%% Trace de chaine avec justification diverse \n\
+%% hxvyshstr  stack: TheString \n\
+%% hx (x=r,c,l) Horizontal-X Right,Center,Left \n\
+%% vy (y=t,c,b) Vertical-Y Top,Center,Bottom \n\
+/hlvbshstr   %% Horizontal-left Vertical-Bottom justified \n\
+{ gs 1 -1 sc show gr } bind def \n\
+/hcvbshstr   %% Horizontal-Center Vertical-Bottom justified \n\
+{ dup stringwidth pop 2 div neg  %% get minus(string length/2)  \n\
+  0 rmoveto gs 1 -1 sc show gr } bind def \n\
+/hrvbshstr   %% Horizontal-Right Vertical-Bottom justified \n\
+{ dup stringwidth pop neg  %% get minus(string width)  \n\
+  0 rmoveto gs 1 -1 sc show gr } bind def \n\
+/hlvcshstr   %% Horizontal-left Vertical-Center justified \n\
+{ dup stringwidth exch pop 2 div   %% get (string height)/2  \n\
+  0 exch rmoveto gs 1 -1 sc show gr } bind def \n\
+/hcvcshstr   %% Horizontal-Center Vertical-Center justified \n\
+{ dup stringwidth 2 div exch 2 div neg   %% s_wy/2 -s_wx/2  \n\
+  exch rmoveto gs 1 -1 sc show gr } bind def \n\
+/hrvcshstr   %% Horizontal-Right Vertical-Center justified \n\
+{ dup stringwidth 2 div exch neg   %% s_wy/2 -s_wx  \n\
+  exch rmoveto gs 1 -1 sc show gr } bind def \n\
+/hlvtshstr   %% Horizontal-left Vertical-Top justified \n\
+{ dup stringwidth exch pop    %% get s_wy  \n\
+  0 exch rmoveto gs 1 -1 sc show gr } bind def \n\
+/hcvtshstr   %% Horizontal-Center Vertical-Top justified \n\
+{ dup stringwidth exch 2 div neg   %% s_wy -s_wx/2  \n\
+  exch rmoveto gs 1 -1 sc show gr } bind def \n\
+/hrvtshstr   %% Horizontal-Right Vertical-Top justified \n\
+{ dup stringwidth exch neg   %% s_wy -s_wx  \n\
+  exch rmoveto gs 1 -1 sc show gr } bind def \n\
 %% Tx Ty X0 Y0 box\n\
 /box {tr 0 3 1 roll neg exch 0 0 3 index neg 0 0 m rl rl rl c} bind def\n\
@@ -795,5 +826,6 @@
 			   PIFontName FontName, 
 			   PIFontAtt FontAtt, 
-			   int FontSize) {
+			   int FontSize, 
+			   int pos) {
     bool change = false;
 
@@ -861,6 +893,28 @@
       setFontDone = true ;   // $CHECK$ - doit etre fait uniquement a ce moment
     }
-        
-    fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 
+    if (pos == 0) 
+      fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 
+    else {
+      int posh = pos & PI_HorizontalPosition;
+      int posv = pos & PI_VerticalPosition;
+      if ((posh == PI_HorizontalLeft)  && (posv == PI_VerticalBottom))
+	fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) hlvbshstr gr\n", 
+		x, y, s) ; 
+      else {
+	char ssvp = 'b';
+	char sshp = 'l';
+	if (posh != PI_HorizontalLeft) {
+	  if (posh == PI_HorizontalCenter)  sshp = 'c';
+	  else if (posh == PI_HorizontalRight)  sshp = 'r';
+	  else sshp = 'l';
+	}
+	if (posv != PI_VerticalBottom) {
+	  if (posv == PI_VerticalCenter)  ssvp = 'c';
+	  else if (posv == PI_VerticalTop)  ssvp = 't';
+	}
+	fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cv%cshstr gr\n", 
+		x, y, s, sshp, ssvp) ; 
+      }
+    }
 }
 
Index: /trunk/SophyaPI/PI/psfile.h
===================================================================
--- /trunk/SophyaPI/PI/psfile.h	(revision 1847)
+++ /trunk/SophyaPI/PI/psfile.h	(revision 1848)
@@ -112,5 +112,6 @@
 			       PIFontName FontName = PI_DefaultFont,
 			       PIFontAtt FontAtt   = PI_NotDefFontAtt, 
-			       int FontSize        = 8);
+			       int FontSize        = 8, 
+			       int pos = 0);
     virtual void  DrawLine    (double x1, double y1, double x2, double y2, 
 			       PIColors DrawColor  = PI_NotDefColor,
