Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_compass.cpp


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (3 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_compass.cpp

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1010#include "qwt_compass.h"
    1111#include "qwt_compass_rose.h"
    12 #include "qwt_math.h"
    13 #include "qwt_scale_draw.h"
    14 #include "qwt_painter.h"
    15 #include "qwt_dial_needle.h"
    16 #include <qpainter.h>
    17 #include <qpixmap.h>
     12#include "qwt_text.h"
     13
    1814#include <qevent.h>
    19 
    20 /*!
    21   \brief Constructor
    22 
    23   Initializes a label map for multiples of 45 degrees
     15#include <qmap.h>
     16
     17class QwtCompassScaleDraw::PrivateData
     18{
     19  public:
     20    QMap< double, QString > labelMap;
     21};
     22
     23/*!
     24   \brief Constructor
     25
     26   Initializes a label map for multiples of 45 degrees
    2427 */
    2528QwtCompassScaleDraw::QwtCompassScaleDraw()
    2629{
     30    m_data = new PrivateData;
     31
    2732    enableComponent( QwtAbstractScaleDraw::Backbone, false );
    2833    enableComponent( QwtAbstractScaleDraw::Ticks, false );
    2934
    30     d_labelMap.insert( 0.0, QString::fromLatin1( "N" ) );
    31     d_labelMap.insert( 45.0, QString::fromLatin1( "NE" ) );
    32     d_labelMap.insert( 90.0, QString::fromLatin1( "E" ) );
    33     d_labelMap.insert( 135.0, QString::fromLatin1( "SE" ) );
    34     d_labelMap.insert( 180.0, QString::fromLatin1( "S" ) );
    35     d_labelMap.insert( 225.0, QString::fromLatin1( "SW" ) );
    36     d_labelMap.insert( 270.0, QString::fromLatin1( "W" ) );
    37     d_labelMap.insert( 315.0, QString::fromLatin1( "NW" ) );
     35    QMap< double, QString >& map = m_data->labelMap;
     36
     37    map.insert( 0.0, QString::fromLatin1( "N" ) );
     38    map.insert( 45.0, QString::fromLatin1( "NE" ) );
     39    map.insert( 90.0, QString::fromLatin1( "E" ) );
     40    map.insert( 135.0, QString::fromLatin1( "SE" ) );
     41    map.insert( 180.0, QString::fromLatin1( "S" ) );
     42    map.insert( 225.0, QString::fromLatin1( "SW" ) );
     43    map.insert( 270.0, QString::fromLatin1( "W" ) );
     44    map.insert( 315.0, QString::fromLatin1( "NW" ) );
    3845
    3946#if 0
    40     d_labelMap.insert( 22.5, QString::fromLatin1( "NNE" ) );
    41     d_labelMap.insert( 67.5, QString::fromLatin1( "NEE" ) );
    42     d_labelMap.insert( 112.5, QString::fromLatin1( "SEE" ) );
    43     d_labelMap.insert( 157.5, QString::fromLatin1( "SSE" ) );
    44     d_labelMap.insert( 202.5, QString::fromLatin1( "SSW" ) );
    45     d_labelMap.insert( 247.5, QString::fromLatin1( "SWW" ) );
    46     d_labelMap.insert( 292.5, QString::fromLatin1( "NWW" ) );
    47     d_labelMap.insert( 337.5, QString::fromLatin1( "NNW" ) );
     47    map.insert( 22.5, QString::fromLatin1( "NNE" ) );
     48    map.insert( 67.5, QString::fromLatin1( "NEE" ) );
     49    map.insert( 112.5, QString::fromLatin1( "SEE" ) );
     50    map.insert( 157.5, QString::fromLatin1( "SSE" ) );
     51    map.insert( 202.5, QString::fromLatin1( "SSW" ) );
     52    map.insert( 247.5, QString::fromLatin1( "SWW" ) );
     53    map.insert( 292.5, QString::fromLatin1( "NWW" ) );
     54    map.insert( 337.5, QString::fromLatin1( "NNW" ) );
    4855#endif
    4956}
    5057
    5158/*!
    52   \brief Constructor
    53 
    54   \param map Value to label map
    55  */
    56 QwtCompassScaleDraw::QwtCompassScaleDraw( const QMap<double, QString> &map ):
    57     d_labelMap( map )
    58 {
     59   \brief Constructor
     60
     61   \param map Value to label map
     62 */
     63QwtCompassScaleDraw::QwtCompassScaleDraw( const QMap< double, QString >& map )
     64{
     65    m_data = new PrivateData;
     66    m_data->labelMap = map;
     67
    5968    enableComponent( QwtAbstractScaleDraw::Backbone, false );
    6069    enableComponent( QwtAbstractScaleDraw::Ticks, false );
    6170}
    6271
    63 /*!
    64   \brief Set a map, mapping values to labels
    65   \param map Value to label map
    66 
    67   The values of the major ticks are found by looking into this
    68   map. The default map consists of the labels N, NE, E, SE, S, SW, W, NW.
    69 
    70   \warning The map will have no effect for values that are no major
     72//!  Destructor
     73QwtCompassScaleDraw::~QwtCompassScaleDraw()
     74{
     75    delete m_data;
     76}
     77
     78/*!
     79   \brief Set a map, mapping values to labels
     80   \param map Value to label map
     81
     82   The values of the major ticks are found by looking into this
     83   map. The default map consists of the labels N, NE, E, SE, S, SW, W, NW.
     84
     85   \warning The map will have no effect for values that are no major
    7186           tick values. Major ticks can be changed by QwtScaleDraw::setScale
    7287
    73   \sa labelMap(), scaleDraw(), setScale()
    74 */
    75 void QwtCompassScaleDraw::setLabelMap( const QMap<double, QString> &map )
    76 {
    77     d_labelMap = map;
    78 }
    79 
    80 
    81 /*!
    82   \return map, mapping values to labels
    83   \sa setLabelMap()
    84 */
    85 QMap<double, QString> QwtCompassScaleDraw::labelMap() const
    86 {
    87     return d_labelMap;
    88 }
    89 
    90 /*!
    91   Map a value to a corresponding label
    92 
    93   \param value Value that will be mapped
    94 
    95   label() looks in the labelMap() for a corresponding label for value
    96   or returns an null text.
    97 
    98   \return Label
    99   \sa labelMap(), setLabelMap()
    100 */
     88   \sa labelMap(), scaleDraw(), setScale()
     89 */
     90void QwtCompassScaleDraw::setLabelMap( const QMap< double, QString >& map )
     91{
     92    m_data->labelMap = map;
     93}
     94
     95/*!
     96   \return map, mapping values to labels
     97   \sa setLabelMap()
     98 */
     99QMap< double, QString > QwtCompassScaleDraw::labelMap() const
     100{
     101    return m_data->labelMap;
     102}
     103
     104/*!
     105   Map a value to a corresponding label
     106
     107   \param value Value that will be mapped
     108
     109   label() looks in the labelMap() for a corresponding label for value
     110   or returns an null text.
     111
     112   \return Label
     113   \sa labelMap(), setLabelMap()
     114 */
    101115
    102116QwtText QwtCompassScaleDraw::label( double value ) const
    … …  
    108122        value += 360.0;
    109123
    110     if ( d_labelMap.contains( value ) )
    111         return d_labelMap[value];
     124    QMap< double, QString >::const_iterator it =
     125        m_data->labelMap.constFind( value );
     126
     127    if ( it != m_data->labelMap.constEnd() )
     128        return *it;
    112129
    113130    return QwtText();
    … …  
    116133class QwtCompass::PrivateData
    117134{
    118 public:
     135  public:
    119136    PrivateData():
    120137        rose( NULL )
    … …  
    127144    }
    128145
    129     QwtCompassRose *rose;
     146    QwtCompassRose* rose;
    130147};
    131148
    132149/*!
    133   \brief Constructor
    134   \param parent Parent widget
    135 
    136   Create a compass widget with a scale, no needle and no rose.
    137   The default origin is 270.0 with no valid value. It accepts
    138   mouse and keyboard inputs and has no step size. The default mode
    139   is QwtDial::RotateNeedle.
    140 */
    141 QwtCompass::QwtCompass( QWidget* parent ):
    142     QwtDial( parent )
    143 {
    144     d_data = new PrivateData;
     150   \brief Constructor
     151   \param parent Parent widget
     152
     153   Create a compass widget with a scale, no needle and no rose.
     154   The default origin is 270.0 with no valid value. It accepts
     155   mouse and keyboard inputs and has no step size. The default mode
     156   is QwtDial::RotateNeedle.
     157 */
     158QwtCompass::QwtCompass( QWidget* parent )
     159    : QwtDial( parent )
     160{
     161    m_data = new PrivateData;
    145162
    146163    setScaleDraw( new QwtCompassScaleDraw() );
    … …  
    159176QwtCompass::~QwtCompass()
    160177{
    161     delete d_data;
     178    delete m_data;
    162179}
    163180
    … …  
    169186   \param center Center of the content circle
    170187   \param radius Radius of the content circle
    171 */
    172 void QwtCompass::drawScaleContents( QPainter *painter,
    173     const QPointF &center, double radius ) const
     188 */
     189void QwtCompass::drawScaleContents( QPainter* painter,
     190    const QPointF& center, double radius ) const
    174191{
    175192    QPalette::ColorGroup cg;
    … …  
    191208
    192209/*!
    193   Draw the compass rose
    194 
    195   \param painter Painter
    196   \param center Center of the compass
    197   \param radius of the circle, where to paint the rose
    198   \param north Direction pointing north, in degrees counter clockwise
    199   \param cg Color group
    200 */
    201 void QwtCompass::drawRose( QPainter *painter, const QPointF &center,
     210   Draw the compass rose
     211
     212   \param painter Painter
     213   \param center Center of the compass
     214   \param radius of the circle, where to paint the rose
     215   \param north Direction pointing north, in degrees counter clockwise
     216   \param cg Color group
     217 */
     218void QwtCompass::drawRose( QPainter* painter, const QPointF& center,
    202219    double radius, double north, QPalette::ColorGroup cg ) const
    203220{
    204     if ( d_data->rose )
    205         d_data->rose->draw( painter, center, radius, north,  cg );
    206 }
    207 
    208 /*!
    209   Set a rose for the compass
    210   \param rose Compass rose
    211   \warning The rose will be deleted, when a different rose is
     221    if ( m_data->rose )
     222        m_data->rose->draw( painter, center, radius, north,  cg );
     223}
     224
     225/*!
     226   Set a rose for the compass
     227   \param rose Compass rose
     228   \warning The rose will be deleted, when a different rose is
    212229    set or in ~QwtCompass
    213   \sa rose()
    214 */
    215 void QwtCompass::setRose( QwtCompassRose *rose )
    216 {
    217     if ( rose != d_data->rose )
    218     {
    219         if ( d_data->rose )
    220             delete d_data->rose;
    221 
    222         d_data->rose = rose;
     230   \sa rose()
     231 */
     232void QwtCompass::setRose( QwtCompassRose* rose )
     233{
     234    if ( rose != m_data->rose )
     235    {
     236        if ( m_data->rose )
     237            delete m_data->rose;
     238
     239        m_data->rose = rose;
    223240        update();
    224241    }
    … …  
    226243
    227244/*!
    228   \return rose
    229   \sa setRose()
    230 */
    231 const QwtCompassRose *QwtCompass::rose() const
    232 {
    233     return d_data->rose;
    234 }
    235 
    236 /*!
    237   \return rose
    238   \sa setRose()
    239 */
    240 QwtCompassRose *QwtCompass::rose()
    241 {
    242     return d_data->rose;
    243 }
    244 
    245 /*!
    246   Handles key events
    247 
    248   Beside the keys described in QwtDial::keyPressEvent numbers
    249   from 1-9 (without 5) set the direction according to their
    250   position on the num pad.
    251 
    252   \sa isReadOnly()
    253 */
    254 void QwtCompass::keyPressEvent( QKeyEvent *kev )
     245   \return rose
     246   \sa setRose()
     247 */
     248const QwtCompassRose* QwtCompass::rose() const
     249{
     250    return m_data->rose;
     251}
     252
     253/*!
     254   \return rose
     255   \sa setRose()
     256 */
     257QwtCompassRose* QwtCompass::rose()
     258{
     259    return m_data->rose;
     260}
     261
     262/*!
     263   Handles key events
     264
     265   Beside the keys described in QwtDial::keyPressEvent numbers
     266   from 1-9 (without 5) set the direction according to their
     267   position on the num pad.
     268
     269   \sa isReadOnly()
     270 */
     271void QwtCompass::keyPressEvent( QKeyEvent* kev )
    255272{
    256273    if ( isReadOnly() )
    … …  
    307324    }
    308325}
     326
     327#include "moc_qwt_compass.cpp"
Note: See TracChangeset for help on using the changeset viewer.