QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_plot_histogram.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_PLOT_HISTOGRAM_H
28#define QWT_PLOT_HISTOGRAM_H
29
30#include "qwt_global.h"
31#include "qwt_plot_seriesitem.h"
32
33class QwtColumnSymbol;
34class QwtColumnRect;
35class QColor;
36class QPolygonF;
37
38#if QT_VERSION < 0x060000
39template< typename T >
40class QVector;
41#endif
42
59class QWT_EXPORT QwtPlotHistogram : public QwtPlotSeriesItem, public QwtSeriesStore< QwtIntervalSample >
60{
61public:
69 {
78
86
92
99 UserStyle = 100
100 };
101
102 // Constructor
103 explicit QwtPlotHistogram(const QString& title = QString());
104
105 // Constructor with QwtText title
106 explicit QwtPlotHistogram(const QwtText& title);
107
108 // Destructor
109 ~QwtPlotHistogram() override;
110
111 // Get the runtime type information
112 virtual int rtti() const override;
113
114 // Attach the histogram to a plot (applies color cycle if pen/brush not user-set)
115 void attach(QwtPlot* plot) override;
116
117 // Set pen
118 void setPen(const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine);
119
120 // Set pen
121 void setPen(const QPen&);
122
123 // Get pen
124 const QPen& pen() const;
125
126 // Set brush
127 void setBrush(const QBrush&);
128
129 // Get brush
130 const QBrush& brush() const;
131
132 // Set samples from a vector
133 void setSamples(const QVector< QwtIntervalSample >&);
134
135 // Set samples from a series data
136 void setSamples(QwtSeriesData< QwtIntervalSample >*);
137
138 // Set baseline
139 void setBaseline(double);
140
141 // Get baseline
142 double baseline() const;
143
144 // Set histogram style
145 void setStyle(HistogramStyle style);
146
147 // Get histogram style
148 HistogramStyle style() const;
149
150 // Set symbol
151 void setSymbol(const QwtColumnSymbol*);
152
153 // Get symbol
154 const QwtColumnSymbol* symbol() const;
155
156 // Draw the series
157 virtual void drawSeries(QPainter*,
158 const QwtScaleMap& xMap,
159 const QwtScaleMap& yMap,
160 const QRectF& canvasRect,
161 int from,
162 int to) const override;
163
164 // Get the bounding rectangle
165 virtual QRectF boundingRect() const override;
166
167 // Get the legend icon
168 virtual QwtGraphic legendIcon(int index, const QSizeF&) const override;
169
170protected:
174 virtual QwtColumnRect columnRect(const QwtIntervalSample&, const QwtScaleMap&, const QwtScaleMap&) const;
175
179 virtual void drawColumn(QPainter*, const QwtColumnRect&, const QwtIntervalSample&) const;
180
184 void drawColumns(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, int from, int to) const;
185
189 void drawOutline(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, int from, int to) const;
190
194 void drawLines(QPainter*, const QwtScaleMap& xMap, const QwtScaleMap& yMap, int from, int to) const;
195
196private:
200 void init();
201
205 void flushPolygon(QPainter*, double baseLine, QPolygonF&) const;
206
207 QWT_DECLARE_PRIVATE(QwtPlotHistogram)
208};
209
210#endif
Definition qwt_clipper.h:41
Directed rectangle representing bounding rectangle and orientation of a column
Definition qwt_column_symbol.h:47
A drawing primitive for columns
Definition qwt_column_symbol.h:102
A paint device for scalable graphics
Definition qwt_graphic.h:85
A sample of the types (x1-x2, y) or (x, y1-y2)
Definition qwt_samples.h:74
QwtPlotHistogram represents a series of samples, where an interval is associated with a value ( )
Definition qwt_plot_histogram.h:60
HistogramStyle
Histogram styles
Definition qwt_plot_histogram.h:69
@ Lines
Definition qwt_plot_histogram.h:91
@ Columns
Definition qwt_plot_histogram.h:85
@ Outline
Definition qwt_plot_histogram.h:77
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
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
Class storing a QwtSeriesData object
Definition qwt_series_store.h:91
A class representing a text
Definition qwt_text.h:70