Index: trunk/BNC/qwt/qwt_scale_map.cpp
===================================================================
--- trunk/BNC/qwt/qwt_scale_map.cpp	(revision 4271)
+++ trunk/BNC/qwt/qwt_scale_map.cpp	(revision 8127)
@@ -9,89 +9,7 @@
 
 #include "qwt_scale_map.h"
+#include "qwt_math.h"
 #include <qrect.h>
-#include <qalgorithms.h>
-#include <qmath.h>
 #include <qdebug.h>
-
-#if QT_VERSION < 0x040601
-#define qExp(x) ::exp(x)
-#endif
-
-//! Smallest allowed value for logarithmic scales: 1.0e-150
-QT_STATIC_CONST_IMPL double QwtScaleMap::LogMin = 1.0e-150;
-
-//! Largest allowed value for logarithmic scales: 1.0e150
-QT_STATIC_CONST_IMPL double QwtScaleMap::LogMax = 1.0e150;
-
-//! Constructor for a linear transformation
-QwtScaleTransformation::QwtScaleTransformation( Type type ):
-    d_type( type )
-{
-}
-
-//! Destructor
-QwtScaleTransformation::~QwtScaleTransformation()
-{
-}
-
-//! Create a clone of the transformation
-QwtScaleTransformation *QwtScaleTransformation::copy() const
-{
-    return new QwtScaleTransformation( d_type );
-}
-
-/*!
-  \brief Transform a value from the coordinate system of a scale
-         into the coordinate system of the paint device
-
-  \param s  Value related to the coordinate system of the scale
-  \param s1 First border of the coordinate system of the scale
-  \param s2 Second border of the coordinate system of the scale
-  \param p1 First border of the coordinate system of the paint device
-  \param p2 Second border of the coordinate system of the paint device
-  \return
-  <dl>
-  <dt>linear mapping:<dd>p1 + (p2 - p1) / (s2 - s1) * (s - s1);</dd>
-  </dl>
-  <dl>
-  <dt>log10 mapping: <dd>p1 + (p2 - p1) / log(s2 / s1) * log(s / s1);</dd>
-  </dl>
-*/
-
-double QwtScaleTransformation::xForm(
-    double s, double s1, double s2, double p1, double p2 ) const
-{
-    if ( d_type == Log10 )
-        return p1 + ( p2 - p1 ) / log( s2 / s1 ) * log( s / s1 );
-    else
-        return p1 + ( p2 - p1 ) / ( s2 - s1 ) * ( s - s1 );
-}
-
-/*!
-  \brief Transform a value from the coordinate system of the paint device
-         into the coordinate system of a scale.
-
-  \param p Value related to the coordinate system of the paint device 
-  \param p1 First border of the coordinate system of the paint device
-  \param p2 Second border of the coordinate system of the paint device
-  \param s1 First border of the coordinate system of the scale
-  \param s2 Second border of the coordinate system of the scale
-  \return
-  <dl>
-  <dt>linear mapping:<dd>s1 + ( s2 - s1 ) / ( p2 - p1 ) * ( p - p1 );</dd>
-  </dl>
-  <dl>
-  <dt>log10 mapping:<dd>exp((p - p1) / (p2 - p1) * log(s2 / s1)) * s1;</dd>
-  </dl>
-*/
-
-double QwtScaleTransformation::invXForm( double p, double p1, double p2,
-    double s1, double s2 ) const
-{
-    if ( d_type == Log10 )
-        return qExp( ( p - p1 ) / ( p2 - p1 ) * log( s2 / s1 ) ) * s1;
-    else
-        return s1 + ( s2 - s1 ) / ( p2 - p1 ) * ( p - p1 );
-}
 
 /*!
@@ -105,8 +23,8 @@
     d_p1( 0.0 ),
     d_p2( 1.0 ),
-    d_cnv( 1.0 )
-{
-    d_transformation = new QwtScaleTransformation(
-        QwtScaleTransformation::Linear );
+    d_cnv( 1.0 ),
+    d_ts1( 0.0 ),
+    d_transform( NULL )
+{
 }
 
@@ -117,7 +35,10 @@
     d_p1( other.d_p1 ),
     d_p2( other.d_p2 ),
-    d_cnv( other.d_cnv )
-{
-    d_transformation = other.d_transformation->copy();
+    d_cnv( other.d_cnv ),
+    d_ts1( other.d_ts1 ),
+    d_transform( NULL )
+{
+    if ( other.d_transform )
+        d_transform = other.d_transform->copy();
 }
 
@@ -127,5 +48,5 @@
 QwtScaleMap::~QwtScaleMap()
 {
-    delete d_transformation;
+    delete d_transform;
 }
 
@@ -138,7 +59,11 @@
     d_p2 = other.d_p2;
     d_cnv = other.d_cnv;
-
-    delete d_transformation;
-    d_transformation = other.d_transformation->copy();
+    d_ts1 = other.d_ts1;
+
+    delete d_transform;
+    d_transform = NULL;
+
+    if ( other.d_transform )
+        d_transform = other.d_transform->copy();
 
     return *this;
@@ -148,14 +73,10 @@
    Initialize the map with a transformation
 */
