Index: /trunk/SophyaPI/PI/Makefile
===================================================================
--- /trunk/SophyaPI/PI/Makefile	(revision 2002)
+++ /trunk/SophyaPI/PI/Makefile	(revision 2003)
@@ -89,11 +89,12 @@
  piwdggen.h pimsghandler.h picolist.h
 $(OBJ)pidrawer.o: pidrawer.cc $(INC)machdefs.h \
- pidrawer.h pibwdggen.h pisysdep.h piwdgx.h piwdggen.h pimsghandler.h \
- picolist.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
- pifontx.h pifontgen.h pigraphuc.h pievthandler.h psfile.h pigratt.h \
- pidrwtools.h pistdwdgx.h pistdwdggen.h pioptmenux.h pioptmenugen.h \
- pimenux.h pimenugen.h piwindowx.h piwindowgen.h picontainerx.h \
- picontainergen.h piapplx.h piapplgen.h pimenubarx.h pimenubargen.h \
- picons.h pibwdgx.h pigraphps.h
+ $(INC)utilgeom.h pidrawer.h pibwdggen.h \
+ pisysdep.h piwdgx.h piwdggen.h pimsghandler.h picolist.h picmap.h \
+ picmapx.h picmapgen.h pigraphx.h pigraphgen.h pifontx.h pifontgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigratt.h pidrwtools.h \
+ pistdwdgx.h pistdwdggen.h pioptmenux.h pioptmenugen.h pimenux.h \
+ pimenugen.h piwindowx.h piwindowgen.h picontainerx.h picontainergen.h \
+ piapplx.h piapplgen.h pimenubarx.h pimenubargen.h picons.h pibwdgx.h \
+ pigraphps.h ucckprot.h
 $(OBJ)pidrawwin.o: pidrawwin.cc pidrawwin.h pisysdep.h \
  $(INC)machdefs.h piwindowx.h piwindowgen.h \
@@ -154,5 +155,5 @@
  pigraphuc.h pisysdep.h pigraphgen.h piwdgx.h piwdggen.h \
  pimsghandler.h picolist.h picmap.h picmapx.h picmapgen.h pifontx.h \
- pifontgen.h
+ pifontgen.h ucckprot.h
 $(OBJ)pigraphx.o: pigraphx.cc pigraphx.h pisysdep.h \
  $(INC)machdefs.h pigraphgen.h piwdgx.h \
Index: /trunk/SophyaPI/PI/pidrawer.cc
===================================================================
--- /trunk/SophyaPI/PI/pidrawer.cc	(revision 2002)
+++ /trunk/SophyaPI/PI/pidrawer.cc	(revision 2003)
@@ -12,9 +12,5 @@
 #include "pidrwtools.h"
 
-#include <math.h>
-//  Pour la declaration de finite() isnan() ...
-#if defined(SunOS)
-#include <ieeefp.h>
-#endif
+#include "ucckprot.h"
 
 //++
@@ -128,14 +124,20 @@
 //    return; 
 //    }
-#if defined(OSF1) || defined(SunOS) || (defined(Linux) && !defined(__KCC__) )
-  if (!finite(xmin) || !finite(xmax) || !finite(ymin) || !finite(ymax)) {
+  
+  if (!UC_CheckFinite(xmin, xmax) || !UC_CheckFinite(ymin, ymax)) {
     cerr << "PIDrawer::SetLimits() Error - Non finite value for x/ymin-max ! " << endl;
     return; 
     }
-#endif
+
   if (axrl == kAxeDirLtoR)  aXdir = false;
   else if (axrl == kAxeDirRtoL)  aXdir = true;
   if (ayud == kAxeDirDownUp)  aYdir = false;
   else if (ayud == kAxeDirUpDown)  aYdir = true;
+  //  cerr << " DBG-SetLimits xmax-xmin= " << xmax-xmin << " xmin,max=" 
+  //     << xmin << "," << xmax << endl;
+  UC_CheckMinMaxDiff(xmin, xmax);
+  //cerr << " DBG-SetLimits ymax-ymin= " << ymax-ymin << " ymin,max=" 
+  //     << ymin << "," << ymax << endl;
+  UC_CheckMinMaxDiff(ymin, ymax);
   xMin = xmin;
   xMax = xmax;
@@ -545,5 +547,5 @@
 PIDrawer::DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, unsigned long just)
 {
-  double fsz = xMajTickLen*4.;
+  double fsz = xMajTickLen*3.5;
   if(axesAFSz) g->SelFontSz(fsz);
 
@@ -584,5 +586,5 @@
 PIDrawer::DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, unsigned long just)
 {
-  double fsz = xMajTickLen*4.;
+  double fsz = xMajTickLen*3.5;
   if(axesAFSz) g->SelFontSz(fsz);
 
Index: /trunk/SophyaPI/PI/pigraphuc.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphuc.cc	(revision 2002)
+++ /trunk/SophyaPI/PI/pigraphuc.cc	(revision 2003)
@@ -7,18 +7,6 @@
 #include "pigraphuc.h"
 
-#include <math.h>
-//  Pour la declaration de finite() isnan() ...
-#if defined(SunOS)
-#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
-// qque probleme sur le trace - J'augmente les marges - Reza 14/5/2002 
-// #define PREC_DBLE  1.e-16  
-#define PREC_DBLE  1.e-14
-#define PROT_DBLE  1.e-40
+#include "ucckprot.h"
+
 
 //++
@@ -178,33 +166,21 @@
   }
 
