10#include "qwt_plot_barchart.h"
11#include "qwt_scale_map.h"
12#include "qwt_column_symbol.h"
14#include "qwt_graphic.h"
15#include "qwt_legend_data.h"
19class QwtPlotBarChart::PrivateData
63void QwtPlotBarChart::init()
65 m_data =
new PrivateData;
101 points.reserve( samples.size() );
103 for (
int i = 0; i < samples.size(); i++ )
104 points += QPointF( i, samples[ i ] );
136 if (
symbol != m_data->symbol )
138 delete m_data->symbol;
152 return m_data->symbol;
166 if ( mode != m_data->legendMode )
168 m_data->legendMode = mode;
179 return m_data->legendMode;
188 const size_t numSamples =
dataSize();
189 if ( numSamples == 0 )
193 if ( rect.height() >= 0 )
197 if ( rect.bottom() < baseLine )
198 rect.setBottom( baseLine );
200 if ( rect.top() > baseLine )
201 rect.setTop( baseLine );
205 rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
225 const QRectF& canvasRect,
int from,
int to )
const
238 const QwtInterval interval( br.left(), br.right() );
242 for (
int i = from; i <= to; i++ )
245 canvasRect, interval, i,
sample( i ) );
264 const QRectF& canvasRect,
const QwtInterval& boundingInterval,
265 const QPointF& sample )
const
271 const double barHeight =
sampleWidth( yMap, canvasRect.height(),
278 const double y1 = y - 0.5 * barHeight;
279 const double y2 = y + 0.5 * barHeight;
289 const double barWidth =
sampleWidth( xMap, canvasRect.width(),
293 const double x1 = x - 0.5 * barWidth;
294 const double x2 = x + 0.5 * barWidth;
324 const QRectF& canvasRect,
const QwtInterval& boundingInterval,
325 int index,
const QPointF& sample )
const
328 canvasRect, boundingInterval,
sample );
342 int sampleIndex,
const QPointF& sample,
350 sym = m_data->symbol;
354 sym->
draw( painter, rect );
362 columnSymbol.
draw( painter, rect );
378 int sampleIndex,
const QPointF& sample )
const
380 Q_UNUSED( sampleIndex );
401 Q_UNUSED( sampleIndex );
422 const size_t numSamples =
dataSize();
423 list.reserve( numSamples );
425 for (
size_t i = 0; i < numSamples; i++ )
429 data.setValue( QwtLegendData::TitleRole,
430 QVariant::fromValue(
barTitle( i ) ) );
434 data.setValue( QwtLegendData::IconRole,
463 int index,
const QSizeF& size )
const
473 QPainter painter( &icon );
474 painter.setRenderHint( QPainter::Antialiasing,
481 drawBar( &painter, barIndex, QPointF(), column );
Template class for data, that is organized as QVector.
Directed rectangle representing bounding rectangle and orientation of a column.
QwtInterval vInterval
Interval for the vertical coordinates.
QwtInterval hInterval
Interval for the horizontal coordinates.
@ LeftToRight
From left to right.
@ TopToBottom
From top to bottom.
@ BottomToTop
From bottom to top.
@ RightToLeft
From right to left.
Direction direction
Direction.
A drawing primitive for columns.
@ Plain
A plain frame style.
virtual void draw(QPainter *, const QwtColumnRect &) const
void setFrameStyle(FrameStyle)
void setLineWidth(int width)
A paint device for scalable graphics.
void setRenderHint(RenderHint, bool on=true)
void setDefaultSize(const QSizeF &)
Set a default size.
A class representing an interval.
QwtInterval normalized() const
Normalize the limits of the interval.
double width() const
Return the width of an interval.
Attributes of an entry on a legend.
Abstract base class for bar chart items.
double sampleWidth(const QwtScaleMap &map, double canvasSize, double boundingSize, double value) const
QwtPlotBarChart displays a series of a values as bars.
QwtPlotBarChart(const QString &title=QString())
void setLegendMode(LegendMode)
LegendMode legendMode() const
void setSymbol(QwtColumnSymbol *)
Assign a symbol.
virtual QwtColumnSymbol * specialSymbol(int sampleIndex, const QPointF &) const
QList< QwtLegendData > legendData() const override
Return all information, that is needed to represent the item on the legend.
void setSamples(const QVector< QPointF > &)
virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const override
virtual int rtti() const override
virtual QwtText barTitle(int sampleIndex) const
Return the title of a bar.
const QwtColumnSymbol * symbol() const
virtual void drawBar(QPainter *, int sampleIndex, const QPointF &sample, const QwtColumnRect &) const
QwtColumnRect columnRect(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, const QwtInterval &boundingInterval, const QPointF &sample) const
virtual ~QwtPlotBarChart()
Destructor.
virtual QRectF boundingRect() const override
QwtGraphic legendIcon(int index, const QSizeF &) const override
virtual void drawSample(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, const QwtInterval &boundingInterval, int index, const QPointF &sample) const
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
virtual void legendChanged()
@ Rtti_PlotBarChart
For QwtPlotBarChart.
@ RenderAntialiased
Enable antialiasing.
bool testRenderHint(RenderHint) const
virtual void itemChanged()
QSize legendIconSize() const
Qt::Orientation orientation() const
virtual QRectF boundingRect() const override
double transform(double s) const
virtual QRectF boundingRect() const
QPointF sample(int index) const
virtual size_t dataSize() const override
QwtSeriesData< QPointF > * data()
void setData(QwtSeriesData< QPointF > *series)
A class representing a text.