Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_plot_seriesitem.h


Ignore:
Timestamp:
May 10, 2017, 3:20:54 PM (7 years ago)
Author:
stoecker
Message:

update qwt and qwtpolar, many QT5 fixes (unfinished)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_plot_seriesitem.h

    r4271 r8127  
    1515#include "qwt_scale_div.h"
    1616#include "qwt_series_data.h"
     17#include "qwt_series_store.h"
    1718
    1819/*!
    1920  \brief Base class for plot items representing a series of samples
    2021*/
    21 class QWT_EXPORT QwtPlotAbstractSeriesItem: public QwtPlotItem
     22class QWT_EXPORT QwtPlotSeriesItem: public QwtPlotItem,
     23    public virtual QwtAbstractSeriesStore
    2224{
    2325public:
    24     explicit QwtPlotAbstractSeriesItem( const QString &title = QString::null );
    25     explicit QwtPlotAbstractSeriesItem( const QwtText &title );
     26    explicit QwtPlotSeriesItem( const QString &title = QString::null );
     27    explicit QwtPlotSeriesItem( const QwtText &title );
    2628
    27     virtual ~QwtPlotAbstractSeriesItem();
     29    virtual ~QwtPlotSeriesItem();
    2830
    2931    void setOrientation( Qt::Orientation );
     
    4042      \param xMap Maps x-values into pixel coordinates.
    4143      \param yMap Maps y-values into pixel coordinates.
    42       \param canvasRect Contents rect of the canvas
     44      \param canvasRect Contents rectangle of the canvas
    4345      \param from Index of the first point to be painted
    4446      \param to Index of the last point to be painted. If to < 0 the
     
    4951        const QRectF &canvasRect, int from, int to ) const = 0;
    5052
     53    virtual QRectF boundingRect() const;
     54
     55    virtual void updateScaleDiv(
     56        const QwtScaleDiv &, const QwtScaleDiv & );
     57
     58protected:
     59    virtual void dataChanged();
     60
    5161private:
    5262    class PrivateData;
     
    5464};
    5565
    56 /*!
    57   \brief Class template for plot items representing a series of samples
    58 */
    59 template <typename T>
    60 class QwtPlotSeriesItem: public QwtPlotAbstractSeriesItem
    61 {
    62 public:
    63     explicit QwtPlotSeriesItem<T>( const QString &title = QString::null );
    64     explicit QwtPlotSeriesItem<T>( const QwtText &title );
    65 
    66     virtual ~QwtPlotSeriesItem<T>();
    67 
    68     void setData( QwtSeriesData<T> * );
    69 
    70     QwtSeriesData<T> *data();
    71     const QwtSeriesData<T> *data() const;
    72 
    73     size_t dataSize() const;
    74     T sample( int index ) const;
    75 
    76     virtual QRectF boundingRect() const;
    77     virtual void updateScaleDiv( const QwtScaleDiv &,
    78                                  const QwtScaleDiv & );
    79 
    80 protected:
    81     //! Series
    82     QwtSeriesData<T> *d_series;
    83 };
    84 
    85 /*!
    86   Constructor
    87   \param title Title of the series item
    88 */
    89 template <typename T>
    90 QwtPlotSeriesItem<T>::QwtPlotSeriesItem( const QString &title ):
    91     QwtPlotAbstractSeriesItem( QwtText( title ) ),
    92     d_series( NULL )
    93 {
    94 }
    95 
    96 /*!
    97   Constructor
    98   \param title Title of the series item
    99 */
    100 template <typename T>
    101 QwtPlotSeriesItem<T>::QwtPlotSeriesItem( const QwtText &title ):
    102     QwtPlotAbstractSeriesItem( title ),
    103     d_series( NULL )
    104 {
    105 }
    106 
    107 //! Destructor
    108 template <typename T>
    109 QwtPlotSeriesItem<T>::~QwtPlotSeriesItem()
    110 {
    111     delete d_series;
    112 }
    113 
    114 //! \return the the curve data
    115 template <typename T>
    116 inline QwtSeriesData<T> *QwtPlotSeriesItem<T>::data()
    117 {
    118     return d_series;
    119 }
    120 
    121 //! \return the the curve data
    122 template <typename T>
    123 inline const QwtSeriesData<T> *QwtPlotSeriesItem<T>::data() const
    124 {
    125     return d_series;
    126 }
    127 
    128 /*!
    129     \param index Index
    130     \return Sample at position index
    131 */
    132 template <typename T>
    133 inline T QwtPlotSeriesItem<T>::sample( int index ) const
    134 {
    135     return d_series ? d_series->sample( index ) : T();
    136 }
    137 
    138 /*!
    139   Assign a series of samples
    140 
    141   \param data Data
    142   \warning The item takes ownership of the data object, deleting
    143            it when its not used anymore.
    144 */
    145 template <typename T>
    146 void QwtPlotSeriesItem<T>::setData( QwtSeriesData<T> *data )
    147 {
    148     if ( d_series != data )
    149     {
    150         delete d_series;
    151         d_series = data;
    152         itemChanged();
    153     }
    154 }
    155 
    156 /*!
    157   Return the size of the data arrays
    158   \sa setData()
    159 */
    160 template <typename T>
    161 size_t QwtPlotSeriesItem<T>::dataSize() const
    162 {
    163     if ( d_series == NULL )
    164         return 0;
    165 
    166     return d_series->size();
    167 }
    168 
    169 /*!
    170   \return Bounding rectangle of the data.
    171   If there is no bounding rect, like for empty data the rectangle is invalid.
    172 
    173   \sa QwtSeriesData<T>::boundingRect(), QRectF::isValid()
    174 */
    175 template <typename T>
    176 QRectF QwtPlotSeriesItem<T>::boundingRect() const
    177 {
    178     if ( d_series == NULL )
    179         return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid
    180 
    181     return d_series->boundingRect();
    182 }
    183 
    184 /*!
    185    Update the rect of interest according to the current scale ranges
    186 
    187    \param xScaleDiv Scale division of the x-axis
    188    \param yScaleDiv Scale division of the y-axis
    189 
    190    \sa QwtSeriesData<T>::setRectOfInterest()
    191 */
    192 template <typename T>
    193 void QwtPlotSeriesItem<T>::updateScaleDiv(
    194     const QwtScaleDiv &xScaleDiv, const QwtScaleDiv &yScaleDiv )
    195 {
    196     const QRectF rect = QRectF(
    197         xScaleDiv.lowerBound(), yScaleDiv.lowerBound(),
    198         xScaleDiv.range(), yScaleDiv.range() );
    199 
    200     d_series->setRectOfInterest( rect );
    201 }
    202 
    20366#endif
Note: See TracChangeset for help on using the changeset viewer.