All Classes Functions Variables Typedefs Enumerations Enumerator Pages
qwt_samples.h
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_SAMPLES_H
#define QWT_SAMPLES_H 1
#include "qwt_global.h"
#include "qwt_interval.h"
#include <qvector.h>
#include <qrect.h>
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;
double value;
QwtInterval interval;
};
inline QwtIntervalSample::QwtIntervalSample():
value( 0.0 )
{
}
inline QwtIntervalSample::QwtIntervalSample(
double v, const QwtInterval &intv ):
value( v ),
interval( intv )
{
}
inline QwtIntervalSample::QwtIntervalSample(
double v, double min, double max ):
value( v ),
interval( min, max )
{
}
inline bool QwtIntervalSample::operator==(
const QwtIntervalSample &other ) const
{
return value == other.value && interval == other.interval;
}
inline bool QwtIntervalSample::operator!=(
const QwtIntervalSample &other ) const
{
return !( *this == other );
}
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;
double value;
QVector<double> set;
};
inline QwtSetSample::QwtSetSample():
value( 0.0 )
{
}
inline QwtSetSample::QwtSetSample( double v, const QVector< double > &s ):
value( v ),
set( s )
{
}
inline bool QwtSetSample::operator==( const QwtSetSample &other ) const
{
return value == other.value && set == other.set;
}
inline bool QwtSetSample::operator!=( const QwtSetSample &other ) const
{
return !( *this == other );
}
inline double QwtSetSample::added() const
{
double y = 0.0;
for ( int i = 0; i < set.size(); i++ )
y += set[i];
return y;
}
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;
double time;
double open;
double high;
double low;
double close;
};
inline QwtOHLCSample::QwtOHLCSample( double t,
double o, double h, double l, double c ):
time( t ),
open( o ),
high( h ),
low( l ),
close( c )
{
}
inline bool QwtOHLCSample::isValid() const
{
return ( low <= high )
&& ( open >= low )
&& ( open <= high )
&& ( close >= low )
&& ( close <= high );
}
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 );
}
#endif