Qwt源码解读之样本类——QwtIntervalSample、QwtSetSample、QwtOHLCSample
2014-07-11 13:56
218 查看
QwtIntervalSample类
A sample of the types (x1-x2, y) or (x, y1-y2)
QwtIntervalSample类表征一个区间样点。
QwtSetSample类
A sample of the types (x1...xn, y) or (x, y1..yn)
QwtOHLCSample类
A sample of the types (x1-x2, y) or (x, y1-y2)
QwtIntervalSample类表征一个区间样点。
class QWT_EXPORT QwtIntervalSample { public: QwtIntervalSample();// value初始为0,interval为一个无效的区间[0.0. -1.0] QwtIntervalSample( double, const QwtInterval & ); QwtIntervalSample( double value, double min, double max ); bool operator==( const QwtIntervalSample & ) const; bool operator!=( const QwtIntervalSample & ) const; //! Value double value;//值 //! Interval QwtInterval interval;//区间 };这个类十分简单。成员变量声明为public,因此只提供了简单的构造函数和==、!=操作符。
QwtSetSample类
A sample of the types (x1...xn, y) or (x, y1..yn)
class QWT_EXPORT QwtSetSample { public: QwtSetSample(); QwtSetSample( double, const QVector<double> & = QVector<double>() ); bool operator==( const QwtSetSample &other ) const; bool operator!=( const QwtSetSample &other ) const; double added() const; //! value double value; //! Vector of values associated to value QVector<double> set; };一个成员函数
//! \return All values of the set added inline double QwtSetSample::added() const { double y = 0.0; for ( int i = 0; i < set.size(); i++ ) y += set[i]; return y; }返回set中所有值的和。
QwtOHLCSample类
/*! \brief Open-High-Low-Close sample used in financial charts In financial charts the movement of a price in a time interval is often represented by the opening/closing prices and the lowest/highest prices in this interval. \sa QwtTradingChartData */ class QWT_EXPORT QwtOHLCSample { public: QwtOHLCSample( double time = 0.0, double open = 0.0, double high = 0.0, double low = 0.0, double close = 0.0 ); QwtInterval boundingInterval() const; bool isValid() const; /*! Time of the sample, usually a number representing a specific interval - like a day. */ double time; //! Opening price double open; //! Highest price double high; //! Lowest price double low; //! Closing price double close; };成员函数
/*! \brief Check if a sample is valid A sample is valid, when all of the following checks are true: - low <= high - low <= open <= high - low <= close <= high \return True, when the sample is valid */ inline bool QwtOHLCSample::isValid() const { return ( low <= high ) && ( open >= low ) && ( open <= high ) && ( close >= low ) && ( close <= high ); }
/*! \brief Calculate the bounding interval of the OHLC values For valid samples the limits of this interval are always low/high. \return Bounding interval \sa isValid() */ inline QwtInterval QwtOHLCSample::boundingInterval() const { double minY = open; minY = qMin( minY, high ); minY = qMin( minY, low ); minY = qMin( minY, close ); double maxY = open; maxY = qMax( maxY, high ); maxY = qMax( maxY, low ); maxY = qMax( maxY, close ); return QwtInterval( minY, maxY ); }
相关文章推荐
- Qwt源码解读之QwtIntervalSample类和QwtSetSample类
- Qwt源码解读之QwtIntervalSample类和QwtSetSample类
- Qwt源码解读之QwtInterval 类
- Qwt源码解读之区间类——QwtInterval
- Qwt源码解读之QwtInterval 类
- Qwt源码解读之QwtPlotItem类(一)
- Qwt源码解读之棒图类——QwtPlotBarChart
- Qwt源码解读之QwtPoint3D类
- Qwt源码解读之QwtPlotItem类(二)
- Qwt源码解读之QwtLegend类
- Qwt源码解读之拾取操作类(二)
- Qwt源码解读之QwtPickerMachine类
- jdk1.8.0_45源码解读——Set接口和AbstractSet抽象类的实现
- Qwt源码解读之列矩形类——QwtColumnRect
- Qwt源码解读之标尺相关类
- Qwt源码解读之QwtWheel类
- Qwt源码解读之标尺相关类——日期时间标尺绘制类QwtDateScaleDraw
- Qwt源码解读之QwtClipper 类
- Qwt源码解读之QwtPlotItem类(二)
- caffe源码解读(12)-convert_imageset.cpp