qwt_samples.h
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #ifndef QWT_SAMPLES_H
11 #define QWT_SAMPLES_H 1
12 
13 #include "qwt_global.h"
14 #include "qwt_interval.h"
15 #include <qvector.h>
16 #include <qrect.h>
17 
20 {
21 public:
23  QwtIntervalSample( double, const QwtInterval & );
24  QwtIntervalSample( double value, double min, double max );
25 
26  bool operator==( const QwtIntervalSample & ) const;
27  bool operator!=( const QwtIntervalSample & ) const;
28 
30  double value;
31 
34 };
35 
41  value( 0.0 )
42 {
43 }
44 
47  double v, const QwtInterval &intv ):
48  value( v ),
49  interval( intv )
50 {
51 }
52 
55  double v, double min, double max ):
56  value( v ),
57  interval( min, max )
58 {
59 }
60 
63  const QwtIntervalSample &other ) const
64 {
65  return value == other.value && interval == other.interval;
66 }
67 
70  const QwtIntervalSample &other ) const
71 {
72  return !( *this == other );
73 }
74 
77 {
78 public:
79  QwtSetSample();
80  explicit QwtSetSample( double, const QVector<double> & = QVector<double>() );
81 
82  bool operator==( const QwtSetSample &other ) const;
83  bool operator!=( const QwtSetSample &other ) const;
84 
85  double added() const;
86 
88  double value;
89 
91  QVector<double> set;
92 };
93 
99  value( 0.0 )
100 {
101 }
102 
109 inline QwtSetSample::QwtSetSample( double v, const QVector< double > &s ):
110  value( v ),
111  set( s )
112 {
113 }
114 
116 inline bool QwtSetSample::operator==( const QwtSetSample &other ) const
117 {
118  return value == other.value && set == other.set;
119 }
120 
122 inline bool QwtSetSample::operator!=( const QwtSetSample &other ) const
123 {
124  return !( *this == other );
125 }
126 
128 inline double QwtSetSample::added() const
129 {
130  double y = 0.0;
131  for ( int i = 0; i < set.size(); i++ )
132  y += set[i];
133 
134  return y;
135 }
136 
147 {
148 public:
149  QwtOHLCSample( double time = 0.0,
150  double open = 0.0, double high = 0.0,
151  double low = 0.0, double close = 0.0 );
152 
153  QwtInterval boundingInterval() const;
154 
155  bool isValid() const;
156 
161  double time;
162 
164  double open;
165 
167  double high;
168 
170  double low;
171 
173  double close;
174 };
175 
176 
187  double o, double h, double l, double c ):
188  time( t ),
189  open( o ),
190  high( h ),
191  low( l ),
192  close( c )
193 {
194 }
195 
207 inline bool QwtOHLCSample::isValid() const
208 {
209  return ( low <= high )
210  && ( open >= low )
211  && ( open <= high )
212  && ( close >= low )
213  && ( close <= high );
214 }
215 
225 {
226  double minY = open;
227  minY = qMin( minY, high );
228  minY = qMin( minY, low );
229  minY = qMin( minY, close );
230 
231  double maxY = open;
232  maxY = qMax( maxY, high );
233  maxY = qMax( maxY, low );
234  maxY = qMax( maxY, close );
235 
236  return QwtInterval( minY, maxY );
237 }
238 
239 #endif
Open-High-Low-Close sample used in financial charts.
Definition: qwt_samples.h:146
QwtInterval boundingInterval() const
Calculate the bounding interval of the OHLC values.
Definition: qwt_samples.h:224
double value
value
Definition: qwt_samples.h:88
A class representing an interval.
Definition: qwt_interval.h:26
double open
Opening price.
Definition: qwt_samples.h:164
#define QWT_EXPORT
Definition: qwt_global.h:38
bool operator==(optional< T > const &x, optional< T > const &y)
Definition: optional.hpp:854
bool operator!=(const QwtSetSample &other) const
Compare operator.
Definition: qwt_samples.h:122
TFSIMD_FORCE_INLINE const tfScalar & y() const
double high
Highest price.
Definition: qwt_samples.h:167
A sample of the types (x1...xn, y) or (x, y1..yn)
Definition: qwt_samples.h:76
double low
Lowest price.
Definition: qwt_samples.h:170
double added() const
Definition: qwt_samples.h:128
bool operator==(const QwtIntervalSample &) const
Compare operator.
Definition: qwt_samples.h:62
double close
Closing price.
Definition: qwt_samples.h:173
A sample of the types (x1-x2, y) or (x, y1-y2)
Definition: qwt_samples.h:19
T value
bool operator!=(const QwtIntervalSample &) const
Compare operator.
Definition: qwt_samples.h:69
int min(int a, int b)
bool isValid() const
Check if a sample is valid.
Definition: qwt_samples.h:207
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:186
double value
Value.
Definition: qwt_samples.h:30
int i
bool operator!=(optional< T > const &x, optional< T > const &y)
Definition: optional.hpp:859
bool operator==(const QwtSetSample &other) const
Compare operator.
Definition: qwt_samples.h:116
QVector< double > set
Vector of values associated to value.
Definition: qwt_samples.h:91
QwtInterval interval
Interval.
Definition: qwt_samples.h:33


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17