Index: trunk/SophyaPI/PI/piaxes.cc
===================================================================
--- trunk/SophyaPI/PI/piaxes.cc	(revision 2515)
+++ trunk/SophyaPI/PI/piaxes.cc	(revision 2516)
@@ -111,7 +111,14 @@
 
     // Les axes
+    double x0axes = (xMin+xMax)/2.;
+    double y0axes = (yMin+yMax)/2.;
+    // POUR REZA: ici si on a demande de forcer les axes en x0,y0
+    // alors on le fait ici: il faut faire a peu pres ca:
+    // > if(getaxescenter()) getaxescenter(x0axes,y0axes);
+    if(x0axes<xMin || x0axes>xMax) x0axes = (xMin+xMax)/2.;
+    if(y0axes<yMin || y0axes>yMax) y0axes = (yMin+yMax)/2.;
     
-    g->DrawLine(xMin, (yMin+yMax)/2., xMax, (yMin+yMax)/2.);
-    g->DrawLine((xMin+xMax)/2., yMin, (xMin+xMax)/2., yMax);
+    g->DrawLine(xMin, y0axes, xMax, y0axes);
+    g->DrawLine(x0axes, yMin, x0axes, yMax);
     //    PIArrowMarker amk = g->GetArrowMarker();
     //    if (amk == PI_NotDefArrowMarker) 
@@ -120,7 +127,7 @@
     //    g->SelArrowMarker(5, g->GetArrowMarker());
     double xm2 = g->DeltaUCX(xMax, yMajTickLen*2.);
-    g->DrawArrowMarker(xMax, (yMin+yMax)/2., xm2, (yMin+yMax)/2., true);
+    g->DrawArrowMarker(xMax, y0axes, xm2, y0axes, true);
     double ym2 = g->DeltaUCY(yMax, xMajTickLen*2.);
-    g->DrawArrowMarker((xMin+xMax)/2., yMax, (xMin+xMax)/2., ym2, true);
+    g->DrawArrowMarker(x0axes, yMax, x0axes, ym2, true);
     // La grille en pointilles
 
@@ -130,6 +137,6 @@
   
     if (flags & kMajTicks) {
-        DrawHTicks(g, (yMin+yMax)/2., xMajTickLen, xMajTickLen, xMajTicks);
-        DrawVTicks(g, (xMin+xMax)/2., yMajTickLen, yMajTickLen, yMajTicks);
+        DrawHTicks(g, y0axes, xMajTickLen, xMajTickLen, xMajTicks);
+        DrawVTicks(g, x0axes, yMajTickLen, yMajTickLen, yMajTicks);
     }
     
@@ -137,6 +144,6 @@
   
     if (flags & kMinTicks) {
-        DrawHTicks(g, (yMin+yMax)/2., xMinTickLen, xMinTickLen, xMinTicks);
-        DrawVTicks(g, (xMin+xMax)/2., yMinTickLen, yMinTickLen, yMinTicks);
+        DrawHTicks(g, y0axes, xMinTickLen, xMinTickLen, xMinTicks);
+        DrawVTicks(g, x0axes, yMinTickLen, yMinTickLen, yMinTicks);
     }
     
@@ -146,13 +153,13 @@
       double declab = 2*xMajTickLen;
       if (!aYdir)
-        DrawHLabels(g, (yMin+yMax)/2.-declab, xMajTicks, PI_VerticalTop);
+        DrawHLabels(g, y0axes-declab, xMajTicks, PI_VerticalTop);
       else 
-        DrawHLabels(g, (yMin+yMax)/2.+declab, xMajTicks, PI_VerticalTop);
+        DrawHLabels(g, y0axes+declab, xMajTicks, PI_VerticalTop);
 
       declab = 2.*yMajTickLen;
       if (!aXdir)
-        DrawVLabels(g, (xMin+xMax)/2.-declab, yMajTicks, PI_HorizontalRight);
+        DrawVLabels(g, x0axes-declab, yMajTicks, PI_HorizontalRight);
       else 
-        DrawVLabels(g, (xMin+xMax)/2.+declab, yMajTicks, PI_HorizontalRight);
+        DrawVLabels(g, x0axes+declab, yMajTicks, PI_HorizontalRight);
     }
     
