QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_plot_boxchart.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 *****************************************************************************/
11
12#ifndef QWT_PLOT_BOXCHART_H
13#define QWT_PLOT_BOXCHART_H
14
15#include "qwt_global.h"
16#include "qwt_plot_seriesitem.h"
17#include "qwt_series_store.h"
18#include "qwt_samples.h"
19
20class QwtSymbol;
21template< typename T >
22class QwtSeriesData;
23
36class QWT_EXPORT QwtPlotBoxChart : public QwtPlotSeriesItem, public QwtSeriesStore< QwtBoxSample >
37{
38public:
43 {
46
49
52
54 Notch
55 };
56
61 {
64
67
69 MinMaxLine
70 };
71
76 {
78 ClipBoxes = 0x01,
79
81 ClipOutliers = 0x02,
82
84 ImageBuffer = 0x04
85 };
86
87 Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute)
88
89
92 explicit QwtPlotBoxChart(const QString& title = QString());
93
97 explicit QwtPlotBoxChart(const QwtText& title);
98
102 ~QwtPlotBoxChart() override;
103
104 // Get runtime type information
105 virtual int rtti() const override;
106
107 // Attach the box chart to a plot (applies color cycle if pen not user-set)
108 void attach(QwtPlot* plot) override;
109
110 // Set paint attribute
111 void setPaintAttribute(PaintAttribute, bool on = true);
112
113 // Test paint attribute
114 bool testPaintAttribute(PaintAttribute) const;
115
116 // Set box samples
117 void setSamples(const QVector< QwtBoxSample >&);
118 void setSamples(QwtSeriesData< QwtBoxSample >*);
119
120 // Set outlier samples (optional)
121 void setOutliers(const QVector< QwtBoxOutlierSample >&);
122 void setOutliers(QwtSeriesData< QwtBoxOutlierSample >*);
123
124 // Get outlier data
125 const QwtSeriesData< QwtBoxOutlierSample >* outlierData() const;
126
127 // Set box style
128 void setBoxStyle(BoxStyle);
129 BoxStyle boxStyle() const;
130
131 // Set whisker style
132 void setWhiskerStyle(WhiskerStyle);
133 WhiskerStyle whiskerStyle() const;
134
135 // Set orientation (vertical: x-position, horizontal: y-position)
136 void setOrientation(Qt::Orientation);
137 Qt::Orientation orientation() const;
138
139 // Set box width in scale coordinates
140 void setBoxExtent(double extent);
141 double boxExtent() const;
142
143 // Set minimum box width in pixels
144 void setMinBoxWidth(double pixels);
145 double minBoxWidth() const;
146
147 // Set maximum box width in pixels (negative = unlimited)
148 void setMaxBoxWidth(double pixels);
149 double maxBoxWidth() const;
150
151 // Set pen for box outline and whiskers
152 void setPen(const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine);
153 void setPen(const QPen&);
154 const QPen& pen() const;
155
156 // Set brush for box body fill
157 void setBrush(const QBrush&);
158 const QBrush& brush() const;
159
160 // Set pen for median line
161 void setMedianPen(const QPen&);
162 QPen medianPen() const;
163
164 // Set symbol for outliers
165 void setOutlierSymbol(const QwtSymbol*);
166 const QwtSymbol* outlierSymbol() const;
167
168 // Set symbol for mean marker
169 void setMeanSymbol(const QwtSymbol*);
170 const QwtSymbol* meanSymbol() const;
171
172 // Show/hide median line
173 void setMedianVisible(bool);
174 bool isMedianVisible() const;
175
176 // Show/hide mean marker
177 void setMeanVisible(bool);
178 bool isMeanVisible() const;
179
180 // Set outlier jitter width (for overlapping outliers)
181 void setOutlierJitter(double jitterWidth);
182 double outlierJitter() const;
183
184 // Draw the series
185 virtual void drawSeries(QPainter*,
186 const QwtScaleMap& xMap,
187 const QwtScaleMap& yMap,
188 const QRectF& canvasRect,
189 int from,
190 int to) const override;
191
192 // Get bounding rectangle
193 virtual QRectF boundingRect() const override;
194
195 // Get legend icon
196 virtual QwtGraphic legendIcon(int index, const QSizeF&) const override;
197
198protected:
200 void init();
201
203 virtual double scaledBoxWidth(const QwtScaleMap& posMap, const QwtScaleMap& valueMap, const QRectF& canvasRect) const;
204
206 virtual void
207 drawBox(QPainter*, const QwtBoxSample&, Qt::Orientation, double boxWidth, double posPixel, const QwtScaleMap& valueMap) const;
208
210 virtual void drawWhiskers(QPainter*,
211 const QwtBoxSample&,
212 Qt::Orientation,
213 double boxWidth,
214 double posPixel,
215 const QwtScaleMap& valueMap) const;
216
218 virtual void drawMedian(QPainter*,
219 const QwtBoxSample&,
220 Qt::Orientation,
221 double boxWidth,
222 double posPixel,
223 const QwtScaleMap& valueMap) const;
224
226 virtual void drawOutliers(QPainter*,
227 const QwtScaleMap& posMap,
228 const QwtScaleMap& valueMap,
229 const QRectF& canvasRect,
230 int from,
231 int to) const;
232
234 virtual void drawOutlierSymbol(QPainter*, double posPixel, double valuePixel, const QwtSymbol& symbol) const;
235
236private:
237 QWT_DECLARE_PRIVATE(QwtPlotBoxChart)
238
240};
241
242Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotBoxChart::PaintAttributes)
243
244#endif // QWT_PLOT_BOXCHART_H
Sample for box-and-whisker plot (boxplot) visualization
Definition qwt_samples.h:363
A paint device for scalable graphics
Definition qwt_graphic.h:85
Plot item for box-and-whisker (boxplot) visualization
Definition qwt_plot_boxchart.h:37
WhiskerStyle
Whisker display style
Definition qwt_plot_boxchart.h:61
@ NoWhiskers
No whisker lines drawn
Definition qwt_plot_boxchart.h:63
@ StandardWhisker
Traditional T-bar whiskers with horizontal caps (default)
Definition qwt_plot_boxchart.h:66
PaintAttribute
Paint attributes for performance optimization
Definition qwt_plot_boxchart.h:76
BoxStyle
Box body display style
Definition qwt_plot_boxchart.h:43
@ Diamond
Diamond shape connecting extremes
Definition qwt_plot_boxchart.h:51
@ Rect
Traditional rectangular box (Q1-Q3)
Definition qwt_plot_boxchart.h:48
@ NoBox
No box body, only whiskers and outliers
Definition qwt_plot_boxchart.h:45
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
Return a legend icon
Definition qwt_plot_item.cpp:420
virtual int rtti() const
Runtime type information
Definition qwt_plot_item.cpp:155
virtual void attach(QwtPlot *plot)
Attach the item to a plot
Definition qwt_plot_item.cpp:118
Base class for plot items representing a series of samples
Definition qwt_plot_seriesitem.h:44
Qt::Orientation orientation() const
Get the orientation of the plot item
Definition qwt_plot_seriesitem.cpp:92
void setOrientation(Qt::Orientation)
Set the orientation of the item
Definition qwt_plot_seriesitem.cpp:76
virtual QRectF boundingRect() const override
Get the bounding rectangle
Definition qwt_plot_seriesitem.cpp:114
virtual void drawSeries(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const =0
Draw a subset of the samples
A 2-D plotting widget
Definition qwt_plot.h:99
A scale map
Definition qwt_scale_map.h:44
Abstract interface for iterating over samples
Definition qwt_series_data.h:88
Class storing a QwtSeriesData object
Definition qwt_series_store.h:91
A class for drawing symbols
Definition qwt_symbol.h:51
A class representing a text
Definition qwt_text.h:70