Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_plot_seriesitem.h
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_seriesitem.h
r4271 r8127 15 15 #include "qwt_scale_div.h" 16 16 #include "qwt_series_data.h" 17 #include "qwt_series_store.h" 17 18 18 19 /*! 19 20 \brief Base class for plot items representing a series of samples 20 21 */ 21 class QWT_EXPORT QwtPlotAbstractSeriesItem: public QwtPlotItem 22 class QWT_EXPORT QwtPlotSeriesItem: public QwtPlotItem, 23 public virtual QwtAbstractSeriesStore 22 24 { 23 25 public: 24 explicit QwtPlot AbstractSeriesItem( const QString &title = QString::null );25 explicit QwtPlot AbstractSeriesItem( const QwtText &title );26 explicit QwtPlotSeriesItem( const QString &title = QString::null ); 27 explicit QwtPlotSeriesItem( const QwtText &title ); 26 28 27 virtual ~QwtPlot AbstractSeriesItem();29 virtual ~QwtPlotSeriesItem(); 28 30 29 31 void setOrientation( Qt::Orientation ); … … 40 42 \param xMap Maps x-values into pixel coordinates. 41 43 \param yMap Maps y-values into pixel coordinates. 42 \param canvasRect Contents rect of the canvas44 \param canvasRect Contents rectangle of the canvas 43 45 \param from Index of the first point to be painted 44 46 \param to Index of the last point to be painted. If to < 0 the … … 49 51 const QRectF &canvasRect, int from, int to ) const = 0; 50 52 53 virtual QRectF boundingRect() const; 54 55 virtual void updateScaleDiv( 56 const QwtScaleDiv &, const QwtScaleDiv & ); 57 58 protected: 59 virtual void dataChanged(); 60 51 61 private: 52 62 class PrivateData; … … 54 64 }; 55 65 56 /*!57 \brief Class template for plot items representing a series of samples58 */59 template <typename T>60 class QwtPlotSeriesItem: public QwtPlotAbstractSeriesItem61 {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 //! Series82 QwtSeriesData<T> *d_series;83 };84 85 /*!86 Constructor87 \param title Title of the series item88 */89 template <typename T>90 QwtPlotSeriesItem<T>::QwtPlotSeriesItem( const QString &title ):91 QwtPlotAbstractSeriesItem( QwtText( title ) ),92 d_series( NULL )93 {94 }95 96 /*!97 Constructor98 \param title Title of the series item99 */100 template <typename T>101 QwtPlotSeriesItem<T>::QwtPlotSeriesItem( const QwtText &title ):102 QwtPlotAbstractSeriesItem( title ),103 d_series( NULL )104 {105 }106 107 //! Destructor108 template <typename T>109 QwtPlotSeriesItem<T>::~QwtPlotSeriesItem()110 {111 delete d_series;112 }113 114 //! \return the the curve data115 template <typename T>116 inline QwtSeriesData<T> *QwtPlotSeriesItem<T>::data()117 {118 return d_series;119 }120 121 //! \return the the curve data122 template <typename T>123 inline const QwtSeriesData<T> *QwtPlotSeriesItem<T>::data() const124 {125 return d_series;126 }127 128 /*!129 \param index Index130 \return Sample at position index131 */132 template <typename T>133 inline T QwtPlotSeriesItem<T>::sample( int index ) const134 {135 return d_series ? d_series->sample( index ) : T();136 }137 138 /*!139 Assign a series of samples140 141 \param data Data142 \warning The item takes ownership of the data object, deleting143 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 arrays158 \sa setData()159 */160 template <typename T>161 size_t QwtPlotSeriesItem<T>::dataSize() const162 {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() const177 {178 if ( d_series == NULL )179 return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid180 181 return d_series->boundingRect();182 }183 184 /*!185 Update the rect of interest according to the current scale ranges186 187 \param xScaleDiv Scale division of the x-axis188 \param yScaleDiv Scale division of the y-axis189 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 203 66 #endif
Note:
See TracChangeset
for help on using the changeset viewer.