Loading...
Searching...
No Matches
qwt_samples.h
/******************************************************************************
* 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
#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();
explicit 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 );
}
class QWT_EXPORT QwtVectorFieldSample
{
public:
QwtVectorFieldSample( double x = 0.0, double y = 0.0,
double vx = 0.0, double vy = 0.0 );
QwtVectorFieldSample( const QPointF& pos,
double vx = 0.0, double vy = 0.0 );
QPointF pos() const;
bool isNull() const;
double x;
double y;
double vx;
double vy;
};
inline QwtVectorFieldSample::QwtVectorFieldSample(
double posX, double posY, double vectorX, double vectorY )
: x( posX )
, y( posY )
, vx( vectorX )
, vy( vectorY )
{
}
inline QwtVectorFieldSample::QwtVectorFieldSample(
const QPointF& pos, double vectorX, double vectorY )
: x( pos.x() )
, y( pos.y() )
, vx( vectorX )
, vy( vectorY )
{
}
inline QPointF QwtVectorFieldSample::pos() const
{
return QPointF( x, y );
}
inline bool QwtVectorFieldSample::isNull() const
{
return ( vx == 0.0 ) && ( vy == 0.0 );
}
#endif
QVector< double >
QwtInterval
A class representing an interval.
Definition qwt_interval.h:23
QwtIntervalSample
A sample of the types (x1-x2, y) or (x, y1-y2)
Definition qwt_samples.h:21
QwtIntervalSample::interval
QwtInterval interval
Interval.
Definition qwt_samples.h:34
QwtIntervalSample::operator==
bool operator==(const QwtIntervalSample &) const
Compare operator.
Definition qwt_samples.h:61
QwtIntervalSample::operator!=
bool operator!=(const QwtIntervalSample &) const
Compare operator.
Definition qwt_samples.h:67
QwtIntervalSample::QwtIntervalSample
QwtIntervalSample()
Definition qwt_samples.h:41
QwtIntervalSample::value
double value
Value.
Definition qwt_samples.h:31
QwtOHLCSample
Open-High-Low-Close sample used in financial charts.
Definition qwt_samples.h:144
QwtOHLCSample::high
double high
Highest price.
Definition qwt_samples.h:164
QwtOHLCSample::isValid
bool isValid() const
Check if a sample is valid.
Definition qwt_samples.h:203
QwtOHLCSample::open
double open
Opening price.
Definition qwt_samples.h:161
QwtOHLCSample::close
double close
Closing price.
Definition qwt_samples.h:170
QwtOHLCSample::time
double time
Definition qwt_samples.h:158
QwtOHLCSample::boundingInterval
QwtInterval boundingInterval() const
Calculate the bounding interval of the OHLC values.
Definition qwt_samples.h:220
QwtOHLCSample::QwtOHLCSample
QwtOHLCSample(double time=0.0, double open=0.0, double high=0.0, double low=0.0, double close=0.0)
Definition qwt_samples.h:182
QwtOHLCSample::low
double low
Lowest price.
Definition qwt_samples.h:167
QwtSetSample
A sample of the types (x1...xn, y) or (x, y1..yn)
Definition qwt_samples.h:74
QwtSetSample::added
double added() const
Definition qwt_samples.h:125
QwtSetSample::value
double value
value
Definition qwt_samples.h:85
QwtSetSample::set
QVector< double > set
Vector of values associated to value.
Definition qwt_samples.h:88
QwtSetSample::operator!=
bool operator!=(const QwtSetSample &other) const
Compare operator.
Definition qwt_samples.h:119
QwtSetSample::operator==
bool operator==(const QwtSetSample &other) const
Compare operator.
Definition qwt_samples.h:113
QwtSetSample::QwtSetSample
QwtSetSample()
Definition qwt_samples.h:95
QwtVectorFieldSample
Sample used in vector fields.
Definition qwt_samples.h:244
QwtVectorFieldSample::y
double y
y coordinate of the position
Definition qwt_samples.h:260
QwtVectorFieldSample::QwtVectorFieldSample
QwtVectorFieldSample(double x=0.0, double y=0.0, double vx=0.0, double vy=0.0)
Constructor.
Definition qwt_samples.h:277
QwtVectorFieldSample::pos
QPointF pos() const
Definition qwt_samples.h:303
QwtVectorFieldSample::isNull
bool isNull() const
Definition qwt_samples.h:309
QwtVectorFieldSample::vx
double vx
x coordinate of the vector
Definition qwt_samples.h:263
QwtVectorFieldSample::x
double x
x coordinate of the position
Definition qwt_samples.h:257
QwtVectorFieldSample::vy
double vy
y coordinate of the vector
Definition qwt_samples.h:266