-  double xym;
-  //DBG-REZA  cerr << " DBG-SetUCS() xmax-xmin = " << xmax-xmin << " xmin,max=" << xmin << "," << xmax << endl;
-  if ((xmax-xmin) < PREC_DBLE*fabs(xmax+xmin)) { 
-    xym = fabs(xmax);  xym = (xym > PETIT_DBLE) ? xym : PETIT_DBLE;
-    xmax += PREC_DBLE/2.*xym;
-    xmin -= PREC_DBLE/2.*xym;
-    //DBG-REZA  cerr << " PIGraphicUC::SetUCS() xmin,max=" << xmin << "," << xmax << " xym=" << xym << endl;
-  }
-  //DBG-REZAcerr << " DBG-SetUCS() ymax-ymin = " << ymax-ymin << " ymin,max=" << ymin << "," << ymax << endl;
-  if ((ymax-ymin) < PREC_DBLE*fabs(ymax+ymin)) { 
-    xym = fabs(ymax);  xym = (xym > PETIT_DBLE) ? xym : PETIT_DBLE;
-    ymax += PREC_DBLE/2.*xym;
-    ymin -= PREC_DBLE/2.*xym;
-    //DBG-REZAcerr << " PIGraphicUC::SetUCS() ymin,max=" << ymin << "," << ymax << " xym=" << xym << endl;
-  }
-  //    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;}
+  UC_CheckMinMaxDiff(xmin, xmax);
+  UC_CheckMinMaxDiff(ymin, ymax);
+
+  //  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;
 //    return; 
 //    }
