qwt_samples.h
Go to the documentation of this file.
1 /******************************************************************************
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 
34  QwtInterval interval;
35 };
36 
42  : value( 0.0 )
43 {
44 }
45 
47 inline QwtIntervalSample::QwtIntervalSample( double v, const QwtInterval& intv )
48  : value( v )
49  , interval( intv )
50 {
51 }
52 
54 inline QwtIntervalSample::QwtIntervalSample( double v, double min, double max )
55  : value( v )
56  , interval( min, max )
57 {
58 }
59 
61 inline bool QwtIntervalSample::operator==( const QwtIntervalSample& other ) const
62 {
63  return value == other.value && interval == other.interval;
64 }
65 
67 inline bool QwtIntervalSample::operator!=( const QwtIntervalSample& other ) const
68 {
69  return !( *this == other );
70 }
71 
74 {
75  public:
76  QwtSetSample();
77  explicit QwtSetSample( double, const QVector< double >& = QVector< double >( ) );
78 
79  bool operator==( const QwtSetSample& other ) const;
80  bool operator!=( const QwtSetSample& other ) const;
81 
82  double added() const;
83 
85  double value;
86 
89 };
90 
96  : value( 0.0 )
97 {
98 }
99 
106 inline QwtSetSample::QwtSetSample( double v, const QVector< double >& s )
107  : value( v )
108  , set( s )
109 {
110 }
111 
113 inline bool QwtSetSample::operator==( const QwtSetSample& other ) const
114 {
115  return value == other.value && set == other.set;
116 }
117 
119 inline bool QwtSetSample::operator!=( const QwtSetSample& other ) const
120 {
121  return !( *this == other );
122 }
123 
125 inline double QwtSetSample::added() const
126 {
127  double y = 0.0;
128  for ( int i = 0; i < set.size(); i++ )
129  y += set[i];
130 
131  return y;
132 }
133 
144 {
145  public:
146  QwtOHLCSample( double time = 0.0,
147  double open = 0.0, double high = 0.0,
148  double low = 0.0, double close = 0.0 );
149 
150  QwtInterval boundingInterval() const;
151 
152  bool isValid() const;
153 
158  double time;
159 
161  double open;
162 
164  double high;
165 
167  double low;
168 
170  double close;
171 };
172 
183  double t, double o, double h, double l, double c )
184  : time( t )
185  , open( o )
186  , high( h )
187  , low( l )
188  , close( c )
189 {
190 }
191 
203 inline bool QwtOHLCSample::isValid() const
204 {
205  return ( low <= high )
206  && ( open >= low )
207  && ( open <= high )
208  && ( close >= low )
209  && ( close <= high );
210 }
211 
221 {
222  double minY = open;
223  minY = qMin( minY, high );
224  minY = qMin( minY, low );
225  minY = qMin( minY, close );
226 
227  double maxY = open;
228  maxY = qMax( maxY, high );
229  maxY = qMax( maxY, low );
230  maxY = qMax( maxY, close );
231 
232  return QwtInterval( minY, maxY );
233 }
234 
244 {
245  public:
246  QwtVectorFieldSample( double x = 0.0, double y = 0.0,
247  double vx = 0.0, double vy = 0.0 );
248 
249  QwtVectorFieldSample( const QPointF& pos,
250  double vx = 0.0, double vy = 0.0 );
251 
252  QPointF pos() const;
253 
254  bool isNull() const;
255 
257  double x;
258 
260  double y;
261 
263  double vx;
264 
266  double vy;
267 };
268 
278  double posX, double posY, double vectorX, double vectorY )
279  : x( posX )
280  , y( posY )
281  , vx( vectorX )
282  , vy( vectorY )
283 {
284 }
285 
294  const QPointF& pos, double vectorX, double vectorY )
295  : x( pos.x() )
296  , y( pos.y() )
297  , vx( vectorX )
298  , vy( vectorY )
299 {
300 }
301 
303 inline QPointF QwtVectorFieldSample::pos() const
304 {
305  return QPointF( x, y );
306 }
307 
309 inline bool QwtVectorFieldSample::isNull() const
310 {
311  return ( vx == 0.0 ) && ( vy == 0.0 );
312 }
313 
314 #endif
QwtOHLCSample::open
double open
Opening price.
Definition: qwt_samples.h:161
QwtIntervalSample::interval
QwtInterval interval
Interval.
Definition: qwt_samples.h:41
QwtVectorFieldSample
Sample used in vector fields.
Definition: qwt_samples.h:243
QwtVectorFieldSample::y
double y
y coordinate of the position
Definition: qwt_samples.h:260
s
XmlRpcServer s
QwtOHLCSample::close
double close
Closing price.
Definition: qwt_samples.h:170
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
QVector< double >
QwtSetSample::operator!=
bool operator!=(const QwtSetSample &other) const
Compare operator.
Definition: qwt_samples.h:119
QwtIntervalSample::operator==
bool operator==(const QwtIntervalSample &) const
Compare operator.
Definition: qwt_samples.h:61
qwt_global.h
QwtOHLCSample::isValid
bool isValid() const
Check if a sample is valid.
Definition: qwt_samples.h:203
qwt_interval.h
mqtt_test_proto.x
x
Definition: mqtt_test_proto.py:34
QwtVectorFieldSample::vy
double vy
y coordinate of the vector
Definition: qwt_samples.h:266
mqtt_test_proto.y
y
Definition: mqtt_test_proto.py:35
QwtOHLCSample::time
double time
Definition: qwt_samples.h:158
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:22
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
QwtSetSample::added
double added() const
Definition: qwt_samples.h:125
QwtSetSample
A sample of the types (x1...xn, y) or (x, y1..yn)
Definition: qwt_samples.h:73
operator==
bool operator==(QwtEventPattern::MousePattern b1, QwtEventPattern::MousePattern b2)
Compare operator.
Definition: qwt_event_pattern.h:228
mqtt_test.time
float time
Definition: mqtt_test.py:17
QwtOHLCSample::low
double low
Lowest price.
Definition: qwt_samples.h:167
QwtVectorFieldSample::pos
QPointF pos() const
Definition: qwt_samples.h:303
sol::operator!=
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
\group relop
Definition: sol.hpp:6020
QwtSetSample::QwtSetSample
QwtSetSample()
Definition: qwt_samples.h:95
detail::set
constexpr auto set(type rhs) -> int
Definition: core.h:627
QwtIntervalSample
A sample of the types (x1-x2, y) or (x, y1-y2)
Definition: qwt_samples.h:20
QwtOHLCSample::boundingInterval
QwtInterval boundingInterval() const
Calculate the bounding interval of the OHLC values.
Definition: qwt_samples.h:220
QwtVectorFieldSample::vx
double vx
x coordinate of the vector
Definition: qwt_samples.h:263
QwtSetSample::operator==
bool operator==(const QwtSetSample &other) const
Compare operator.
Definition: qwt_samples.h:113
QwtOHLCSample::high
double high
Highest price.
Definition: qwt_samples.h:164
QwtSetSample::set
QVector< double > set
Vector of values associated to value.
Definition: qwt_samples.h:88
QwtVectorFieldSample::x
double x
x coordinate of the position
Definition: qwt_samples.h:257
QWT_EXPORT
#define QWT_EXPORT
Definition: qwt_global.h:38
QwtIntervalSample::operator!=
bool operator!=(const QwtIntervalSample &) const
Compare operator.
Definition: qwt_samples.h:67
QwtVectorFieldSample::isNull
bool isNull() const
Definition: qwt_samples.h:309
QwtSetSample::value
double value
value
Definition: qwt_samples.h:85
QwtOHLCSample
Open-High-Low-Close sample used in financial charts.
Definition: qwt_samples.h:143
QwtIntervalSample::QwtIntervalSample
QwtIntervalSample()
Definition: qwt_samples.h:41
QwtAxis::isValid
bool isValid(int axisPos)
Definition: qwt_axis.h:45
QwtIntervalSample::value
double value
Value.
Definition: qwt_samples.h:38


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46