Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_point_data.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_point_data.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_point_data.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 9 9 10 10 #include "qwt_point_data.h" 11 #include "qwt_math.h"12 #include <string.h>13 14 /*!15 Constructor16 17 \param x Array of x values18 \param y Array of y values19 20 \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()21 */22 QwtPointArrayData::QwtPointArrayData(23 const QVector<double> &x, const QVector<double> &y ):24 d_x( x ),25 d_y( y )26 {27 }28 29 /*!30 Constructor31 32 \param x Array of x values33 \param y Array of y values34 \param size Size of the x and y arrays35 \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()36 */37 QwtPointArrayData::QwtPointArrayData( const double *x,38 const double *y, size_t size )39 {40 d_x.resize( size );41 ::memcpy( d_x.data(), x, size * sizeof( double ) );42 43 d_y.resize( size );44 ::memcpy( d_y.data(), y, size * sizeof( double ) );45 }46 47 /*!48 \brief Calculate the bounding rectangle49 50 The bounding rectangle is calculated once by iterating over all51 points and is stored for all following requests.52 53 \return Bounding rectangle54 */55 QRectF QwtPointArrayData::boundingRect() const56 {57 if ( d_boundingRect.width() < 0 )58 d_boundingRect = qwtBoundingRect( *this );59 60 return d_boundingRect;61 }62 63 //! \return Size of the data set64 size_t QwtPointArrayData::size() const65 {66 return qMin( d_x.size(), d_y.size() );67 }68 69 /*!70 Return the sample at position i71 72 \param index Index73 \return Sample at position i74 */75 QPointF QwtPointArrayData::sample( size_t index ) const76 {77 return QPointF( d_x[int( index )], d_y[int( index )] );78 }79 80 //! \return Array of the x-values81 const QVector<double> &QwtPointArrayData::xData() const82 {83 return d_x;84 }85 86 //! \return Array of the y-values87 const QVector<double> &QwtPointArrayData::yData() const88 {89 return d_y;90 }91 92 /*!93 Constructor94 95 \param x Array of x values96 \param y Array of y values97 \param size Size of the x and y arrays98 99 \warning The programmer must assure that the memory blocks referenced100 by the pointers remain valid during the lifetime of the101 QwtPlotCPointer object.102 103 \sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples()104 */105 QwtCPointerData::QwtCPointerData(106 const double *x, const double *y, size_t size ):107 d_x( x ),108 d_y( y ),109 d_size( size )110 {111 }112 113 /*!114 \brief Calculate the bounding rectangle115 116 The bounding rectangle is calculated once by iterating over all117 points and is stored for all following requests.118 119 \return Bounding rectangle120 */121 QRectF QwtCPointerData::boundingRect() const122 {123 if ( d_boundingRect.width() < 0 )124 d_boundingRect = qwtBoundingRect( *this );125 126 return d_boundingRect;127 }128 129 //! \return Size of the data set130 size_t QwtCPointerData::size() const131 {132 return d_size;133 }134 135 /*!136 Return the sample at position i137 138 \param index Index139 \return Sample at position i140 */141 QPointF QwtCPointerData::sample( size_t index ) const142 {143 return QPointF( d_x[int( index )], d_y[int( index )] );144 }145 146 //! \return Array of the x-values147 const double *QwtCPointerData::xData() const148 {149 return d_x;150 }151 152 //! \return Array of the y-values153 const double *QwtCPointerData::yData() const154 {155 return d_y;156 }157 11 158 12 /*! … … 163 17 164 18 \sa setInterval(), setSize() 165 */ 19 */ 166 20 QwtSyntheticPointData::QwtSyntheticPointData( 167 size_t size, const QwtInterval &interval ):168 d_size( size ),169 d_interval( interval )21 size_t size, const QwtInterval& interval ) 22 : m_size( size ) 23 , m_interval( interval ) 170 24 { 171 25 } 172 26 173 27 /*! 174 Change the number of points 28 Change the number of points 175 29 176 \param size Number of points 177 \sa size(), setInterval() 178 */ 30 \param size Number of points 31 \sa size(), setInterval() 32 */ 179 33 void QwtSyntheticPointData::setSize( size_t size ) 180 34 { 181 d_size = size;35 m_size = size; 182 36 } 183 37 184 38 /*! 185 \return Number of points 186 \sa setSize(), interval() 187 */ 39 \return Number of points 40 \sa setSize(), interval() 41 */ 188 42 size_t QwtSyntheticPointData::size() const 189 43 { 190 return d_size;44 return m_size; 191 45 } 192 46 … … 196 50 \param interval Interval 197 51 \sa interval(), setSize() 198 */ 199 void QwtSyntheticPointData::setInterval( const QwtInterval &interval )52 */ 53 void QwtSyntheticPointData::setInterval( const QwtInterval& interval ) 200 54 { 201 d_interval = interval.normalized();55 m_interval = interval.normalized(); 202 56 } 203 57 … … 205 59 \return Bounding interval 206 60 \sa setInterval(), size() 207 */ 61 */ 208 62 QwtInterval QwtSyntheticPointData::interval() const 209 63 { 210 return d_interval;64 return m_interval; 211 65 } 212 66 … … 221 75 222 76 \sa rectOfInterest() 223 */ 224 void QwtSyntheticPointData::setRectOfInterest( const QRectF &rect )77 */ 78 void QwtSyntheticPointData::setRectOfInterest( const QRectF& rect ) 225 79 { 226 d_rectOfInterest = rect;227 d_intervalOfInterest = QwtInterval(80 m_rectOfInterest = rect; 81 m_intervalOfInterest = QwtInterval( 228 82 rect.left(), rect.right() ).normalized(); 229 83 } … … 232 86 \return "rectangle of interest" 233 87 \sa setRectOfInterest() 234 */ 88 */ 235 89 QRectF QwtSyntheticPointData::rectOfInterest() const 236 90 { 237 return d_rectOfInterest;91 return m_rectOfInterest; 238 92 } 239 93 240 94 /*! 241 \brief Calculate the bounding rectangle 95 \brief Calculate the bounding rectangle 242 96 243 This implementation iterates over all points, what could often 244 be implemented much faster using the characteristics of the series. 245 When there are many points it is recommended to overload and 246 reimplement this method using the characteristics of the series 247 ( if possible ). 97 This implementation iterates over all points, what could often 98 be implemented much faster using the characteristics of the series. 99 When there are many points it is recommended to overload and 100 reimplement this method using the characteristics of the series 101 ( if possible ). 248 102 249 \return Bounding rectangle 250 */ 103 \return Bounding rectangle 104 */ 251 105 QRectF QwtSyntheticPointData::boundingRect() const 252 106 { 253 if ( d_size == 0 ||254 !( d_interval.isValid() ||d_intervalOfInterest.isValid() ) )107 if ( m_size == 0 || 108 !( m_interval.isValid() || m_intervalOfInterest.isValid() ) ) 255 109 { 256 110 return QRectF( 1.0, 1.0, -2.0, -2.0 ); // something invalid … … 268 122 \warning For invalid indices ( index < 0 || index >= size() ) 269 123 (0, 0) is returned. 270 */ 124 */ 271 125 QPointF QwtSyntheticPointData::sample( size_t index ) const 272 126 { 273 if ( index >= d_size )127 if ( index >= m_size ) 274 128 return QPointF( 0, 0 ); 275 129 … … 291 145 292 146 \sa interval(), rectOfInterest(), y() 293 */ 147 */ 294 148 double QwtSyntheticPointData::x( uint index ) const 295 149 { 296 const QwtInterval &interval =d_interval.isValid() ?297 d_interval :d_intervalOfInterest;150 const QwtInterval& interval = m_interval.isValid() ? 151 m_interval : m_intervalOfInterest; 298 152 299 153 if ( !interval.isValid() ) 300 154 return 0.0; 301 155 302 if ( d_size <= 1 )156 if ( m_size <= 1 ) 303 157 return interval.minValue(); 304 158 305 const double dx = interval.width() / ( d_size - 1 );159 const double dx = interval.width() / ( m_size - 1 ); 306 160 return interval.minValue() + index * dx; 307 161 }
Note:
See TracChangeset
for help on using the changeset viewer.
