Index: trunk/SophyaPI/PI/pidrawer.cc
===================================================================
--- trunk/SophyaPI/PI/pidrawer.cc	(revision 1945)
+++ trunk/SophyaPI/PI/pidrawer.cc	(revision 1946)
@@ -52,4 +52,6 @@
   limitsFixed = 0;
   SetAxesFlags(kAxesNone);   // Pas de trace d'axes par defaut 
+  SetAxesAutoFontSize();
+
   mDndfg = false;  // Pour controle de l'appel de Detach() si delete
 
@@ -358,6 +360,6 @@
     // Les axes
     
-    g->DrawLine(xMin, 0, xMax, 0);
-    g->DrawLine(0, yMin, 0, yMax);
+    g->DrawLine(xMin, (yMin+yMax)/2., xMax, (yMin+yMax)/2.);
+    g->DrawLine((xMin+xMax)/2., yMin, (xMin+xMax)/2., yMax);
 
     // La grille en pointilles
@@ -368,6 +370,6 @@
   
     if (flags & kMajTicks) {
-        DrawHTicks(g, 0, xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep);
-        DrawVTicks(g, 0, yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep);
+        DrawHTicks(g, (yMin+yMax)/2., xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawVTicks(g, (xMin+xMax)/2., yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep);
     }
     
@@ -375,6 +377,6 @@
   
     if (flags & kMinTicks) {
-        DrawHTicks(g, 0, xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep);
-        DrawVTicks(g, 0, yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep);
+        DrawHTicks(g, (yMin+yMax)/2., xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawVTicks(g, (xMin+xMax)/2., yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep);
     }
     
@@ -383,11 +385,11 @@
     if (flags & kLabels) {
       if (!aYdir)
-        DrawHLabels(g, -xMajTickLen*6, xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(g, (yMin+yMax)/2.-xMajTickLen*2, xFirstMajTick, xMajTickStep,PI_VerticalTop);
       else 
-        DrawHLabels(g, xMajTickLen*6, xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(g, (yMin+yMax)/2.+xMajTickLen*2, xFirstMajTick, xMajTickStep,PI_VerticalTop);
       if (!aXdir)
-        DrawVLabels(g, -yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+        DrawVLabels(g, (xMin+xMax)/2.-yMajTickLen*2, yFirstMajTick, yMajTickStep,PI_HorizontalRight);
       else 
-        DrawVLabels(g, yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+        DrawVLabels(g, (xMin+xMax)/2.+yMajTickLen*2, yFirstMajTick, yMajTickStep,PI_HorizontalRight);
     }
     
@@ -441,18 +443,18 @@
     if (flags & kLabels) {
       if (!aYdir) {
-        DrawHLabels(g, g->DeltaUCY(yMin, -xMajTickLen*6), xFirstMajTick, xMajTickStep,0);
-        //DrawHLabels(g, g->DeltaUCY(yMax,  xMajTickLen*2), xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(g, g->DeltaUCY(yMin, -xMajTickLen*2), xFirstMajTick, xMajTickStep,PI_VerticalTop);
+        //DrawHLabels(g, g->DeltaUCY(yMax,  xMajTickLen*2), xFirstMajTick, xMajTickStep,PI_VerticalBottom);
       }
       else {
-        //DrawHLabels(g, g->DeltaUCY(yMin, -xMajTickLen*2), xFirstMajTick, xMajTickStep,0);
-        DrawHLabels(g, g->DeltaUCY(yMax,  xMajTickLen*6), xFirstMajTick, xMajTickStep,0);
+        //DrawHLabels(g, g->DeltaUCY(yMin, -xMajTickLen*2), xFirstMajTick, xMajTickStep,PI_VerticalBottom);
+        DrawHLabels(g, g->DeltaUCY(yMax,  xMajTickLen*2), xFirstMajTick, xMajTickStep,PI_VerticalTop);
       }
       if (!aXdir) {
-        DrawVLabels(g, g->DeltaUCX(xMin, -yMajTickLen*2), yFirstMajTick, yMajTickStep,1);
-        //DrawVLabels(g, g->DeltaUCX(xMax,  yMajTickLen*2), yFirstMajTick, yMajTickStep,-1);
+        DrawVLabels(g, g->DeltaUCX(xMin, -yMajTickLen*2), yFirstMajTick, yMajTickStep,PI_HorizontalRight);
+        //DrawVLabels(g, g->DeltaUCX(xMax,  yMajTickLen*2), yFirstMajTick, yMajTickStep,PI_HorizontalLeft);
       }
       else {
-        //DrawVLabels(g, g->DeltaUCX(xMin, -yMajTickLen*2), yFirstMajTick, yMajTickStep,-1);
-        DrawVLabels(g, g->DeltaUCX(xMax,  yMajTickLen*2), yFirstMajTick, yMajTickStep,1);
+        //DrawVLabels(g, g->DeltaUCX(xMin, -yMajTickLen*2), yFirstMajTick, yMajTickStep,PI_HorizontalLeft);
+        DrawVLabels(g, g->DeltaUCX(xMax,  yMajTickLen*2), yFirstMajTick, yMajTickStep,PI_HorizontalRight);
       }
     }
@@ -493,5 +495,5 @@
 
 void
-PIDrawer::DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, int just)
+PIDrawer::DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, unsigned long just)
 {
   double fsz = xMajTickLen*4.;
@@ -499,14 +501,8 @@
 
   // Choix du bon format pour les labels des axes;
-  char label[64]; string format; double fac = 1.;
+  char label[64]; string format; double fac=1.; bool p10=false;
   int npuiss = BonFormatAxes(xBeg,xMax,xStep,format,2,1);
-
-  if(npuiss!=0) {
-    fac = pow(10.,(double)npuiss);
-    sprintf(label,"10^%d",npuiss);
-    double xm = (aXdir)? xMin: xMax;
-    double ym = (aYdir)? yMax+1.5*fsz: yMin-1.5*fsz;
-    g->DrawString(xm,ym,label,PI_HorizontalCenter|PI_VerticalTop);
-  }
+  if(npuiss<-2 || npuiss>3) {p10 = true; fac=pow(10.,(double)npuiss);}
+  else BonFormatAxes(xBeg,xMax,xStep,format,0,1);
 
   double xOffset = 0;
@@ -518,15 +514,25 @@
     for(int kk=0;kk<64;kk++) if(label[kk]==' ') {label[kk]='\0'; break;}
     double largeur = g->CalcStringWidth(label);
-    if(just==1) xOffset=-largeur; else if(just==0) xOffset=-largeur/2;
-    if(aXdir) xOffset = -xOffset;
+    if(aXdir) xOffset = largeur/2; else xOffset=-largeur/2;
     if(x+xOffset > xlastlabelfin) {
-      g->DrawString(g->DeltaUCX(x,xOffset),y,label);
+      g->DrawString(x,y,label,PI_HorizontalCenter|just);
       xlastlabelfin = x + xOffset + 1.1*largeur;
     }
   }
-}
-
-void
-PIDrawer::DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, int just)
+
+  if(p10) {
+    PIGrCoord asc,desc;
+    double h = g->GetFontHeight(asc,desc);
+    if((aYdir && (just&PI_VerticalBottom)) || (!aYdir && (just&PI_VerticalTop)) ) h = -h; 
+    double xm = (aXdir)? xMin: xMax;
+    double ym = g->DeltaUCY(y,1.5*h);
+    sprintf(label,"%d",npuiss);
+    g->DrawCompString(xm,ym,"x 10",label,NULL,PI_HorizontalCenter|just);
+  }
+
+}
+
+void
+PIDrawer::DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, unsigned long just)
 {
   double fsz = xMajTickLen*4.;
@@ -534,25 +540,25 @@
 
   // Choix du bon format pour les labels des axes;
-  char label[64]; string format; double fac = 1.;
+  char label[64]; string format; double fac=1.; bool p10=false;
   int npuiss = BonFormatAxes(yBeg,yMax,yStep,format,2,1);
-
-  if(npuiss!=0) {
-    fac = pow(10.,(double)npuiss);
-    sprintf(label,"10^%d",npuiss);
-    double xm = (aXdir)? xMax: xMin;
-    double ym = (aYdir)? yMin-1.5*fsz: yMax+1.5*fsz;
-    g->DrawString(xm,ym,label,PI_HorizontalRight|PI_VerticalBottom);
+  if(npuiss<-2 || npuiss>3) {p10 = true; fac=pow(10.,(double)npuiss);}
+  else BonFormatAxes(yBeg,yMax,yStep,format,0,1);
+
+  for(double y=yBeg; y<=yMax; y += yStep) {
+    double yy = (fabs(y/yStep)<1.e-5) ? 0.: y;
+    sprintf(label,format.c_str(),yy/fac);
+    for(int kk=0;kk<64;kk++) if(label[kk]==' ') {label[kk]='\0'; break;}
+    g->DrawString(x,y,label,PI_VerticalCenter|just);
   }
 
-  double xOffset = 0;
-  for (double y=yBeg; y<=yMax; y += yStep) {
-      double yy = (fabs(y/yStep)<1.e-5) ? 0.: y;
-      sprintf(label,format.c_str(),yy/fac);
-      for(int kk=0;kk<64;kk++) if(label[kk]==' ') {label[kk]='\0'; break;}
-      double largeur = g->CalcStringWidth(label);
-      if (just==1) xOffset=-largeur; else if(just==0) xOffset=-largeur/2;
-      if (aXdir)  xOffset = -xOffset;
-      g->DrawString(g->DeltaUCX(x, xOffset), y, label);
+  if(p10) {
+    PIGrCoord asc,desc;
+    double h = g->GetFontHeight(asc,desc);
+    if(aYdir) h = -h; 
+    double ym = (aYdir)? yMin: yMax; ym = g->DeltaUCY(ym,h);
+    sprintf(label,"%d",npuiss);
+    g->DrawCompString(x,ym,"x 10",label,NULL,PI_VerticalBottom|just);
   }
+
 }
 
@@ -665,5 +671,5 @@
    // Ex: 1.2345e+2 -> 123.45   /  -1.2345e+2 -> -123.45
    //     1.2345e-1 -> 0.12345  /  -1.2345e-1 -> -0.12345
-   if(axmin>=1e-4 && axmax<1e4) ftype='f';
+   if((axmin>=1e-4 || axmin==0.) && axmax<1e4) ftype='f';
  }
 
Index: trunk/SophyaPI/PI/pidrawer.h
===================================================================
--- trunk/SophyaPI/PI/pidrawer.h	(revision 1945)
+++ trunk/SophyaPI/PI/pidrawer.h	(revision 1946)
@@ -122,6 +122,6 @@
   void DrawHTicks(PIGraphicUC* g, double y, double tickUp, double tickDown, double xBeg, double xStep);
   void DrawVTicks(PIGraphicUC* g, double x, double tickLeft, double tickRight, double yBeg, double yStep);
-  void DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, int just=0);
-  void DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, int just=0);
+  void DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, unsigned long just=0);
+  void DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, unsigned long just=0);
   void DrawGrid(PIGraphicUC* g);
 
