Qwt源码解读之QwtIntervalSample类和QwtSetSample类

QwtIntervalSample类表征一个区间样点,即(dx, y)或者 (x, dy) [A sample of the types (x1-x2, y) or (x, y1-y2)]。

代码分析:

//! \brief A sample of the types(x1-x2,y)or(x,y1-y2)
class QWT_EXPORT QwtIntervalSample
{
public:
    QwtIntervalSample();
    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;
};
这个类十分简单。
1)作者将属性interval和value 声明为public, 所以没有提供相应的访问函数。
2)除了构造函数以外,还提供了相等与不等于操作符函数。
------------------------------------------------

QwtIntervalSample类表征 A sample of the types (x1...xn, y) or (x, y1..yn) 。
代码分析:
这个类同样十分简单。

//! \brief A sample of the types(x1...xn,y)or(x,y1..yn)
class QWT_EXPORT QwtSetSample
{
public:
    QwtSetSample();

    bool operator==( const QwtSetSample &other ) const;
    bool operator!=( const QwtSetSample &other ) const;

    //! value
    double value;
    //! Vector of values associated to value
    QVector set;
};
这两个简单的类,我们在编码中时常将其定义成纯数据的结构体(struct)。那样初始化常存在问题,面向过程的味道较重。


你可能感兴趣的:(源码解读)