Index: trunk/SophyaPI/PI/piscdrawwdg.cc
===================================================================
--- trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 23)
+++ trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 37)
@@ -32,13 +32,17 @@
 
 void
-PIScDrawWdg::SetLimits(double xmin, double xmax, 
-                       double ymin, double ymax, bool tmp)
+PIScDrawWdg::SetLimits(double xmin, double xmax, double ymin, double ymax,
+                       bool axrl, bool ayud, bool tmp)
 {
   if (xmax <= xmin || ymax <= ymin)
     return; // $CHECK$ exception ?
+  aXdir = axrl;      // Vrai si Axe X de Droite vers Gauche
+  aYdir = ayud;      // Vrai si Axe Y de Haut vers Bas
   xMin = xmin;
   xMax = xmax;
   yMin = ymin;
   yMax = ymax;
+  mPPos[0] = 0.5*(xMin+xMax);
+  mPPos[1] = 0.5*(yMin+yMax);
   if (!tmp) {
     xMinS = xmin;
@@ -63,10 +67,19 @@
 PIScDrawWdg::CalcScale()
 {
-  double margeH = (xMax-xMin)*0.2;
-  double margeV = (yMax-yMin)*0.2;
+  double margeH = (xMax-xMin)*0.15;
+  double margeV = (yMax-yMin)*0.15;
   xScale = XSize() / (xMax-xMin + 2*margeH);
-  yScale = -YSize() / (yMax-yMin + 2*margeV);
-  xOrg   = (-xMin + margeH) * xScale;// + XPos();
-  yOrg   = (-yMax - margeV) * yScale;// + YPos();
+  if (aXdir)  { 
+    xScale = -xScale;
+    xOrg   = (-xMax - margeH) * xScale;// + XPos();
+  }
+  else xOrg   = (-xMin + margeH) * xScale;// + XPos();
+  yScale = YSize() / (yMax-yMin + 2*margeV);
+  if (!aYdir) {
+    yScale = -yScale;
+    yOrg   = (-yMax - margeV) * yScale;// + YPos();
+  }
+  else yOrg   = (-yMin + margeV) * yScale;// + YPos();
+return;
 }
 
@@ -361,8 +374,10 @@
 {
   double xOffset = 0;
-  
+  int kk;
   ScSelFontSz(xMajTickLen*4);
   for (double x=xBeg; x<=xMax; x += xStep) {
       char label[20]; sprintf(label, "%-6g", x);
+      for(kk=0; kk<20; kk++)
+        if (label[kk] == ' ')   { label[kk] = '\0' ; break; }
       double largeur = ScStringWidth(label);
       if (just == 1)
@@ -372,4 +387,5 @@
       else
         xOffset = 0;
+      if (aXdir)  xOffset = -xOffset;
       ScDrawString(x+xOffset, y, label);
   }
@@ -390,4 +406,5 @@
       else
         xOffset = 0;
+      if (aXdir)  xOffset = -xOffset;
       ScDrawString(x+xOffset, y, label);
   }
@@ -427,6 +444,12 @@
     
     if (flags & kLabels) {
+      if (!aYdir)
         DrawHLabels(-xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      else 
+        DrawHLabels(xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      if (!aXdir)
         DrawVLabels(-yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+      else 
+        DrawVLabels(yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
     }
     
@@ -475,8 +498,20 @@
     
     if (flags & kLabels) {
+      if (!aYdir) {
         DrawHLabels(yMin-xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
         DrawHLabels(yMax+xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
+      }
+      else {
+        DrawHLabels(yMin-xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(yMax+xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      }
+      if (!aXdir) {
         DrawVLabels(xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
         DrawVLabels(xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
+      }
+      else {
+        DrawVLabels(xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
+        DrawVLabels(xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+      }
     }
   }
@@ -604,9 +639,11 @@
 PIScDrawWdg::UpdateText(int xp, int yp)
 {
-  if ((mTxw == NULL) && (mTrlb == NULL)) return(false);
-
-  char buff[128];
+
   double dx, dy;
   Local2Sc(xp, yp, dx, dy); 
+  mPPos[0] = dx;  mPPos[1] = dy; 
+  if ((mTxw == NULL) && (mTrlb == NULL)) return(false);
+
+  char buff[128];
   sprintf(buff, "X= %g  Y= %g",  dx, dy);
   if (mTxw)
@@ -647,5 +684,5 @@
   
   if (xBegDrag == xEndDrag || yBegDrag == yEndDrag)
-    SetLimits(xMinS, xMaxS, yMinS, yMaxS);
+    SetLimits(xMinS, xMaxS, yMinS, yMaxS, aXdir, aYdir );
   else {
     double xl,yl,xh,yh;
@@ -654,5 +691,5 @@
     if (xl > xh) swap(xl, xh);
     if (yl > yh) swap(yl, yh);
-    SetLimits(xl,xh,yl,yh, true);
+    SetLimits(xl,xh,yl,yh, aXdir, aYdir, true);
   }
   
