QGIS API Documentation  2.9.0-Master
qwt5_histogram_item.h
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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 #include <qwt_global.h>
10 
11 #if defined(QWT_VERSION) && QWT_VERSION<0x060000
12 
13 #ifndef HISTOGRAM_ITEM_H
14 #define HISTOGRAM_ITEM_H
15 
16 #include <qglobal.h>
17 #include <qcolor.h>
18 
19 #include "qwt_plot_item.h"
20 
21 class QwtIntervalData;
22 class QString;
23 
24 class HistogramItem: public QwtPlotItem
25 {
26  public:
27  explicit HistogramItem( const QString &title = QString::null );
28  explicit HistogramItem( const QwtText &title );
29  virtual ~HistogramItem();
30 
31  void setData( const QwtIntervalData &data );
32  const QwtIntervalData &data() const;
33 
34  void setColor( const QColor & );
35  QColor color() const;
36 
37  void setFlat( bool flat );
38  bool flat() const;
39 
40  void setSpacing( int spacing );
41  int spacing() const;
42 
43  void setPen( const QPen& pen );
44  QPen pen() const;
45 
46  virtual QwtDoubleRect boundingRect() const override;
47 
48  virtual int rtti() const override;
49 
50  virtual void draw( QPainter *, const QwtScaleMap &xMap,
51  const QwtScaleMap &yMap, const QRect & ) const override;
52 
53  virtual void updateLegend( QwtLegend * ) const override;
54 
55  void setBaseline( double reference );
56  double baseline() const;
57 
58  enum HistogramAttribute
59  {
60  Auto = 0,
61  Xfy = 1
62  };
63 
64  void setHistogramAttribute( HistogramAttribute, bool on = true );
65  bool testHistogramAttribute( HistogramAttribute ) const;
66 
67  protected:
68  virtual void drawBar( QPainter *,
69  Qt::Orientation o, const QRect & ) const;
70 
71  private:
72  void init();
73 
74  class PrivateData;
75  PrivateData *d_data;
76 };
77 
78 #include <qstring.h>
79 #include <qpainter.h>
80 #include <qwt_plot.h>
81 #include <qwt_interval_data.h>
82 #include <qwt_painter.h>
83 #include <qwt_scale_map.h>
84 #include <qwt_legend_item.h>
85 
86 class HistogramItem::PrivateData
87 {
88  public:
89  int attributes;
90  QwtIntervalData data;
91  QColor color;
92  QPen pen;
93  double reference;
94  bool flat;
95  int spacing;
96 };
97 
98 #endif
99 #endif