Index: trunk/BNC/qwt/qwt_abstract_scale.cpp
===================================================================
--- trunk/BNC/qwt/qwt_abstract_scale.cpp	(revision 9383)
+++ trunk/BNC/qwt/qwt_abstract_scale.cpp	(revision 11158)
@@ -1,3 +1,3 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+/******************************************************************************
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
@@ -15,7 +15,9 @@
 #include "qwt_interval.h"
 
+#include <qcoreevent.h>
+
 class QwtAbstractScale::PrivateData
 {
-public:
+  public:
     PrivateData():
         maxMajor( 5 ),
@@ -33,6 +35,6 @@
     }
 
-    QwtScaleEngine *scaleEngine;
-    QwtAbstractScaleDraw *scaleDraw;
+    QwtScaleEngine* scaleEngine;
+    QwtAbstractScaleDraw* scaleDraw;
 
     int maxMajor;
@@ -42,20 +44,20 @@
 
 /*!
-  Constructor
-
-  \param parent Parent widget
-
-  Creates a default QwtScaleDraw and a QwtLinearScaleEngine.
-  The initial scale boundaries are set to [ 0.0, 100.0 ]
-
-  The scaleStepSize() is initialized to 0.0, scaleMaxMajor() to 5
-  and scaleMaxMajor to 3.
-*/
-
-QwtAbstractScale::QwtAbstractScale( QWidget *parent ):
-    QWidget( parent )
-{
-    d_data = new PrivateData;
-    rescale( 0.0, 100.0, d_data->stepSize );
+   Constructor
+
+   \param parent Parent widget
+
+   Creates a default QwtScaleDraw and a QwtLinearScaleEngine.
+   The initial scale boundaries are set to [ 0.0, 100.0 ]
+
+   The scaleStepSize() is initialized to 0.0, scaleMaxMajor() to 5
+   and scaleMaxMajor to 3.
+ */
+
+QwtAbstractScale::QwtAbstractScale( QWidget* parent )
+    : QWidget( parent )
+{
+    m_data = new PrivateData;
+    rescale( 0.0, 100.0, m_data->stepSize );
 }
 
@@ -63,16 +65,16 @@
 QwtAbstractScale::~QwtAbstractScale()
 {
-    delete d_data;
-}
-
-/*!
-  Set the lower bound of the scale
-
-  \param value Lower bound
-
-  \sa lowerBound(), setScale(), setUpperBound()
-  \note For inverted scales the lower bound
+    delete m_data;
+}
+
+/*!
+   Set the lower bound of the scale
+
+   \param value Lower bound
+
+   \sa lowerBound(), setScale(), setUpperBound()
+   \note For inverted scales the lower bound
         is greater than the upper bound
-*/
+ */
 void QwtAbstractScale::setLowerBound( double value )
 {
@@ -81,21 +83,21 @@
 
 /*!
-  \return Lower bound of the scale
-  \sa setLowerBound(), setScale(), upperBound()
-*/
+   \return Lower bound of the scale
+   \sa setLowerBound(), setScale(), upperBound()
+ */
 double QwtAbstractScale::lowerBound() const
 {
-    return d_data->scaleDraw->scaleDiv().lowerBound();
-}
-
-/*!
-  Set the upper bound of the scale
-
-  \param value Upper bound
-
-  \sa upperBound(), setScale(), setLowerBound()
-  \note For inverted scales the lower bound
+    return m_data->scaleDraw->scaleDiv().lowerBound();
+}
+
+/*!
+   Set the upper bound of the scale
+
+   \param value Upper bound
+
+   \sa upperBound(), setScale(), setLowerBound()
+   \note For inverted scales the lower bound
         is greater than the upper bound
-*/
+ */
 void QwtAbstractScale::setUpperBound( double value )
 {
@@ -104,42 +106,42 @@
 
 /*!
-  \return Upper bound of the scale
-  \sa setUpperBound(), setScale(), lowerBound()
-*/
+   \return Upper bound of the scale
+   \sa setUpperBound(), setScale(), lowerBound()
+ */
 double QwtAbstractScale::upperBound() const
 {
-    return d_data->scaleDraw->scaleDiv().upperBound();
-}
-
-/*!
-  \brief Specify a scale.
-
-  Define a scale by an interval
-
-  The ticks are calculated using scaleMaxMinor(),
-  scaleMaxMajor() and scaleStepSize().
-
-  \param lowerBound lower limit of the scale interval
-  \param upperBound upper limit of the scale interval
-
-  \note For inverted scales the lower bound
+    return m_data->scaleDraw->scaleDiv().upperBound();
+}
+
+/*!
+   \brief Specify a scale.
+
+   Define a scale by an interval
+
+   The ticks are calculated using scaleMaxMinor(),
+   scaleMaxMajor() and scaleStepSize().
+
+   \param lowerBound lower limit of the scale interval
+   \param upperBound upper limit of the scale interval
+
+   \note For inverted scales the lower bound
         is greater than the upper bound
-*/
+ */
 void QwtAbstractScale::setScale( double lowerBound, double upperBound )
 {
-    rescale( lowerBound, upperBound, d_data->stepSize );
-}
-
-/*!
-  \brief Specify a scale.
-
-  Define a scale by an interval
-
-  The ticks are calculated using scaleMaxMinor(),
-  scaleMaxMajor() and scaleStepSize().
-
-  \param interval Interval
-*/
-void QwtAbstractScale::setScale( const QwtInterval &interval )
+    rescale( lowerBound, upperBound, m_data->stepSize );
+}
+
+/*!
+   \brief Specify a scale.
+
+   Define a scale by an interval
+
+   The ticks are calculated using scaleMaxMinor(),
+   scaleMaxMajor() and scaleStepSize().
+
+   \param interval Interval
+ */
+void QwtAbstractScale::setScale( const QwtInterval& interval )
 {
     setScale( interval.minValue(), interval.maxValue() );
@@ -147,24 +149,24 @@
 
 /*!
-  \brief Specify a scale.
-
-  scaleMaxMinor(), scaleMaxMajor() and scaleStepSize() and have no effect.
-
-  \param scaleDiv Scale division
-  \sa setAutoScale()
-*/
-void QwtAbstractScale::setScale( const QwtScaleDiv &scaleDiv )
-{
-    if ( scaleDiv != d_data->scaleDraw->scaleDiv() )
+   \brief Specify a scale.
+
+   scaleMaxMinor(), scaleMaxMajor() and scaleStepSize() and have no effect.
+
+   \param scaleDiv Scale division
+   \sa setAutoScale()
+ */
+void QwtAbstractScale::setScale( const QwtScaleDiv& scaleDiv )
+{
+    if ( scaleDiv != m_data->scaleDraw->scaleDiv() )
     {
 #if 1
-        if ( d_data->scaleEngine )
+        if ( m_data->scaleEngine )
         {
-            d_data->scaleDraw->setTransformation(
-                d_data->scaleEngine->transformation() );
+            m_data->scaleDraw->setTransformation(
+                m_data->scaleEngine->transformation() );
         }
 #endif
 
-        d_data->scaleDraw->setScaleDiv( scaleDiv );
+        m_data->scaleDraw->setScaleDiv( scaleDiv );
 
         scaleChange();
@@ -173,21 +175,21 @@
 
 /*!
-  \brief Set the maximum number of major tick intervals.
-
-  The scale's major ticks are calculated automatically such that
-  the number of major intervals does not exceed ticks.
-
-  The default value is 5.
-
-  \param ticks Maximal number of major ticks.
-
-  \sa scaleMaxMajor(), setScaleMaxMinor(),
+   \brief Set the maximum number of major tick intervals.
+
+   The scale's major ticks are calculated automatically such that
+   the number of major intervals does not exceed ticks.
+
+   The default value is 5.
+
+   \param ticks Maximal number of major ticks.
+
+   \sa scaleMaxMajor(), setScaleMaxMinor(),
       setScaleStepSize(), QwtScaleEngine::divideInterval()
-*/
+ */
 void QwtAbstractScale::setScaleMaxMajor( int ticks )
 {
-    if ( ticks != d_data->maxMajor )
-    {
-        d_data->maxMajor = ticks;
+    if ( ticks != m_data->maxMajor )
+    {
+        m_data->maxMajor = ticks;
         updateScaleDraw();
     }
@@ -195,29 +197,29 @@
 
 /*!
-  \return Maximal number of major tick intervals
-  \sa setScaleMaxMajor(), scaleMaxMinor()
-*/
+   \return Maximal number of major tick intervals
+   \sa setScaleMaxMajor(), scaleMaxMinor()
+ */
 int QwtAbstractScale::scaleMaxMajor() const
 {
-    return d_data->maxMajor;
-}
-
-/*!
-  \brief Set the maximum number of minor tick intervals
-
-  The scale's minor ticks are calculated automatically such that
-  the number of minor intervals does not exceed ticks.
-  The default value is 3.
-
-  \param ticks Maximal number of minor ticks.
-
-  \sa scaleMaxMajor(), setScaleMaxMinor(),
+    return m_data->maxMajor;
+}
+
+/*!
+   \brief Set the maximum number of minor tick intervals
+
+   The scale's minor ticks are calculated automatically such that
+   the number of minor intervals does not exceed ticks.
+   The default value is 3.
+
+   \param ticks Maximal number of minor ticks.
+
+   \sa scaleMaxMajor(), setScaleMaxMinor(),
       setScaleStepSize(), QwtScaleEngine::divideInterval()
-*/
+ */
 void QwtAbstractScale::setScaleMaxMinor( int ticks )
 {
-    if ( ticks != d_data->maxMinor )
-    {
-        d_data->maxMinor = ticks;
+    if ( ticks != m_data->maxMinor )
+    {
+        m_data->maxMinor = ticks;
         updateScaleDraw();
     }
@@ -225,10 +227,10 @@
 
 /*!
-  \return Maximal number of minor tick intervals
-  \sa setScaleMaxMinor(), scaleMaxMajor()
-*/
+   \return Maximal number of minor tick intervals
+   \sa setScaleMaxMinor(), scaleMaxMajor()
+ */
 int QwtAbstractScale::scaleMaxMinor() const
 {
-    return d_data->maxMinor;
+    return m_data->maxMinor;
 }
 
@@ -246,10 +248,10 @@
    \note Position and distance between the major ticks also
          depends on scaleMaxMajor().
-*/
+ */
 void QwtAbstractScale::setScaleStepSize( double stepSize )
 {
-    if ( stepSize != d_data->stepSize )
-    {
-        d_data->stepSize = stepSize;
+    if ( stepSize != m_data->stepSize )
+    {
+        m_data->stepSize = stepSize;
         updateScaleDraw();
     }
@@ -257,30 +259,30 @@
 
 /*!
-  \return Hint for the step size of the scale
-  \sa setScaleStepSize(), QwtScaleEngine::divideScale()
-*/
+   \return Hint for the step size of the scale
+   \sa setScaleStepSize(), QwtScaleEngine::divideScale()
+ */
 double QwtAbstractScale::scaleStepSize() const
 {
-    return d_data->stepSize;
-}
-
-/*!
-  \brief Set a scale draw
-
-  scaleDraw has to be created with new and will be deleted in
-  the destructor or the next call of setAbstractScaleDraw().
-
-  \sa abstractScaleDraw()
-*/
-void QwtAbstractScale::setAbstractScaleDraw( QwtAbstractScaleDraw *scaleDraw )
-{
-    if ( scaleDraw == NULL || scaleDraw == d_data->scaleDraw )
+    return m_data->stepSize;
+}
+
+/*!
+   \brief Set a scale draw
+
+   scaleDraw has to be created with new and will be deleted in
+   the destructor or the next call of setAbstractScaleDraw().
+
+   \sa abstractScaleDraw()
+ */
+void QwtAbstractScale::setAbstractScaleDraw( QwtAbstractScaleDraw* scaleDraw )
+{
+    if ( scaleDraw == NULL || scaleDraw == m_data->scaleDraw )
         return;
 
-    if ( d_data->scaleDraw != NULL )
-        scaleDraw->setScaleDiv( d_data->scaleDraw->scaleDiv() );
-
-    delete d_data->scaleDraw;
-    d_data->scaleDraw = scaleDraw;
+    if ( m_data->scaleDraw != NULL )
+        scaleDraw->setScaleDiv( m_data->scaleDraw->scaleDiv() );
+
+    delete m_data->scaleDraw;
+    m_data->scaleDraw = scaleDraw;
 }
 
@@ -288,8 +290,8 @@
     \return Scale draw
     \sa setAbstractScaleDraw()
-*/
-QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw()
-{
-    return d_data->scaleDraw;
+ */
+QwtAbstractScaleDraw* QwtAbstractScale::abstractScaleDraw()
+{
+    return m_data->scaleDraw;
 }
 
@@ -297,116 +299,116 @@
     \return Scale draw
     \sa setAbstractScaleDraw()
-*/
-const QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw() const
-{
-    return d_data->scaleDraw;
-}
-
-/*!
-  \brief Set a scale engine
-
-  The scale engine is responsible for calculating the scale division
-  and provides a transformation between scale and widget coordinates.
-
-  scaleEngine has to be created with new and will be deleted in
-  the destructor or the next call of setScaleEngine.
-*/
-void QwtAbstractScale::setScaleEngine( QwtScaleEngine *scaleEngine )
-{
-    if ( scaleEngine != NULL && scaleEngine != d_data->scaleEngine )
-    {
-        delete d_data->scaleEngine;
-        d_data->scaleEngine = scaleEngine;
-    }
-}
-
-/*!
-  \return Scale engine
-  \sa setScaleEngine()
-*/
-const QwtScaleEngine *QwtAbstractScale::scaleEngine() const
-{
-    return d_data->scaleEngine;
-}
-
-/*!
-  \return Scale engine
-  \sa setScaleEngine()
-*/
-QwtScaleEngine *QwtAbstractScale::scaleEngine()
-{
-    return d_data->scaleEngine;
-}
-
-/*!
-  \return Scale boundaries and positions of the ticks
-
-  The scale division might have been assigned explicitly
-  or calculated implicitly by rescale().
- */
-const QwtScaleDiv &QwtAbstractScale::scaleDiv() const
-{
-    return d_data->scaleDraw->scaleDiv();
-}
-
-/*!
-  \return Map to translate between scale and widget coordinates
- */
-const QwtScaleMap &QwtAbstractScale::scaleMap() const
-{
-    return d_data->scaleDraw->scaleMap();
-}
-
-/*!
-  Translate a scale value into a widget coordinate
-
-  \param value Scale value
-  \return Corresponding widget coordinate for value
-  \sa scaleMap(), invTransform()
+ */
+const QwtAbstractScaleDraw* QwtAbstractScale::abstractScaleDraw() const
+{
+    return m_data->scaleDraw;
+}
+
+/*!
+   \brief Set a scale engine
+
+   The scale engine is responsible for calculating the scale division
+   and provides a transformation between scale and widget coordinates.
+
+   scaleEngine has to be created with new and will be deleted in
+   the destructor or the next call of setScaleEngine.
+ */
+void QwtAbstractScale::setScaleEngine( QwtScaleEngine* scaleEngine )
+{
+    if ( scaleEngine != NULL && scaleEngine != m_data->scaleEngine )
+    {
+        delete m_data->scaleEngine;
+        m_data->scaleEngine = scaleEngine;
+    }
+}
+
+/*!
+   \return Scale engine
+   \sa setScaleEngine()
+ */
+const QwtScaleEngine* QwtAbstractScale::scaleEngine() const
+{
+    return m_data->scaleEngine;
+}
+
+/*!
+   \return Scale engine
+   \sa setScaleEngine()
+ */
+QwtScaleEngine* QwtAbstractScale::scaleEngine()
+{
+    return m_data->scaleEngine;
+}
+
+/*!
+   \return Scale boundaries and positions of the ticks
+
+   The scale division might have been assigned explicitly
+   or calculated implicitly by rescale().
+ */
+const QwtScaleDiv& QwtAbstractScale::scaleDiv() const
+{
+    return m_data->scaleDraw->scaleDiv();
+}
+
+/*!
+   \return Map to translate between scale and widget coordinates
+ */
+const QwtScaleMap& QwtAbstractScale::scaleMap() const
+{
+    return m_data->scaleDraw->scaleMap();
+}
+
+/*!
+   Translate a scale value into a widget coordinate
+
+   \param value Scale value
+   \return Corresponding widget coordinate for value
+   \sa scaleMap(), invTransform()
  */
 int QwtAbstractScale::transform( double value ) const
 {
-    return qRound( d_data->scaleDraw->scaleMap().transform( value ) );
-}
-
-/*!
-  Translate a widget coordinate into a scale value
-
-  \param value Widget coordinate
-  \return Corresponding scale coordinate for value
-  \sa scaleMap(), transform()
+    return qRound( m_data->scaleDraw->scaleMap().transform( value ) );
+}
+
+/*!
+   Translate a widget coordinate into a scale value
+
+   \param value Widget coordinate
+   \return Corresponding scale coordinate for value
+   \sa scaleMap(), transform()
  */
 double QwtAbstractScale::invTransform( int value ) const
 {
-    return d_data->scaleDraw->scaleMap().invTransform( value );
-}
-
-/*!
-  \return True, when the scale is increasing in opposite direction
+    return m_data->scaleDraw->scaleMap().invTransform( value );
+}
+
+/*!
+   \return True, when the scale is increasing in opposite direction
           to the widget coordinates
  */
 bool QwtAbstractScale::isInverted() const
 {
-    return d_data->scaleDraw->scaleMap().isInverting();
-}
-
-/*!
-  \return The boundary with the smaller value
-  \sa maximum(), lowerBound(), upperBound()
+    return m_data->scaleDraw->scaleMap().isInverting();
+}
+
+/*!
+   \return The boundary with the smaller value
+   \sa maximum(), lowerBound(), upperBound()
  */
 double QwtAbstractScale::minimum() const
 {
-    return qMin( d_data->scaleDraw->scaleDiv().lowerBound(),
-        d_data->scaleDraw->scaleDiv().upperBound() );
-}
-
-/*!
-  \return The boundary with the larger value
-  \sa minimum(), lowerBound(), upperBound()
+    return qMin( m_data->scaleDraw->scaleDiv().lowerBound(),
+        m_data->scaleDraw->scaleDiv().upperBound() );
+}
+
+/*!
+   \return The boundary with the larger value
+   \sa minimum(), lowerBound(), upperBound()
  */
 double QwtAbstractScale::maximum() const
 {
-    return qMax( d_data->scaleDraw->scaleDiv().lowerBound(),
-        d_data->scaleDraw->scaleDiv().upperBound() );
+    return qMax( m_data->scaleDraw->scaleDiv().lowerBound(),
+        m_data->scaleDraw->scaleDiv().upperBound() );
 }
 
@@ -417,33 +419,54 @@
 
 /*!
-  Recalculate the scale division and update the scale.
-
-  \param lowerBound Lower limit of the scale interval
-  \param upperBound Upper limit of the scale interval
-  \param stepSize Major step size
-
-  \sa scaleChange()
-*/
+   Recalculate the scale division and update the scale.
+
+   \param lowerBound Lower limit of the scale interval
+   \param upperBound Upper limit of the scale interval
+   \param stepSize Major step size
+
+   \sa scaleChange()
+ */
 void QwtAbstractScale::rescale(
     double lowerBound, double upperBound, double stepSize )
 {
-    const QwtScaleDiv scaleDiv = d_data->scaleEngine->divideScale(
-        lowerBound, upperBound, d_data->maxMajor, d_data->maxMinor, stepSize );
-
-    if ( scaleDiv != d_data->scaleDraw->scaleDiv() )
+    const QwtScaleDiv scaleDiv = m_data->scaleEngine->divideScale(
+        lowerBound, upperBound, m_data->maxMajor, m_data->maxMinor, stepSize );
+
+    if ( scaleDiv != m_data->scaleDraw->scaleDiv() )
     {
 #if 1
-        d_data->scaleDraw->setTransformation(
-            d_data->scaleEngine->transformation() );
+        m_data->scaleDraw->setTransformation(
+            m_data->scaleEngine->transformation() );
 #endif
 
-        d_data->scaleDraw->setScaleDiv( scaleDiv );
+        m_data->scaleDraw->setScaleDiv( scaleDiv );
         scaleChange();
     }
 }
 
+/*!
+   Change Event handler
+   \param event Change event
+
+   Invalidates internal caches if necessary
+ */
+void QwtAbstractScale::changeEvent( QEvent* event )
+{
+    if ( event->type() == QEvent::LocaleChange )
+    {
+        m_data->scaleDraw->invalidateCache();
+    }
+
+    QWidget::changeEvent( event );
+}
+
+/*!
+   Recalculate ticks and scale boundaries.
+ */
 void QwtAbstractScale::updateScaleDraw()
 {
-    rescale( d_data->scaleDraw->scaleDiv().lowerBound(),
-        d_data->scaleDraw->scaleDiv().upperBound(), d_data->stepSize );
-}
+    rescale( m_data->scaleDraw->scaleDiv().lowerBound(),
+        m_data->scaleDraw->scaleDiv().upperBound(), m_data->stepSize );
+}
+
+#include "moc_qwt_abstract_scale.cpp"