-#if defined(OSF1) || defined(SunOS) || (defined(Linux) && !defined(__KCC__) )
-  if (!finite(xmin) || !finite(xmax) || !finite(ymin) || !finite(ymax)) {
+
+  if (!UC_CheckFinite(xmin, xmax) || !UC_CheckFinite(ymin, ymax)) {
     cerr << "PIGraphicUC::SetUCS() Error - Non finite value for x/ymin-max ! " << endl;
     return; 
     }
-#endif
+
   if (axrl == kAxeDirLtoR)  aXdir = false;
   else if (axrl == kAxeDirRtoL)  aXdir = true;
@@ -216,6 +192,5 @@
   yMax = ymax;
 
-  xScale = xWd/(xMax-xMin);
-  if (xScale < PROT_DBLE)  xScale = PROT_DBLE;  // Protection 
+  xScale = UC_LimitProtectDouble(xWd/(xMax-xMin)); // Protection 
   if (aXdir)  { 
     xScale = -xScale;
@@ -225,6 +200,5 @@
   xOrg += xW0;
 
-  yScale = yWd/(yMax-yMin);
-  if (yScale < PROT_DBLE)  yScale = PROT_DBLE;  // Protection 
+  yScale = UC_LimitProtectDouble(yWd/(yMax-yMin)); // Protection  
   if (!aYdir) {
     yScale = -yScale;
@@ -259,5 +233,5 @@
   xMinLog = (xMin > PETIT_DBLE) ? xMin : ( (1. < xMax/10.) ? 1. : xMax/10.);
   xScaleLog = xWd*(xMax-xMinLog)/(xMax-xMin) / (log10(xMax)-log10(xMinLog));
-  if (xScaleLog < PROT_DBLE)  xScaleLog = PROT_DBLE;  // Protection 
+  xScaleLog = UC_LimitProtectDouble(xScaleLog); // Protection 
   if (aXdir)  { 
     xScaleLog = -xScaleLog;
@@ -276,5 +250,5 @@
   yMinLog = (yMin > PETIT_DBLE) ? yMin : ( (1. < yMax/10.) ? 1. : yMax/10.);
   yScaleLog = yWd*(yMax-yMinLog)/(yMax-yMin) / (log10(yMax)-log10(yMinLog));
-  if (yScaleLog < PROT_DBLE)  yScaleLog = PROT_DBLE;  // Protection 
+  yScaleLog = UC_LimitProtectDouble(yScaleLog); // Protection 
   if (!aYdir) {
     yScaleLog = -yScaleLog;
Index: /trunk/SophyaPI/PI/piscdrawwdg.cc
===================================================================
--- /trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 2002)
+++ /trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 2003)
@@ -91,9 +91,8 @@
   mBDrw->SetName("AxesDrw");
   SetLimits(-1.,1.,-1.,1.,kAxeDirLtoR,kAxeDirDownUp);
+  // SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true); fait par SetAxesFlags() - Reza Mai 2002
   SetAxesFlags(kBoxAxes | kExtTicks | kLabels);  
   FreeLimits();
   xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
-  SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true);
-//  SetDefaultDrawRectangle(0.12, 0.08, 0.88, 0.92, true);
   AddDrawer(mBDrw, true, false, false);
 
@@ -205,9 +204,22 @@
 }
 
+void
+PIScDrawWdg::SetAxesFlags(unsigned int flags)
+{
+  mBDrw->SetAxesFlags(flags);
+  if ((flags & kBoxAxes) == kBoxAxes) 
+    SetDefaultDrawRectangle(0.13, 0.09, 0.93, 0.89, true);
+  else 
+    SetDefaultDrawRectangle(0.06, 0.06, 0.94, 0.94, true);
+}
+
 int 
 PIScDrawWdg::DecodeOptionString(vector<string> & opt, bool rmdecopt)
 {
   if (opt.size() == 0)  return(0);  
+  unsigned int aflg = BaseDrawer()->GetAxesFlags();
   int ndec1 = BaseDrawer()->DecodeOptionString(opt, rmdecopt);
+  if (aflg != BaseDrawer()->GetAxesFlags())
+    SetAxesFlags(BaseDrawer()->GetAxesFlags());
   vector<string> udopt;
   unsigned int k = 0;
Index: /trunk/SophyaPI/PI/piscdrawwdg.h
===================================================================
--- /trunk/SophyaPI/PI/piscdrawwdg.h	(revision 2002)
+++ /trunk/SophyaPI/PI/piscdrawwdg.h	(revision 2003)
@@ -36,6 +36,6 @@
   virtual void	     UpdateLimits();  // Calcule et change les limites a partir de Drawer-No-1 
 
-  inline void        SetAxesFlags(unsigned int flags=kBoxAxes | kExtTicks | kLabels) 
-                                  { mBDrw->SetAxesFlags(flags); }
+  virtual void       SetAxesFlags(unsigned int flags=kBoxAxes | kExtTicks | kLabels);
+
   inline void	     SetTitles(const char* tt=NULL, const char* tb=NULL)
                             { mBDrw->SetTitles(tt, tb); }
Index: /trunk/SophyaPI/PI/ucckprot.h
===================================================================
--- /trunk/SophyaPI/PI/ucckprot.h	(revision 2003)
+++ /trunk/SophyaPI/PI/ucckprot.h	(revision 2003)
@@ -0,0 +1,67 @@
+// Module PI : Peida Interactive   - ucckprot.h
+// Protection transfo coordonnees UserCoord<>GraphicCoord 
+//                    C. Magneville, R. Ansari  2002
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef UCCKPROT_H_SEEN
+#define UCCKPROT_H_SEEN
+
+#include <math.h>
+//  Pour la declaration de finite() isnan() ...
+#if defined(SunOS)
+#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-85
+// qque probleme sur le trace - J'augmente les marges - Reza 14/5/2002 
+// #define PREC_DBLE  1.e-16  
+#define PREC_DBLE  1.e-14
+#define MINRAP_DBLE  1.e-12
+#define PROT_DBLE_MIN  1.e-100
+#define PROT_DBLE_MAX  1.e+100
+
+inline double UC_LimitProtectDouble(double x)
+{ 
+  if (x < 0.) {
+    if (x < -PROT_DBLE_MAX) return (-PROT_DBLE_MAX);
+    if (x > -PROT_DBLE_MIN) return (-PROT_DBLE_MIN);
+    return(x);
+  }
+  else {
+    if (x > PROT_DBLE_MAX) return (PROT_DBLE_MAX);
+    if (x < PROT_DBLE_MIN) return (PROT_DBLE_MIN);
+    return(x);
+  }
+}
+
+inline bool UC_CheckMinMaxDiff(double& xmin, double& xmax) 
+{
+  bool rc = false;
+  double xym,xym2;
+  xym = fabs(xmax);
+  xym2 = fabs(xmin);
+  if (xym2 > xym) xym = xym2;
+  if (xym < PETIT_DBLE) xym = PETIT_DBLE;
+  if ((xmax-xmin) < MINRAP_DBLE*xym) {
+    xmin -= MINRAP_DBLE*xym*0.5;  xmax = xmin+MINRAP_DBLE*xym;
+    //    cerr << " DBG-CheckMinMaxDiff: xmin,max=" << xmin << "," << xmax 
+    //	 << " xym=" << xym << " diff=" << xmax-xmin << endl;
+    rc = true;
+  }
+  return(rc);
+}
+
+inline bool UC_CheckFinite(double xmin, double xmax)
+{
+#if defined(OSF1) || defined(SunOS) || (defined(Linux) && !defined(__KCC__) )
+  if (finite(xmin) && finite(xmax)) return(true);
+  else return(false);
+#else
+  return(false);
+#endif
+}
+
+#endif
