QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_samples.h
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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_SAMPLES_H
28#define QWT_SAMPLES_H
29
30#include "qwt_global.h"
31#include "qwt_interval.h"
32
33#include <qvector.h>
34#include <qrect.h>
35
49class QWT_EXPORT QwtStatisticalSample
50{
51public:
62 QwtStatisticalSample(double position = 0.0);
63
65 double position;
66
68 double lower;
69
71 double upper;
72
74 double center;
75};
76
78 : position(pos)
79 , lower(0.0)
80 , upper(0.0)
81 , center(0.0)
82{
83}
84
96class QWT_EXPORT QwtIntervalSample
97{
98public:
100 QwtIntervalSample(double, const QwtInterval&);
101 QwtIntervalSample(double value, double min, double max);
102
103 bool operator==(const QwtIntervalSample&) const;
104 bool operator!=(const QwtIntervalSample&) const;
105
107 double value;
108
111};
112
124{
125}
126
139inline QwtIntervalSample::QwtIntervalSample(double v, const QwtInterval& intv) : value(v), interval(intv)
140{
141}
142
157inline QwtIntervalSample::QwtIntervalSample(double v, double min, double max) : value(v), interval(min, max)
158{
159}
160
170{
171 return value == other.value && interval == other.interval;
172}
173
183{
184 return !(*this == other);
185}
186
199class QWT_EXPORT QwtSetSample
200{
201public:
202 QwtSetSample();
203 explicit QwtSetSample(double, const QVector< double >& = QVector< double >());
204
205 bool operator==(const QwtSetSample& other) const;
206 bool operator!=(const QwtSetSample& other) const;
207
208 double added() const;
209
211 double value;
212
215};
216
227inline QwtSetSample::QwtSetSample() : value(0.0)
228{
229}
230
243inline QwtSetSample::QwtSetSample(double v, const QVector< double >& s) : value(v), set(s)
244{
245}
246
255inline bool QwtSetSample::operator==(const QwtSetSample& other) const
256{
257 return value == other.value && set == other.set;
258}
259
268inline bool QwtSetSample::operator!=(const QwtSetSample& other) const
269{
270 return !(*this == other);
271}
272
283inline double QwtSetSample::added() const
284{
285 double y = 0.0;
286 for (int i = 0; i < set.size(); i++)
287 y += set[ i ];
288
289 return y;
290}
291
307class QWT_EXPORT QwtOHLCSample
308{
309public:
310 QwtOHLCSample(double time = 0.0, double open = 0.0, double high = 0.0, double low = 0.0, double close = 0.0);
311
312 QwtInterval boundingInterval() const;
313
314 bool isValid() const;
315
320 double time;
321
323 double open;
324
326 double high;
327
329 double low;
330
332 double close;
333};
334
353inline QwtOHLCSample::QwtOHLCSample(double t, double o, double h, double l, double c)
354 : time(t), open(o), high(h), low(l), close(c)
355{
356}
357
376inline bool QwtOHLCSample::isValid() const
377{
378 return (low <= high) && (open >= low) && (open <= high) && (close >= low) && (close <= high);
379}
380
396{
397 double minY = open;
398 minY = qMin(minY, high);
399 minY = qMin(minY, low);
400 minY = qMin(minY, close);
401
402 double maxY = open;
403 maxY = qMax(maxY, high);
404 maxY = qMax(maxY, low);
405 maxY = qMax(maxY, close);
406
407 return QwtInterval(minY, maxY);
408}
409
424class QWT_EXPORT QwtVectorFieldSample
425{
426public:
427 QwtVectorFieldSample(double x = 0.0, double y = 0.0, double vx = 0.0, double vy = 0.0);
428
429 QwtVectorFieldSample(const QPointF& pos, double vx = 0.0, double vy = 0.0);
430
431 QPointF pos() const;
432
433 bool isNull() const;
434
436 double x;
437
439 double y;
440
442 double vx;
443
445 double vy;
446};
447
464inline QwtVectorFieldSample::QwtVectorFieldSample(double posX, double posY, double vectorX, double vectorY)
465 : x(posX), y(posY), vx(vectorX), vy(vectorY)
466{
467}
468
483inline QwtVectorFieldSample::QwtVectorFieldSample(const QPointF& pos, double vectorX, double vectorY)
484 : x(pos.x()), y(pos.y()), vx(vectorX), vy(vectorY)
485{
486}
487
498inline QPointF QwtVectorFieldSample::pos() const
499{
500 return QPointF(x, y);
501}
502
514{
515 return (vx == 0.0) && (vy == 0.0);
516}
517
533class QWT_EXPORT QwtBoxSample : public QwtStatisticalSample
534{
535public:
546 QwtBoxSample(double position = 0.0);
547
568 QwtBoxSample(double position, double whiskerLower, double q1,
569 double median, double q3, double whiskerUpper);
570
581 bool isValid() const;
582
593 QwtInterval boundingInterval() const;
594
605 QwtInterval boxInterval() const;
606
609
611 double q1;
612
614 double median;
615
617 double q3;
618
621
624};
625
628 , whiskerLower(0.0)
629 , q1(0.0)
630 , median(0.0)
631 , q3(0.0)
632 , whiskerUpper(0.0)
633 , outlierCount(0)
634{
635}
636
637inline QwtBoxSample::QwtBoxSample(double pos, double wl, double q1v,
638 double med, double q3v, double wu)
640 , whiskerLower(wl)
641 , q1(q1v)
642 , median(med)
643 , q3(q3v)
644 , whiskerUpper(wu)
645 , outlierCount(0)
646{
647 center = median;
648}
649
650inline bool QwtBoxSample::isValid() const
651{
652 return (whiskerLower <= q1) && (q1 <= median) &&
653 (median <= q3) && (q3 <= whiskerUpper);
654}
655
660
662{
663 return QwtInterval(q1, q3);
664}
665
679class QWT_EXPORT QwtBoxOutlierSample
680{
681public:
690 QwtBoxOutlierSample(double boxPosition = 0.0);
691
704 QwtBoxOutlierSample(double boxPosition, const QVector<double>& values);
705
714 QwtBoxOutlierSample(double boxPosition, QVector<double>&& values);
715
717 bool isEmpty() const { return values.isEmpty(); }
718
720 int count() const { return values.size(); }
721
724
727};
728
730 : boxPosition(pos)
731 , values()
732{
733}
734
736 : boxPosition(pos)
737 , values(vals)
738{
739}
740
742 : boxPosition(pos)
743 , values(std::move(vals))
744{
745}
746
747#endif
单个箱线图位置的异常值
Definition qwt_samples.h:680
bool isEmpty() const
Check if no outliers present
Definition qwt_samples.h:717
double boxPosition
Position of the parent box (matches QwtBoxSample.position)
Definition qwt_samples.h:723
QVector< double > values
All outlier values for this box
Definition qwt_samples.h:726
int count() const
Get number of outliers
Definition qwt_samples.h:720
QwtBoxOutlierSample(double boxPosition=0.0)
默认构造函数
Definition qwt_samples.h:729
箱线图(boxplot)样本
Definition qwt_samples.h:534
double q3
Third quartile (75th percentile)
Definition qwt_samples.h:617
double whiskerLower
Lower whisker endpoint
Definition qwt_samples.h:608
double whiskerUpper
Upper whisker endpoint
Definition qwt_samples.h:620
int outlierCount
Number of outliers (stored separately, this is count only)
Definition qwt_samples.h:623
QwtBoxSample(double position=0.0)
默认构造函数
Definition qwt_samples.h:626
QwtInterval boundingInterval() const
获取包含须须的边界区间
Definition qwt_samples.h:656
bool isValid() const
检查样本顺序是否有效
Definition qwt_samples.h:650
double q1
First quartile (25th percentile)
Definition qwt_samples.h:611
QwtInterval boxInterval() const
获取箱体区间(Q1 到 Q3)
Definition qwt_samples.h:661
double median
Median (50th percentile) - also stored in inherited 'center' field
Definition qwt_samples.h:614
类型为 (x1-x2, y) 或 (x, y1-y2) 的样本
Definition qwt_samples.h:97
QwtInterval interval
Interval
Definition qwt_samples.h:110
bool operator==(const QwtIntervalSample &) const
相等比较运算符
Definition qwt_samples.h:169
bool operator!=(const QwtIntervalSample &) const
不相等比较运算符
Definition qwt_samples.h:182
QwtIntervalSample()
默认构造函数
Definition qwt_samples.h:123
double value
Value
Definition qwt_samples.h:107
表示区间的类
Definition qwt_interval.h:45
用于金融图表的开盘-最高-最低-收盘样本
Definition qwt_samples.h:308
double high
Highest price
Definition qwt_samples.h:326
bool isValid() const
检查样本是否有效
Definition qwt_samples.h:376
double open
Opening price
Definition qwt_samples.h:323
double close
Closing price
Definition qwt_samples.h:332
double time
Time of the sample, usually a number representing a specific interval - like a day.
Definition qwt_samples.h:320
QwtInterval boundingInterval() const
计算 OHLC 值的边界区间
Definition qwt_samples.h:395
QwtOHLCSample(double time=0.0, double open=0.0, double high=0.0, double low=0.0, double close=0.0)
包含所有 OHLC 值的构造函数
Definition qwt_samples.h:353
double low
Lowest price
Definition qwt_samples.h:329
类型为 (x1...xn, y) 或 (x, y1..yn) 的样本
Definition qwt_samples.h:200
double added() const
返回集合中所有值的总和
Definition qwt_samples.h:283
double value
value
Definition qwt_samples.h:211
QVector< double > set
Vector of values associated to value
Definition qwt_samples.h:214
bool operator!=(const QwtSetSample &other) const
不相等比较运算符
Definition qwt_samples.h:268
bool operator==(const QwtSetSample &other) const
相等比较运算符
Definition qwt_samples.h:255
QwtSetSample()
默认构造函数
Definition qwt_samples.h:227
统计样本的基类,包含位置和范围
Definition qwt_samples.h:50
double lower
Lower bound of the statistical range
Definition qwt_samples.h:68
double position
Position on the "time" axis (x for vertical, y for horizontal orientation)
Definition qwt_samples.h:65
QwtStatisticalSample(double position=0.0)
默认构造函数
Definition qwt_samples.h:77
double upper
Upper bound of the statistical range
Definition qwt_samples.h:71
double center
Central reference value
Definition qwt_samples.h:74
用于向量场的样本
Definition qwt_samples.h:425
double y
y coordinate of the position
Definition qwt_samples.h:439
QwtVectorFieldSample(double x=0.0, double y=0.0, double vx=0.0, double vy=0.0)
带位置和向量坐标的构造函数
Definition qwt_samples.h:464
QPointF pos() const
返回 QPointF 格式的位置
Definition qwt_samples.h:498
bool isNull() const
检查向量是否为空
Definition qwt_samples.h:513
double vx
x coordinate of the vector
Definition qwt_samples.h:442
double x
x coordinate of the position
Definition qwt_samples.h:436
double vy
y coordinate of the vector
Definition qwt_samples.h:445