Index: trunk/SophyaPI/PI/pigraphuc.cc
===================================================================
--- trunk/SophyaPI/PI/pigraphuc.cc	(revision 1945)
+++ trunk/SophyaPI/PI/pigraphuc.cc	(revision 1946)
@@ -12,4 +12,11 @@
 #include <ieeefp.h>
 #endif
+
+//define PETIT_DBLE 1.e-39
+//define PREC_DBLE  1.e-5
+//define PROT_DBLE  1.e-19
+#define PETIT_DBLE 1.e-100
+#define PREC_DBLE  1.e-16
+#define PROT_DBLE  1.e-40
 
 //++
@@ -169,11 +176,9 @@
   }
 
-  // $ CMV A FAIRE: metrte des define pour les 1.e-39 1.e-19 1.e-5
-  //                ET ADAPTER POUR DES DOUBLES !!!!! ==> 1.e-100 etc..
   double xym;
-  xym = fabs(xmax+xmin); xym = (xym > 1.e-39) ? xym : 1.e-39;
-  if ((xmax-xmin)/xym < 1.e-5) { xmin = xmin - 5.e-6*xym;  xmax = xmin + 1.e-5*xym; }
-  xym = fabs(ymax+ymin); xym = (xym > 1.e-39) ? xym : 1.e-39;
-  if ((ymax-ymin)/xym < 1.e-5) { ymin = ymin - 5.e-6*xym;  ymax = ymin + 1.e-5*xym; }
+  xym = fabs(xmax+xmin); xym = (xym > PETIT_DBLE) ? xym : PETIT_DBLE;
+  if ((xmax-xmin)/xym < PREC_DBLE) {xmin=xmin-PREC_DBLE/2.*xym; xmax=xmin+PREC_DBLE*xym;}
+  xym = fabs(ymax+ymin); xym = (xym > PETIT_DBLE) ? xym : PETIT_DBLE;
+  if ((ymax-ymin)/xym < PREC_DBLE) {ymin=ymin-PREC_DBLE/2.*xym; ymax=ymin+PREC_DBLE*xym;}
 //  if (xmax <= xmin  || ymax <= ymin) {
 //    cerr << "PIGraphicUC::SetUCS() Error - xmax <= xmin  || ymax <= ymin ! " << endl;
