QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_plot_barchart.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_BAR_CHART_H
28#define QWT_PLOT_BAR_CHART_H
29
30#include "qwt_global.h"
31#include "qwt_plot_abstract_barchart.h"
32#include "qwt_column_symbol.h"
33
34class QwtColumnRect;
35template< typename T >
36class QwtSeriesData;
37
58class QWT_EXPORT QwtPlotBarChart : public QwtPlotAbstractBarChart, public QwtSeriesStore< QPointF >
59{
60public:
67 {
74
80 LegendBarTitles
81 };
82
83 // Constructor
84 explicit QwtPlotBarChart(const QString& title = QString());
85 // Constructor with QwtText title
86 explicit QwtPlotBarChart(const QwtText& title);
87
88 // Destructor
89 ~QwtPlotBarChart() override;
90
91 // Get the runtime type information
92 virtual int rtti() const override;
93
94 // Attach the bar chart to a plot (applies color cycle if pen/brush not user-set)
95 void attach(QwtPlot* plot) override;
96
97 // Set samples from QVector<QPointF>
98 void setSamples(const QVector< QPointF >&);
99 // Set samples from QVector<double>
100 void setSamples(const QVector< double >&);
101 // Set samples from QwtSeriesData
102 void setSamples(QwtSeriesData< QPointF >*);
103
104 // Set symbol
105 void setSymbol(QwtColumnSymbol*);
106 // Get symbol
107 const QwtColumnSymbol* symbol() const;
108
109 // Set pen
110 void setPen(const QPen& p);
111 // Get pen
112 QPen pen() const;
113
114 // Set brush
115 void setBrush(const QBrush& b);
116 // Get brush
117 QBrush brush() const;
118
119 // Set frame style
120 void setFrameStyle(QwtColumnSymbol::FrameStyle f);
121 // Get frame style
122 QwtColumnSymbol::FrameStyle frameStyle() const;
123
124 // Set legend mode
125 void setLegendMode(LegendMode);
126 // Get legend mode
127 LegendMode legendMode() const;
128
129 // Draw the series
130 virtual void drawSeries(QPainter*,
131 const QwtScaleMap& xMap,
132 const QwtScaleMap& yMap,
133 const QRectF& canvasRect,
134 int from,
135 int to) const override;
136
137 // Get the bounding rectangle
138 virtual QRectF boundingRect() const override;
139
140 // Get special symbol for a sample
141 virtual QwtColumnSymbol* specialSymbol(int sampleIndex, const QPointF&) const;
142
143 // Get bar title for a sample
144 virtual QwtText barTitle(int sampleIndex) const;
145
146protected:
148 virtual void drawSample(QPainter* painter,
149 const QwtScaleMap& xMap,
150 const QwtScaleMap& yMap,
151 const QRectF& canvasRect,
152 const QwtInterval& boundingInterval,
153 int index,
154 const QPointF& sample) const;
155
157 virtual void drawBar(QPainter*, int sampleIndex, const QPointF& sample, const QwtColumnRect&) const;
158
160 QwtColumnRect columnRect(const QwtScaleMap& xMap,
161 const QwtScaleMap& yMap,
162 const QRectF& canvasRect,
163 const QwtInterval& boundingInterval,
164 const QPointF& sample) const;
165
167 QList< QwtLegendData > legendData() const override;
169 QwtGraphic legendIcon(int index, const QSizeF&) const override;
170
171private:
173 void init();
174
175 QWT_DECLARE_PRIVATE(QwtPlotBarChart)
176};
177
178#endif
Definition qwt_raster_data.h:38
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
FrameStyle
Frame Style used in Box style()
Definition qwt_column_symbol.h:130
A paint device for scalable graphics
Definition qwt_graphic.h:85
A class representing an interval
Definition qwt_interval.h:39
Abstract base class for bar chart items
Definition qwt_plot_abstract_barchart.h:41
QwtPlotBarChart displays a series of values as bars
Definition qwt_plot_barchart.h:59
LegendMode
Legend modes
Definition qwt_plot_barchart.h:67
@ LegendChartTitle
Definition qwt_plot_barchart.h:73
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
Return a legend icon
Definition qwt_plot_item.cpp:420
virtual QList< QwtLegendData > legendData() const
Return legend data
Definition qwt_plot_item.cpp:642
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
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 representing a text
Definition qwt_text.h:70