-void QwtScaleMap::setTransformation(
-    QwtScaleTransformation *transformation )
-{
-    if ( transformation == NULL )
-        return;
-
-    if ( transformation != d_transformation )
+void QwtScaleMap::setTransformation( QwtTransform *transform )
+{
+    if ( transform != d_transform )
     {
-        delete d_transformation;
-        d_transformation = transformation;
+        delete d_transform;
+        d_transform = transform;
     }
 
@@ -164,7 +85,7 @@
 
 //! Get the transformation
-const QwtScaleTransformation *QwtScaleMap::transformation() const
-{
-    return d_transformation;
+const QwtTransform *QwtScaleMap::transformation() const
+{
+    return d_transform;
 }
 
@@ -173,26 +94,19 @@
   \param s1 first border
   \param s2 second border
-  \warning logarithmic scales might be aligned to [LogMin, LogMax]
+  \warning scales might be aligned to 
+           transformation depending boundaries
 */
 void QwtScaleMap::setScaleInterval( double s1, double s2 )
 {
-    if ( d_transformation->type() == QwtScaleTransformation::Log10 )
-    {
-        if ( s1 < LogMin )
-            s1 = LogMin;
-        else if ( s1 > LogMax )
-            s1 = LogMax;
-
-        if ( s2 < LogMin )
-            s2 = LogMin;
-        else if ( s2 > LogMax )
-            s2 = LogMax;
-    }
-
     d_s1 = s1;
     d_s2 = s2;
 
-    if ( d_transformation->type() != QwtScaleTransformation::Other )
-        newFactor();
+    if ( d_transform )
+    {
+        d_s1 = d_transform->bounded( d_s1 );
+        d_s2 = d_transform->bounded( d_s2 );
+    }
+
+    updateFactor();
 }
 
@@ -207,31 +121,21 @@
     d_p2 = p2;
 
-    if ( d_transformation->type() != QwtScaleTransformation::Other )
-        newFactor();
-}
-
-/*!
-  \brief Re-calculate the conversion factor.
-*/
-void QwtScaleMap::newFactor()
-{
-    d_cnv = 0.0;
-
-    switch ( d_transformation->type() )
+    updateFactor();
+}
+
+void QwtScaleMap::updateFactor()
+{
+    d_ts1 = d_s1;
+    double ts2 = d_s2;
+
+    if ( d_transform )
     {
-        case QwtScaleTransformation::Linear:
-        {
-            if ( d_s2 != d_s1 )
-                d_cnv = ( d_p2 - d_p1 ) / ( d_s2 - d_s1 );
-            break;
-        }
-        case QwtScaleTransformation::Log10:
-        {
-            if ( d_s1 != 0 )
-                d_cnv = ( d_p2 - d_p1 ) / log( d_s2 / d_s1 );
-            break;
-        }
-        default:;
+        d_ts1 = d_transform->transform( d_ts1 );
+        ts2 = d_transform->transform( ts2 );
     }
+
+    d_cnv = 1.0;
+    if ( d_ts1 != ts2 )
+        d_cnv = ( d_p2 - d_p1 ) / ( ts2 - d_ts1 );
 }
 
@@ -334,5 +238,5 @@
 {
     debug.nospace() << "QwtScaleMap("
-        << static_cast<int>( map.transformation()->type() )
+        << map.transformation()
         << ", s:" << map.s1() << "->" << map.s2()
         << ", p:" << map.p1() << "->" << map.p2()