@@ -196,5 +201,5 @@
 
   xScale = xWd/(xMax-xMin);
-  if (xScale < 1.e-19)  xScale = 1.e-19;  // Protection 
+  if (xScale < PROT_DBLE)  xScale = PROT_DBLE;  // Protection 
   if (aXdir)  { 
     xScale = -xScale;
@@ -205,5 +210,5 @@
 
   yScale = yWd/(yMax-yMin);
-  if (yScale < 1.e-19)  yScale = 1.e-19;  // Protection 
+  if (yScale < PROT_DBLE)  yScale = PROT_DBLE;  // Protection 
   if (!aYdir) {
     yScale = -yScale;
@@ -220,13 +225,13 @@
 {
 if (logx) 
-  if (xMax < 1.e-39) {
-    cerr << "PIGraphicUC::SetLogScale() Warning - XLogScale not valid for XMax ="
-         << xMax << " < 1.e-39" << endl;
+  if (xMax < PETIT_DBLE) {
+    cerr<< "PIGraphicUC::SetLogScale() Warning - XLogScale not valid for XMax ="
+        << xMax<<" < "<<PETIT_DBLE<<endl;
     logx = false;
   }
 if (logy)
-  if (yMax < 1.e-39) {
-    cerr << "PIGraphicUC::SetLogScale() Warning - YLogScale not valid for YMax ="
-         << yMax << " < 1.e-39" << endl;
+  if (yMax < PETIT_DBLE) {
+    cerr<<"PIGraphicUC::SetLogScale() Warning - YLogScale not valid for YMax ="
+        <<yMax<<" < "<<PETIT_DBLE<<endl;
     logy = false;
   }
@@ -236,7 +241,7 @@
 
 if (aXlog) {     
-  xMinLog = (xMin > 1.e-39) ? xMin : ( (1. < xMax/10.) ? 1. : xMax/10.);
+  xMinLog = (xMin > PETIT_DBLE) ? xMin : ( (1. < xMax/10.) ? 1. : xMax/10.);
   xScaleLog = xWd*(xMax-xMinLog)/(xMax-xMin) / (log10(xMax)-log10(xMinLog));
-  if (xScaleLog < 1.e-19)  xScaleLog = 1.e-19;  // Protection 
+  if (xScaleLog < PROT_DBLE)  xScaleLog = PROT_DBLE;  // Protection 
   if (aXdir)  { 
     xScaleLog = -xScaleLog;
@@ -253,7 +258,7 @@
 }
 if (aYlog) {     
-  yMinLog = (yMin > 1.e-39) ? yMin : ( (1. < yMax/10.) ? 1. : yMax/10.);
+  yMinLog = (yMin > PETIT_DBLE) ? yMin : ( (1. < yMax/10.) ? 1. : yMax/10.);
   yScaleLog = yWd*(yMax-yMinLog)/(yMax-yMin) / (log10(yMax)-log10(yMinLog));
-  if (yScaleLog < 1.e-19)  yScaleLog = 1.e-19;  // Protection 
+  if (yScaleLog < PROT_DBLE)  yScaleLog = PROT_DBLE;  // Protection 
   if (!aYdir) {
     yScaleLog = -yScaleLog;
Index: trunk/SophyaPI/PI/piscdrawwdg.cc
===================================================================
--- trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 1945)
+++ trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 1946)
@@ -10,4 +10,9 @@
 #include "pidrwtools.h"
 #include "piaxestools.h"
+
+//define PETIT_DBLE 1.e-39
+//define PREC_DBLE  1.e-5
+#define PETIT_DBLE 1.e-100
+#define PREC_DBLE  1.e-16
 
 
@@ -166,8 +171,8 @@
 //    }
   double xym;
-  xym = fabs(xmax+xmin); xym = (xym > 1.e-39) ? xym : 1.e-39;
-  if ((xmax-xmin)/xym < 1.e-5) { xmin = xmin - 5.e-6*xym;  xmax = xmin + 1.e-5*xym; }
-  xym = fabs(ymax+ymin); xym = (xym > 1.e-39) ? xym : 1.e-39;
-  if ((ymax-ymin)/xym < 1.e-5) { ymin = ymin - 5.e-6*xym;  ymax = ymin + 1.e-5*xym; }
+  xym = fabs(xmax+xmin); xym = (xym > PETIT_DBLE) ? xym : PETIT_DBLE;
+  if ((xmax-xmin)/xym < PREC_DBLE) { xmin = xmin - PREC_DBLE/2.*xym;  xmax = xmin + PREC_DBLE*xym; }
+  xym = fabs(ymax+ymin); xym = (xym > PETIT_DBLE) ? xym : PETIT_DBLE;
+  if ((ymax-ymin)/xym < PREC_DBLE) { ymin = ymin - PREC_DBLE/2.*xym;  ymax = ymin + PREC_DBLE*xym; }
 
   SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);
