public void SetWorldLimitsFromPhysical(Point min, Point max)
{
double minc;
double maxc;
if (Axis != null)
{
minc = Axis.WorldMin;
maxc = Axis.WorldMax;
double tmp = PhysicalToWorld(min, true);
Axis.WorldMax = PhysicalToWorld(max, true);
Axis.WorldMin = tmp;
// need to trap somehow if the user selects an
// arbitrarily small range. Otherwise the GDI+
// drawing routines lead to an overflow in painting
// the picture. This may be not the optimal solution,
// but if the GDI+ draw leads to an overflow the
// graphic surface becomes unusable anymore and I
// had difficulty to trap the error.
double half = (Axis.WorldMin + Axis.WorldMax) / 2;
double width = Axis.WorldMax - Axis.WorldMin;
if (Math.Abs(half / width) > 1.0e12)
{
Axis.WorldMin = minc;
Axis.WorldMax = maxc;
}
}
}