Index: trunk/BNC/qwt/qwt_interval.cpp
===================================================================
--- trunk/BNC/qwt/qwt_interval.cpp	(revision 9383)
+++ trunk/BNC/qwt/qwt_interval.cpp	(revision 11158)
@@ -1,3 +1,3 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+/******************************************************************************
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
@@ -9,22 +9,29 @@
 
 #include "qwt_interval.h"
-#include "qwt_math.h"
-#include <qalgorithms.h>
-
-/*!
-  \brief Normalize the limits of the interval
-
-  If maxValue() < minValue() the limits will be inverted.
-  \return Normalized interval
-
-  \sa isValid(), inverted()
-*/
+
+namespace
+{
+    static const struct RegisterQwtInterval
+    {
+        inline RegisterQwtInterval() { qRegisterMetaType< QwtInterval >(); }
+
+    } qwtRegisterQwtInterval;
+}
+
+/*!
+   \brief Normalize the limits of the interval
+
+   If maxValue() < minValue() the limits will be inverted.
+   \return Normalized interval
+
+   \sa isValid(), inverted()
+ */
 QwtInterval QwtInterval::normalized() const
 {
-    if ( d_minValue > d_maxValue )
+    if ( m_minValue > m_maxValue )
     {
         return inverted();
     }
-    if ( d_minValue == d_maxValue && d_borderFlags == ExcludeMinimum )
+    if ( m_minValue == m_maxValue && m_borderFlags == ExcludeMinimum )
     {
         return inverted();
@@ -35,25 +42,27 @@
 
 /*!
-  Invert the limits of the interval
-  \return Inverted interval
-  \sa normalized()
-*/
+   Invert the limits of the interval
+   \return Inverted interval
+   \sa normalized()
+ */
 QwtInterval QwtInterval::inverted() const
 {
     BorderFlags borderFlags = IncludeBorders;
-    if ( d_borderFlags & ExcludeMinimum )
+
+    if ( m_borderFlags & ExcludeMinimum )
         borderFlags |= ExcludeMaximum;
-    if ( d_borderFlags & ExcludeMaximum )
+
+    if ( m_borderFlags & ExcludeMaximum )
         borderFlags |= ExcludeMinimum;
 
-    return QwtInterval( d_maxValue, d_minValue, borderFlags );
-}
-
-/*!
-  Test if a value is inside an interval
-
-  \param value Value
-  \return true, if value >= minValue() && value <= maxValue()
-*/
+    return QwtInterval( m_maxValue, m_minValue, borderFlags );
+}
+
+/*!
+   Test if a value is inside an interval
+
+   \param value Value
+   \return true, if value lies inside the boundaries
+ */
 bool QwtInterval::contains( double value ) const
 {
@@ -61,11 +70,11 @@
         return false;
 
-    if ( value < d_minValue || value > d_maxValue )
-        return false;
-
-    if ( value == d_minValue && d_borderFlags & ExcludeMinimum )
-        return false;
-
-    if ( value == d_maxValue && d_borderFlags & ExcludeMaximum )
+    if ( ( value < m_minValue ) || ( value > m_maxValue ) )
+        return false;
+
+    if ( ( value == m_minValue ) && ( m_borderFlags & ExcludeMinimum ) )
+        return false;
+
+    if ( ( value == m_maxValue ) && ( m_borderFlags & ExcludeMaximum ) )
         return false;
 
@@ -73,10 +82,48 @@
 }
 
+/*!
+   Test if an interval is inside an interval
+
+   \param interval Interval
+   \return true, if interval lies inside the boundaries
+ */
+bool QwtInterval::contains( const QwtInterval& interval ) const
+{
+    if ( !isValid() || !interval.isValid() )
+        return false;
+
+    if ( ( interval.m_minValue < m_minValue ) || ( interval.m_maxValue > m_maxValue ) )
+        return false;
+
+    if ( m_borderFlags )
+    {
+        if ( interval.m_minValue == m_minValue )
+        {
+            if ( ( m_borderFlags & ExcludeMinimum )
+                && !( interval.m_borderFlags & ExcludeMinimum ) )
+            {
+                return false;
+            }
+        }
+
+        if ( interval.m_maxValue == m_maxValue )
+        {
+            if ( ( m_borderFlags & ExcludeMaximum )
+                && !( interval.m_borderFlags & ExcludeMaximum ) )
+            {
+                return false;
+            }
+        }
+    }
+
+    return true;
+}
+
 //! Unite 2 intervals
-QwtInterval QwtInterval::unite( const QwtInterval &other ) const
+QwtInterval QwtInterval::unite( const QwtInterval& other ) const
 {
     /*
-     If one of the intervals is invalid return the other one.
-     If both are invalid return an invalid default interval
+       If one of the intervals is invalid return the other one.
+       If both are invalid return an invalid default interval
      */
     if ( !isValid() )
@@ -94,35 +141,35 @@
 
     // minimum
-    if ( d_minValue < other.minValue() )
-    {
-        united.setMinValue( d_minValue );
-        flags &= d_borderFlags & ExcludeMinimum;
-    }
-    else if ( other.minValue() < d_minValue )
+    if ( m_minValue < other.minValue() )
+    {
+        united.setMinValue( m_minValue );
+        flags &= m_borderFlags & ExcludeMinimum;
+    }
+    else if ( other.minValue() < m_minValue )
     {
         united.setMinValue( other.minValue() );
         flags &= other.borderFlags() & ExcludeMinimum;
     }
-    else // d_minValue == other.minValue()
-    {
-        united.setMinValue( d_minValue );
-        flags &= ( d_borderFlags & other.borderFlags() ) & ExcludeMinimum;
+    else // m_minValue == other.minValue()
+    {
+        united.setMinValue( m_minValue );
+        flags &= ( m_borderFlags & other.borderFlags() ) & ExcludeMinimum;
     }
 
     // maximum
-    if ( d_maxValue > other.maxValue() )
-    {
-        united.setMaxValue( d_maxValue );
-        flags &= d_borderFlags & ExcludeMaximum;
-    }
-    else if ( other.maxValue() > d_maxValue )
+    if ( m_maxValue > other.maxValue() )
+    {
+        united.setMaxValue( m_maxValue );
+        flags &= m_borderFlags & ExcludeMaximum;
+    }
+    else if ( other.maxValue() > m_maxValue )
     {
         united.setMaxValue( other.maxValue() );
         flags &= other.borderFlags() & ExcludeMaximum;
     }
-    else // d_maxValue == other.maxValue() )
-    {
-        united.setMaxValue( d_maxValue );
-        flags &= d_borderFlags & other.borderFlags() & ExcludeMaximum;
+    else // m_maxValue == other.maxValue() )
+    {
+        united.setMaxValue( m_maxValue );
+        flags &= m_borderFlags & other.borderFlags() & ExcludeMaximum;
     }
 
@@ -132,10 +179,10 @@
 
 /*!
-  \brief Intersect 2 intervals
-
-  \param other Interval to be intersect with
-  \return Intersection
- */
-QwtInterval QwtInterval::intersect( const QwtInterval &other ) const
+   \brief Intersect 2 intervals
+
+   \param other Interval to be intersect with
+   \return Intersection
+ */
+QwtInterval QwtInterval::intersect( const QwtInterval& other ) const
 {
     if ( !other.isValid() || !isValid() )
@@ -199,10 +246,10 @@
 
 /*!
-  \brief Unite this interval with the given interval.
-
-  \param other Interval to be united with
-  \return This interval
- */
-QwtInterval& QwtInterval::operator|=( const QwtInterval &other )
+   \brief Unite this interval with the given interval.
+
+   \param other Interval to be united with
+   \return This interval
+ */
+QwtInterval& QwtInterval::operator|=( const QwtInterval& other )
 {
     *this = *this | other;
@@ -211,10 +258,10 @@
 
 /*!
-  \brief Intersect this interval with the given interval.
-
-  \param other Interval to be intersected with
-  \return This interval
- */
-QwtInterval& QwtInterval::operator&=( const QwtInterval &other )
+   \brief Intersect this interval with the given interval.
+
+   \param other Interval to be intersected with
+   \return This interval
+ */
+QwtInterval& QwtInterval::operator&=( const QwtInterval& other )
 {
     *this = *this & other;
@@ -223,10 +270,10 @@
 
 /*!
-  \brief Test if two intervals overlap
-
-  \param other Interval
-  \return True, when the intervals are intersecting
-*/
-bool QwtInterval::intersects( const QwtInterval &other ) const
+   \brief Test if two intervals overlap
+
+   \param other Interval
+   \return True, when the intervals are intersecting
+ */
+bool QwtInterval::intersects( const QwtInterval& other ) const
 {
     if ( !isValid() || !other.isValid() )
@@ -244,5 +291,5 @@
     }
     else if ( i1.minValue() == i2.minValue() &&
-              i1.borderFlags() & ExcludeMinimum )
+        i1.borderFlags() & ExcludeMinimum )
     {
         qSwap( i1, i2 );
@@ -256,5 +303,5 @@
     {
         return !( ( i1.borderFlags() & ExcludeMaximum ) ||
-            ( i2.borderFlags() & ExcludeMinimum ) );
+               ( i2.borderFlags() & ExcludeMinimum ) );
     }
     return false;
@@ -262,10 +309,10 @@
 
 /*!
-  Adjust the limit that is closer to value, so that value becomes
-  the center of the interval.
-
-  \param value Center
-  \return Interval with value as center
-*/
+   Adjust the limit that is closer to value, so that value becomes
+   the center of the interval.
+
+   \param value Center
+   \return Interval with value as center
+ */
 QwtInterval QwtInterval::symmetrize( double value ) const
 {
@@ -274,5 +321,5 @@
 
     const double delta =
-        qMax( qAbs( value - d_maxValue ), qAbs( value - d_minValue ) );
+        qMax( qAbs( value - m_maxValue ), qAbs( value - m_minValue ) );
 
     return QwtInterval( value - delta, value + delta );
@@ -280,11 +327,11 @@
 
 /*!
-  Limit the interval, keeping the border modes
-
-  \param lowerBound Lower limit
-  \param upperBound Upper limit
-
-  \return Limited interval
-*/
+   Limit the interval, keeping the border modes
+
+   \param lowerBound Lower limit
+   \param upperBound Upper limit
+
+   \return Limited interval
+ */
 QwtInterval QwtInterval::limited( double lowerBound, double upperBound ) const
 {
@@ -292,26 +339,26 @@
         return QwtInterval();
 
-    double minValue = qMax( d_minValue, lowerBound );
+    double minValue = qMax( m_minValue, lowerBound );
     minValue = qMin( minValue, upperBound );
 
-    double maxValue = qMax( d_maxValue, lowerBound );
+    double maxValue = qMax( m_maxValue, lowerBound );
     maxValue = qMin( maxValue, upperBound );
 
-    return QwtInterval( minValue, maxValue, d_borderFlags );
-}
-
-/*!
-  \brief Extend the interval
-
-  If value is below minValue(), value becomes the lower limit.
-  If value is above maxValue(), value becomes the upper limit.
-
-  extend() has no effect for invalid intervals
-
-  \param value Value
-  \return extended interval
-
-  \sa isValid()
-*/
+    return QwtInterval( minValue, maxValue, m_borderFlags );
+}
+
+/*!
+   \brief Extend the interval
+
+   If value is below minValue(), value becomes the lower limit.
+   If value is above maxValue(), value becomes the upper limit.
+
+   extend() has no effect for invalid intervals
+
+   \param value Value
+   \return extended interval
+
+   \sa isValid()
+ */
 QwtInterval QwtInterval::extend( double value ) const
 {
@@ -319,16 +366,16 @@
         return *this;
 
-    return QwtInterval( qMin( value, d_minValue ),
-        qMax( value, d_maxValue ), d_borderFlags );
-}
-
-/*!
-  Extend an interval
-
-  \param value Value
-  \return Reference of the extended interval
-
-  \sa extend()
-*/
+    return QwtInterval( qMin( value, m_minValue ),
+        qMax( value, m_maxValue ), m_borderFlags );
+}
+
+/*!
+   Extend an interval
+
+   \param value Value
+   \return Reference of the extended interval
+
+   \sa extend()
+ */
 QwtInterval& QwtInterval::operator|=( double value )
 {
@@ -339,13 +386,15 @@
 #ifndef QT_NO_DEBUG_STREAM
 
-QDebug operator<<( QDebug debug, const QwtInterval &interval )
+#include <qdebug.h>
+
+QDebug operator<<( QDebug debug, const QwtInterval& interval )
 {
     const int flags = interval.borderFlags();
 
     debug.nospace() << "QwtInterval("
-        << ( ( flags & QwtInterval::ExcludeMinimum ) ? "]" : "[" )
-        << interval.minValue() << "," << interval.maxValue()
-        << ( ( flags & QwtInterval::ExcludeMaximum ) ? "[" : "]" )
-        << ")";
+                    << ( ( flags& QwtInterval::ExcludeMinimum ) ? "]" : "[" )
+                    << interval.minValue() << "," << interval.maxValue()
+                    << ( ( flags& QwtInterval::ExcludeMaximum ) ? "[" : "]" )
+                    << ")";
 
     return debug.space();
