Qwt User's Guide
6.1.0
Main Page
Related Pages
Classes
All
Classes
Functions
Variables
Typedefs
Enumerations
Enumerator
Pages
src
qwt_samples.h
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
19
class
QWT_EXPORT
QwtIntervalSample
20
{
21
public
:
22
QwtIntervalSample
();
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
33
QwtInterval
interval
;
34
};
35
40
inline
QwtIntervalSample::QwtIntervalSample
():
41
value( 0.0 )
42
{
43
}
44
46
inline
QwtIntervalSample::QwtIntervalSample
(
47
double
v,
const
QwtInterval
&intv ):
48
value( v ),
49
interval( intv )
50
{
51
}
52
54
inline
QwtIntervalSample::QwtIntervalSample
(
55
double
v,
double
min,
double
max ):
56
value( v ),
57
interval( min, max )
58
{
59
}
60
62
inline
bool
QwtIntervalSample::operator==
(
63
const
QwtIntervalSample
&other )
const
64
{
65
return
value
== other.
value
&&
interval
== other.
interval
;
66
}
67
69
inline
bool
QwtIntervalSample::operator!=
(
70
const
QwtIntervalSample
&other )
const
71
{
72
return
!( *
this
== other );
73
}
74
76
class
QWT_EXPORT
QwtSetSample
77
{
78
public
:
79
QwtSetSample
();
80
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
98
inline
QwtSetSample::QwtSetSample
():
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
146
class
QWT_EXPORT
QwtOHLCSample
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
186
inline
QwtOHLCSample::QwtOHLCSample
(
double
t,
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
224
inline
QwtInterval
QwtOHLCSample::boundingInterval
()
const
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
Generated by
1.8.3.1