@@ -1,79 +1,79 | |||||
1 | /*! |
|
1 | /*! | |
2 | \page classes.html |
|
2 | \page classes.html | |
3 | \title QtCommercial Charts API |
|
3 | \title QtCommercial Charts API | |
4 | \keyword All Classes |
|
4 | \keyword All Classes | |
5 |
|
5 | |||
6 | Charts API is build on top of Qt Graphics View Framework. Charts can be displayed as QGraphicsWidget using QChart class. However |
|
6 | Charts API is build on top of Qt Graphics View Framework. Charts can be displayed as QGraphicsWidget using QChart class. However | |
7 | there is also convenience class QChartView which is QWidget based. These lets quickly use QCharts as normal Qt widget. |
|
7 | there is also convenience class QChartView which is QWidget based. These lets quickly use QCharts as normal Qt widget. | |
8 | The API supports following chart types: |
|
8 | The API supports following chart types: | |
9 |
|
9 | |||
10 | \list |
|
10 | \list | |
11 | \o area |
|
11 | \o area | |
12 | \o line |
|
12 | \o line | |
13 | \o bar |
|
13 | \o bar | |
14 | \o percent bar |
|
14 | \o percent bar | |
15 | \o pie |
|
15 | \o pie | |
16 | \o scatter |
|
16 | \o scatter | |
17 | \o spline |
|
17 | \o spline | |
18 | \o stacked bar |
|
18 | \o stacked bar | |
19 | \endlist |
|
19 | \endlist | |
20 |
|
20 | |||
21 |
|
21 | |||
22 | Each chart type is represented by QSeries derived class. To create given chart type users have to use instace of releted sereis class and add it to QChart/QChartView instance. |
|
22 | Each chart type is represented by QSeries derived class. To create given chart type users have to use instace of releted sereis class and add it to QChart/QChartView instance. | |
23 | \code |
|
23 | \code | |
24 | QLineSeries* series = new QLineSeries(); |
|
24 | QLineSeries* series = new QLineSeries(); | |
25 | series->add(0, 6); |
|
25 | series->add(0, 6); | |
26 | series->add(2, 4); |
|
26 | series->add(2, 4); | |
27 | ... |
|
27 | ... | |
28 | chartView->addSeries(series); |
|
28 | chartView->addSeries(series); | |
29 | \endcode |
|
29 | \endcode | |
30 |
|
30 | |||
31 | \raw HTML |
|
31 | \raw HTML | |
32 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> |
|
32 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> | |
33 | <tr> |
|
33 | <tr> | |
34 | <th class="titleheader" width="33%"> |
|
34 | <th class="titleheader" width="33%"> | |
35 | List of classes |
|
35 | List of classes | |
36 | </th> |
|
36 | </th> | |
37 | </tr> |
|
37 | </tr> | |
38 | <tr> |
|
38 | <tr> | |
39 | <td valign="top"> |
|
39 | <td valign="top"> | |
40 | <ul> |
|
40 | <ul> | |
41 | <li><a href="qareaseries.html">QAreaSeries</a></li> |
|
41 | <li><a href="qareaseries.html">QAreaSeries</a></li> | |
42 | <li><a href="qbarseries.html">QBarSeries</a></li> |
|
42 | <li><a href="qbarseries.html">QBarSeries</a></li> | |
43 | <li><a href="qbarset.html">QBarSet</a></li> |
|
43 | <li><a href="qbarset.html">QBarSet</a></li> | |
44 | <li><a href="qchart.html">QChart</a></li> |
|
44 | <li><a href="qchart.html">QChart</a></li> | |
45 |
<li><a href="q |
|
45 | <li><a href="qaxis.html">QAxis</a></li> | |
46 | <li><a href="qchartview.html">QChartView</a></li> |
|
46 | <li><a href="qchartview.html">QChartView</a></li> | |
47 | <li><a href="qlineseries.html">QLineSeries</a></li> |
|
47 | <li><a href="qlineseries.html">QLineSeries</a></li> | |
48 | <li><a href="qpercentbarseries.html">QPercentBarSeries</a></li> |
|
48 | <li><a href="qpercentbarseries.html">QPercentBarSeries</a></li> | |
49 | <li><a href="qpieseries.html">QPieSeries</a></li> |
|
49 | <li><a href="qpieseries.html">QPieSeries</a></li> | |
50 | <li><a href="qpieslice.html">QPieSlice</a></li> |
|
50 | <li><a href="qpieslice.html">QPieSlice</a></li> | |
51 | <li><a href="qscatterseries.html">QScatterSeries</a></li> |
|
51 | <li><a href="qscatterseries.html">QScatterSeries</a></li> | |
52 | <li><a href="qabstractseries.html">QAbstractSeries</a></li> |
|
52 | <li><a href="qabstractseries.html">QAbstractSeries</a></li> | |
53 | <li><a href="qsplineseries.html">QSplineSeries</a></li> |
|
53 | <li><a href="qsplineseries.html">QSplineSeries</a></li> | |
54 | <li><a href="qstackedbarseries.html">QStackedBarSeries</a></li> |
|
54 | <li><a href="qstackedbarseries.html">QStackedBarSeries</a></li> | |
55 | <li><a href="qxyseries.html">QXYSeries</a></li> |
|
55 | <li><a href="qxyseries.html">QXYSeries</a></li> | |
56 | <li><a href="qlegend.html">QLegend</a></li> |
|
56 | <li><a href="qlegend.html">QLegend</a></li> | |
57 | </ul> |
|
57 | </ul> | |
58 | </td> |
|
58 | </td> | |
59 | </tr> |
|
59 | </tr> | |
60 | </table> |
|
60 | </table> | |
61 |
|
61 | |||
62 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> |
|
62 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> | |
63 | <tr> |
|
63 | <tr> | |
64 | <th class="titleheader" width="33%"> |
|
64 | <th class="titleheader" width="33%"> | |
65 | Other files: |
|
65 | Other files: | |
66 | </th> |
|
66 | </th> | |
67 | </tr> |
|
67 | </tr> | |
68 | <tr> |
|
68 | <tr> | |
69 | <td valign="top"> |
|
69 | <td valign="top"> | |
70 | <ul> |
|
70 | <ul> | |
71 | <li><a href="qchartglobal.html">QChartGlobal</a></li> |
|
71 | <li><a href="qchartglobal.html">QChartGlobal</a></li> | |
72 | </ul> |
|
72 | </ul> | |
73 | </td> |
|
73 | </td> | |
74 | </tr> |
|
74 | </tr> | |
75 | </table> |
|
75 | </table> | |
76 |
|
76 | |||
77 | \endraw |
|
77 | \endraw | |
78 |
|
78 | |||
79 | */ |
|
79 | */ |
@@ -1,533 +1,533 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qaxis.h" |
|
21 | #include "qaxis.h" | |
22 | #include "qaxis_p.h" |
|
22 | #include "qaxis_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QAxis |
|
27 | \class QAxis | |
28 |
\brief The Q |
|
28 | \brief The QAxis class is used for manipulating chart's axis | |
29 | and for adding optional axes to the chart. |
|
29 | and for adding optional axes to the chart. | |
30 | \mainclass |
|
30 | \mainclass | |
31 |
|
31 | |||
32 | There is only one x Axis, however there can be multiple y axes. |
|
32 | There is only one x Axis, however there can be multiple y axes. | |
33 | Each chart series can be bound to exactly one Y axis and the share common X axis. |
|
33 | Each chart series can be bound to exactly one Y axis and the share common X axis. | |
34 | Axis can be setup to show axis line with ticks, gird lines and shades. |
|
34 | Axis can be setup to show axis line with ticks, gird lines and shades. | |
35 |
|
35 | |||
36 | */ |
|
36 | */ | |
37 |
|
37 | |||
38 | /*! |
|
38 | /*! | |
39 | \fn bool QAxis::isAxisVisible() const |
|
39 | \fn bool QAxis::isAxisVisible() const | |
40 | \brief Returns if axis is visible |
|
40 | \brief Returns if axis is visible | |
41 | \sa setAxisVisible() |
|
41 | \sa setAxisVisible() | |
42 | */ |
|
42 | */ | |
43 |
|
43 | |||
44 | /*! |
|
44 | /*! | |
45 | \fn QPen QAxis::axisPen() const |
|
45 | \fn QPen QAxis::axisPen() const | |
46 | \brief Returns pen used to draw axis and ticks. |
|
46 | \brief Returns pen used to draw axis and ticks. | |
47 | \sa setAxisPen() |
|
47 | \sa setAxisPen() | |
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 |
|
50 | |||
51 | /*! |
|
51 | /*! | |
52 | \fn bool QAxis::isGridLineVisible() const |
|
52 | \fn bool QAxis::isGridLineVisible() const | |
53 | \brief Returns if grid is visible |
|
53 | \brief Returns if grid is visible | |
54 | \sa setGridLineVisible() |
|
54 | \sa setGridLineVisible() | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \fn QPen QAxis::gridLinePen() const |
|
58 | \fn QPen QAxis::gridLinePen() const | |
59 | \brief Returns pen used to draw grid. |
|
59 | \brief Returns pen used to draw grid. | |
60 | \sa setGridLinePen() |
|
60 | \sa setGridLinePen() | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \fn bool QAxis::labelsVisible() const |
|
64 | \fn bool QAxis::labelsVisible() const | |
65 | \brief Returns if grid is visible |
|
65 | \brief Returns if grid is visible | |
66 | \sa setLabelsVisible() |
|
66 | \sa setLabelsVisible() | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \fn QPen QAxis::labelsPen() const |
|
70 | \fn QPen QAxis::labelsPen() const | |
71 | \brief Returns the pen used to labels. |
|
71 | \brief Returns the pen used to labels. | |
72 | \sa setLabelsPen() |
|
72 | \sa setLabelsPen() | |
73 | */ |
|
73 | */ | |
74 |
|
74 | |||
75 | /*! |
|
75 | /*! | |
76 | \fn QBrush QAxis::labelsBrush() const |
|
76 | \fn QBrush QAxis::labelsBrush() const | |
77 | \brief Returns brush used to draw labels. |
|
77 | \brief Returns brush used to draw labels. | |
78 | \sa setLabelsBrush() |
|
78 | \sa setLabelsBrush() | |
79 | */ |
|
79 | */ | |
80 |
|
80 | |||
81 | /*! |
|
81 | /*! | |
82 | \fn QFont QAxis::labelsFont() const |
|
82 | \fn QFont QAxis::labelsFont() const | |
83 | \brief Returns font used to draw labels. |
|
83 | \brief Returns font used to draw labels. | |
84 | \sa setLabelsFont() |
|
84 | \sa setLabelsFont() | |
85 | */ |
|
85 | */ | |
86 |
|
86 | |||
87 | /*! |
|
87 | /*! | |
88 | \fn QFont QAxis::labelsAngle() const |
|
88 | \fn QFont QAxis::labelsAngle() const | |
89 | \brief Returns angle used to draw labels. |
|
89 | \brief Returns angle used to draw labels. | |
90 | \sa setLabelsAngle() |
|
90 | \sa setLabelsAngle() | |
91 | */ |
|
91 | */ | |
92 |
|
92 | |||
93 | /*! |
|
93 | /*! | |
94 | \fn bool QAxis::shadesVisible() const |
|
94 | \fn bool QAxis::shadesVisible() const | |
95 | \brief Returns if shades are visible. |
|
95 | \brief Returns if shades are visible. | |
96 | \sa setShadesVisible() |
|
96 | \sa setShadesVisible() | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \fn qreal QAxis::shadesOpacity() const |
|
100 | \fn qreal QAxis::shadesOpacity() const | |
101 | \brief Returns opacity of shades. |
|
101 | \brief Returns opacity of shades. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \fn QPen QAxis::shadesPen() const |
|
105 | \fn QPen QAxis::shadesPen() const | |
106 | \brief Returns pen used to draw shades. |
|
106 | \brief Returns pen used to draw shades. | |
107 | \sa setShadesPen() |
|
107 | \sa setShadesPen() | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | \fn QBrush QAxis::shadesBrush() const |
|
111 | \fn QBrush QAxis::shadesBrush() const | |
112 | \brief Returns brush used to draw shades. |
|
112 | \brief Returns brush used to draw shades. | |
113 | \sa setShadesBrush() |
|
113 | \sa setShadesBrush() | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \fn qreal QAxis::min() const |
|
117 | \fn qreal QAxis::min() const | |
118 | \brief Returns minimum value on the axis. |
|
118 | \brief Returns minimum value on the axis. | |
119 | \sa setMin() |
|
119 | \sa setMin() | |
120 | */ |
|
120 | */ | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | \fn qreal QAxis::max() const |
|
123 | \fn qreal QAxis::max() const | |
124 | \brief Returns maximim value on the axis. |
|
124 | \brief Returns maximim value on the axis. | |
125 | \sa setMax() |
|
125 | \sa setMax() | |
126 | */ |
|
126 | */ | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | \fn void QAxis::minChanged(qreal min) |
|
129 | \fn void QAxis::minChanged(qreal min) | |
130 | \brief Axis emits signal when \a min of axis has changed. |
|
130 | \brief Axis emits signal when \a min of axis has changed. | |
131 | */ |
|
131 | */ | |
132 |
|
132 | |||
133 | /*! |
|
133 | /*! | |
134 | \fn void QAxis::maxChanged(qreal max) |
|
134 | \fn void QAxis::maxChanged(qreal max) | |
135 | \brief Axis emits signal when \a max of axis has changed. |
|
135 | \brief Axis emits signal when \a max of axis has changed. | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \fn void QAxis::rangeChanged(qreal min, qreal max) |
|
139 | \fn void QAxis::rangeChanged(qreal min, qreal max) | |
140 | \brief Axis emits signal when \a min or \a max of axis has changed. |
|
140 | \brief Axis emits signal when \a min or \a max of axis has changed. | |
141 | */ |
|
141 | */ | |
142 |
|
142 | |||
143 | /*! |
|
143 | /*! | |
144 | \fn int QAxis::ticksCount() const |
|
144 | \fn int QAxis::ticksCount() const | |
145 | \brief Return number of ticks on the axis |
|
145 | \brief Return number of ticks on the axis | |
146 | \sa setTicksCount() |
|
146 | \sa setTicksCount() | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | /*! |
|
149 | /*! | |
150 | \fn QChartAxisCategories* QAxis::categories() |
|
150 | \fn QChartAxisCategories* QAxis::categories() | |
151 | \brief Returns pointer to the list of categories which correspond to the values on the axis. |
|
151 | \brief Returns pointer to the list of categories which correspond to the values on the axis. | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | \fn void QAxis::ticksCountChanged(int count) |
|
155 | \fn void QAxis::ticksCountChanged(int count) | |
156 | \brief Emits the new \a count of ticks on the axis |
|
156 | \brief Emits the new \a count of ticks on the axis | |
157 | Signal is emitted when the number of the ticks on the axis has been changed to a different value. |
|
157 | Signal is emitted when the number of the ticks on the axis has been changed to a different value. | |
158 | Parementer count\a count is the new number of ticks on the axis. |
|
158 | Parementer count\a count is the new number of ticks on the axis. | |
159 | */ |
|
159 | */ | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
162 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
163 |
QCha |
|
163 | QChart when axis added. | |
164 | */ |
|
164 | */ | |
165 |
|
165 | |||
166 | QAxis::QAxis(QObject *parent) : QObject(parent), |
|
166 | QAxis::QAxis(QObject *parent) : QObject(parent), | |
167 | d_ptr(new QAxisPrivate(this)) |
|
167 | d_ptr(new QAxisPrivate(this)) | |
168 | { |
|
168 | { | |
169 |
|
169 | |||
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | /*! |
|
172 | /*! | |
173 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
173 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
174 | */ |
|
174 | */ | |
175 |
|
175 | |||
176 | QAxis::~QAxis() |
|
176 | QAxis::~QAxis() | |
177 | { |
|
177 | { | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | /*! |
|
180 | /*! | |
181 | Sets \a pen used to draw axis line and ticks. |
|
181 | Sets \a pen used to draw axis line and ticks. | |
182 | */ |
|
182 | */ | |
183 | void QAxis::setAxisPen(const QPen &pen) |
|
183 | void QAxis::setAxisPen(const QPen &pen) | |
184 | { |
|
184 | { | |
185 | if (d_ptr->m_axisPen!=pen) { |
|
185 | if (d_ptr->m_axisPen!=pen) { | |
186 | d_ptr->m_axisPen = pen; |
|
186 | d_ptr->m_axisPen = pen; | |
187 | emit d_ptr->updated(); |
|
187 | emit d_ptr->updated(); | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | QPen QAxis::axisPen() const |
|
191 | QPen QAxis::axisPen() const | |
192 | { |
|
192 | { | |
193 | return d_ptr->m_axisPen; |
|
193 | return d_ptr->m_axisPen; | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | /*! |
|
196 | /*! | |
197 | Sets if axis and ticks are \a visible. |
|
197 | Sets if axis and ticks are \a visible. | |
198 | */ |
|
198 | */ | |
199 | void QAxis::setAxisVisible(bool visible) |
|
199 | void QAxis::setAxisVisible(bool visible) | |
200 | { |
|
200 | { | |
201 | if (d_ptr->m_axisVisible != visible) { |
|
201 | if (d_ptr->m_axisVisible != visible) { | |
202 | d_ptr->m_axisVisible = visible; |
|
202 | d_ptr->m_axisVisible = visible; | |
203 | emit d_ptr->updated(); |
|
203 | emit d_ptr->updated(); | |
204 | } |
|
204 | } | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | bool QAxis::isAxisVisible() const |
|
207 | bool QAxis::isAxisVisible() const | |
208 | { |
|
208 | { | |
209 | return d_ptr->m_axisVisible; |
|
209 | return d_ptr->m_axisVisible; | |
210 | } |
|
210 | } | |
211 |
|
211 | |||
212 | /*! |
|
212 | /*! | |
213 | Sets if grid line is \a visible. |
|
213 | Sets if grid line is \a visible. | |
214 | */ |
|
214 | */ | |
215 | void QAxis::setGridLineVisible(bool visible) |
|
215 | void QAxis::setGridLineVisible(bool visible) | |
216 | { |
|
216 | { | |
217 | if (d_ptr->m_gridLineVisible != visible) { |
|
217 | if (d_ptr->m_gridLineVisible != visible) { | |
218 | d_ptr->m_gridLineVisible = visible; |
|
218 | d_ptr->m_gridLineVisible = visible; | |
219 | emit d_ptr->updated(); |
|
219 | emit d_ptr->updated(); | |
220 | } |
|
220 | } | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 | bool QAxis::isGridLineVisible() const |
|
223 | bool QAxis::isGridLineVisible() const | |
224 | { |
|
224 | { | |
225 | return d_ptr->m_gridLineVisible; |
|
225 | return d_ptr->m_gridLineVisible; | |
226 | } |
|
226 | } | |
227 | /*! |
|
227 | /*! | |
228 | Sets \a pen used to draw grid line. |
|
228 | Sets \a pen used to draw grid line. | |
229 | */ |
|
229 | */ | |
230 | void QAxis::setGridLinePen(const QPen &pen) |
|
230 | void QAxis::setGridLinePen(const QPen &pen) | |
231 | { |
|
231 | { | |
232 | if (d_ptr->m_gridLinePen != pen) { |
|
232 | if (d_ptr->m_gridLinePen != pen) { | |
233 | d_ptr->m_gridLinePen = pen; |
|
233 | d_ptr->m_gridLinePen = pen; | |
234 | emit d_ptr->updated(); |
|
234 | emit d_ptr->updated(); | |
235 | } |
|
235 | } | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | QPen QAxis::gridLinePen() const |
|
238 | QPen QAxis::gridLinePen() const | |
239 | { |
|
239 | { | |
240 | return d_ptr->m_gridLinePen; |
|
240 | return d_ptr->m_gridLinePen; | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | /*! |
|
243 | /*! | |
244 | Sets if axis' labels are \a visible. |
|
244 | Sets if axis' labels are \a visible. | |
245 | */ |
|
245 | */ | |
246 | void QAxis::setLabelsVisible(bool visible) |
|
246 | void QAxis::setLabelsVisible(bool visible) | |
247 | { |
|
247 | { | |
248 | if (d_ptr->m_labelsVisible != visible) { |
|
248 | if (d_ptr->m_labelsVisible != visible) { | |
249 | d_ptr->m_labelsVisible = visible; |
|
249 | d_ptr->m_labelsVisible = visible; | |
250 | emit d_ptr->updated(); |
|
250 | emit d_ptr->updated(); | |
251 | } |
|
251 | } | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | bool QAxis::labelsVisible() const |
|
254 | bool QAxis::labelsVisible() const | |
255 | { |
|
255 | { | |
256 | return d_ptr->m_labelsVisible; |
|
256 | return d_ptr->m_labelsVisible; | |
257 | } |
|
257 | } | |
258 | /*! |
|
258 | /*! | |
259 | Sets \a pen used to draw labels. |
|
259 | Sets \a pen used to draw labels. | |
260 | */ |
|
260 | */ | |
261 | void QAxis::setLabelsPen(const QPen &pen) |
|
261 | void QAxis::setLabelsPen(const QPen &pen) | |
262 | { |
|
262 | { | |
263 | if (d_ptr->m_labelsPen != pen) { |
|
263 | if (d_ptr->m_labelsPen != pen) { | |
264 | d_ptr->m_labelsPen = pen; |
|
264 | d_ptr->m_labelsPen = pen; | |
265 | emit d_ptr->updated(); |
|
265 | emit d_ptr->updated(); | |
266 | } |
|
266 | } | |
267 | } |
|
267 | } | |
268 |
|
268 | |||
269 | QPen QAxis::labelsPen() const |
|
269 | QPen QAxis::labelsPen() const | |
270 | { |
|
270 | { | |
271 | return d_ptr->m_labelsPen; |
|
271 | return d_ptr->m_labelsPen; | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | /*! |
|
274 | /*! | |
275 | Sets \a brush used to draw labels. |
|
275 | Sets \a brush used to draw labels. | |
276 | */ |
|
276 | */ | |
277 | void QAxis::setLabelsBrush(const QBrush &brush) |
|
277 | void QAxis::setLabelsBrush(const QBrush &brush) | |
278 | { |
|
278 | { | |
279 | if (d_ptr->m_labelsBrush != brush) { |
|
279 | if (d_ptr->m_labelsBrush != brush) { | |
280 | d_ptr->m_labelsBrush = brush; |
|
280 | d_ptr->m_labelsBrush = brush; | |
281 | emit d_ptr->updated(); |
|
281 | emit d_ptr->updated(); | |
282 | } |
|
282 | } | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 | QBrush QAxis::labelsBrush() const |
|
285 | QBrush QAxis::labelsBrush() const | |
286 | { |
|
286 | { | |
287 | return d_ptr->m_labelsBrush; |
|
287 | return d_ptr->m_labelsBrush; | |
288 | } |
|
288 | } | |
289 |
|
289 | |||
290 | /*! |
|
290 | /*! | |
291 | Sets \a font used to draw labels. |
|
291 | Sets \a font used to draw labels. | |
292 | */ |
|
292 | */ | |
293 | void QAxis::setLabelsFont(const QFont &font) |
|
293 | void QAxis::setLabelsFont(const QFont &font) | |
294 | { |
|
294 | { | |
295 | if (d_ptr->m_labelsFont != font) { |
|
295 | if (d_ptr->m_labelsFont != font) { | |
296 | d_ptr->m_labelsFont = font; |
|
296 | d_ptr->m_labelsFont = font; | |
297 | emit d_ptr->updated(); |
|
297 | emit d_ptr->updated(); | |
298 | } |
|
298 | } | |
299 | } |
|
299 | } | |
300 |
|
300 | |||
301 | QFont QAxis::labelsFont() const |
|
301 | QFont QAxis::labelsFont() const | |
302 | { |
|
302 | { | |
303 | return d_ptr->m_labelsFont; |
|
303 | return d_ptr->m_labelsFont; | |
304 | } |
|
304 | } | |
305 |
|
305 | |||
306 | /*! |
|
306 | /*! | |
307 | Sets \a angle for all the labels on given axis. |
|
307 | Sets \a angle for all the labels on given axis. | |
308 | */ |
|
308 | */ | |
309 | void QAxis::setLabelsAngle(int angle) |
|
309 | void QAxis::setLabelsAngle(int angle) | |
310 | { |
|
310 | { | |
311 | if (d_ptr->m_labelsAngle != angle) { |
|
311 | if (d_ptr->m_labelsAngle != angle) { | |
312 | d_ptr->m_labelsAngle = angle; |
|
312 | d_ptr->m_labelsAngle = angle; | |
313 | emit d_ptr->updated(); |
|
313 | emit d_ptr->updated(); | |
314 | } |
|
314 | } | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | int QAxis::labelsAngle() const |
|
317 | int QAxis::labelsAngle() const | |
318 | { |
|
318 | { | |
319 | return d_ptr->m_labelsAngle; |
|
319 | return d_ptr->m_labelsAngle; | |
320 | } |
|
320 | } | |
321 |
|
321 | |||
322 | /*! |
|
322 | /*! | |
323 | Sets if shades are \a visible. |
|
323 | Sets if shades are \a visible. | |
324 | */ |
|
324 | */ | |
325 | void QAxis::setShadesVisible(bool visible) |
|
325 | void QAxis::setShadesVisible(bool visible) | |
326 | { |
|
326 | { | |
327 | if (d_ptr->m_shadesVisible != visible) { |
|
327 | if (d_ptr->m_shadesVisible != visible) { | |
328 | d_ptr->m_shadesVisible = visible; |
|
328 | d_ptr->m_shadesVisible = visible; | |
329 | emit d_ptr->updated(); |
|
329 | emit d_ptr->updated(); | |
330 | } |
|
330 | } | |
331 | } |
|
331 | } | |
332 |
|
332 | |||
333 | bool QAxis::shadesVisible() const |
|
333 | bool QAxis::shadesVisible() const | |
334 | { |
|
334 | { | |
335 | return d_ptr->m_shadesVisible; |
|
335 | return d_ptr->m_shadesVisible; | |
336 | } |
|
336 | } | |
337 |
|
337 | |||
338 | /*! |
|
338 | /*! | |
339 | Sets \a pen used to draw shades. |
|
339 | Sets \a pen used to draw shades. | |
340 | */ |
|
340 | */ | |
341 | void QAxis::setShadesPen(const QPen &pen) |
|
341 | void QAxis::setShadesPen(const QPen &pen) | |
342 | { |
|
342 | { | |
343 | if (d_ptr->m_shadesPen != pen) { |
|
343 | if (d_ptr->m_shadesPen != pen) { | |
344 | d_ptr->m_shadesPen = pen; |
|
344 | d_ptr->m_shadesPen = pen; | |
345 | emit d_ptr->updated(); |
|
345 | emit d_ptr->updated(); | |
346 | } |
|
346 | } | |
347 | } |
|
347 | } | |
348 |
|
348 | |||
349 | QPen QAxis::shadesPen() const |
|
349 | QPen QAxis::shadesPen() const | |
350 | { |
|
350 | { | |
351 | return d_ptr->m_shadesPen; |
|
351 | return d_ptr->m_shadesPen; | |
352 | } |
|
352 | } | |
353 |
|
353 | |||
354 | /*! |
|
354 | /*! | |
355 | Sets \a brush used to draw shades. |
|
355 | Sets \a brush used to draw shades. | |
356 | */ |
|
356 | */ | |
357 | void QAxis::setShadesBrush(const QBrush &brush) |
|
357 | void QAxis::setShadesBrush(const QBrush &brush) | |
358 | { |
|
358 | { | |
359 | if (d_ptr->m_shadesBrush != brush) { |
|
359 | if (d_ptr->m_shadesBrush != brush) { | |
360 | d_ptr->m_shadesBrush = brush; |
|
360 | d_ptr->m_shadesBrush = brush; | |
361 | emit d_ptr->updated(); |
|
361 | emit d_ptr->updated(); | |
362 | } |
|
362 | } | |
363 | } |
|
363 | } | |
364 |
|
364 | |||
365 | QBrush QAxis::shadesBrush() const |
|
365 | QBrush QAxis::shadesBrush() const | |
366 | { |
|
366 | { | |
367 | return d_ptr->m_shadesBrush; |
|
367 | return d_ptr->m_shadesBrush; | |
368 | } |
|
368 | } | |
369 |
|
369 | |||
370 | /*! |
|
370 | /*! | |
371 | Sets \a opacity of the shades. |
|
371 | Sets \a opacity of the shades. | |
372 | */ |
|
372 | */ | |
373 | void QAxis::setShadesOpacity(qreal opacity) |
|
373 | void QAxis::setShadesOpacity(qreal opacity) | |
374 | { |
|
374 | { | |
375 | if (d_ptr->m_shadesOpacity != opacity) { |
|
375 | if (d_ptr->m_shadesOpacity != opacity) { | |
376 | d_ptr->m_shadesOpacity=opacity; |
|
376 | d_ptr->m_shadesOpacity=opacity; | |
377 | emit d_ptr->updated(); |
|
377 | emit d_ptr->updated(); | |
378 | } |
|
378 | } | |
379 | } |
|
379 | } | |
380 |
|
380 | |||
381 | qreal QAxis::shadesOpacity() const |
|
381 | qreal QAxis::shadesOpacity() const | |
382 | { |
|
382 | { | |
383 | return d_ptr->m_shadesOpacity; |
|
383 | return d_ptr->m_shadesOpacity; | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | /*! |
|
386 | /*! | |
387 | Sets \a min value on the axis. |
|
387 | Sets \a min value on the axis. | |
388 | */ |
|
388 | */ | |
389 | void QAxis::setMin(qreal min) |
|
389 | void QAxis::setMin(qreal min) | |
390 | { |
|
390 | { | |
391 | setRange(min,d_ptr->m_max); |
|
391 | setRange(min,d_ptr->m_max); | |
392 | } |
|
392 | } | |
393 |
|
393 | |||
394 | qreal QAxis::min() const |
|
394 | qreal QAxis::min() const | |
395 | { |
|
395 | { | |
396 | return d_ptr->m_min; |
|
396 | return d_ptr->m_min; | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | /*! |
|
399 | /*! | |
400 | Sets \a max value on the axis. |
|
400 | Sets \a max value on the axis. | |
401 | */ |
|
401 | */ | |
402 | void QAxis::setMax(qreal max) |
|
402 | void QAxis::setMax(qreal max) | |
403 | { |
|
403 | { | |
404 | setRange(d_ptr->m_min,max); |
|
404 | setRange(d_ptr->m_min,max); | |
405 | } |
|
405 | } | |
406 |
|
406 | |||
407 | qreal QAxis::max() const |
|
407 | qreal QAxis::max() const | |
408 | { |
|
408 | { | |
409 | return d_ptr->m_max; |
|
409 | return d_ptr->m_max; | |
410 | } |
|
410 | } | |
411 |
|
411 | |||
412 | /*! |
|
412 | /*! | |
413 | Sets range from \a min to \a max on the axis. |
|
413 | Sets range from \a min to \a max on the axis. | |
414 | */ |
|
414 | */ | |
415 | void QAxis::setRange(qreal min, qreal max) |
|
415 | void QAxis::setRange(qreal min, qreal max) | |
416 | { |
|
416 | { | |
417 | bool changed = false; |
|
417 | bool changed = false; | |
418 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { |
|
418 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { | |
419 | d_ptr->m_min = min; |
|
419 | d_ptr->m_min = min; | |
420 | changed = true; |
|
420 | changed = true; | |
421 | emit minChanged(min); |
|
421 | emit minChanged(min); | |
422 | } |
|
422 | } | |
423 |
|
423 | |||
424 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { |
|
424 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { | |
425 | d_ptr->m_max = max; |
|
425 | d_ptr->m_max = max; | |
426 | changed = true; |
|
426 | changed = true; | |
427 | emit maxChanged(max); |
|
427 | emit maxChanged(max); | |
428 | } |
|
428 | } | |
429 |
|
429 | |||
430 | if (changed) { |
|
430 | if (changed) { | |
431 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); |
|
431 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); | |
432 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
432 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
433 | } |
|
433 | } | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | /*! |
|
436 | /*! | |
437 | Sets \a count for ticks on the axis. |
|
437 | Sets \a count for ticks on the axis. | |
438 | */ |
|
438 | */ | |
439 | void QAxis::setTicksCount(int count) |
|
439 | void QAxis::setTicksCount(int count) | |
440 | { |
|
440 | { | |
441 | if (d_ptr->m_ticksCount != count) { |
|
441 | if (d_ptr->m_ticksCount != count) { | |
442 | d_ptr->m_ticksCount = count; |
|
442 | d_ptr->m_ticksCount = count; | |
443 | emit ticksCountChanged(count); |
|
443 | emit ticksCountChanged(count); | |
444 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
444 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
445 | } |
|
445 | } | |
446 | } |
|
446 | } | |
447 |
|
447 | |||
448 | int QAxis::ticksCount() const |
|
448 | int QAxis::ticksCount() const | |
449 | { |
|
449 | { | |
450 | return d_ptr->m_ticksCount; |
|
450 | return d_ptr->m_ticksCount; | |
451 | } |
|
451 | } | |
452 |
|
452 | |||
453 | /*! |
|
453 | /*! | |
454 | Sets axis, shades, labels and grid lines to be visible. |
|
454 | Sets axis, shades, labels and grid lines to be visible. | |
455 | */ |
|
455 | */ | |
456 | void QAxis::show() |
|
456 | void QAxis::show() | |
457 | { |
|
457 | { | |
458 | d_ptr->m_axisVisible=true; |
|
458 | d_ptr->m_axisVisible=true; | |
459 | d_ptr->m_gridLineVisible=true; |
|
459 | d_ptr->m_gridLineVisible=true; | |
460 | d_ptr->m_labelsVisible=true; |
|
460 | d_ptr->m_labelsVisible=true; | |
461 | d_ptr->m_shadesVisible=true; |
|
461 | d_ptr->m_shadesVisible=true; | |
462 | emit d_ptr->updated(); |
|
462 | emit d_ptr->updated(); | |
463 | } |
|
463 | } | |
464 |
|
464 | |||
465 | /*! |
|
465 | /*! | |
466 | Sets axis, shades, labels and grid lines to not be visible. |
|
466 | Sets axis, shades, labels and grid lines to not be visible. | |
467 | */ |
|
467 | */ | |
468 | void QAxis::hide() |
|
468 | void QAxis::hide() | |
469 | { |
|
469 | { | |
470 | d_ptr->m_axisVisible = false; |
|
470 | d_ptr->m_axisVisible = false; | |
471 | d_ptr->m_gridLineVisible = false; |
|
471 | d_ptr->m_gridLineVisible = false; | |
472 | d_ptr->m_labelsVisible = false; |
|
472 | d_ptr->m_labelsVisible = false; | |
473 | d_ptr->m_shadesVisible = false; |
|
473 | d_ptr->m_shadesVisible = false; | |
474 | emit d_ptr->updated(); |
|
474 | emit d_ptr->updated(); | |
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 | /*! |
|
477 | /*! | |
478 | Sets the nice numbers state to \a enable |
|
478 | Sets the nice numbers state to \a enable | |
479 | */ |
|
479 | */ | |
480 | void QAxis::setNiceNumbersEnabled(bool enable) |
|
480 | void QAxis::setNiceNumbersEnabled(bool enable) | |
481 | { |
|
481 | { | |
482 | if (d_ptr->m_niceNumbers != enable){ |
|
482 | if (d_ptr->m_niceNumbers != enable){ | |
483 | d_ptr->m_niceNumbers = enable; |
|
483 | d_ptr->m_niceNumbers = enable; | |
484 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
484 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
485 | } |
|
485 | } | |
486 | } |
|
486 | } | |
487 |
|
487 | |||
488 | /*! |
|
488 | /*! | |
489 | Returns whether nice numbers are enabled or not. |
|
489 | Returns whether nice numbers are enabled or not. | |
490 | */ |
|
490 | */ | |
491 | bool QAxis::niceNumbersEnabled() const |
|
491 | bool QAxis::niceNumbersEnabled() const | |
492 | { |
|
492 | { | |
493 | return d_ptr->m_niceNumbers; |
|
493 | return d_ptr->m_niceNumbers; | |
494 | } |
|
494 | } | |
495 |
|
495 | |||
496 | QChartAxisCategories* QAxis::categories() |
|
496 | QChartAxisCategories* QAxis::categories() | |
497 | { |
|
497 | { | |
498 | return &d_ptr->m_category; |
|
498 | return &d_ptr->m_category; | |
499 | } |
|
499 | } | |
500 |
|
500 | |||
501 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
501 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
502 |
|
502 | |||
503 | QAxisPrivate::QAxisPrivate(QAxis* q): |
|
503 | QAxisPrivate::QAxisPrivate(QAxis* q): | |
504 | q_ptr(q), |
|
504 | q_ptr(q), | |
505 | m_axisVisible(true), |
|
505 | m_axisVisible(true), | |
506 | m_gridLineVisible(true), |
|
506 | m_gridLineVisible(true), | |
507 | m_labelsVisible(true), |
|
507 | m_labelsVisible(true), | |
508 | m_labelsAngle(0), |
|
508 | m_labelsAngle(0), | |
509 | m_shadesVisible(false), |
|
509 | m_shadesVisible(false), | |
510 | m_shadesOpacity(1.0), |
|
510 | m_shadesOpacity(1.0), | |
511 | m_min(0), |
|
511 | m_min(0), | |
512 | m_max(0), |
|
512 | m_max(0), | |
513 | m_ticksCount(5), |
|
513 | m_ticksCount(5), | |
514 | m_niceNumbers(false) |
|
514 | m_niceNumbers(false) | |
515 | { |
|
515 | { | |
516 |
|
516 | |||
517 | } |
|
517 | } | |
518 |
|
518 | |||
519 | QAxisPrivate::~QAxisPrivate() |
|
519 | QAxisPrivate::~QAxisPrivate() | |
520 | { |
|
520 | { | |
521 |
|
521 | |||
522 | } |
|
522 | } | |
523 |
|
523 | |||
524 | void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
524 | void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
525 | { |
|
525 | { | |
526 | q_ptr->setRange(min,max); |
|
526 | q_ptr->setRange(min,max); | |
527 | q_ptr->setTicksCount(count); |
|
527 | q_ptr->setTicksCount(count); | |
528 | } |
|
528 | } | |
529 |
|
529 | |||
530 | #include "moc_qaxis.cpp" |
|
530 | #include "moc_qaxis.cpp" | |
531 | #include "moc_qaxis_p.cpp" |
|
531 | #include "moc_qaxis_p.cpp" | |
532 |
|
532 | |||
533 | QTCOMMERCIALCHART_END_NAMESPACE |
|
533 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,436 +1,436 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qchart_p.h" |
|
22 | #include "qchart_p.h" | |
23 | #include "legendscroller_p.h" |
|
23 | #include "legendscroller_p.h" | |
24 | #include "qlegend_p.h" |
|
24 | #include "qlegend_p.h" | |
25 | #include "chartbackground_p.h" |
|
25 | #include "chartbackground_p.h" | |
26 | #include "qaxis.h" |
|
26 | #include "qaxis.h" | |
27 | #include <QGraphicsScene> |
|
27 | #include <QGraphicsScene> | |
28 | #include <QGraphicsSceneResizeEvent> |
|
28 | #include <QGraphicsSceneResizeEvent> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | /*! |
|
32 | /*! | |
33 | \enum QChart::ChartTheme |
|
33 | \enum QChart::ChartTheme | |
34 |
|
34 | |||
35 | This enum describes the theme used by the chart. |
|
35 | This enum describes the theme used by the chart. | |
36 |
|
36 | |||
37 | \value ChartThemeLight The default theme |
|
37 | \value ChartThemeLight The default theme | |
38 | \value ChartThemeBlueCerulean |
|
38 | \value ChartThemeBlueCerulean | |
39 | \value ChartThemeDark |
|
39 | \value ChartThemeDark | |
40 | \value ChartThemeBrownSand |
|
40 | \value ChartThemeBrownSand | |
41 | \value ChartThemeBlueNcs |
|
41 | \value ChartThemeBlueNcs | |
42 | \value ChartThemeHighContrast |
|
42 | \value ChartThemeHighContrast | |
43 | \value ChartThemeBlueIcy |
|
43 | \value ChartThemeBlueIcy | |
44 | */ |
|
44 | */ | |
45 |
|
45 | |||
46 | /*! |
|
46 | /*! | |
47 | \enum QChart::AnimationOption |
|
47 | \enum QChart::AnimationOption | |
48 |
|
48 | |||
49 | For enabling/disabling animations. Defaults to NoAnimation. |
|
49 | For enabling/disabling animations. Defaults to NoAnimation. | |
50 |
|
50 | |||
51 | \value NoAnimation |
|
51 | \value NoAnimation | |
52 | \value GridAxisAnimations |
|
52 | \value GridAxisAnimations | |
53 | \value SeriesAnimations |
|
53 | \value SeriesAnimations | |
54 | \value AllAnimations |
|
54 | \value AllAnimations | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \class QChart |
|
58 | \class QChart | |
59 | \brief QtCommercial chart API. |
|
59 | \brief QtCommercial chart API. | |
60 |
|
60 | |||
61 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical |
|
61 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical | |
62 |
representation of different types of |
|
62 | representation of different types of series and other chart related objects like | |
63 |
Q |
|
63 | QAxis and QLegend. If you simply want to show a chart in a layout, you can use the | |
64 | convenience class QChartView instead of QChart. |
|
64 | convenience class QChartView instead of QChart. | |
65 | \sa QChartView |
|
65 | \sa QChartView | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. |
|
69 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. | |
70 | */ |
|
70 | */ | |
71 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), |
|
71 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), | |
72 | d_ptr(new QChartPrivate()) |
|
72 | d_ptr(new QChartPrivate()) | |
73 | { |
|
73 | { | |
74 | d_ptr->m_dataset = new ChartDataSet(this); |
|
74 | d_ptr->m_dataset = new ChartDataSet(this); | |
75 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); |
|
75 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); | |
76 | d_ptr->createConnections(); |
|
76 | d_ptr->createConnections(); | |
77 | d_ptr->m_legend = new LegendScroller(this); |
|
77 | d_ptr->m_legend = new LegendScroller(this); | |
78 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); |
|
78 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | /*! |
|
81 | /*! | |
82 |
Destroys the object and it's children, like |
|
82 | Destroys the object and it's children, like series and axis objects added to it. | |
83 | */ |
|
83 | */ | |
84 | QChart::~QChart() |
|
84 | QChart::~QChart() | |
85 | { |
|
85 | { | |
86 | //delete first presenter , since this is a root of all the graphical items |
|
86 | //delete first presenter , since this is a root of all the graphical items | |
87 | delete d_ptr->m_presenter; |
|
87 | delete d_ptr->m_presenter; | |
88 | d_ptr->m_presenter=0; |
|
88 | d_ptr->m_presenter=0; | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | /*! |
|
91 | /*! | |
92 | Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects. |
|
92 | Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects. | |
93 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and |
|
93 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and | |
94 | the y axis). |
|
94 | the y axis). | |
95 | */ |
|
95 | */ | |
96 | void QChart::addSeries(QAbstractSeries *series, QAxis *axisY) |
|
96 | void QChart::addSeries(QAbstractSeries *series, QAxis *axisY) | |
97 | { |
|
97 | { | |
98 | Q_ASSERT(series); |
|
98 | Q_ASSERT(series); | |
99 | d_ptr->m_dataset->addSeries(series, axisY); |
|
99 | d_ptr->m_dataset->addSeries(series, axisY); | |
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | /*! |
|
102 | /*! | |
103 | Removes the \a series specified in a perameter from the QChartView. |
|
103 | Removes the \a series specified in a perameter from the QChartView. | |
104 | It releses its ownership of the specified QChartSeries object. |
|
104 | It releses its ownership of the specified QChartSeries object. | |
105 | It does not delete the pointed QChartSeries data object |
|
105 | It does not delete the pointed QChartSeries data object | |
106 | \sa addSeries(), removeAllSeries() |
|
106 | \sa addSeries(), removeAllSeries() | |
107 | */ |
|
107 | */ | |
108 | void QChart::removeSeries(QAbstractSeries *series) |
|
108 | void QChart::removeSeries(QAbstractSeries *series) | |
109 | { |
|
109 | { | |
110 | Q_ASSERT(series); |
|
110 | Q_ASSERT(series); | |
111 | d_ptr->m_dataset->removeSeries(series); |
|
111 | d_ptr->m_dataset->removeSeries(series); | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 | /*! |
|
114 | /*! | |
115 | Removes all the QChartSeries that have been added to the QChartView |
|
115 | Removes all the QChartSeries that have been added to the QChartView | |
116 | It also deletes the pointed QChartSeries data objects |
|
116 | It also deletes the pointed QChartSeries data objects | |
117 | \sa addSeries(), removeSeries() |
|
117 | \sa addSeries(), removeSeries() | |
118 | */ |
|
118 | */ | |
119 | void QChart::removeAllSeries() |
|
119 | void QChart::removeAllSeries() | |
120 | { |
|
120 | { | |
121 | d_ptr->m_dataset->removeAllSeries(); |
|
121 | d_ptr->m_dataset->removeAllSeries(); | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | /*! |
|
124 | /*! | |
125 | Sets the \a brush that is used for painting the background of the chart area. |
|
125 | Sets the \a brush that is used for painting the background of the chart area. | |
126 | */ |
|
126 | */ | |
127 | void QChart::setBackgroundBrush(const QBrush& brush) |
|
127 | void QChart::setBackgroundBrush(const QBrush& brush) | |
128 | { |
|
128 | { | |
129 | //TODO: refactor me |
|
129 | //TODO: refactor me | |
130 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
130 | d_ptr->m_presenter->createChartBackgroundItem(); | |
131 | d_ptr->m_presenter->m_backgroundItem->setBrush(brush); |
|
131 | d_ptr->m_presenter->m_backgroundItem->setBrush(brush); | |
132 | d_ptr->m_presenter->m_backgroundItem->update(); |
|
132 | d_ptr->m_presenter->m_backgroundItem->update(); | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | /*! |
|
135 | /*! | |
136 | Gets the brush that is used for painting the background of the chart area. |
|
136 | Gets the brush that is used for painting the background of the chart area. | |
137 | */ |
|
137 | */ | |
138 | QBrush QChart::backgroundBrush() const |
|
138 | QBrush QChart::backgroundBrush() const | |
139 | { |
|
139 | { | |
140 | //TODO: refactor me |
|
140 | //TODO: refactor me | |
141 | if (!d_ptr->m_presenter->m_backgroundItem) return QBrush(); |
|
141 | if (!d_ptr->m_presenter->m_backgroundItem) return QBrush(); | |
142 | return (d_ptr->m_presenter->m_backgroundItem)->brush(); |
|
142 | return (d_ptr->m_presenter->m_backgroundItem)->brush(); | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | Sets the \a pen that is used for painting the background of the chart area. |
|
146 | Sets the \a pen that is used for painting the background of the chart area. | |
147 | */ |
|
147 | */ | |
148 | void QChart::setBackgroundPen(const QPen& pen) |
|
148 | void QChart::setBackgroundPen(const QPen& pen) | |
149 | { |
|
149 | { | |
150 | //TODO: refactor me |
|
150 | //TODO: refactor me | |
151 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
151 | d_ptr->m_presenter->createChartBackgroundItem(); | |
152 | d_ptr->m_presenter->m_backgroundItem->setPen(pen); |
|
152 | d_ptr->m_presenter->m_backgroundItem->setPen(pen); | |
153 | d_ptr->m_presenter->m_backgroundItem->update(); |
|
153 | d_ptr->m_presenter->m_backgroundItem->update(); | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | /*! |
|
156 | /*! | |
157 | Gets the pen that is used for painting the background of the chart area. |
|
157 | Gets the pen that is used for painting the background of the chart area. | |
158 | */ |
|
158 | */ | |
159 | QPen QChart::backgroundPen() const |
|
159 | QPen QChart::backgroundPen() const | |
160 | { |
|
160 | { | |
161 | //TODO: refactor me |
|
161 | //TODO: refactor me | |
162 | if (!d_ptr->m_presenter->m_backgroundItem) return QPen(); |
|
162 | if (!d_ptr->m_presenter->m_backgroundItem) return QPen(); | |
163 | return d_ptr->m_presenter->m_backgroundItem->pen(); |
|
163 | return d_ptr->m_presenter->m_backgroundItem->pen(); | |
164 | } |
|
164 | } | |
165 |
|
165 | |||
166 | /*! |
|
166 | /*! | |
167 | Sets the chart \a title. The description text that is drawn above the chart. |
|
167 | Sets the chart \a title. The description text that is drawn above the chart. | |
168 | */ |
|
168 | */ | |
169 | void QChart::setTitle(const QString& title) |
|
169 | void QChart::setTitle(const QString& title) | |
170 | { |
|
170 | { | |
171 | //TODO: refactor me |
|
171 | //TODO: refactor me | |
172 | d_ptr->m_presenter->createChartTitleItem(); |
|
172 | d_ptr->m_presenter->createChartTitleItem(); | |
173 | d_ptr->m_presenter->m_titleItem->setText(title); |
|
173 | d_ptr->m_presenter->m_titleItem->setText(title); | |
174 | d_ptr->m_presenter->updateLayout(); |
|
174 | d_ptr->m_presenter->updateLayout(); | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | /*! |
|
177 | /*! | |
178 | Returns the chart title. The description text that is drawn above the chart. |
|
178 | Returns the chart title. The description text that is drawn above the chart. | |
179 | */ |
|
179 | */ | |
180 | QString QChart::title() const |
|
180 | QString QChart::title() const | |
181 | { |
|
181 | { | |
182 | //TODO: refactor me |
|
182 | //TODO: refactor me | |
183 | if (d_ptr->m_presenter->m_titleItem) |
|
183 | if (d_ptr->m_presenter->m_titleItem) | |
184 | return d_ptr->m_presenter->m_titleItem->text(); |
|
184 | return d_ptr->m_presenter->m_titleItem->text(); | |
185 | else |
|
185 | else | |
186 | return QString(); |
|
186 | return QString(); | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | /*! |
|
189 | /*! | |
190 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. |
|
190 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. | |
191 | */ |
|
191 | */ | |
192 | void QChart::setTitleFont(const QFont& font) |
|
192 | void QChart::setTitleFont(const QFont& font) | |
193 | { |
|
193 | { | |
194 | //TODO: refactor me |
|
194 | //TODO: refactor me | |
195 | d_ptr->m_presenter->createChartTitleItem(); |
|
195 | d_ptr->m_presenter->createChartTitleItem(); | |
196 | d_ptr->m_presenter->m_titleItem->setFont(font); |
|
196 | d_ptr->m_presenter->m_titleItem->setFont(font); | |
197 | d_ptr->m_presenter->updateLayout(); |
|
197 | d_ptr->m_presenter->updateLayout(); | |
198 | } |
|
198 | } | |
199 |
|
199 | |||
200 | /*! |
|
200 | /*! | |
201 | Gets the font that is used for drawing the chart description text that is rendered above the chart. |
|
201 | Gets the font that is used for drawing the chart description text that is rendered above the chart. | |
202 | */ |
|
202 | */ | |
203 | QFont QChart::titleFont() const |
|
203 | QFont QChart::titleFont() const | |
204 | { |
|
204 | { | |
205 | if (d_ptr->m_presenter->m_titleItem) |
|
205 | if (d_ptr->m_presenter->m_titleItem) | |
206 | return d_ptr->m_presenter->m_titleItem->font(); |
|
206 | return d_ptr->m_presenter->m_titleItem->font(); | |
207 | else |
|
207 | else | |
208 | return QFont(); |
|
208 | return QFont(); | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | /*! |
|
211 | /*! | |
212 | Sets the \a brush used for rendering the title text. |
|
212 | Sets the \a brush used for rendering the title text. | |
213 | */ |
|
213 | */ | |
214 | void QChart::setTitleBrush(const QBrush &brush) |
|
214 | void QChart::setTitleBrush(const QBrush &brush) | |
215 | { |
|
215 | { | |
216 | //TODO: refactor me |
|
216 | //TODO: refactor me | |
217 | d_ptr->m_presenter->createChartTitleItem(); |
|
217 | d_ptr->m_presenter->createChartTitleItem(); | |
218 | d_ptr->m_presenter->m_titleItem->setBrush(brush); |
|
218 | d_ptr->m_presenter->m_titleItem->setBrush(brush); | |
219 | d_ptr->m_presenter->updateLayout(); |
|
219 | d_ptr->m_presenter->updateLayout(); | |
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 | /*! |
|
222 | /*! | |
223 | Returns the brush used for rendering the title text. |
|
223 | Returns the brush used for rendering the title text. | |
224 | */ |
|
224 | */ | |
225 | QBrush QChart::titleBrush() const |
|
225 | QBrush QChart::titleBrush() const | |
226 | { |
|
226 | { | |
227 | //TODO: refactor me |
|
227 | //TODO: refactor me | |
228 | if (!d_ptr->m_presenter->m_titleItem) return QBrush(); |
|
228 | if (!d_ptr->m_presenter->m_titleItem) return QBrush(); | |
229 | return d_ptr->m_presenter->m_titleItem->brush(); |
|
229 | return d_ptr->m_presenter->m_titleItem->brush(); | |
230 | } |
|
230 | } | |
231 |
|
231 | |||
232 | /*! |
|
232 | /*! | |
233 | Sets the \a theme used by the chart for rendering the graphical representation of the data |
|
233 | Sets the \a theme used by the chart for rendering the graphical representation of the data | |
234 | \sa theme() |
|
234 | \sa theme() | |
235 | */ |
|
235 | */ | |
236 | void QChart::setTheme(QChart::ChartTheme theme) |
|
236 | void QChart::setTheme(QChart::ChartTheme theme) | |
237 | { |
|
237 | { | |
238 | d_ptr->m_presenter->setTheme(theme); |
|
238 | d_ptr->m_presenter->setTheme(theme); | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | /*! |
|
241 | /*! | |
242 | Returns the theme enum used by the chart. |
|
242 | Returns the theme enum used by the chart. | |
243 | \sa ChartTheme, setTheme() |
|
243 | \sa ChartTheme, setTheme() | |
244 | */ |
|
244 | */ | |
245 | QChart::ChartTheme QChart::theme() const |
|
245 | QChart::ChartTheme QChart::theme() const | |
246 | { |
|
246 | { | |
247 | return d_ptr->m_presenter->theme(); |
|
247 | return d_ptr->m_presenter->theme(); | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | /*! |
|
250 | /*! | |
251 | Zooms in the view by a factor of 2 |
|
251 | Zooms in the view by a factor of 2 | |
252 | */ |
|
252 | */ | |
253 | void QChart::zoomIn() |
|
253 | void QChart::zoomIn() | |
254 | { |
|
254 | { | |
255 | d_ptr->m_presenter->zoomIn(); |
|
255 | d_ptr->m_presenter->zoomIn(); | |
256 | } |
|
256 | } | |
257 |
|
257 | |||
258 | /*! |
|
258 | /*! | |
259 | Zooms in the view to a maximum level at which \a rect is still fully visible. |
|
259 | Zooms in the view to a maximum level at which \a rect is still fully visible. | |
260 | */ |
|
260 | */ | |
261 | void QChart::zoomIn(const QRectF& rect) |
|
261 | void QChart::zoomIn(const QRectF& rect) | |
262 | { |
|
262 | { | |
263 | if (!rect.isValid()) return; |
|
263 | if (!rect.isValid()) return; | |
264 | d_ptr->m_presenter->zoomIn(rect); |
|
264 | d_ptr->m_presenter->zoomIn(rect); | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | /*! |
|
267 | /*! | |
268 | Restores the view zoom level to the previous one. |
|
268 | Restores the view zoom level to the previous one. | |
269 | */ |
|
269 | */ | |
270 | void QChart::zoomOut() |
|
270 | void QChart::zoomOut() | |
271 | { |
|
271 | { | |
272 | d_ptr->m_presenter->zoomOut(); |
|
272 | d_ptr->m_presenter->zoomOut(); | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | /*! |
|
275 | /*! | |
276 | Returns the pointer to the x axis object of the chart |
|
276 | Returns the pointer to the x axis object of the chart | |
277 | */ |
|
277 | */ | |
278 | QAxis* QChart::axisX() const |
|
278 | QAxis* QChart::axisX() const | |
279 | { |
|
279 | { | |
280 | return d_ptr->m_dataset->axisX(); |
|
280 | return d_ptr->m_dataset->axisX(); | |
281 | } |
|
281 | } | |
282 |
|
282 | |||
283 | /*! |
|
283 | /*! | |
284 | Returns the pointer to the y axis object of the \a series |
|
284 | Returns the pointer to the y axis object of the \a series | |
285 | If no \a series is provided then default Y axis of the chart is returned. |
|
285 | If no \a series is provided then default Y axis of the chart is returned. | |
286 | */ |
|
286 | */ | |
287 | QAxis* QChart::axisY(QAbstractSeries *series) const |
|
287 | QAxis* QChart::axisY(QAbstractSeries *series) const | |
288 | { |
|
288 | { | |
289 | return d_ptr->m_dataset->axisY(series); |
|
289 | return d_ptr->m_dataset->axisY(series); | |
290 | } |
|
290 | } | |
291 |
|
291 | |||
292 | /*! |
|
292 | /*! | |
293 | Returns the legend object of the chart. Ownership stays in chart. |
|
293 | Returns the legend object of the chart. Ownership stays in chart. | |
294 | */ |
|
294 | */ | |
295 | QLegend* QChart::legend() const |
|
295 | QLegend* QChart::legend() const | |
296 | { |
|
296 | { | |
297 | return d_ptr->m_legend; |
|
297 | return d_ptr->m_legend; | |
298 | } |
|
298 | } | |
299 |
|
299 | |||
300 | /*! |
|
300 | /*! | |
301 | Returns the rect that contains information about margins (distance between chart widget edge and axes). |
|
301 | Returns the rect that contains information about margins (distance between chart widget edge and axes). | |
302 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. |
|
302 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. | |
303 | */ |
|
303 | */ | |
304 | QRectF QChart::margins() const |
|
304 | QRectF QChart::margins() const | |
305 | { |
|
305 | { | |
306 | return d_ptr->m_presenter->margins(); |
|
306 | return d_ptr->m_presenter->margins(); | |
307 | } |
|
307 | } | |
308 |
|
308 | |||
309 |
|
309 | |||
310 | /*! |
|
310 | /*! | |
311 | Resizes and updates the chart area using the \a event data |
|
311 | Resizes and updates the chart area using the \a event data | |
312 | */ |
|
312 | */ | |
313 | void QChart::resizeEvent(QGraphicsSceneResizeEvent *event) |
|
313 | void QChart::resizeEvent(QGraphicsSceneResizeEvent *event) | |
314 | { |
|
314 | { | |
315 | d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize()); |
|
315 | d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize()); | |
316 | QGraphicsWidget::resizeEvent(event); |
|
316 | QGraphicsWidget::resizeEvent(event); | |
317 | d_ptr->m_presenter->setGeometry(d_ptr->m_rect); |
|
317 | d_ptr->m_presenter->setGeometry(d_ptr->m_rect); | |
318 | } |
|
318 | } | |
319 |
|
319 | |||
320 | /*! |
|
320 | /*! | |
321 | Sets animation \a options for the chart |
|
321 | Sets animation \a options for the chart | |
322 | */ |
|
322 | */ | |
323 | void QChart::setAnimationOptions(AnimationOptions options) |
|
323 | void QChart::setAnimationOptions(AnimationOptions options) | |
324 | { |
|
324 | { | |
325 | d_ptr->m_presenter->setAnimationOptions(options); |
|
325 | d_ptr->m_presenter->setAnimationOptions(options); | |
326 | } |
|
326 | } | |
327 |
|
327 | |||
328 | /*! |
|
328 | /*! | |
329 | Returns animation options for the chart |
|
329 | Returns animation options for the chart | |
330 | */ |
|
330 | */ | |
331 | QChart::AnimationOptions QChart::animationOptions() const |
|
331 | QChart::AnimationOptions QChart::animationOptions() const | |
332 | { |
|
332 | { | |
333 | return d_ptr->m_presenter->animationOptions(); |
|
333 | return d_ptr->m_presenter->animationOptions(); | |
334 | } |
|
334 | } | |
335 |
|
335 | |||
336 | /*! |
|
336 | /*! | |
337 | Scrolls the visible area of the chart to the left by the distance between two x axis ticks |
|
337 | Scrolls the visible area of the chart to the left by the distance between two x axis ticks | |
338 | */ |
|
338 | */ | |
339 | void QChart::scrollLeft() |
|
339 | void QChart::scrollLeft() | |
340 | { |
|
340 | { | |
341 | d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); |
|
341 | d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); | |
342 | } |
|
342 | } | |
343 |
|
343 | |||
344 | /*! |
|
344 | /*! | |
345 | Scrolls the visible area of the chart to the right by the distance between two x axis ticks |
|
345 | Scrolls the visible area of the chart to the right by the distance between two x axis ticks | |
346 | */ |
|
346 | */ | |
347 | void QChart::scrollRight() |
|
347 | void QChart::scrollRight() | |
348 | { |
|
348 | { | |
349 | d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); |
|
349 | d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); | |
350 | } |
|
350 | } | |
351 |
|
351 | |||
352 | /*! |
|
352 | /*! | |
353 | Scrolls the visible area of the chart up by the distance between two y axis ticks |
|
353 | Scrolls the visible area of the chart up by the distance between two y axis ticks | |
354 | */ |
|
354 | */ | |
355 | void QChart::scrollUp() |
|
355 | void QChart::scrollUp() | |
356 | { |
|
356 | { | |
357 | d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); |
|
357 | d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); | |
358 | } |
|
358 | } | |
359 |
|
359 | |||
360 | /*! |
|
360 | /*! | |
361 | Scrolls the visible area of the chart down by the distance between two y axis ticks |
|
361 | Scrolls the visible area of the chart down by the distance between two y axis ticks | |
362 | */ |
|
362 | */ | |
363 | void QChart::scrollDown() |
|
363 | void QChart::scrollDown() | |
364 | { |
|
364 | { | |
365 | d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); |
|
365 | d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); | |
366 | } |
|
366 | } | |
367 |
|
367 | |||
368 | /*! |
|
368 | /*! | |
369 | Sets the chart background visibility state to \a visible |
|
369 | Sets the chart background visibility state to \a visible | |
370 | */ |
|
370 | */ | |
371 | void QChart::setBackgroundVisible(bool visible) |
|
371 | void QChart::setBackgroundVisible(bool visible) | |
372 | { |
|
372 | { | |
373 | //TODO: refactor me |
|
373 | //TODO: refactor me | |
374 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
374 | d_ptr->m_presenter->createChartBackgroundItem(); | |
375 | d_ptr->m_presenter->m_backgroundItem->setVisible(visible); |
|
375 | d_ptr->m_presenter->m_backgroundItem->setVisible(visible); | |
376 | } |
|
376 | } | |
377 |
|
377 | |||
378 | /*! |
|
378 | /*! | |
379 | Returns the chart's background visibility state |
|
379 | Returns the chart's background visibility state | |
380 | */ |
|
380 | */ | |
381 | bool QChart::isBackgroundVisible() const |
|
381 | bool QChart::isBackgroundVisible() const | |
382 | { |
|
382 | { | |
383 | //TODO: refactor me |
|
383 | //TODO: refactor me | |
384 | if (!d_ptr->m_presenter->m_backgroundItem) |
|
384 | if (!d_ptr->m_presenter->m_backgroundItem) | |
385 | return false; |
|
385 | return false; | |
386 |
|
386 | |||
387 | return d_ptr->m_presenter->m_backgroundItem->isVisible(); |
|
387 | return d_ptr->m_presenter->m_backgroundItem->isVisible(); | |
388 | } |
|
388 | } | |
389 |
|
389 | |||
390 | /*! |
|
390 | /*! | |
391 | Sets the background drop shadow effect state to \a enabled. |
|
391 | Sets the background drop shadow effect state to \a enabled. | |
392 | */ |
|
392 | */ | |
393 | void QChart::setBackgroundDropShadowEnabled(bool enabled) |
|
393 | void QChart::setBackgroundDropShadowEnabled(bool enabled) | |
394 | { |
|
394 | { | |
395 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
395 | d_ptr->m_presenter->createChartBackgroundItem(); | |
396 | d_ptr->m_presenter->m_backgroundItem->setDropShadowEnabled(enabled); |
|
396 | d_ptr->m_presenter->m_backgroundItem->setDropShadowEnabled(enabled); | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | /*! |
|
399 | /*! | |
400 | Returns true if the drop shadow effect is enabled for the chart background. |
|
400 | Returns true if the drop shadow effect is enabled for the chart background. | |
401 | */ |
|
401 | */ | |
402 | bool QChart::isBackgroundDropShadowEnabled() const |
|
402 | bool QChart::isBackgroundDropShadowEnabled() const | |
403 | { |
|
403 | { | |
404 | if (!d_ptr->m_presenter->m_backgroundItem) |
|
404 | if (!d_ptr->m_presenter->m_backgroundItem) | |
405 | return false; |
|
405 | return false; | |
406 |
|
406 | |||
407 | return d_ptr->m_presenter->m_backgroundItem->isDropShadowEnabled(); |
|
407 | return d_ptr->m_presenter->m_backgroundItem->isDropShadowEnabled(); | |
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
410 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
411 |
|
411 | |||
412 | QChartPrivate::QChartPrivate(): |
|
412 | QChartPrivate::QChartPrivate(): | |
413 | m_legend(0), |
|
413 | m_legend(0), | |
414 | m_dataset(0), |
|
414 | m_dataset(0), | |
415 | m_presenter(0) |
|
415 | m_presenter(0) | |
416 | { |
|
416 | { | |
417 |
|
417 | |||
418 | } |
|
418 | } | |
419 |
|
419 | |||
420 | QChartPrivate::~QChartPrivate() |
|
420 | QChartPrivate::~QChartPrivate() | |
421 | { |
|
421 | { | |
422 |
|
422 | |||
423 | } |
|
423 | } | |
424 |
|
424 | |||
425 | void QChartPrivate::createConnections() |
|
425 | void QChartPrivate::createConnections() | |
426 | { |
|
426 | { | |
427 |
|
427 | |||
428 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries *, Domain *)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries *, Domain *))); |
|
428 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries *, Domain *)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries *, Domain *))); | |
429 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries *)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries *))); |
|
429 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries *)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries *))); | |
430 | QObject::connect(m_dataset,SIGNAL(axisAdded(QAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAxis*,Domain*))); |
|
430 | QObject::connect(m_dataset,SIGNAL(axisAdded(QAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAxis*,Domain*))); | |
431 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QAxis*)),m_presenter,SLOT(handleAxisRemoved(QAxis*))); |
|
431 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QAxis*)),m_presenter,SLOT(handleAxisRemoved(QAxis*))); | |
432 | } |
|
432 | } | |
433 |
|
433 | |||
434 | #include "moc_qchart.cpp" |
|
434 | #include "moc_qchart.cpp" | |
435 |
|
435 | |||
436 | QTCOMMERCIALCHART_END_NAMESPACE |
|
436 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,218 +1,218 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qchartview.h" |
|
21 | #include "qchartview.h" | |
22 | #include "qchartview_p.h" |
|
22 | #include "qchartview_p.h" | |
23 | #include "qchart_p.h" |
|
23 | #include "qchart_p.h" | |
24 | #include <QGraphicsScene> |
|
24 | #include <QGraphicsScene> | |
25 | #include <QRubberBand> |
|
25 | #include <QRubberBand> | |
26 |
|
26 | |||
27 | /*! |
|
27 | /*! | |
28 | \enum QChartView::RubberBand |
|
28 | \enum QChartView::RubberBand | |
29 |
|
29 | |||
30 | This enum describes the different types of rubber bands that can be used for zoom rect selection |
|
30 | This enum describes the different types of rubber bands that can be used for zoom rect selection | |
31 |
|
31 | |||
32 | \value NoRubberBand |
|
32 | \value NoRubberBand | |
33 | \value VerticalRubberBand |
|
33 | \value VerticalRubberBand | |
34 | \value HorizonalRubberBand |
|
34 | \value HorizonalRubberBand | |
35 | \value RectangleRubberBand |
|
35 | \value RectangleRubberBand | |
36 | */ |
|
36 | */ | |
37 |
|
37 | |||
38 | /*! |
|
38 | /*! | |
39 | \class QChartView |
|
39 | \class QChartView | |
40 | \brief Standalone charting widget. |
|
40 | \brief Standalone charting widget. | |
41 |
|
41 | |||
42 | QChartView is a standalone widget that can display charts. It does not require separate |
|
42 | QChartView is a standalone widget that can display charts. It does not require separate | |
43 | QGraphicsScene to work. It manages the graphical representation of different types of |
|
43 | QGraphicsScene to work. It manages the graphical representation of different types of | |
44 |
|
|
44 | series and other chart related objects like QAxis and QLegend. If you want to | |
45 | display a chart in your existing QGraphicsScene, you can use the QChart class instead. |
|
45 | display a chart in your existing QGraphicsScene, you can use the QChart class instead. | |
46 |
|
46 | |||
47 | \sa QChart |
|
47 | \sa QChart | |
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
50 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
51 |
|
51 | |||
52 | /*! |
|
52 | /*! | |
53 | Constructs a chartView object with parent \a parent to display a \a chart. |
|
53 | Constructs a chartView object with parent \a parent to display a \a chart. | |
54 | */ |
|
54 | */ | |
55 | QChartView::QChartView(QChart *chart,QWidget *parent) : |
|
55 | QChartView::QChartView(QChart *chart,QWidget *parent) : | |
56 | QGraphicsView(parent), |
|
56 | QGraphicsView(parent), | |
57 | d_ptr(new QChartViewPrivate()) |
|
57 | d_ptr(new QChartViewPrivate()) | |
58 | { |
|
58 | { | |
59 | Q_ASSERT(chart); |
|
59 | Q_ASSERT(chart); | |
60 | d_ptr->m_scene = new QGraphicsScene(this); |
|
60 | d_ptr->m_scene = new QGraphicsScene(this); | |
61 | d_ptr->m_chart = chart; |
|
61 | d_ptr->m_chart = chart; | |
62 | setFrameShape(QFrame::NoFrame); |
|
62 | setFrameShape(QFrame::NoFrame); | |
63 | setBackgroundRole(QPalette::Window); |
|
63 | setBackgroundRole(QPalette::Window); | |
64 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
64 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
65 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
65 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
66 | setScene(d_ptr->m_scene); |
|
66 | setScene(d_ptr->m_scene); | |
67 | d_ptr->m_scene->addItem(chart); |
|
67 | d_ptr->m_scene->addItem(chart); | |
68 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
68 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 |
|
71 | |||
72 | /*! |
|
72 | /*! | |
73 |
Destroys the object and it's children, like |
|
73 | Destroys the object and it's children, like series and axis objects added to it. | |
74 | */ |
|
74 | */ | |
75 | QChartView::~QChartView() |
|
75 | QChartView::~QChartView() | |
76 | { |
|
76 | { | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | Returns the pointer to the associated chart |
|
80 | Returns the pointer to the associated chart | |
81 | */ |
|
81 | */ | |
82 | QChart* QChartView::chart() const |
|
82 | QChart* QChartView::chart() const | |
83 | { |
|
83 | { | |
84 | return d_ptr->m_chart; |
|
84 | return d_ptr->m_chart; | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | /*! |
|
87 | /*! | |
88 | Sets the RubberBandPlicy to \a rubberBand. Selected policy determines the way zooming is performed. |
|
88 | Sets the RubberBandPlicy to \a rubberBand. Selected policy determines the way zooming is performed. | |
89 | */ |
|
89 | */ | |
90 | void QChartView::setRubberBand(const RubberBands& rubberBand) |
|
90 | void QChartView::setRubberBand(const RubberBands& rubberBand) | |
91 | { |
|
91 | { | |
92 | d_ptr->m_rubberBandFlags=rubberBand; |
|
92 | d_ptr->m_rubberBandFlags=rubberBand; | |
93 |
|
93 | |||
94 | if (!d_ptr->m_rubberBandFlags) { |
|
94 | if (!d_ptr->m_rubberBandFlags) { | |
95 | delete d_ptr->m_rubberBand; |
|
95 | delete d_ptr->m_rubberBand; | |
96 | d_ptr->m_rubberBand=0; |
|
96 | d_ptr->m_rubberBand=0; | |
97 | return; |
|
97 | return; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | if (!d_ptr->m_rubberBand) { |
|
100 | if (!d_ptr->m_rubberBand) { | |
101 | d_ptr->m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this); |
|
101 | d_ptr->m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this); | |
102 | d_ptr->m_rubberBand->setEnabled(true); |
|
102 | d_ptr->m_rubberBand->setEnabled(true); | |
103 | } |
|
103 | } | |
104 | } |
|
104 | } | |
105 |
|
105 | |||
106 | /*! |
|
106 | /*! | |
107 | Returns the RubberBandPolicy that is currently being used by the widget. |
|
107 | Returns the RubberBandPolicy that is currently being used by the widget. | |
108 | */ |
|
108 | */ | |
109 | QChartView::RubberBands QChartView::rubberBand() const |
|
109 | QChartView::RubberBands QChartView::rubberBand() const | |
110 | { |
|
110 | { | |
111 | return d_ptr->m_rubberBandFlags; |
|
111 | return d_ptr->m_rubberBandFlags; | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 | /*! |
|
114 | /*! | |
115 | If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area. |
|
115 | If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area. | |
116 | If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation. |
|
116 | If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation. | |
117 | */ |
|
117 | */ | |
118 | void QChartView::mousePressEvent(QMouseEvent *event) |
|
118 | void QChartView::mousePressEvent(QMouseEvent *event) | |
119 | { |
|
119 | { | |
120 | if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) { |
|
120 | if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) { | |
121 |
|
121 | |||
122 | int padding = d_ptr->m_chart->margins().top(); |
|
122 | int padding = d_ptr->m_chart->margins().top(); | |
123 | QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding); |
|
123 | QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding); | |
124 |
|
124 | |||
125 | if (rect.contains(event->pos())) { |
|
125 | if (rect.contains(event->pos())) { | |
126 | d_ptr->m_rubberBandOrigin = event->pos(); |
|
126 | d_ptr->m_rubberBandOrigin = event->pos(); | |
127 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize())); |
|
127 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize())); | |
128 | d_ptr->m_rubberBand->show(); |
|
128 | d_ptr->m_rubberBand->show(); | |
129 | event->accept(); |
|
129 | event->accept(); | |
130 | } |
|
130 | } | |
131 | } |
|
131 | } | |
132 | else { |
|
132 | else { | |
133 | QGraphicsView::mousePressEvent(event); |
|
133 | QGraphicsView::mousePressEvent(event); | |
134 | } |
|
134 | } | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | /*! |
|
137 | /*! | |
138 | If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry. |
|
138 | If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry. | |
139 | In other case the defualt QGraphicsView::mouseMoveEvent implementation is called. |
|
139 | In other case the defualt QGraphicsView::mouseMoveEvent implementation is called. | |
140 | */ |
|
140 | */ | |
141 | void QChartView::mouseMoveEvent(QMouseEvent *event) |
|
141 | void QChartView::mouseMoveEvent(QMouseEvent *event) | |
142 | { |
|
142 | { | |
143 | if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) { |
|
143 | if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) { | |
144 | QRectF margins = d_ptr->m_chart->margins(); |
|
144 | QRectF margins = d_ptr->m_chart->margins(); | |
145 | QRectF geometry = d_ptr->m_chart->geometry(); |
|
145 | QRectF geometry = d_ptr->m_chart->geometry(); | |
146 | QRectF rect =geometry.adjusted(margins.left(),margins.top(),-margins.right(),-margins.bottom()); |
|
146 | QRectF rect =geometry.adjusted(margins.left(),margins.top(),-margins.right(),-margins.bottom()); | |
147 | int width = event->pos().x() - d_ptr->m_rubberBandOrigin.x(); |
|
147 | int width = event->pos().x() - d_ptr->m_rubberBandOrigin.x(); | |
148 | int height = event->pos().y() - d_ptr->m_rubberBandOrigin.y(); |
|
148 | int height = event->pos().y() - d_ptr->m_rubberBandOrigin.y(); | |
149 | if (!d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) { |
|
149 | if (!d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) { | |
150 | d_ptr->m_rubberBandOrigin.setY(rect.top()); |
|
150 | d_ptr->m_rubberBandOrigin.setY(rect.top()); | |
151 | height = rect.height(); |
|
151 | height = rect.height(); | |
152 | } |
|
152 | } | |
153 | if (!d_ptr->m_rubberBandFlags.testFlag(HorizonalRubberBand)) { |
|
153 | if (!d_ptr->m_rubberBandFlags.testFlag(HorizonalRubberBand)) { | |
154 | d_ptr->m_rubberBandOrigin.setX(rect.left()); |
|
154 | d_ptr->m_rubberBandOrigin.setX(rect.left()); | |
155 | width= rect.width(); |
|
155 | width= rect.width(); | |
156 | } |
|
156 | } | |
157 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized()); |
|
157 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized()); | |
158 | } |
|
158 | } | |
159 | else { |
|
159 | else { | |
160 | QGraphicsView::mouseMoveEvent(event); |
|
160 | QGraphicsView::mouseMoveEvent(event); | |
161 | } |
|
161 | } | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand |
|
165 | If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand | |
166 | If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled. |
|
166 | If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled. | |
167 | */ |
|
167 | */ | |
168 | void QChartView::mouseReleaseEvent(QMouseEvent *event) |
|
168 | void QChartView::mouseReleaseEvent(QMouseEvent *event) | |
169 | { |
|
169 | { | |
170 | if(d_ptr->m_rubberBand) { |
|
170 | if(d_ptr->m_rubberBand) { | |
171 | if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) { |
|
171 | if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) { | |
172 | d_ptr->m_rubberBand->hide(); |
|
172 | d_ptr->m_rubberBand->hide(); | |
173 | QRect rect = d_ptr->m_rubberBand->geometry(); |
|
173 | QRect rect = d_ptr->m_rubberBand->geometry(); | |
174 | d_ptr->m_chart->zoomIn(rect); |
|
174 | d_ptr->m_chart->zoomIn(rect); | |
175 | event->accept(); |
|
175 | event->accept(); | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | if(event->button()==Qt::RightButton){ |
|
178 | if(event->button()==Qt::RightButton){ | |
179 | d_ptr->m_chart->zoomOut(); |
|
179 | d_ptr->m_chart->zoomOut(); | |
180 | event->accept(); |
|
180 | event->accept(); | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 | else { |
|
183 | else { | |
184 | QGraphicsView::mouseReleaseEvent(event); |
|
184 | QGraphicsView::mouseReleaseEvent(event); | |
185 | } |
|
185 | } | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | /*! |
|
188 | /*! | |
189 | Resizes and updates the chart area using the \a event data |
|
189 | Resizes and updates the chart area using the \a event data | |
190 | */ |
|
190 | */ | |
191 | void QChartView::resizeEvent(QResizeEvent *event) |
|
191 | void QChartView::resizeEvent(QResizeEvent *event) | |
192 | { |
|
192 | { | |
193 | QGraphicsView::resizeEvent(event); |
|
193 | QGraphicsView::resizeEvent(event); | |
194 | d_ptr->m_chart->resize(size()); |
|
194 | d_ptr->m_chart->resize(size()); | |
195 | setMinimumSize(d_ptr->m_chart->minimumSize().toSize()); |
|
195 | setMinimumSize(d_ptr->m_chart->minimumSize().toSize()); | |
196 | setSceneRect(d_ptr->m_chart->geometry()); |
|
196 | setSceneRect(d_ptr->m_chart->geometry()); | |
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
199 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
200 |
|
200 | |||
201 | QChartViewPrivate::QChartViewPrivate(): |
|
201 | QChartViewPrivate::QChartViewPrivate(): | |
202 | m_scene(0), |
|
202 | m_scene(0), | |
203 | m_chart(0), |
|
203 | m_chart(0), | |
204 | m_presenter(0), |
|
204 | m_presenter(0), | |
205 | m_rubberBand(0), |
|
205 | m_rubberBand(0), | |
206 | m_rubberBandFlags(QChartView::NoRubberBand) |
|
206 | m_rubberBandFlags(QChartView::NoRubberBand) | |
207 | { |
|
207 | { | |
208 |
|
208 | |||
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | QChartViewPrivate::~QChartViewPrivate() |
|
211 | QChartViewPrivate::~QChartViewPrivate() | |
212 | { |
|
212 | { | |
213 |
|
213 | |||
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | #include "moc_qchartview.cpp" |
|
216 | #include "moc_qchartview.cpp" | |
217 |
|
217 | |||
218 | QTCOMMERCIALCHART_END_NAMESPACE |
|
218 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now