QSint Library  0.2.2
barchartplotter.h
1 #ifndef BARCHARTPLOTTER_H
2 #define BARCHARTPLOTTER_H
3 
4 
5 #include "plotterbase.h"
6 
7 
8 namespace QSint
9 {
10 
11 
26 {
27  Q_OBJECT
28 public:
29  explicit BarChartPlotter(QWidget *parent = 0);
30 
31 
34  {
41  };
42 
44  void setBarType(BarChartType type);
46  inline BarChartType barType() const { return m_type; }
47 
50  void setBarSize(int min, int max = INT_MAX);
52  inline int barSizeMin() const { return m_barsize_min; }
54  inline int barSizeMax() const { return m_barsize_max; }
55 
61  void setBarScale(double scale);
63  inline double barScale() const { return m_scale; }
64 
66  void setBarOpacity(double value);
68  inline double barOpacity() const { return m_opacity; }
69 
70 
72  void setZeroLinePen(const QPen &pen);
74  inline const QPen& zeroLinePen() const { return m_zeroLinePen; }
75 
76 protected:
77  virtual void drawContent(QPainter &p);
78 
79  virtual void drawSegment(QPainter &p, QRect rect,
80  const QModelIndex &index, double value,
81  bool isHighlighted) const;
82 
83  virtual void drawValue(QPainter &p, QRect rect,
84  const QModelIndex &index, double value,
85  bool isHighlighted) const;
86 
87  virtual void drawValueText(QPainter &p,
88  const QRect &rect,
89  int flags,
90  bool isHighlighted,
91  const QModelIndex &index,
92  const QString &text) const;
93 
94  virtual QRect drawHighlightedValueFrame(QPainter &p,
95  const QRect &rect,
96  const QRect &textRect) const;
97 
98  int m_barsize_min, m_barsize_max;
99  double m_scale;
100  double m_opacity;
101  BarChartType m_type;
102 
103  QPen m_zeroLinePen;
104 
105 protected:
106  class BarPainter
107  {
108  protected:
109  static void drawBarItem(QPainter &p, QRect rect,
110  const QPen &pen, const QBrush &brush,
111  const QModelIndex &index,
112  double value);
113 
114  static void drawValueText(QPainter &p, QRect rect, int flags,
115  const QPen &pen, const QBrush &brush,
116  const QModelIndex &index,
117  double value);
118  };
119 
120  class StackedBarPainter: public BarPainter
121  {
122  public:
123  static void draw(BarChartPlotter *plotter,
124  QPainter &p,
125  int count,
126  int row_count,
127  int p_start,
128  int p_offs,
129  int bar_size);
130  };
131 
132  class ColumnBarPainter: public BarPainter
133  {
134  public:
135  static void draw(BarChartPlotter *plotter,
136  QPainter &p,
137  int count,
138  int row_count,
139  int p_start,
140  int p_offs,
141  int bar_size);
142  };
143 
144  class TrendPainter: public BarPainter
145  {
146  public:
147  static void draw(BarChartPlotter *plotter,
148  QPainter &p,
149  int count,
150  int row_count,
151  int p_start,
152  int p_offs,
153  int bar_size);
154  };
155 };
156 
157 
158 } // namespace
159 
160 #endif // BARCHARTPLOTTER_H
double barOpacity() const
Retrieves bar opacity.
Definition: barchartplotter.h:68
BarChartType barType() const
Retrieves type of the plotter.
Definition: barchartplotter.h:46
int barSizeMin() const
Retrieves minimum bar size.
Definition: barchartplotter.h:52
double barScale() const
Retrieves bar scale coefficient.
Definition: barchartplotter.h:63
trend-like plot
Definition: barchartplotter.h:40
int barSizeMax() const
Retrieves maximum bar size.
Definition: barchartplotter.h:54
BarChartType
Defines type of the chart.
Definition: barchartplotter.h:33
void setBarOpacity(double value)
Sets opacity of a single bar to value (should be in ranges between 0.1 and 1.0, 1.0 is the default).
Definition: barchartplotter.cpp:49
void setBarType(BarChartType type)
Sets the plotter type to type.
Definition: barchartplotter.cpp:27
void setBarSize(int min, int max=INT_MAX)
Definition: barchartplotter.cpp:33
void setBarScale(double scale)
Definition: barchartplotter.cpp:40
virtual void drawContent(QPainter &p)
Draws content of the plotter.
Definition: barchartplotter.cpp:64
bar represents single model column
Definition: barchartplotter.h:36
const QPen & zeroLinePen() const
Retrieves zero line pen.
Definition: barchartplotter.h:74
Base class for 2-dimensional plotter widgets.
Definition: plotterbase.h:36
bar represents single model value
Definition: barchartplotter.h:38
Class representing a barchart plotting widget.
Definition: barchartplotter.h:25
void setZeroLinePen(const QPen &pen)
Sets pen of zero line of the plotter to pen.
Definition: barchartplotter.cpp:58

© Sintegrial Technologies 2011-2014
http://www.sintegrial.com