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
12 
13 #include "qwt_global.h"
14 #include "qwt_interval.h"
15 
16 #include <qvector.h>
17 #include <qrect.h>
18 
21 {
22 public:
24  QwtIntervalSample( double, const QwtInterval & );
25  QwtIntervalSample( double value, double min, double max );
26 
27  bool operator==( const QwtIntervalSample & ) const;
28  bool operator!=( const QwtIntervalSample & ) const;
29 
31  double value;
32 
35 };
36 
42  value( 0.0 )
43 {
44 }
45 
48  double v, const QwtInterval &intv ):
49  value( v ),
50  interval( intv )
51 {
52 }
53 
56  double v, double min, double max ):
57  value( v ),
58  interval( min, max )
59 {
60 }
61 
64  const QwtIntervalSample &other ) const
65 {
66  return value == other.value && interval == other.interval;
67 }
68 
71  const QwtIntervalSample &other ) const
72 {
73  return !( *this == other );
74 }
75 
78 {
79 public:
80  QwtSetSample();
81  explicit QwtSetSample( double, const QVector<double> & = QVector<double>() );
82 
83  bool operator==( const QwtSetSample &other ) const;
84  bool operator!=( const QwtSetSample &other ) const;
85 
86  double added() const;
87 
89  double value;
90 
93 };
94 
100  value( 0.0 )
101 {
102 }
103 
110 inline QwtSetSample::QwtSetSample( double v, const QVector< double > &s ):
111  value( v ),
112  set( s )
113 {
114 }
115 
117 inline bool QwtSetSample::operator==( const QwtSetSample &other ) const
118 {
119  return value == other.value && set == other.set;
120 }
121 
123 inline bool QwtSetSample::operator!=( const QwtSetSample &other ) const
124 {
125  return !( *this == other );
126 }
127 
129 inline double QwtSetSample::added() const
130 {
131  double y = 0.0;
132  for ( int i = 0; i < set.size(); i++ )
133  y += set[i];
134 
135  return y;
136 }
137 
148 {
149 public:
150  QwtOHLCSample( double time = 0.0,
151  double open = 0.0, double high = 0.0,
152  double low = 0.0, double close = 0.0 );
153 
154  QwtInterval boundingInterval() const;
155 
156  bool isValid() const;
157 
162  double time;
163 
165  double open;
166 
168  double high;
169 
171  double low;
172 
174  double close;
175 };
176 
177 
188  double o, double h, double l, double c ):
189  time( t ),
190  open( o ),
191  high( h ),
192  low( l ),
193  close( c )
194 {
195 }
196 
208 inline bool QwtOHLCSample::isValid() const
209 {
210  return ( low <= high )
211  && ( open >= low )
212  && ( open <= high )
213  && ( close >= low )
214  && ( close <= high );
215 }
216 
226 {
227  double minY = open;
228  minY = qMin( minY, high );
229  minY = qMin( minY, low );
230  minY = qMin( minY, close );
231 
232  double maxY = open;
233  maxY = qMax( maxY, high );
234  maxY = qMax( maxY, low );
235  maxY = qMax( maxY, close );
236 
237  return QwtInterval( minY, maxY );
238 }
239 
241 {
242 public:
243  QwtVectorFieldSample( double x = 0.0, double y = 0.0,
244  double vx = 0.0, double vy = 0.0 );
245 
246  QwtVectorFieldSample( const QPointF& pos,
247  double vx = 0.0, double vy = 0.0 );
248 
249  QPointF pos() const;
250 
251  bool isNull() const;
252 
253  double x;
254  double y;
255 
256  double vx;
257  double vy;
258 };
259 
261  double posX, double posY, double vectorX, double vectorY ):
262  x( posX ),
263  y( posY ),
264  vx( vectorX ),
265  vy( vectorY )
266 {
267 }
268 
270  const QPointF &pos, double vectorX, double vectorY ):
271  x( pos.x() ),
272  y( pos.y() ),
273  vx( vectorX ),
274  vy( vectorY )
275 {
276 }
277 
278 inline QPointF QwtVectorFieldSample::pos() const
279 {
280  return QPointF( x, y );
281 }
282 
283 inline bool QwtVectorFieldSample::isNull() const
284 {
285  return ( vx == 0.0 ) && ( vy == 0.0 );
286 }
287 
288 #endif
Open-High-Low-Close sample used in financial charts.
Definition: qwt_samples.h:147
enum MQTTPropertyCodes value
QwtInterval boundingInterval() const
Calculate the bounding interval of the OHLC values.
Definition: qwt_samples.h:225
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
relop
Definition: sol.hpp:5324
double value
value
Definition: qwt_samples.h:89
bool operator==(fp x, fp y)
Definition: format-inl.h:1167
A class representing an interval.
Definition: qwt_interval.h:22
double open
Opening price.
Definition: qwt_samples.h:165
#define QWT_EXPORT
Definition: qwt_global.h:38
bool operator!=(const QwtSetSample &other) const
Compare operator.
Definition: qwt_samples.h:123
double high
Highest price.
Definition: qwt_samples.h:168
A sample of the types (x1...xn, y) or (x, y1..yn)
Definition: qwt_samples.h:77
double low
Lowest price.
Definition: qwt_samples.h:171
double added() const
Definition: qwt_samples.h:129
bool operator==(const QwtIntervalSample &) const
Compare operator.
Definition: qwt_samples.h:63
QwtVectorFieldSample(double x=0.0, double y=0.0, double vx=0.0, double vy=0.0)
Definition: qwt_samples.h:260
#define min(A, B)
Definition: Log.c:64
#define max(A, B)
Definition: Socket.h:88
double close
Closing price.
Definition: qwt_samples.h:174
bool isNull() const
Definition: qwt_samples.h:283
A sample of the types (x1-x2, y) or (x, y1-y2)
Definition: qwt_samples.h:20
QPointF pos() const
Definition: qwt_samples.h:278
MQTTClient c
Definition: test10.c:1656
float time
Definition: mqtt_test.py:17
bool operator!=(const QwtIntervalSample &) const
Compare operator.
Definition: qwt_samples.h:70
bool isValid() const
Check if a sample is valid.
Definition: qwt_samples.h:208
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:187
double value
Value.
Definition: qwt_samples.h:31
bool operator==(const QwtSetSample &other) const
Compare operator.
Definition: qwt_samples.h:117
QVector< double > set
Vector of values associated to value.
Definition: qwt_samples.h:92
QwtInterval interval
Interval.
Definition: qwt_samples.h:34


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:10