Index: trunk/SophyaPI/PI/pidrawer.cc
===================================================================
--- trunk/SophyaPI/PI/pidrawer.cc	(revision 2515)
+++ trunk/SophyaPI/PI/pidrawer.cc	(revision 2516)
@@ -65,4 +65,5 @@
   SetAxesFlags(kAxesNone);   // Pas de trace d'axes par defaut 
   SetAxesAutoFontSize();
+  SetAxesCenter();
 
   mDndfg = false;  // Pour controle de l'appel de Detach() si delete
@@ -142,4 +143,6 @@
 //|	kMajTicks , kMinTicks , kLabels , kGridOn
 //|	kAxesDflt , kAxesNone
+// void  SetAxesCenter(bool fset,double x0,double y0)
+//	Force axe center to be at (x0,y0) or let it be in the middle
 // void SetAxesAutoFontSize(bool fg=true)
 //	Si "fg==true", la taille de la fonte pour les labels d'axes (chiffres) est 
@@ -488,4 +491,12 @@
 }
 
+void
+PIDrawer::SetAxesCenter(bool fset,double x0,double y0)
+{
+ axesCenter = fset;
+ if(!axesCenter) return;
+ axesCentX0 = x0;
+ axesCentY0 = y0;
+}
 
 void
Index: trunk/SophyaPI/PI/pidrawer.h
===================================================================
--- trunk/SophyaPI/PI/pidrawer.h	(revision 2515)
+++ trunk/SophyaPI/PI/pidrawer.h	(revision 2516)
@@ -30,4 +30,5 @@
 
   virtual void       SetAxesFlags(unsigned int flags=kAxesNone);
+  virtual void       SetAxesCenter(bool fset=false,double x0=0.,double y0=0.);
   inline  void       SetAxesAutoFontSize(bool fg=true) { axesAFSz = fg; }
 
@@ -63,5 +64,8 @@
 
   inline unsigned int GetAxesFlags() { return(axesFlags); }
-  inline  bool       isAxesAutoFontSize() { return axesAFSz; }
+  inline  bool        GetAxesCenter() { return(axesCenter); }
+  inline  bool        GetAxesCenter(double &x0,double& y0)
+                       {x0=axesCentX0; y0=axesCentY0; return(axesCenter);}
+  inline  bool        isAxesAutoFontSize() { return axesAFSz; }
 
   inline PIGraphicUC*    GetGraphicUC() { return(mGrUC); }
@@ -128,4 +132,5 @@
   unsigned int axesFlags;
   bool axesAFSz;
+  bool axesCenter; double axesCentX0,axesCentY0;
   PIBaseWdgGen* mBWdg;
   PIGraphicUC* mGrUC;
Index: trunk/SophyaPI/PI/pieldrw.cc
===================================================================
--- trunk/SophyaPI/PI/pieldrw.cc	(revision 2515)
+++ trunk/SophyaPI/PI/pieldrw.cc	(revision 2516)
@@ -563,4 +563,13 @@
     else if (opts == "nogrid")
       SetAxesFlags(GetAxesFlags() & ~kGridOn);
+    else if (opts.substr(0,11) == "axescenter=") {
+      if(opts == "axescenter=") {
+        SetAxesCenter();
+      } else {
+        double x0=0., y0=0.;
+        sscanf(opts.substr(11).c_str(),"%lf,%lf",&x0,&y0);
+        SetAxesCenter(true,x0,y0);
+      }
+    }
 
     else if (opts.substr(0,13) == "autofontsize=") {
Index: trunk/SophyaPI/PI/piyfxdrw.cc
===================================================================
--- trunk/SophyaPI/PI/piyfxdrw.cc	(revision 2515)
+++ trunk/SophyaPI/PI/piyfxdrw.cc	(revision 2516)
@@ -4,4 +4,6 @@
 
 #include "machdefs.h"
+#include <stdlib.h>
+#include <iostream>
 #include <math.h>
 #include "piyfxdrw.h"
@@ -54,4 +56,5 @@
   mAy = ay;
   mName = "YfXDrawer";
+  NptDraw = 0;
 } 
 
@@ -119,4 +122,5 @@
     }
   if (mSz <= 0)  return;
+  NptDraw=0;
 
 //  Trace des markers 
@@ -128,4 +132,5 @@
       if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
       g->DrawMarker(xp, yp);
+      NptDraw++;
     }
   }
@@ -134,4 +139,5 @@
 
 // Trace des lignes 
+  NptDraw=0;
   double xp2, yp2;
   if (mAy) { xp2 = mAx->Value(0); yp2 = mAy->Value(0); }
@@ -144,6 +150,44 @@
          ((xp2 < xmin) || (xp2 > xmax) || (yp2 < ymin) || (yp2 > ymax)) )  continue;
     g->DrawLine(xp, yp, xp2, yp2);
+    NptDraw++;
   }
-}
+
+}
+
+
+/* --Methode-- */
+double PIYfXDrawer::GetDistanceToPoint(double x, double y)
+{
+ if(mSz<=0)  return 1.e+9;
+
+ const int nessai = 100;
+ long inc = (NptDraw>nessai) ? (long)(NptDraw/nessai)+1 : 1;
+
+ double dist = -1.e+18;
+ long n = 0;
+ for(long i=0; i<mSz; i++) {
+   double xp,yp;
+   if(mAy) {xp=mAx->Value(i); yp=mAy->Value(i);}
+     else  {xp=mAx->X(i);     yp=mAx->Value(i);}
+   if(xp<XMin() || xp>XMax()) continue;
+   if(yp<YMin() || yp>YMax()) continue;
+   if(n%inc==0) {
+     xp = (xp-x)/(XMax()-XMin())/0.5;
+     yp = (yp-y)/(YMax()-YMin())/0.5;
+     xp = xp*xp+yp*yp;
+     if(dist<0. || xp<dist) dist = xp;
+   }
+   n++;
+ }
+ dist=sqrt(fabs(dist));
+ //cout<<"PIYfXDrawer: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax()
+ //    <<" mSz="<<mSz<<" inc="<<inc<<endl;
+ //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<" NptDraw="<<NptDraw<<endl;
+
+ return dist;
+}
+
+
+
 
 
@@ -176,5 +220,5 @@
 /* --Methode-- */
 PIFuncDrawer::PIFuncDrawer(PIFuncDrawer::FUNC f)
-: mFunc(f)
+  : mFunc(f)
 {}
 
@@ -209,2 +253,22 @@
 }
 
+
+/* --Methode-- */
+double PIFuncDrawer::GetDistanceToPoint(double x, double y)
+{
+ if(mFunc==NULL) return 1.e+9;
+
+ double xStep = (XMax()-XMin())/50;
+ double dist = -1.e+18;
+ for(double xx=XMin()+xStep; xx<XMax(); xx+=xStep) {
+   double xp = (xx-x)/(XMax()-XMin())/0.5;
+   double yp = (mFunc(xp)-y)/(YMax()-YMin())/0.5;
+   xp = xp*xp+yp*yp;
+   if(dist<0. || xp<dist) dist = xp;
+ }
+ dist=sqrt(fabs(dist));
+ //cout<<"PIFuncDrawer: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax()<<endl;
+ //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<endl;
+
+ return dist;
+}
Index: trunk/SophyaPI/PI/piyfxdrw.h
===================================================================
--- trunk/SophyaPI/PI/piyfxdrw.h	(revision 2515)
+++ trunk/SophyaPI/PI/piyfxdrw.h	(revision 2516)
@@ -25,5 +25,7 @@
   virtual void       UpdateLimits();
   
-       
+ // Renvoie une distance au point x,y
+  virtual double     GetDistanceToPoint(double x, double y);
+
 protected:
   P1DArrayAdapter* mAx;
@@ -31,4 +33,5 @@
   int mSz;
   bool mAdDO;
+  long NptDraw; // nombre de points effectivement dessines dans la fenetre
 };
 
@@ -44,4 +47,8 @@
   
   virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+
+ // Renvoie une distance au point x,y
+  virtual double     GetDistanceToPoint(double x, double y);
+
 protected:
   FUNC               mFunc;
