##// END OF EJS Templates
QAbstractAxis: renamed Arrow and Axis to line in methods names
Marek Rosa -
r1844:691cce09e051
parent child
Show More
@@ -1,121 +1,121
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 <QApplication>
21 #include <QApplication>
22 #include <QMainWindow>
22 #include <QMainWindow>
23 #include <QChartView>
23 #include <QChartView>
24 #include <QLineSeries>
24 #include <QLineSeries>
25 #include <QCategoryAxis>
25 #include <QCategoryAxis>
26
26
27 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
28
28
29 int main(int argc, char *argv[])
29 int main(int argc, char *argv[])
30 {
30 {
31 QApplication a(argc, argv);
31 QApplication a(argc, argv);
32
32
33 //![1]
33 //![1]
34 QLineSeries* series = new QLineSeries();
34 QLineSeries* series = new QLineSeries();
35 *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26);
35 *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26);
36 QChart* chart = new QChart();
36 QChart* chart = new QChart();
37 chart->legend()->hide();
37 chart->legend()->hide();
38 chart->addSeries(series);
38 chart->addSeries(series);
39 //![1]
39 //![1]
40
40
41 //![2]
41 //![2]
42 // Customize series
42 // Customize series
43 QPen pen(QRgb(0xfdb157));
43 QPen pen(QRgb(0xfdb157));
44 pen.setWidth(5);
44 pen.setWidth(5);
45 series->setPen(pen);
45 series->setPen(pen);
46
46
47 // Customize chart title
47 // Customize chart title
48 QFont font;
48 QFont font;
49 font.setPixelSize(18);
49 font.setPixelSize(18);
50 chart->setTitleFont(font);
50 chart->setTitleFont(font);
51 chart->setTitleBrush(QBrush(Qt::white));
51 chart->setTitleBrush(QBrush(Qt::white));
52 chart->setTitle("Customchart example");
52 chart->setTitle("Customchart example");
53
53
54 // Customize chart background
54 // Customize chart background
55 QLinearGradient backgroundGradient;
55 QLinearGradient backgroundGradient;
56 backgroundGradient.setStart(QPointF(0,0));
56 backgroundGradient.setStart(QPointF(0,0));
57 backgroundGradient.setFinalStop(QPointF(0,1));
57 backgroundGradient.setFinalStop(QPointF(0,1));
58 backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1));
58 backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1));
59 backgroundGradient.setColorAt(1.0, QRgb(0x4c4547));
59 backgroundGradient.setColorAt(1.0, QRgb(0x4c4547));
60 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
60 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
61 chart->setBackgroundBrush(backgroundGradient);
61 chart->setBackgroundBrush(backgroundGradient);
62 //![2]
62 //![2]
63
63
64 //![3]
64 //![3]
65 QCategoryAxis* axisX = new QCategoryAxis();
65 QCategoryAxis* axisX = new QCategoryAxis();
66 QCategoryAxis* axisY = new QCategoryAxis();
66 QCategoryAxis* axisY = new QCategoryAxis();
67
67
68 // Customize axis label font
68 // Customize axis label font
69 QFont labelsFont;
69 QFont labelsFont;
70 labelsFont.setPixelSize(12);
70 labelsFont.setPixelSize(12);
71 axisX->setLabelsFont(labelsFont);
71 axisX->setLabelsFont(labelsFont);
72 axisY->setLabelsFont(labelsFont);
72 axisY->setLabelsFont(labelsFont);
73
73
74 // Customize axis colors
74 // Customize axis colors
75 QPen axisPen(QRgb(0xd18952));
75 QPen axisPen(QRgb(0xd18952));
76 axisPen.setWidth(2);
76 axisPen.setWidth(2);
77 axisX->setAxisPen(axisPen);
77 axisX->setLinePen(axisPen);
78 axisY->setAxisPen(axisPen);
78 axisY->setLinePen(axisPen);
79
79
80 // Customize axis label colors
80 // Customize axis label colors
81 QBrush axisBrush(Qt::white);
81 QBrush axisBrush(Qt::white);
82 axisX->setLabelsBrush(axisBrush);
82 axisX->setLabelsBrush(axisBrush);
83 axisY->setLabelsBrush(axisBrush);
83 axisY->setLabelsBrush(axisBrush);
84
84
85 // Customize grid lines and shades
85 // Customize grid lines and shades
86 axisX->setGridLineVisible(false);
86 axisX->setGridLineVisible(false);
87 axisY->setGridLineVisible(false);
87 axisY->setGridLineVisible(false);
88 axisY->setShadesPen(Qt::NoPen);
88 axisY->setShadesPen(Qt::NoPen);
89 axisY->setShadesBrush(QBrush(QRgb(0xa5a2a3)));
89 axisY->setShadesBrush(QBrush(QRgb(0xa5a2a3)));
90 axisY->setShadesVisible(true);
90 axisY->setShadesVisible(true);
91 //![3]
91 //![3]
92
92
93 //![4]
93 //![4]
94 axisX->append("low", 10);
94 axisX->append("low", 10);
95 axisX->append("optimal", 20);
95 axisX->append("optimal", 20);
96 axisX->append("high", 30);
96 axisX->append("high", 30);
97 axisX->setRange(0, 30);
97 axisX->setRange(0, 30);
98
98
99 axisY->append("slow", 10);
99 axisY->append("slow", 10);
100 axisY->append("med", 20);
100 axisY->append("med", 20);
101 axisY->append("fast", 30);
101 axisY->append("fast", 30);
102 axisY->setRange(0, 30);
102 axisY->setRange(0, 30);
103
103
104 chart->setAxisX(axisX, series);
104 chart->setAxisX(axisX, series);
105 chart->setAxisY(axisY, series);
105 chart->setAxisY(axisY, series);
106 //![4]
106 //![4]
107
107
108 //![5]
108 //![5]
109 QChartView* chartView = new QChartView(chart);
109 QChartView* chartView = new QChartView(chart);
110 chartView->setRenderHint(QPainter::Antialiasing);
110 chartView->setRenderHint(QPainter::Antialiasing);
111 //![5]
111 //![5]
112
112
113 //![6]
113 //![6]
114 QMainWindow window;
114 QMainWindow window;
115 window.setCentralWidget(chartView);
115 window.setCentralWidget(chartView);
116 window.resize(400, 300);
116 window.resize(400, 300);
117 window.show();
117 window.show();
118 //![6]
118 //![6]
119
119
120 return a.exec();
120 return a.exec();
121 }
121 }
@@ -1,371 +1,371
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 "chartaxis_p.h"
21 #include "chartaxis_p.h"
22 #include "qabstractaxis.h"
22 #include "qabstractaxis.h"
23 #include "qabstractaxis_p.h"
23 #include "qabstractaxis_p.h"
24 #include "chartpresenter_p.h"
24 #include "chartpresenter_p.h"
25 #include "domain_p.h"
25 #include "domain_p.h"
26 #include <qmath.h>
26 #include <qmath.h>
27 #include <QDateTime>
27 #include <QDateTime>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : ChartElement(presenter),
31 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : ChartElement(presenter),
32 m_chartAxis(axis),
32 m_chartAxis(axis),
33 m_labelsAngle(0),
33 m_labelsAngle(0),
34 m_grid(new QGraphicsItemGroup(presenter->rootItem())),
34 m_grid(new QGraphicsItemGroup(presenter->rootItem())),
35 m_shades(new QGraphicsItemGroup(presenter->rootItem())),
35 m_shades(new QGraphicsItemGroup(presenter->rootItem())),
36 m_labels(new QGraphicsItemGroup(presenter->rootItem())),
36 m_labels(new QGraphicsItemGroup(presenter->rootItem())),
37 m_arrow(new QGraphicsItemGroup(presenter->rootItem())),
37 m_arrow(new QGraphicsItemGroup(presenter->rootItem())),
38 m_min(0),
38 m_min(0),
39 m_max(0),
39 m_max(0),
40 m_animation(0),
40 m_animation(0),
41 m_minWidth(0),
41 m_minWidth(0),
42 m_minHeight(0)
42 m_minHeight(0)
43 {
43 {
44 //initial initialization
44 //initial initialization
45 m_arrow->setZValue(ChartPresenter::AxisZValue);
45 m_arrow->setZValue(ChartPresenter::AxisZValue);
46 m_arrow->setHandlesChildEvents(false);
46 m_arrow->setHandlesChildEvents(false);
47 m_labels->setZValue(ChartPresenter::AxisZValue);
47 m_labels->setZValue(ChartPresenter::AxisZValue);
48 m_shades->setZValue(ChartPresenter::ShadesZValue);
48 m_shades->setZValue(ChartPresenter::ShadesZValue);
49 m_grid->setZValue(ChartPresenter::GridZValue);
49 m_grid->setZValue(ChartPresenter::GridZValue);
50
50
51 QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated()));
51 QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated()));
52
52
53 QGraphicsSimpleTextItem item;
53 QGraphicsSimpleTextItem item;
54 m_font = item.font();
54 m_font = item.font();
55
55
56 }
56 }
57
57
58 ChartAxis::~ChartAxis()
58 ChartAxis::~ChartAxis()
59 {
59 {
60 }
60 }
61
61
62 void ChartAxis::setAnimation(AxisAnimation* animation)
62 void ChartAxis::setAnimation(AxisAnimation* animation)
63 {
63 {
64 m_animation=animation;
64 m_animation=animation;
65 }
65 }
66
66
67 void ChartAxis::setLayout(QVector<qreal> &layout)
67 void ChartAxis::setLayout(QVector<qreal> &layout)
68 {
68 {
69 m_layoutVector=layout;
69 m_layoutVector=layout;
70 }
70 }
71
71
72 void ChartAxis::createItems(int count)
72 void ChartAxis::createItems(int count)
73 {
73 {
74 if (m_arrow->children().size() == 0)
74 if (m_arrow->children().size() == 0)
75 m_arrow->addToGroup(new AxisItem(this,presenter()->rootItem()));
75 m_arrow->addToGroup(new AxisItem(this,presenter()->rootItem()));
76 for (int i = 0; i < count; ++i) {
76 for (int i = 0; i < count; ++i) {
77 m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
77 m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
78 m_labels->addToGroup(new QGraphicsSimpleTextItem(presenter()->rootItem()));
78 m_labels->addToGroup(new QGraphicsSimpleTextItem(presenter()->rootItem()));
79 m_arrow->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
79 m_arrow->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
80 if ((m_grid->childItems().size())%2 && m_grid->childItems().size()>2) m_shades->addToGroup(new QGraphicsRectItem(presenter()->rootItem()));
80 if ((m_grid->childItems().size())%2 && m_grid->childItems().size()>2) m_shades->addToGroup(new QGraphicsRectItem(presenter()->rootItem()));
81 }
81 }
82 }
82 }
83
83
84 void ChartAxis::deleteItems(int count)
84 void ChartAxis::deleteItems(int count)
85 {
85 {
86 QList<QGraphicsItem *> lines = m_grid->childItems();
86 QList<QGraphicsItem *> lines = m_grid->childItems();
87 QList<QGraphicsItem *> labels = m_labels->childItems();
87 QList<QGraphicsItem *> labels = m_labels->childItems();
88 QList<QGraphicsItem *> shades = m_shades->childItems();
88 QList<QGraphicsItem *> shades = m_shades->childItems();
89 QList<QGraphicsItem *> axis = m_arrow->childItems();
89 QList<QGraphicsItem *> axis = m_arrow->childItems();
90
90
91 for (int i = 0; i < count; ++i) {
91 for (int i = 0; i < count; ++i) {
92 if (lines.size()%2 && lines.size() > 1) delete(shades.takeLast());
92 if (lines.size()%2 && lines.size() > 1) delete(shades.takeLast());
93 delete(lines.takeLast());
93 delete(lines.takeLast());
94 delete(labels.takeLast());
94 delete(labels.takeLast());
95 delete(axis.takeLast());
95 delete(axis.takeLast());
96 }
96 }
97 }
97 }
98
98
99 void ChartAxis::updateLayout(QVector<qreal> &layout)
99 void ChartAxis::updateLayout(QVector<qreal> &layout)
100 {
100 {
101 int diff = m_layoutVector.size() - layout.size();
101 int diff = m_layoutVector.size() - layout.size();
102
102
103 if (diff>0) {
103 if (diff>0) {
104 deleteItems(diff);
104 deleteItems(diff);
105 }
105 }
106 else if (diff<0) {
106 else if (diff<0) {
107 createItems(-diff);
107 createItems(-diff);
108 }
108 }
109
109
110 if(diff<0) handleAxisUpdated();
110 if(diff<0) handleAxisUpdated();
111
111
112 if (m_animation) {
112 if (m_animation) {
113 switch(presenter()->state()){
113 switch(presenter()->state()){
114 case ChartPresenter::ZoomInState:
114 case ChartPresenter::ZoomInState:
115 m_animation->setAnimationType(AxisAnimation::ZoomInAnimation);
115 m_animation->setAnimationType(AxisAnimation::ZoomInAnimation);
116 m_animation->setAnimationPoint(presenter()->statePoint());
116 m_animation->setAnimationPoint(presenter()->statePoint());
117 break;
117 break;
118 case ChartPresenter::ZoomOutState:
118 case ChartPresenter::ZoomOutState:
119 m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation);
119 m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation);
120 m_animation->setAnimationPoint(presenter()->statePoint());
120 m_animation->setAnimationPoint(presenter()->statePoint());
121 break;
121 break;
122 case ChartPresenter::ScrollUpState:
122 case ChartPresenter::ScrollUpState:
123 case ChartPresenter::ScrollLeftState:
123 case ChartPresenter::ScrollLeftState:
124 m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation);
124 m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation);
125 break;
125 break;
126 case ChartPresenter::ScrollDownState:
126 case ChartPresenter::ScrollDownState:
127 case ChartPresenter::ScrollRightState:
127 case ChartPresenter::ScrollRightState:
128 m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation);
128 m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation);
129 break;
129 break;
130 case ChartPresenter::ShowState:
130 case ChartPresenter::ShowState:
131 m_animation->setAnimationType(AxisAnimation::DefaultAnimation);
131 m_animation->setAnimationType(AxisAnimation::DefaultAnimation);
132 break;
132 break;
133 }
133 }
134 m_animation->setValues(m_layoutVector,layout);
134 m_animation->setValues(m_layoutVector,layout);
135 presenter()->startAnimation(m_animation);
135 presenter()->startAnimation(m_animation);
136 }
136 }
137 else {
137 else {
138 setLayout(layout);
138 setLayout(layout);
139 updateGeometry();
139 updateGeometry();
140 }
140 }
141 }
141 }
142
142
143 void ChartAxis::setArrowOpacity(qreal opacity)
143 void ChartAxis::setArrowOpacity(qreal opacity)
144 {
144 {
145 m_arrow->setOpacity(opacity);
145 m_arrow->setOpacity(opacity);
146 }
146 }
147
147
148 qreal ChartAxis::arrowOpacity() const
148 qreal ChartAxis::arrowOpacity() const
149 {
149 {
150 return m_arrow->opacity();
150 return m_arrow->opacity();
151 }
151 }
152
152
153 void ChartAxis::setArrowVisibility(bool visible)
153 void ChartAxis::setArrowVisibility(bool visible)
154 {
154 {
155 m_arrow->setOpacity(visible);
155 m_arrow->setOpacity(visible);
156 }
156 }
157
157
158 void ChartAxis::setGridOpacity(qreal opacity)
158 void ChartAxis::setGridOpacity(qreal opacity)
159 {
159 {
160 m_grid->setOpacity(opacity);
160 m_grid->setOpacity(opacity);
161 }
161 }
162
162
163 qreal ChartAxis::gridOpacity() const
163 qreal ChartAxis::gridOpacity() const
164 {
164 {
165 return m_grid->opacity();
165 return m_grid->opacity();
166 }
166 }
167
167
168 void ChartAxis::setGridVisibility(bool visible)
168 void ChartAxis::setGridVisibility(bool visible)
169 {
169 {
170 m_grid->setOpacity(visible);
170 m_grid->setOpacity(visible);
171 }
171 }
172
172
173 void ChartAxis::setLabelsOpacity(qreal opacity)
173 void ChartAxis::setLabelsOpacity(qreal opacity)
174 {
174 {
175 m_labels->setOpacity(opacity);
175 m_labels->setOpacity(opacity);
176 }
176 }
177
177
178 qreal ChartAxis::labelsOpacity() const
178 qreal ChartAxis::labelsOpacity() const
179 {
179 {
180 return m_labels->opacity();
180 return m_labels->opacity();
181 }
181 }
182
182
183 void ChartAxis::setLabelsVisibility(bool visible)
183 void ChartAxis::setLabelsVisibility(bool visible)
184 {
184 {
185 m_labels->setOpacity(visible);
185 m_labels->setOpacity(visible);
186 }
186 }
187
187
188 void ChartAxis::setShadesOpacity(qreal opacity)
188 void ChartAxis::setShadesOpacity(qreal opacity)
189 {
189 {
190 m_shades->setOpacity(opacity);
190 m_shades->setOpacity(opacity);
191 }
191 }
192
192
193 qreal ChartAxis::shadesOpacity() const
193 qreal ChartAxis::shadesOpacity() const
194 {
194 {
195 return m_shades->opacity();
195 return m_shades->opacity();
196 }
196 }
197
197
198 void ChartAxis::setShadesVisibility(bool visible)
198 void ChartAxis::setShadesVisibility(bool visible)
199 {
199 {
200 m_shades->setVisible(visible);
200 m_shades->setVisible(visible);
201 }
201 }
202
202
203 void ChartAxis::setLabelsAngle(int angle)
203 void ChartAxis::setLabelsAngle(int angle)
204 {
204 {
205 foreach(QGraphicsItem* item , m_labels->childItems()) {
205 foreach(QGraphicsItem* item , m_labels->childItems()) {
206 item->setRotation(angle);
206 item->setRotation(angle);
207 }
207 }
208
208
209 m_labelsAngle=angle;
209 m_labelsAngle=angle;
210 }
210 }
211
211
212 void ChartAxis::setLabelsPen(const QPen &pen)
212 void ChartAxis::setLabelsPen(const QPen &pen)
213 {
213 {
214 foreach(QGraphicsItem* item , m_labels->childItems()) {
214 foreach(QGraphicsItem* item , m_labels->childItems()) {
215 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
215 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
216 }
216 }
217 }
217 }
218
218
219 void ChartAxis::setLabelsBrush(const QBrush &brush)
219 void ChartAxis::setLabelsBrush(const QBrush &brush)
220 {
220 {
221 foreach(QGraphicsItem* item , m_labels->childItems()) {
221 foreach(QGraphicsItem* item , m_labels->childItems()) {
222 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
222 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
223 }
223 }
224 }
224 }
225
225
226 void ChartAxis::setLabelsFont(const QFont &font)
226 void ChartAxis::setLabelsFont(const QFont &font)
227 {
227 {
228 foreach(QGraphicsItem* item , m_labels->childItems()) {
228 foreach(QGraphicsItem* item , m_labels->childItems()) {
229 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
229 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
230 }
230 }
231 m_font = font;
231 m_font = font;
232 }
232 }
233
233
234 void ChartAxis::setShadesBrush(const QBrush &brush)
234 void ChartAxis::setShadesBrush(const QBrush &brush)
235 {
235 {
236 foreach(QGraphicsItem* item , m_shades->childItems()) {
236 foreach(QGraphicsItem* item , m_shades->childItems()) {
237 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
237 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
238 }
238 }
239 }
239 }
240
240
241 void ChartAxis::setShadesPen(const QPen &pen)
241 void ChartAxis::setShadesPen(const QPen &pen)
242 {
242 {
243 foreach(QGraphicsItem* item , m_shades->childItems()) {
243 foreach(QGraphicsItem* item , m_shades->childItems()) {
244 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
244 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
245 }
245 }
246 }
246 }
247
247
248 void ChartAxis::setArrowPen(const QPen &pen)
248 void ChartAxis::setArrowPen(const QPen &pen)
249 {
249 {
250 foreach(QGraphicsItem* item , m_arrow->childItems()) {
250 foreach(QGraphicsItem* item , m_arrow->childItems()) {
251 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
251 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
252 }
252 }
253 }
253 }
254
254
255 void ChartAxis::setGridPen(const QPen &pen)
255 void ChartAxis::setGridPen(const QPen &pen)
256 {
256 {
257 foreach(QGraphicsItem* item , m_grid->childItems()) {
257 foreach(QGraphicsItem* item , m_grid->childItems()) {
258 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
258 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
259 }
259 }
260 }
260 }
261
261
262 bool ChartAxis::isEmpty()
262 bool ChartAxis::isEmpty()
263 {
263 {
264 return m_rect.isEmpty() || qFuzzyIsNull(m_min - m_max);
264 return m_rect.isEmpty() || qFuzzyIsNull(m_min - m_max);
265 }
265 }
266
266
267 void ChartAxis::handleDomainUpdated()
267 void ChartAxis::handleDomainUpdated()
268 {
268 {
269 Domain* domain = qobject_cast<Domain*>(sender());
269 Domain* domain = qobject_cast<Domain*>(sender());
270 qreal min(0);
270 qreal min(0);
271 qreal max(0);
271 qreal max(0);
272
272
273 if(m_chartAxis->orientation()==Qt::Horizontal) {
273 if(m_chartAxis->orientation()==Qt::Horizontal) {
274 min = domain->minX();
274 min = domain->minX();
275 max = domain->maxX();
275 max = domain->maxX();
276 }
276 }
277 else if (m_chartAxis->orientation()==Qt::Vertical)
277 else if (m_chartAxis->orientation()==Qt::Vertical)
278 {
278 {
279 min = domain->minY();
279 min = domain->minY();
280 max = domain->maxY();
280 max = domain->maxY();
281 }
281 }
282
282
283 if (!qFuzzyIsNull(m_min - min) || !qFuzzyIsNull(m_max - max))
283 if (!qFuzzyIsNull(m_min - min) || !qFuzzyIsNull(m_max - max))
284 {
284 {
285 m_min = min;
285 m_min = min;
286 m_max = max;
286 m_max = max;
287
287
288 if (!isEmpty()) {
288 if (!isEmpty()) {
289 QVector<qreal> layout = calculateLayout();
289 QVector<qreal> layout = calculateLayout();
290 updateLayout(layout);
290 updateLayout(layout);
291 }
291 }
292 }
292 }
293 }
293 }
294
294
295 void ChartAxis::handleAxisUpdated()
295 void ChartAxis::handleAxisUpdated()
296 {
296 {
297 if(isEmpty()) return;
297 if(isEmpty()) return;
298
298
299
299
300 bool visible = m_chartAxis->isVisible();
300 bool visible = m_chartAxis->isVisible();
301
301
302 setArrowVisibility(visible && m_chartAxis->isArrowVisible());
302 setArrowVisibility(visible && m_chartAxis->isLineVisible());
303 setGridVisibility(visible && m_chartAxis->isGridLineVisible());
303 setGridVisibility(visible && m_chartAxis->isGridLineVisible());
304 setLabelsVisibility(visible && m_chartAxis->labelsVisible());
304 setLabelsVisibility(visible && m_chartAxis->labelsVisible());
305 setShadesVisibility(visible && m_chartAxis->shadesVisible());
305 setShadesVisibility(visible && m_chartAxis->shadesVisible());
306 setLabelsAngle(m_chartAxis->labelsAngle());
306 setLabelsAngle(m_chartAxis->labelsAngle());
307 setArrowPen(m_chartAxis->axisPen());
307 setArrowPen(m_chartAxis->linePen());
308 setLabelsPen(m_chartAxis->labelsPen());
308 setLabelsPen(m_chartAxis->labelsPen());
309 setLabelsBrush(m_chartAxis->labelsBrush());
309 setLabelsBrush(m_chartAxis->labelsBrush());
310 setLabelsFont(m_chartAxis->labelsFont());
310 setLabelsFont(m_chartAxis->labelsFont());
311 setGridPen(m_chartAxis->gridLinePen());
311 setGridPen(m_chartAxis->gridLinePen());
312 setShadesPen(m_chartAxis->shadesPen());
312 setShadesPen(m_chartAxis->shadesPen());
313 setShadesBrush(m_chartAxis->shadesBrush());
313 setShadesBrush(m_chartAxis->shadesBrush());
314
314
315 }
315 }
316
316
317 void ChartAxis::hide()
317 void ChartAxis::hide()
318 {
318 {
319 setArrowVisibility(false);
319 setArrowVisibility(false);
320 setGridVisibility(false);
320 setGridVisibility(false);
321 setLabelsVisibility(false);
321 setLabelsVisibility(false);
322 setShadesVisibility(false);
322 setShadesVisibility(false);
323 }
323 }
324
324
325 void ChartAxis::handleGeometryChanged(const QRectF &rect)
325 void ChartAxis::handleGeometryChanged(const QRectF &rect)
326 {
326 {
327 if(m_rect != rect)
327 if(m_rect != rect)
328 {
328 {
329 m_rect = rect;
329 m_rect = rect;
330 if (isEmpty()) return;
330 if (isEmpty()) return;
331 QVector<qreal> layout = calculateLayout();
331 QVector<qreal> layout = calculateLayout();
332 updateLayout(layout);
332 updateLayout(layout);
333 }
333 }
334 }
334 }
335
335
336
336
337 qreal ChartAxis::minimumWidth()
337 qreal ChartAxis::minimumWidth()
338 {
338 {
339 if(m_minWidth == 0) updateGeometry();
339 if(m_minWidth == 0) updateGeometry();
340 return m_minWidth;
340 return m_minWidth;
341 }
341 }
342
342
343 qreal ChartAxis::minimumHeight()
343 qreal ChartAxis::minimumHeight()
344 {
344 {
345 if(m_minHeight == 0) updateGeometry();
345 if(m_minHeight == 0) updateGeometry();
346 return m_minHeight;
346 return m_minHeight;
347 }
347 }
348
348
349
349
350 void ChartAxis::axisSelected()
350 void ChartAxis::axisSelected()
351 {
351 {
352 qDebug()<<"TODO: axis clicked";
352 qDebug()<<"TODO: axis clicked";
353 }
353 }
354
354
355
355
356 void ChartAxis::createNumberLabels(QStringList &labels,qreal min, qreal max, int ticks) const
356 void ChartAxis::createNumberLabels(QStringList &labels,qreal min, qreal max, int ticks) const
357 {
357 {
358 Q_ASSERT(max>min);
358 Q_ASSERT(max>min);
359 Q_ASSERT(ticks>1);
359 Q_ASSERT(ticks>1);
360
360
361 int n = qMax(int(-qFloor(log10((max-min)/(ticks-1)))),0);
361 int n = qMax(int(-qFloor(log10((max-min)/(ticks-1)))),0);
362 n++;
362 n++;
363 for (int i=0; i< ticks; i++) {
363 for (int i=0; i< ticks; i++) {
364 qreal value = min + (i * (max - min)/ (ticks-1));
364 qreal value = min + (i * (max - min)/ (ticks-1));
365 labels << QString::number(value,'f',n);
365 labels << QString::number(value,'f',n);
366 }
366 }
367 }
367 }
368
368
369 #include "moc_chartaxis_p.cpp"
369 #include "moc_chartaxis_p.cpp"
370
370
371 QTCOMMERCIALCHART_END_NAMESPACE
371 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,658 +1,658
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 "qabstractaxis.h"
21 #include "qabstractaxis.h"
22 #include "qabstractaxis_p.h"
22 #include "qabstractaxis_p.h"
23
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
25
26 /*!
26 /*!
27 \class QAbstractAxis
27 \class QAbstractAxis
28 \brief The QAbstractAxis class is used for manipulating chart's axis.
28 \brief The QAbstractAxis class is used for manipulating chart's axis.
29 \mainclass
29 \mainclass
30
30
31 There is only one x Axis visible at the time, however there can be multiple y axes.
31 There is only one x Axis visible at the time, however there can be multiple y axes.
32 Each chart series can be bound to exactly one Y axis and the shared common X axis.
32 Each chart series can be bound to exactly one Y axis and the shared common X axis.
33 Axis can be setup to show axis line with tick marks, grid lines and shades.
33 Axis can be setup to show axis line with tick marks, grid lines and shades.
34 */
34 */
35
35
36 /*!
36 /*!
37 \qmlclass AbstractAxis QAbstractAxis
37 \qmlclass AbstractAxis QAbstractAxis
38 \brief The Axis element is used for manipulating chart's axes
38 \brief The Axis element is used for manipulating chart's axes
39
39
40 There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView.
40 There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView.
41 Each chart series can be bound to exactly one Y axis and the shared common X axis.
41 Each chart series can be bound to exactly one Y axis and the shared common X axis.
42 Axis can be setup to show axis line with tick marks, grid lines and shades.
42 Axis can be setup to show axis line with tick marks, grid lines and shades.
43
43
44 To access Axes you can use ChartView API. For example:
44 To access Axes you can use ChartView API. For example:
45 \code
45 \code
46 ChartView {
46 ChartView {
47 axisX.min: 0
47 axisX.min: 0
48 axisX.max: 3
48 axisX.max: 3
49 axisX.ticksCount: 4
49 axisX.ticksCount: 4
50 axisY.min: 0
50 axisY.min: 0
51 axisY.max: 4
51 axisY.max: 4
52 // Add a few series...
52 // Add a few series...
53 }
53 }
54 \endcode
54 \endcode
55 */
55 */
56
56
57 /*!
57 /*!
58 \enum QAbstractAxis::AxisType
58 \enum QAbstractAxis::AxisType
59
59
60 The type of the series object.
60 The type of the series object.
61
61
62 \value AxisTypeNoAxis
62 \value AxisTypeNoAxis
63 \value AxisTypeValue
63 \value AxisTypeValue
64 \value AxisTypeBarCategory
64 \value AxisTypeBarCategory
65 \value AxisTypeCategory
65 \value AxisTypeCategory
66 \value AxisTypeDateTime
66 \value AxisTypeDateTime
67 */
67 */
68
68
69 /*!
69 /*!
70 *\fn void QAbstractAxis::type() const
70 *\fn void QAbstractAxis::type() const
71 Returns the type of the axis
71 Returns the type of the axis
72 */
72 */
73
73
74 /*!
74 /*!
75 \property QAbstractAxis::arrowVisible
75 \property QAbstractAxis::arrowVisible
76 The visibility of the axis arrow
76 The visibility of the axis arrow
77 */
77 */
78 /*!
78 /*!
79 \qmlproperty bool AbstractAxis::arrrowVisible
79 \qmlproperty bool AbstractAxis::arrrowVisible
80 The visibility of the axis arrow
80 The visibility of the axis arrow
81 */
81 */
82
82
83 /*!
83 /*!
84 \property QAbstractAxis::labelsVisible
84 \property QAbstractAxis::labelsVisible
85 Defines if axis labels are visible.
85 Defines if axis labels are visible.
86 */
86 */
87 /*!
87 /*!
88 \qmlproperty bool AbstractAxis::labelsVisible
88 \qmlproperty bool AbstractAxis::labelsVisible
89 Defines if axis labels are visible.
89 Defines if axis labels are visible.
90 */
90 */
91
91
92 /*!
92 /*!
93 \property QAbstractAxis::visible
93 \property QAbstractAxis::visible
94 The visibility of the axis.
94 The visibility of the axis.
95 */
95 */
96 /*!
96 /*!
97 \qmlproperty bool AbstractAxis::visible
97 \qmlproperty bool AbstractAxis::visible
98 The visibility of the axis.
98 The visibility of the axis.
99 */
99 */
100
100
101 /*!
101 /*!
102 \property QAbstractAxis::gridVisible
102 \property QAbstractAxis::gridVisible
103 The visibility of the grid lines.
103 The visibility of the grid lines.
104 */
104 */
105 /*!
105 /*!
106 \qmlproperty bool AbstractAxis::gridVisible
106 \qmlproperty bool AbstractAxis::gridVisible
107 The visibility of the grid lines.
107 The visibility of the grid lines.
108 */
108 */
109
109
110 /*!
110 /*!
111 \property QAbstractAxis::color
111 \property QAbstractAxis::color
112 The color of the axis and ticks.
112 The color of the axis and ticks.
113 */
113 */
114 /*!
114 /*!
115 \qmlproperty color AbstractAxis::color
115 \qmlproperty color AbstractAxis::color
116 The color of the axis and ticks.
116 The color of the axis and ticks.
117 */
117 */
118
118
119 /*!
119 /*!
120 \property QAbstractAxis::labelsFont
120 \property QAbstractAxis::labelsFont
121 The font of the axis labels.
121 The font of the axis labels.
122 */
122 */
123
123
124 /*!
124 /*!
125 \qmlproperty Font AbstractAxis::labelsFont
125 \qmlproperty Font AbstractAxis::labelsFont
126 The font of the axis labels.
126 The font of the axis labels.
127
127
128 See the \l {Font} {QML Font Element} for detailed documentation.
128 See the \l {Font} {QML Font Element} for detailed documentation.
129 */
129 */
130
130
131 /*!
131 /*!
132 \property QAbstractAxis::labelsColor
132 \property QAbstractAxis::labelsColor
133 The color of the axis labels.
133 The color of the axis labels.
134 */
134 */
135 /*!
135 /*!
136 \qmlproperty color AbstractAxis::labelsColor
136 \qmlproperty color AbstractAxis::labelsColor
137 The color of the axis labels.
137 The color of the axis labels.
138 */
138 */
139
139
140 /*!
140 /*!
141 \property QAbstractAxis::labelsAngle
141 \property QAbstractAxis::labelsAngle
142 The angle of the axis labels in degrees.
142 The angle of the axis labels in degrees.
143 */
143 */
144 /*!
144 /*!
145 \qmlproperty int AbstractAxis::labelsAngle
145 \qmlproperty int AbstractAxis::labelsAngle
146 The angle of the axis labels in degrees.
146 The angle of the axis labels in degrees.
147 */
147 */
148
148
149 /*!
149 /*!
150 \property QAbstractAxis::shadesVisible
150 \property QAbstractAxis::shadesVisible
151 The visibility of the axis shades.
151 The visibility of the axis shades.
152 */
152 */
153 /*!
153 /*!
154 \qmlproperty bool AbstractAxis::shadesVisible
154 \qmlproperty bool AbstractAxis::shadesVisible
155 The visibility of the axis shades.
155 The visibility of the axis shades.
156 */
156 */
157
157
158 /*!
158 /*!
159 \property QAbstractAxis::shadesColor
159 \property QAbstractAxis::shadesColor
160 The fill (brush) color of the axis shades.
160 The fill (brush) color of the axis shades.
161 */
161 */
162 /*!
162 /*!
163 \qmlproperty color AbstractAxis::shadesColor
163 \qmlproperty color AbstractAxis::shadesColor
164 The fill (brush) color of the axis shades.
164 The fill (brush) color of the axis shades.
165 */
165 */
166
166
167 /*!
167 /*!
168 \property QAbstractAxis::shadesBorderColor
168 \property QAbstractAxis::shadesBorderColor
169 The border (pen) color of the axis shades.
169 The border (pen) color of the axis shades.
170 */
170 */
171 /*!
171 /*!
172 \qmlproperty color AbstractAxis::shadesBorderColor
172 \qmlproperty color AbstractAxis::shadesBorderColor
173 The border (pen) color of the axis shades.
173 The border (pen) color of the axis shades.
174 */
174 */
175
175
176 /*!
176 /*!
177 \fn void QAbstractAxis::visibleChanged(bool visible)
177 \fn void QAbstractAxis::visibleChanged(bool visible)
178 Visiblity of the axis has changed to \a visible.
178 Visiblity of the axis has changed to \a visible.
179 */
179 */
180 /*!
180 /*!
181 \qmlsignal AbstractAxis::onVisibleChanged(bool visible)
181 \qmlsignal AbstractAxis::onVisibleChanged(bool visible)
182 Visiblity of the axis has changed to \a visible.
182 Visiblity of the axis has changed to \a visible.
183 */
183 */
184
184
185 /*!
185 /*!
186 \fn void QAbstractAxis::arrowVisibleChanged(bool visible)
186 \fn void QAbstractAxis::arrowVisibleChanged(bool visible)
187 Visiblity of the axis arrow has changed to \a visible.
187 Visiblity of the axis arrow has changed to \a visible.
188 */
188 */
189 /*!
189 /*!
190 \qmlsignal AbstractAxis::onArrowVisibleChanged(bool visible)
190 \qmlsignal AbstractAxis::onArrowVisibleChanged(bool visible)
191 Visiblity of the axis arrow has changed to \a visible.
191 Visiblity of the axis arrow has changed to \a visible.
192 */
192 */
193
193
194 /*!
194 /*!
195 \fn void QAbstractAxis::labelsVisibleChanged(bool visible)
195 \fn void QAbstractAxis::labelsVisibleChanged(bool visible)
196 Visiblity of the labels of the axis has changed to \a visible.
196 Visiblity of the labels of the axis has changed to \a visible.
197 */
197 */
198 /*!
198 /*!
199 \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible)
199 \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible)
200 Visiblity of the labels of the axis has changed to \a visible.
200 Visiblity of the labels of the axis has changed to \a visible.
201 */
201 */
202
202
203 /*!
203 /*!
204 \fn void QAbstractAxis::gridVisibleChanged(bool visible)
204 \fn void QAbstractAxis::gridVisibleChanged(bool visible)
205 Visiblity of the grid lines of the axis has changed to \a visible.
205 Visiblity of the grid lines of the axis has changed to \a visible.
206 */
206 */
207 /*!
207 /*!
208 \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible)
208 \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible)
209 Visiblity of the grid lines of the axis has changed to \a visible.
209 Visiblity of the grid lines of the axis has changed to \a visible.
210 */
210 */
211
211
212 /*!
212 /*!
213 \fn void QAbstractAxis::colorChanged(QColor color)
213 \fn void QAbstractAxis::colorChanged(QColor color)
214 Emitted if the \a color of the axis is changed.
214 Emitted if the \a color of the axis is changed.
215 */
215 */
216 /*!
216 /*!
217 \qmlsignal AbstractAxis::onColorChanged(QColor color)
217 \qmlsignal AbstractAxis::onColorChanged(QColor color)
218 Emitted if the \a color of the axis is changed.
218 Emitted if the \a color of the axis is changed.
219 */
219 */
220
220
221 /*!
221 /*!
222 \fn void QAbstractAxis::labelsColorChanged(QColor color)
222 \fn void QAbstractAxis::labelsColorChanged(QColor color)
223 Emitted if the \a color of the axis labels is changed.
223 Emitted if the \a color of the axis labels is changed.
224 */
224 */
225 /*!
225 /*!
226 \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color)
226 \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color)
227 Emitted if the \a color of the axis labels is changed.
227 Emitted if the \a color of the axis labels is changed.
228 */
228 */
229
229
230 /*!
230 /*!
231 \fn void QAbstractAxis::shadesVisibleChanged(bool)
231 \fn void QAbstractAxis::shadesVisibleChanged(bool)
232 Emitted if the visibility of the axis shades is changed to \a visible.
232 Emitted if the visibility of the axis shades is changed to \a visible.
233 */
233 */
234 /*!
234 /*!
235 \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible)
235 \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible)
236 Emitted if the visibility of the axis shades is changed to \a visible.
236 Emitted if the visibility of the axis shades is changed to \a visible.
237 */
237 */
238
238
239 /*!
239 /*!
240 \fn void QAbstractAxis::shadesColorChanged(QColor color)
240 \fn void QAbstractAxis::shadesColorChanged(QColor color)
241 Emitted if the \a color of the axis shades is changed.
241 Emitted if the \a color of the axis shades is changed.
242 */
242 */
243 /*!
243 /*!
244 \qmlsignal AbstractAxis::onShadesColorChanged(QColor color)
244 \qmlsignal AbstractAxis::onShadesColorChanged(QColor color)
245 Emitted if the \a color of the axis shades is changed.
245 Emitted if the \a color of the axis shades is changed.
246 */
246 */
247
247
248 /*!
248 /*!
249 \fn void QAbstractAxis::shadesBorderColorChanged(QColor)
249 \fn void QAbstractAxis::shadesBorderColorChanged(QColor)
250 Emitted if the border \a color of the axis shades is changed.
250 Emitted if the border \a color of the axis shades is changed.
251 */
251 */
252 /*!
252 /*!
253 \qmlsignal AbstractAxis::onBorderColorChanged(QColor color)
253 \qmlsignal AbstractAxis::onBorderColorChanged(QColor color)
254 Emitted if the border \a color of the axis shades is changed.
254 Emitted if the border \a color of the axis shades is changed.
255 */
255 */
256
256
257 /*!
257 /*!
258 \internal
258 \internal
259 Constructs new axis object which is a child of \a parent. Ownership is taken by
259 Constructs new axis object which is a child of \a parent. Ownership is taken by
260 QChart when axis added.
260 QChart when axis added.
261 */
261 */
262
262
263 QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) :
263 QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) :
264 QObject(parent),
264 QObject(parent),
265 d_ptr(&d)
265 d_ptr(&d)
266 {
266 {
267 }
267 }
268
268
269 /*!
269 /*!
270 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
270 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
271 */
271 */
272
272
273 QAbstractAxis::~QAbstractAxis()
273 QAbstractAxis::~QAbstractAxis()
274 {
274 {
275 if(d_ptr->m_dataset) qFatal("Still binded axis detected !");
275 if(d_ptr->m_dataset) qFatal("Still binded axis detected !");
276 }
276 }
277
277
278 /*!
278 /*!
279 Sets \a pen used to draw axis line and ticks.
279 Sets \a pen used to draw axis line and ticks.
280 */
280 */
281 void QAbstractAxis::setAxisPen(const QPen &pen)
281 void QAbstractAxis::setLinePen(const QPen &pen)
282 {
282 {
283 if (d_ptr->m_axisPen!=pen) {
283 if (d_ptr->m_axisPen!=pen) {
284 d_ptr->m_axisPen = pen;
284 d_ptr->m_axisPen = pen;
285 d_ptr->emitUpdated();
285 d_ptr->emitUpdated();
286 }
286 }
287 }
287 }
288
288
289 /*!
289 /*!
290 Returns pen used to draw axis and ticks.
290 Returns pen used to draw axis and ticks.
291 */
291 */
292 QPen QAbstractAxis::axisPen() const
292 QPen QAbstractAxis::linePen() const
293 {
293 {
294 return d_ptr->m_axisPen;
294 return d_ptr->m_axisPen;
295 }
295 }
296
296
297 void QAbstractAxis::setAxisPenColor(QColor color)
297 void QAbstractAxis::setLinePenColor(QColor color)
298 {
298 {
299 QPen p = d_ptr->m_axisPen;
299 QPen p = d_ptr->m_axisPen;
300 if (p.color() != color) {
300 if (p.color() != color) {
301 p.setColor(color);
301 p.setColor(color);
302 setAxisPen(p);
302 setLinePen(p);
303 emit colorChanged(color);
303 emit colorChanged(color);
304 }
304 }
305 }
305 }
306
306
307 QColor QAbstractAxis::axisPenColor() const
307 QColor QAbstractAxis::linePenColor() const
308 {
308 {
309 return d_ptr->m_axisPen.color();
309 return d_ptr->m_axisPen.color();
310 }
310 }
311
311
312 /*!
312 /*!
313 Sets if axis and ticks are \a visible.
313 Sets if axis and ticks are \a visible.
314 */
314 */
315 void QAbstractAxis::setArrowVisible(bool visible)
315 void QAbstractAxis::setLineVisible(bool visible)
316 {
316 {
317 if (d_ptr->m_arrowVisible != visible) {
317 if (d_ptr->m_arrowVisible != visible) {
318 d_ptr->m_arrowVisible = visible;
318 d_ptr->m_arrowVisible = visible;
319 d_ptr->emitUpdated();
319 d_ptr->emitUpdated();
320 emit arrowVisibleChanged(visible);
320 emit lineVisibleChanged(visible);
321 }
321 }
322 }
322 }
323
323
324 bool QAbstractAxis::isArrowVisible() const
324 bool QAbstractAxis::isLineVisible() const
325 {
325 {
326 return d_ptr->m_arrowVisible;
326 return d_ptr->m_arrowVisible;
327 }
327 }
328
328
329 void QAbstractAxis::setGridLineVisible(bool visible)
329 void QAbstractAxis::setGridLineVisible(bool visible)
330 {
330 {
331 if (d_ptr->m_gridLineVisible != visible) {
331 if (d_ptr->m_gridLineVisible != visible) {
332 d_ptr->m_gridLineVisible = visible;
332 d_ptr->m_gridLineVisible = visible;
333 d_ptr->emitUpdated();
333 d_ptr->emitUpdated();
334 emit gridVisibleChanged(visible);
334 emit gridVisibleChanged(visible);
335 }
335 }
336 }
336 }
337
337
338 bool QAbstractAxis::isGridLineVisible() const
338 bool QAbstractAxis::isGridLineVisible() const
339 {
339 {
340 return d_ptr->m_gridLineVisible;
340 return d_ptr->m_gridLineVisible;
341 }
341 }
342
342
343 /*!
343 /*!
344 Sets \a pen used to draw grid line.
344 Sets \a pen used to draw grid line.
345 */
345 */
346 void QAbstractAxis::setGridLinePen(const QPen &pen)
346 void QAbstractAxis::setGridLinePen(const QPen &pen)
347 {
347 {
348 if (d_ptr->m_gridLinePen != pen) {
348 if (d_ptr->m_gridLinePen != pen) {
349 d_ptr->m_gridLinePen = pen;
349 d_ptr->m_gridLinePen = pen;
350 d_ptr->emitUpdated();
350 d_ptr->emitUpdated();
351 }
351 }
352 }
352 }
353
353
354 /*!
354 /*!
355 Returns pen used to draw grid.
355 Returns pen used to draw grid.
356 */
356 */
357 QPen QAbstractAxis::gridLinePen() const
357 QPen QAbstractAxis::gridLinePen() const
358 {
358 {
359 return d_ptr->m_gridLinePen;
359 return d_ptr->m_gridLinePen;
360 }
360 }
361
361
362 void QAbstractAxis::setLabelsVisible(bool visible)
362 void QAbstractAxis::setLabelsVisible(bool visible)
363 {
363 {
364 if (d_ptr->m_labelsVisible != visible) {
364 if (d_ptr->m_labelsVisible != visible) {
365 d_ptr->m_labelsVisible = visible;
365 d_ptr->m_labelsVisible = visible;
366 d_ptr->emitUpdated();
366 d_ptr->emitUpdated();
367 emit labelsVisibleChanged(visible);
367 emit labelsVisibleChanged(visible);
368 }
368 }
369 }
369 }
370
370
371 bool QAbstractAxis::labelsVisible() const
371 bool QAbstractAxis::labelsVisible() const
372 {
372 {
373 return d_ptr->m_labelsVisible;
373 return d_ptr->m_labelsVisible;
374 }
374 }
375
375
376 /*!
376 /*!
377 Sets \a pen used to draw labels.
377 Sets \a pen used to draw labels.
378 */
378 */
379 void QAbstractAxis::setLabelsPen(const QPen &pen)
379 void QAbstractAxis::setLabelsPen(const QPen &pen)
380 {
380 {
381 if (d_ptr->m_labelsPen != pen) {
381 if (d_ptr->m_labelsPen != pen) {
382 d_ptr->m_labelsPen = pen;
382 d_ptr->m_labelsPen = pen;
383 d_ptr->emitUpdated();
383 d_ptr->emitUpdated();
384 }
384 }
385 }
385 }
386
386
387 /*!
387 /*!
388 Returns the pen used to labels.
388 Returns the pen used to labels.
389 */
389 */
390 QPen QAbstractAxis::labelsPen() const
390 QPen QAbstractAxis::labelsPen() const
391 {
391 {
392 return d_ptr->m_labelsPen;
392 return d_ptr->m_labelsPen;
393 }
393 }
394
394
395 /*!
395 /*!
396 Sets \a brush used to draw labels.
396 Sets \a brush used to draw labels.
397 */
397 */
398 void QAbstractAxis::setLabelsBrush(const QBrush &brush)
398 void QAbstractAxis::setLabelsBrush(const QBrush &brush)
399 {
399 {
400 if (d_ptr->m_labelsBrush != brush) {
400 if (d_ptr->m_labelsBrush != brush) {
401 d_ptr->m_labelsBrush = brush;
401 d_ptr->m_labelsBrush = brush;
402 d_ptr->emitUpdated();
402 d_ptr->emitUpdated();
403 }
403 }
404 }
404 }
405
405
406 /*!
406 /*!
407 Returns brush used to draw labels.
407 Returns brush used to draw labels.
408 */
408 */
409 QBrush QAbstractAxis::labelsBrush() const
409 QBrush QAbstractAxis::labelsBrush() const
410 {
410 {
411 return d_ptr->m_labelsBrush;
411 return d_ptr->m_labelsBrush;
412 }
412 }
413
413
414 /*!
414 /*!
415 Sets \a font used to draw labels.
415 Sets \a font used to draw labels.
416 */
416 */
417 void QAbstractAxis::setLabelsFont(const QFont &font)
417 void QAbstractAxis::setLabelsFont(const QFont &font)
418 {
418 {
419 if (d_ptr->m_labelsFont != font) {
419 if (d_ptr->m_labelsFont != font) {
420 d_ptr->m_labelsFont = font;
420 d_ptr->m_labelsFont = font;
421 d_ptr->emitUpdated();
421 d_ptr->emitUpdated();
422 }
422 }
423 }
423 }
424
424
425 /*!
425 /*!
426 Returns font used to draw labels.
426 Returns font used to draw labels.
427 */
427 */
428 QFont QAbstractAxis::labelsFont() const
428 QFont QAbstractAxis::labelsFont() const
429 {
429 {
430 return d_ptr->m_labelsFont;
430 return d_ptr->m_labelsFont;
431 }
431 }
432
432
433 void QAbstractAxis::setLabelsAngle(int angle)
433 void QAbstractAxis::setLabelsAngle(int angle)
434 {
434 {
435 if (d_ptr->m_labelsAngle != angle) {
435 if (d_ptr->m_labelsAngle != angle) {
436 d_ptr->m_labelsAngle = angle;
436 d_ptr->m_labelsAngle = angle;
437 d_ptr->emitUpdated();
437 d_ptr->emitUpdated();
438 }
438 }
439 }
439 }
440
440
441 int QAbstractAxis::labelsAngle() const
441 int QAbstractAxis::labelsAngle() const
442 {
442 {
443 return d_ptr->m_labelsAngle;
443 return d_ptr->m_labelsAngle;
444 }
444 }
445
445
446 void QAbstractAxis::setLabelsColor(QColor color)
446 void QAbstractAxis::setLabelsColor(QColor color)
447 {
447 {
448 QBrush b = d_ptr->m_labelsBrush;
448 QBrush b = d_ptr->m_labelsBrush;
449 if (b.color() != color) {
449 if (b.color() != color) {
450 b.setColor(color);
450 b.setColor(color);
451 setLabelsBrush(b);
451 setLabelsBrush(b);
452 emit labelsColorChanged(color);
452 emit labelsColorChanged(color);
453 }
453 }
454 }
454 }
455
455
456 QColor QAbstractAxis::labelsColor() const
456 QColor QAbstractAxis::labelsColor() const
457 {
457 {
458 return d_ptr->m_labelsBrush.color();
458 return d_ptr->m_labelsBrush.color();
459 }
459 }
460
460
461 void QAbstractAxis::setShadesVisible(bool visible)
461 void QAbstractAxis::setShadesVisible(bool visible)
462 {
462 {
463 if (d_ptr->m_shadesVisible != visible) {
463 if (d_ptr->m_shadesVisible != visible) {
464 d_ptr->m_shadesVisible = visible;
464 d_ptr->m_shadesVisible = visible;
465 d_ptr->emitUpdated();
465 d_ptr->emitUpdated();
466 emit shadesVisibleChanged(visible);
466 emit shadesVisibleChanged(visible);
467 }
467 }
468 }
468 }
469
469
470 bool QAbstractAxis::shadesVisible() const
470 bool QAbstractAxis::shadesVisible() const
471 {
471 {
472 return d_ptr->m_shadesVisible;
472 return d_ptr->m_shadesVisible;
473 }
473 }
474
474
475 /*!
475 /*!
476 Sets \a pen used to draw shades.
476 Sets \a pen used to draw shades.
477 */
477 */
478 void QAbstractAxis::setShadesPen(const QPen &pen)
478 void QAbstractAxis::setShadesPen(const QPen &pen)
479 {
479 {
480 if (d_ptr->m_shadesPen != pen) {
480 if (d_ptr->m_shadesPen != pen) {
481 d_ptr->m_shadesPen = pen;
481 d_ptr->m_shadesPen = pen;
482 d_ptr->emitUpdated();
482 d_ptr->emitUpdated();
483 }
483 }
484 }
484 }
485
485
486 /*!
486 /*!
487 Returns pen used to draw shades.
487 Returns pen used to draw shades.
488 */
488 */
489 QPen QAbstractAxis::shadesPen() const
489 QPen QAbstractAxis::shadesPen() const
490 {
490 {
491 return d_ptr->m_shadesPen;
491 return d_ptr->m_shadesPen;
492 }
492 }
493
493
494 /*!
494 /*!
495 Sets \a brush used to draw shades.
495 Sets \a brush used to draw shades.
496 */
496 */
497 void QAbstractAxis::setShadesBrush(const QBrush &brush)
497 void QAbstractAxis::setShadesBrush(const QBrush &brush)
498 {
498 {
499 if (d_ptr->m_shadesBrush != brush) {
499 if (d_ptr->m_shadesBrush != brush) {
500 d_ptr->m_shadesBrush = brush;
500 d_ptr->m_shadesBrush = brush;
501 d_ptr->emitUpdated();
501 d_ptr->emitUpdated();
502 emit shadesColorChanged(brush.color());
502 emit shadesColorChanged(brush.color());
503 }
503 }
504 }
504 }
505
505
506 /*!
506 /*!
507 Returns brush used to draw shades.
507 Returns brush used to draw shades.
508 */
508 */
509 QBrush QAbstractAxis::shadesBrush() const
509 QBrush QAbstractAxis::shadesBrush() const
510 {
510 {
511 return d_ptr->m_shadesBrush;
511 return d_ptr->m_shadesBrush;
512 }
512 }
513
513
514 void QAbstractAxis::setShadesColor(QColor color)
514 void QAbstractAxis::setShadesColor(QColor color)
515 {
515 {
516 QBrush b = d_ptr->m_shadesBrush;
516 QBrush b = d_ptr->m_shadesBrush;
517 b.setColor(color);
517 b.setColor(color);
518 setShadesBrush(b);
518 setShadesBrush(b);
519 }
519 }
520
520
521 QColor QAbstractAxis::shadesColor() const
521 QColor QAbstractAxis::shadesColor() const
522 {
522 {
523 return d_ptr->m_shadesBrush.color();
523 return d_ptr->m_shadesBrush.color();
524 }
524 }
525
525
526 void QAbstractAxis::setShadesBorderColor(QColor color)
526 void QAbstractAxis::setShadesBorderColor(QColor color)
527 {
527 {
528 QPen p = d_ptr->m_shadesPen;
528 QPen p = d_ptr->m_shadesPen;
529 p.setColor(color);
529 p.setColor(color);
530 setShadesPen(p);
530 setShadesPen(p);
531 }
531 }
532
532
533 QColor QAbstractAxis::shadesBorderColor() const
533 QColor QAbstractAxis::shadesBorderColor() const
534 {
534 {
535 return d_ptr->m_shadesPen.color();
535 return d_ptr->m_shadesPen.color();
536 }
536 }
537
537
538
538
539 bool QAbstractAxis::isVisible() const
539 bool QAbstractAxis::isVisible() const
540 {
540 {
541 return d_ptr->m_visible;
541 return d_ptr->m_visible;
542 }
542 }
543
543
544 /*!
544 /*!
545 Sets axis, shades, labels and grid lines to be visible.
545 Sets axis, shades, labels and grid lines to be visible.
546 */
546 */
547 void QAbstractAxis::setVisible(bool visible)
547 void QAbstractAxis::setVisible(bool visible)
548 {
548 {
549 if(d_ptr->m_visible!=visible){
549 if(d_ptr->m_visible!=visible){
550 d_ptr->m_visible=visible;
550 d_ptr->m_visible=visible;
551 d_ptr->emitUpdated();
551 d_ptr->emitUpdated();
552 emit visibleChanged(visible);
552 emit visibleChanged(visible);
553 }
553 }
554 }
554 }
555
555
556
556
557 /*!
557 /*!
558 Sets axis, shades, labels and grid lines to be visible.
558 Sets axis, shades, labels and grid lines to be visible.
559 */
559 */
560 void QAbstractAxis::show()
560 void QAbstractAxis::show()
561 {
561 {
562 setVisible(true);
562 setVisible(true);
563 }
563 }
564
564
565 /*!
565 /*!
566 Sets axis, shades, labels and grid lines to not be visible.
566 Sets axis, shades, labels and grid lines to not be visible.
567 */
567 */
568 void QAbstractAxis::hide()
568 void QAbstractAxis::hide()
569 {
569 {
570 setVisible(false);
570 setVisible(false);
571 }
571 }
572
572
573 /*!
573 /*!
574 Sets the minimum value shown on the axis.
574 Sets the minimum value shown on the axis.
575 Depending on the actual axis type the \a min paramter is converted to appropriate type.
575 Depending on the actual axis type the \a min paramter is converted to appropriate type.
576 If the conversion is impossible then the function call does nothing
576 If the conversion is impossible then the function call does nothing
577 */
577 */
578 void QAbstractAxis::setMin(const QVariant &min)
578 void QAbstractAxis::setMin(const QVariant &min)
579 {
579 {
580 d_ptr->setMin(min);
580 d_ptr->setMin(min);
581 }
581 }
582
582
583 /*!
583 /*!
584 Sets the maximum value shown on the axis.
584 Sets the maximum value shown on the axis.
585 Depending on the actual axis type the \a max paramter is converted to appropriate type.
585 Depending on the actual axis type the \a max paramter is converted to appropriate type.
586 If the conversion is impossible then the function call does nothing
586 If the conversion is impossible then the function call does nothing
587 */
587 */
588 void QAbstractAxis::setMax(const QVariant &max)
588 void QAbstractAxis::setMax(const QVariant &max)
589 {
589 {
590 d_ptr->setMax(max);
590 d_ptr->setMax(max);
591 }
591 }
592
592
593 /*!
593 /*!
594 Sets the range shown on the axis.
594 Sets the range shown on the axis.
595 Depending on the actual axis type the \a min and \a max paramters are converted to appropriate types.
595 Depending on the actual axis type the \a min and \a max paramters are converted to appropriate types.
596 If the conversion is impossible then the function call does nothing.
596 If the conversion is impossible then the function call does nothing.
597 */
597 */
598 void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
598 void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
599 {
599 {
600 d_ptr->setRange(min,max);
600 d_ptr->setRange(min,max);
601 }
601 }
602
602
603
603
604 /*!
604 /*!
605 Returns the orientation in which the axis is being used (Vertical or Horizontal)
605 Returns the orientation in which the axis is being used (Vertical or Horizontal)
606 */
606 */
607 Qt::Orientation QAbstractAxis::orientation()
607 Qt::Orientation QAbstractAxis::orientation()
608 {
608 {
609 return d_ptr->m_orientation;
609 return d_ptr->m_orientation;
610 }
610 }
611
611
612 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
612 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
613
613
614 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q):
614 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q):
615 q_ptr(q),
615 q_ptr(q),
616 m_orientation(Qt::Orientation(0)),
616 m_orientation(Qt::Orientation(0)),
617 m_dataset(0),
617 m_dataset(0),
618 m_visible(false),
618 m_visible(false),
619 m_arrowVisible(true),
619 m_arrowVisible(true),
620 m_gridLineVisible(true),
620 m_gridLineVisible(true),
621 m_labelsVisible(true),
621 m_labelsVisible(true),
622 m_labelsAngle(0),
622 m_labelsAngle(0),
623 m_shadesVisible(false),
623 m_shadesVisible(false),
624 m_shadesBrush(Qt::SolidPattern),
624 m_shadesBrush(Qt::SolidPattern),
625 m_shadesOpacity(1.0),
625 m_shadesOpacity(1.0),
626 m_dirty(false)
626 m_dirty(false)
627 {
627 {
628
628
629 }
629 }
630
630
631 QAbstractAxisPrivate::~QAbstractAxisPrivate()
631 QAbstractAxisPrivate::~QAbstractAxisPrivate()
632 {
632 {
633
633
634 }
634 }
635
635
636 void QAbstractAxisPrivate::emitUpdated()
636 void QAbstractAxisPrivate::emitUpdated()
637 {
637 {
638 if(!m_dirty){
638 if(!m_dirty){
639 m_dirty=true;
639 m_dirty=true;
640 emit updated();
640 emit updated();
641 }
641 }
642 }
642 }
643
643
644 void QAbstractAxisPrivate::setDirty(bool dirty)
644 void QAbstractAxisPrivate::setDirty(bool dirty)
645 {
645 {
646 m_dirty=dirty;
646 m_dirty=dirty;
647 }
647 }
648
648
649 void QAbstractAxisPrivate::setOrientation(Qt::Orientation orientation)
649 void QAbstractAxisPrivate::setOrientation(Qt::Orientation orientation)
650 {
650 {
651 m_orientation=orientation;
651 m_orientation=orientation;
652 }
652 }
653
653
654
654
655 #include "moc_qabstractaxis.cpp"
655 #include "moc_qabstractaxis.cpp"
656 #include "moc_qabstractaxis_p.cpp"
656 #include "moc_qabstractaxis_p.cpp"
657
657
658 QTCOMMERCIALCHART_END_NAMESPACE
658 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,143 +1,143
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 #ifndef QABSTRACTAXIS_H
21 #ifndef QABSTRACTAXIS_H
22 #define QABSTRACTAXIS_H
22 #define QABSTRACTAXIS_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <QPen>
25 #include <QPen>
26 #include <QFont>
26 #include <QFont>
27 #include <QVariant>
27 #include <QVariant>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QAbstractAxisPrivate;
31 class QAbstractAxisPrivate;
32
32
33 class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject
33 class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
36 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
37 Q_PROPERTY(bool arrowVisible READ isArrowVisible WRITE setArrowVisible NOTIFY arrowVisibleChanged)
37 Q_PROPERTY(bool arrowVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged)
38 Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged)
38 Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged)
39 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
39 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
40 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle)
40 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle)
41 Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont)
41 Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont)
42 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
42 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
43 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
43 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
44 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
44 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
45 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
45 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
46 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
46 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
47
47
48 public:
48 public:
49
49
50 enum AxisType {
50 enum AxisType {
51 AxisTypeNoAxis = 0x0,
51 AxisTypeNoAxis = 0x0,
52 AxisTypeValue = 0x1,
52 AxisTypeValue = 0x1,
53 AxisTypeBarCategory = 0x2,
53 AxisTypeBarCategory = 0x2,
54 AxisTypeCategory = 0x3,
54 AxisTypeCategory = 0x3,
55 AxisTypeDateTime = 0x4
55 AxisTypeDateTime = 0x4
56 };
56 };
57
57
58 Q_DECLARE_FLAGS(AxisTypes, AxisType)
58 Q_DECLARE_FLAGS(AxisTypes, AxisType)
59
59
60 protected:
60 protected:
61 explicit QAbstractAxis(QAbstractAxisPrivate &d,QObject *parent = 0);
61 explicit QAbstractAxis(QAbstractAxisPrivate &d,QObject *parent = 0);
62
62
63 public:
63 public:
64 ~QAbstractAxis();
64 ~QAbstractAxis();
65
65
66 virtual AxisType type() const = 0;
66 virtual AxisType type() const = 0;
67
67
68 //visibilty hadnling
68 //visibilty hadnling
69 bool isVisible() const;
69 bool isVisible() const;
70 void setVisible(bool visible = true);
70 void setVisible(bool visible = true);
71
71
72
72
73 //axis handling
73 //axis handling
74 bool isArrowVisible() const;
74 bool isLineVisible() const;
75 void setArrowVisible(bool visible = true);
75 void setLineVisible(bool visible = true);
76 void setAxisPen(const QPen &pen);
76 void setLinePen(const QPen &pen);
77 QPen axisPen() const;
77 QPen linePen() const;
78 void setAxisPenColor(QColor color);
78 void setLinePenColor(QColor color);
79 QColor axisPenColor() const;
79 QColor linePenColor() const;
80
80
81 //grid handling
81 //grid handling
82 bool isGridLineVisible() const;
82 bool isGridLineVisible() const;
83 void setGridLineVisible(bool visible = true);
83 void setGridLineVisible(bool visible = true);
84 void setGridLinePen(const QPen &pen);
84 void setGridLinePen(const QPen &pen);
85 QPen gridLinePen() const;
85 QPen gridLinePen() const;
86
86
87 //labels handling
87 //labels handling
88 bool labelsVisible() const;
88 bool labelsVisible() const;
89 void setLabelsVisible(bool visible = true);
89 void setLabelsVisible(bool visible = true);
90 void setLabelsPen(const QPen &pen);
90 void setLabelsPen(const QPen &pen);
91 QPen labelsPen() const;
91 QPen labelsPen() const;
92 void setLabelsBrush(const QBrush &brush);
92 void setLabelsBrush(const QBrush &brush);
93 QBrush labelsBrush() const;
93 QBrush labelsBrush() const;
94 void setLabelsFont(const QFont &font);
94 void setLabelsFont(const QFont &font);
95 QFont labelsFont() const;
95 QFont labelsFont() const;
96 void setLabelsAngle(int angle);
96 void setLabelsAngle(int angle);
97 int labelsAngle() const;
97 int labelsAngle() const;
98 void setLabelsColor(QColor color);
98 void setLabelsColor(QColor color);
99 QColor labelsColor() const;
99 QColor labelsColor() const;
100
100
101 //shades handling
101 //shades handling
102 bool shadesVisible() const;
102 bool shadesVisible() const;
103 void setShadesVisible(bool visible = true);
103 void setShadesVisible(bool visible = true);
104 void setShadesPen(const QPen &pen);
104 void setShadesPen(const QPen &pen);
105 QPen shadesPen() const;
105 QPen shadesPen() const;
106 void setShadesBrush(const QBrush &brush);
106 void setShadesBrush(const QBrush &brush);
107 QBrush shadesBrush() const;
107 QBrush shadesBrush() const;
108 void setShadesColor(QColor color);
108 void setShadesColor(QColor color);
109 QColor shadesColor() const;
109 QColor shadesColor() const;
110 void setShadesBorderColor(QColor color);
110 void setShadesBorderColor(QColor color);
111 QColor shadesBorderColor() const;
111 QColor shadesBorderColor() const;
112
112
113 Qt::Orientation orientation();
113 Qt::Orientation orientation();
114
114
115 //range handling
115 //range handling
116 void setMin(const QVariant &min);
116 void setMin(const QVariant &min);
117 void setMax(const QVariant &max);
117 void setMax(const QVariant &max);
118 void setRange(const QVariant &min, const QVariant &max);
118 void setRange(const QVariant &min, const QVariant &max);
119
119
120 void show();
120 void show();
121 void hide();
121 void hide();
122
122
123 Q_SIGNALS:
123 Q_SIGNALS:
124 void visibleChanged(bool visible);
124 void visibleChanged(bool visible);
125 void arrowVisibleChanged(bool visible);
125 void lineVisibleChanged(bool visible);
126 void labelsVisibleChanged(bool visible);
126 void labelsVisibleChanged(bool visible);
127 void gridVisibleChanged(bool visible);
127 void gridVisibleChanged(bool visible);
128 void colorChanged(QColor color);
128 void colorChanged(QColor color);
129 void labelsColorChanged(QColor color);
129 void labelsColorChanged(QColor color);
130 void shadesVisibleChanged(bool visible);
130 void shadesVisibleChanged(bool visible);
131 void shadesColorChanged(QColor color);
131 void shadesColorChanged(QColor color);
132 void shadesBorderColorChanged(QColor color);
132 void shadesBorderColorChanged(QColor color);
133
133
134 protected:
134 protected:
135 QScopedPointer<QAbstractAxisPrivate> d_ptr;
135 QScopedPointer<QAbstractAxisPrivate> d_ptr;
136 Q_DISABLE_COPY(QAbstractAxis)
136 Q_DISABLE_COPY(QAbstractAxis)
137 friend class ChartDataSet;
137 friend class ChartDataSet;
138 friend class ChartAxis;
138 friend class ChartAxis;
139 friend class ChartPresenter;
139 friend class ChartPresenter;
140 };
140 };
141
141
142 QTCOMMERCIALCHART_END_NAMESPACE
142 QTCOMMERCIALCHART_END_NAMESPACE
143 #endif
143 #endif
@@ -1,393 +1,393
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 "charttheme_p.h"
21 #include "charttheme_p.h"
22 #include "qchart.h"
22 #include "qchart.h"
23 #include "qchart_p.h"
23 #include "qchart_p.h"
24 #include "qchartview.h"
24 #include "qchartview.h"
25 #include "qlegend.h"
25 #include "qlegend.h"
26 #include "qabstractaxis.h"
26 #include "qabstractaxis.h"
27 #include <QTime>
27 #include <QTime>
28
28
29 //series
29 //series
30 #include "qbarset.h"
30 #include "qbarset.h"
31 #include "qabstractbarseries.h"
31 #include "qabstractbarseries.h"
32 #include "qstackedbarseries.h"
32 #include "qstackedbarseries.h"
33 #include "qpercentbarseries.h"
33 #include "qpercentbarseries.h"
34 #include "qlineseries.h"
34 #include "qlineseries.h"
35 #include "qareaseries.h"
35 #include "qareaseries.h"
36 #include "qscatterseries.h"
36 #include "qscatterseries.h"
37 #include "qpieseries.h"
37 #include "qpieseries.h"
38 #include "qpieslice.h"
38 #include "qpieslice.h"
39 #include "qpieslice_p.h"
39 #include "qpieslice_p.h"
40 #include "qsplineseries.h"
40 #include "qsplineseries.h"
41
41
42 //items
42 //items
43 #include "chartaxis_p.h"
43 #include "chartaxis_p.h"
44 #include "abstractbarchartitem_p.h"
44 #include "abstractbarchartitem_p.h"
45 #include "stackedbarchartitem_p.h"
45 #include "stackedbarchartitem_p.h"
46 #include "percentbarchartitem_p.h"
46 #include "percentbarchartitem_p.h"
47 #include "linechartitem_p.h"
47 #include "linechartitem_p.h"
48 #include "areachartitem_p.h"
48 #include "areachartitem_p.h"
49 #include "scatterchartitem_p.h"
49 #include "scatterchartitem_p.h"
50 #include "piechartitem_p.h"
50 #include "piechartitem_p.h"
51 #include "splinechartitem_p.h"
51 #include "splinechartitem_p.h"
52
52
53 //themes
53 //themes
54 #include "chartthemesystem_p.h"
54 #include "chartthemesystem_p.h"
55 #include "chartthemelight_p.h"
55 #include "chartthemelight_p.h"
56 #include "chartthemebluecerulean_p.h"
56 #include "chartthemebluecerulean_p.h"
57 #include "chartthemedark_p.h"
57 #include "chartthemedark_p.h"
58 #include "chartthemebrownsand_p.h"
58 #include "chartthemebrownsand_p.h"
59 #include "chartthemebluencs_p.h"
59 #include "chartthemebluencs_p.h"
60 #include "chartthemehighcontrast_p.h"
60 #include "chartthemehighcontrast_p.h"
61 #include "chartthemeblueicy_p.h"
61 #include "chartthemeblueicy_p.h"
62
62
63 QTCOMMERCIALCHART_BEGIN_NAMESPACE
63 QTCOMMERCIALCHART_BEGIN_NAMESPACE
64
64
65 ChartTheme::ChartTheme(QChart::ChartTheme id) :
65 ChartTheme::ChartTheme(QChart::ChartTheme id) :
66 m_masterFont(QFont("arial", 14)),
66 m_masterFont(QFont("arial", 14)),
67 m_labelFont(QFont("arial", 10)),
67 m_labelFont(QFont("arial", 10)),
68 m_labelBrush(QColor(QRgb(0x000000))),
68 m_labelBrush(QColor(QRgb(0x000000))),
69 m_axisLinePen(QPen(QRgb(0x000000))),
69 m_axisLinePen(QPen(QRgb(0x000000))),
70 m_backgroundShadesPen(Qt::NoPen),
70 m_backgroundShadesPen(Qt::NoPen),
71 m_backgroundShadesBrush(Qt::NoBrush),
71 m_backgroundShadesBrush(Qt::NoBrush),
72 m_backgroundShades(BackgroundShadesNone),
72 m_backgroundShades(BackgroundShadesNone),
73 m_backgroundDropShadowEnabled(false),
73 m_backgroundDropShadowEnabled(false),
74 m_gridLinePen(QPen(QRgb(0x000000))),
74 m_gridLinePen(QPen(QRgb(0x000000))),
75 m_force(false)
75 m_force(false)
76 {
76 {
77 m_id = id;
77 m_id = id;
78 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
78 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
79 }
79 }
80
80
81
81
82 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
82 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
83 {
83 {
84 switch(theme) {
84 switch(theme) {
85 case QChart::ChartThemeLight:
85 case QChart::ChartThemeLight:
86 return new ChartThemeLight();
86 return new ChartThemeLight();
87 case QChart::ChartThemeBlueCerulean:
87 case QChart::ChartThemeBlueCerulean:
88 return new ChartThemeBlueCerulean();
88 return new ChartThemeBlueCerulean();
89 case QChart::ChartThemeDark:
89 case QChart::ChartThemeDark:
90 return new ChartThemeDark();
90 return new ChartThemeDark();
91 case QChart::ChartThemeBrownSand:
91 case QChart::ChartThemeBrownSand:
92 return new ChartThemeBrownSand();
92 return new ChartThemeBrownSand();
93 case QChart::ChartThemeBlueNcs:
93 case QChart::ChartThemeBlueNcs:
94 return new ChartThemeBlueNcs();
94 return new ChartThemeBlueNcs();
95 case QChart::ChartThemeHighContrast:
95 case QChart::ChartThemeHighContrast:
96 return new ChartThemeHighContrast();
96 return new ChartThemeHighContrast();
97 case QChart::ChartThemeBlueIcy:
97 case QChart::ChartThemeBlueIcy:
98 return new ChartThemeBlueIcy();
98 return new ChartThemeBlueIcy();
99 default:
99 default:
100 return new ChartThemeSystem();
100 return new ChartThemeSystem();
101 }
101 }
102 }
102 }
103
103
104 void ChartTheme::decorate(QChart *chart)
104 void ChartTheme::decorate(QChart *chart)
105 {
105 {
106 QBrush brush;
106 QBrush brush;
107
107
108 if(m_force || brush == chart->backgroundBrush())
108 if(m_force || brush == chart->backgroundBrush())
109 chart->setBackgroundBrush(m_chartBackgroundGradient);
109 chart->setBackgroundBrush(m_chartBackgroundGradient);
110 chart->setTitleFont(m_masterFont);
110 chart->setTitleFont(m_masterFont);
111 chart->setTitleBrush(m_labelBrush);
111 chart->setTitleBrush(m_labelBrush);
112 chart->setDropShadowEnabled(m_backgroundDropShadowEnabled);
112 chart->setDropShadowEnabled(m_backgroundDropShadowEnabled);
113 }
113 }
114
114
115 void ChartTheme::decorate(QLegend *legend)
115 void ChartTheme::decorate(QLegend *legend)
116 {
116 {
117 QPen pen;
117 QPen pen;
118 QBrush brush;
118 QBrush brush;
119 QFont font;
119 QFont font;
120
120
121 if (m_force || pen == legend->pen())
121 if (m_force || pen == legend->pen())
122 legend->setPen(m_axisLinePen);
122 legend->setPen(m_axisLinePen);
123
123
124 if (m_force || brush == legend->brush())
124 if (m_force || brush == legend->brush())
125 legend->setBrush(m_chartBackgroundGradient);
125 legend->setBrush(m_chartBackgroundGradient);
126
126
127 if (m_force || font == legend->font())
127 if (m_force || font == legend->font())
128 legend->setFont(m_labelFont);
128 legend->setFont(m_labelFont);
129
129
130 if (m_force || brush == legend->labelBrush())
130 if (m_force || brush == legend->labelBrush())
131 legend->setLabelBrush(m_labelBrush);
131 legend->setLabelBrush(m_labelBrush);
132 }
132 }
133
133
134 void ChartTheme::decorate(QAreaSeries *series, int index)
134 void ChartTheme::decorate(QAreaSeries *series, int index)
135 {
135 {
136 QPen pen;
136 QPen pen;
137 QBrush brush;
137 QBrush brush;
138
138
139 if (m_force || pen == series->pen()){
139 if (m_force || pen == series->pen()){
140 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
140 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
141 pen.setWidthF(2);
141 pen.setWidthF(2);
142 series->setPen(pen);
142 series->setPen(pen);
143 }
143 }
144
144
145 if (m_force || brush == series->brush()) {
145 if (m_force || brush == series->brush()) {
146 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
146 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
147 series->setBrush(brush);
147 series->setBrush(brush);
148 }
148 }
149 }
149 }
150
150
151
151
152 void ChartTheme::decorate(QLineSeries *series,int index)
152 void ChartTheme::decorate(QLineSeries *series,int index)
153 {
153 {
154 QPen pen;
154 QPen pen;
155 if(m_force || pen == series->pen()){
155 if(m_force || pen == series->pen()){
156 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
156 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
157 pen.setWidthF(2);
157 pen.setWidthF(2);
158 series->setPen(pen);
158 series->setPen(pen);
159 }
159 }
160 }
160 }
161
161
162 void ChartTheme::decorate(QAbstractBarSeries *series, int index)
162 void ChartTheme::decorate(QAbstractBarSeries *series, int index)
163 {
163 {
164 QBrush brush;
164 QBrush brush;
165 QPen pen;
165 QPen pen;
166 QList<QBarSet *> sets = series->barSets();
166 QList<QBarSet *> sets = series->barSets();
167
167
168 qreal takeAtPos = 0.5;
168 qreal takeAtPos = 0.5;
169 qreal step = 0.2;
169 qreal step = 0.2;
170 if (sets.count() > 1 ) {
170 if (sets.count() > 1 ) {
171 step = 1.0 / (qreal) sets.count();
171 step = 1.0 / (qreal) sets.count();
172 if (sets.count() % m_seriesGradients.count())
172 if (sets.count() % m_seriesGradients.count())
173 step *= m_seriesGradients.count();
173 step *= m_seriesGradients.count();
174 else
174 else
175 step *= (m_seriesGradients.count() - 1);
175 step *= (m_seriesGradients.count() - 1);
176 }
176 }
177
177
178 for (int i(0); i < sets.count(); i++) {
178 for (int i(0); i < sets.count(); i++) {
179 int colorIndex = (index + i) % m_seriesGradients.count();
179 int colorIndex = (index + i) % m_seriesGradients.count();
180 if (i > 0 && i % m_seriesGradients.count() == 0) {
180 if (i > 0 && i % m_seriesGradients.count() == 0) {
181 // There is no dedicated base color for each sets, generate more colors
181 // There is no dedicated base color for each sets, generate more colors
182 takeAtPos += step;
182 takeAtPos += step;
183 if (takeAtPos == 1.0)
183 if (takeAtPos == 1.0)
184 takeAtPos += step;
184 takeAtPos += step;
185 takeAtPos -= (int) takeAtPos;
185 takeAtPos -= (int) takeAtPos;
186 }
186 }
187 if (m_force || brush == sets.at(i)->brush())
187 if (m_force || brush == sets.at(i)->brush())
188 sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos));
188 sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos));
189
189
190 // Pick label color from the opposite end of the gradient.
190 // Pick label color from the opposite end of the gradient.
191 // 0.3 as a boundary seems to work well.
191 // 0.3 as a boundary seems to work well.
192 if (m_force || brush == sets.at(i)->labelBrush()) {
192 if (m_force || brush == sets.at(i)->labelBrush()) {
193 if (takeAtPos < 0.3)
193 if (takeAtPos < 0.3)
194 sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1));
194 sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1));
195 else
195 else
196 sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0));
196 sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0));
197 }
197 }
198
198
199 if (m_force || pen == sets.at(i)->pen()) {
199 if (m_force || pen == sets.at(i)->pen()) {
200 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
200 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
201 sets.at(i)->setPen(c);
201 sets.at(i)->setPen(c);
202 }
202 }
203 }
203 }
204 }
204 }
205
205
206 void ChartTheme::decorate(QScatterSeries *series, int index)
206 void ChartTheme::decorate(QScatterSeries *series, int index)
207 {
207 {
208 QPen pen;
208 QPen pen;
209 QBrush brush;
209 QBrush brush;
210
210
211 if (m_force || pen == series->pen()) {
211 if (m_force || pen == series->pen()) {
212 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
212 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
213 pen.setWidthF(2);
213 pen.setWidthF(2);
214 series->setPen(pen);
214 series->setPen(pen);
215 }
215 }
216
216
217 if (m_force || brush == series->brush()) {
217 if (m_force || brush == series->brush()) {
218 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
218 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
219 series->setBrush(brush);
219 series->setBrush(brush);
220 }
220 }
221 }
221 }
222
222
223 void ChartTheme::decorate(QPieSeries *series, int index)
223 void ChartTheme::decorate(QPieSeries *series, int index)
224 {
224 {
225
225
226 for (int i(0); i < series->slices().count(); i++) {
226 for (int i(0); i < series->slices().count(); i++) {
227
227
228 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
228 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
229
229
230 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
230 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
231 qreal pos = (qreal) (i + 1) / (qreal) series->count();
231 qreal pos = (qreal) (i + 1) / (qreal) series->count();
232 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
232 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
233
233
234 QPieSlice *s = series->slices().at(i);
234 QPieSlice *s = series->slices().at(i);
235 QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s);
235 QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s);
236
236
237 if (m_force || d->m_data.m_slicePen.isThemed())
237 if (m_force || d->m_data.m_slicePen.isThemed())
238 d->setPen(penColor, true);
238 d->setPen(penColor, true);
239
239
240 if (m_force || d->m_data.m_sliceBrush.isThemed())
240 if (m_force || d->m_data.m_sliceBrush.isThemed())
241 d->setBrush(brushColor, true);
241 d->setBrush(brushColor, true);
242
242
243 if (m_force || d->m_data.m_labelBrush.isThemed())
243 if (m_force || d->m_data.m_labelBrush.isThemed())
244 d->setLabelBrush(m_labelBrush.color(), true);
244 d->setLabelBrush(m_labelBrush.color(), true);
245
245
246 if (m_force || d->m_data.m_labelFont.isThemed())
246 if (m_force || d->m_data.m_labelFont.isThemed())
247 d->setLabelFont(m_labelFont, true);
247 d->setLabelFont(m_labelFont, true);
248 }
248 }
249 }
249 }
250
250
251 void ChartTheme::decorate(QSplineSeries *series, int index)
251 void ChartTheme::decorate(QSplineSeries *series, int index)
252 {
252 {
253 QPen pen;
253 QPen pen;
254 if(m_force || pen == series->pen()){
254 if(m_force || pen == series->pen()){
255 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
255 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
256 pen.setWidthF(2);
256 pen.setWidthF(2);
257 series->setPen(pen);
257 series->setPen(pen);
258 }
258 }
259 }
259 }
260
260
261 void ChartTheme::decorate(QAbstractAxis *axis)
261 void ChartTheme::decorate(QAbstractAxis *axis)
262 {
262 {
263 QPen pen;
263 QPen pen;
264 QBrush brush;
264 QBrush brush;
265 QFont font;
265 QFont font;
266
266
267 bool axisX = axis->orientation()== Qt::Horizontal;
267 bool axisX = axis->orientation()== Qt::Horizontal;
268
268
269 if (axis->isArrowVisible()) {
269 if (axis->isLineVisible()) {
270
270
271 if(m_force || brush == axis->labelsBrush()){
271 if(m_force || brush == axis->labelsBrush()){
272 axis->setLabelsBrush(m_labelBrush);
272 axis->setLabelsBrush(m_labelBrush);
273 }
273 }
274 if(m_force || pen == axis->labelsPen()){
274 if(m_force || pen == axis->labelsPen()){
275 axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
275 axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
276 }
276 }
277
277
278
278
279 if (m_force || axis->shadesVisible()) {
279 if (m_force || axis->shadesVisible()) {
280
280
281 if(m_force || brush == axis->shadesBrush()){
281 if(m_force || brush == axis->shadesBrush()){
282 axis->setShadesBrush(m_backgroundShadesBrush);
282 axis->setShadesBrush(m_backgroundShadesBrush);
283 }
283 }
284
284
285 if(m_force || pen == axis->shadesPen()){
285 if(m_force || pen == axis->shadesPen()){
286 axis->setShadesPen(m_backgroundShadesPen);
286 axis->setShadesPen(m_backgroundShadesPen);
287 }
287 }
288
288
289 if( m_force && (m_backgroundShades == BackgroundShadesBoth
289 if( m_force && (m_backgroundShades == BackgroundShadesBoth
290 || (m_backgroundShades == BackgroundShadesVertical && axisX)
290 || (m_backgroundShades == BackgroundShadesVertical && axisX)
291 || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){
291 || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){
292 axis->setShadesVisible(true);
292 axis->setShadesVisible(true);
293
293
294 }
294 }
295 }
295 }
296
296
297 if(m_force || pen == axis->axisPen()){
297 if(m_force || pen == axis->linePen()){
298 axis->setAxisPen(m_axisLinePen);
298 axis->setLinePen(m_axisLinePen);
299 }
299 }
300
300
301 if(m_force || pen == axis->gridLinePen()){
301 if(m_force || pen == axis->gridLinePen()){
302 axis->setGridLinePen(m_gridLinePen);
302 axis->setGridLinePen(m_gridLinePen);
303 }
303 }
304
304
305 if(m_force || font == axis->labelsFont()){
305 if(m_force || font == axis->labelsFont()){
306 axis->setLabelsFont(m_labelFont);
306 axis->setLabelsFont(m_labelFont);
307 }
307 }
308 }
308 }
309 }
309 }
310
310
311 void ChartTheme::generateSeriesGradients()
311 void ChartTheme::generateSeriesGradients()
312 {
312 {
313 // Generate gradients in HSV color space
313 // Generate gradients in HSV color space
314 foreach (const QColor& color, m_seriesColors) {
314 foreach (const QColor& color, m_seriesColors) {
315 QLinearGradient g;
315 QLinearGradient g;
316 qreal h = color.hsvHueF();
316 qreal h = color.hsvHueF();
317 qreal s = color.hsvSaturationF();
317 qreal s = color.hsvSaturationF();
318
318
319 // TODO: tune the algorithm to give nice results with most base colors defined in
319 // TODO: tune the algorithm to give nice results with most base colors defined in
320 // most themes. The rest of the gradients we can define manually in theme specific
320 // most themes. The rest of the gradients we can define manually in theme specific
321 // implementation.
321 // implementation.
322 QColor start = color;
322 QColor start = color;
323 start.setHsvF(h, 0.0, 1.0);
323 start.setHsvF(h, 0.0, 1.0);
324 g.setColorAt(0.0, start);
324 g.setColorAt(0.0, start);
325
325
326 g.setColorAt(0.5, color);
326 g.setColorAt(0.5, color);
327
327
328 QColor end = color;
328 QColor end = color;
329 end.setHsvF(h, s, 0.25);
329 end.setHsvF(h, s, 0.25);
330 g.setColorAt(1.0, end);
330 g.setColorAt(1.0, end);
331
331
332 m_seriesGradients << g;
332 m_seriesGradients << g;
333 }
333 }
334 }
334 }
335
335
336
336
337 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
337 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
338 {
338 {
339 Q_ASSERT(pos >= 0.0 && pos <= 1.0);
339 Q_ASSERT(pos >= 0.0 && pos <= 1.0);
340 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
340 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
341 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
341 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
342 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
342 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
343 QColor c;
343 QColor c;
344 c.setRgbF(r, g, b);
344 c.setRgbF(r, g, b);
345 return c;
345 return c;
346 }
346 }
347
347
348 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
348 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
349 {
349 {
350 Q_ASSERT(pos >= 0 && pos <= 1.0);
350 Q_ASSERT(pos >= 0 && pos <= 1.0);
351
351
352 QGradientStops stops = gradient.stops();
352 QGradientStops stops = gradient.stops();
353 int count = stops.count();
353 int count = stops.count();
354
354
355 // find previous stop relative to position
355 // find previous stop relative to position
356 QGradientStop prev = stops.first();
356 QGradientStop prev = stops.first();
357 for (int i = 0; i < count; i++) {
357 for (int i = 0; i < count; i++) {
358 QGradientStop stop = stops.at(i);
358 QGradientStop stop = stops.at(i);
359 if (pos > stop.first)
359 if (pos > stop.first)
360 prev = stop;
360 prev = stop;
361
361
362 // given position is actually a stop position?
362 // given position is actually a stop position?
363 if (pos == stop.first) {
363 if (pos == stop.first) {
364 //qDebug() << "stop color" << pos;
364 //qDebug() << "stop color" << pos;
365 return stop.second;
365 return stop.second;
366 }
366 }
367 }
367 }
368
368
369 // find next stop relative to position
369 // find next stop relative to position
370 QGradientStop next = stops.last();
370 QGradientStop next = stops.last();
371 for (int i = count - 1; i >= 0; i--) {
371 for (int i = count - 1; i >= 0; i--) {
372 QGradientStop stop = stops.at(i);
372 QGradientStop stop = stops.at(i);
373 if (pos < stop.first)
373 if (pos < stop.first)
374 next = stop;
374 next = stop;
375 }
375 }
376
376
377 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
377 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
378
378
379 qreal range = next.first - prev.first;
379 qreal range = next.first - prev.first;
380 qreal posDelta = pos - prev.first;
380 qreal posDelta = pos - prev.first;
381 qreal relativePos = posDelta / range;
381 qreal relativePos = posDelta / range;
382
382
383 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
383 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
384
384
385 return colorAt(prev.second, next.second, relativePos);
385 return colorAt(prev.second, next.second, relativePos);
386 }
386 }
387
387
388 void ChartTheme::setForced(bool enabled)
388 void ChartTheme::setForced(bool enabled)
389 {
389 {
390 m_force = enabled;
390 m_force = enabled;
391 }
391 }
392
392
393 QTCOMMERCIALCHART_END_NAMESPACE
393 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,847 +1,847
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 "tst_qabstractaxis.h"
21 #include "tst_qabstractaxis.h"
22
22
23 Q_DECLARE_METATYPE(QPen)
23 Q_DECLARE_METATYPE(QPen)
24 Q_DECLARE_METATYPE(Qt::Orientation)
24 Q_DECLARE_METATYPE(Qt::Orientation)
25
25
26 void tst_QAbstractAxis::initTestCase()
26 void tst_QAbstractAxis::initTestCase()
27 {
27 {
28 }
28 }
29
29
30 void tst_QAbstractAxis::cleanupTestCase()
30 void tst_QAbstractAxis::cleanupTestCase()
31 {
31 {
32 }
32 }
33
33
34 void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series)
34 void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series)
35 {
35 {
36 m_axis = axis;
36 m_axis = axis;
37 m_series = series;
37 m_series = series;
38 m_view = new QChartView(new QChart());
38 m_view = new QChartView(new QChart());
39 m_chart = m_view->chart();
39 m_chart = m_view->chart();
40 }
40 }
41
41
42 void tst_QAbstractAxis::cleanup()
42 void tst_QAbstractAxis::cleanup()
43 {
43 {
44 delete m_view;
44 delete m_view;
45 m_view = 0;
45 m_view = 0;
46 m_chart = 0;
46 m_chart = 0;
47 m_axis = 0;
47 m_axis = 0;
48 }
48 }
49
49
50 void tst_QAbstractAxis::qabstractaxis()
50 void tst_QAbstractAxis::qabstractaxis()
51 {
51 {
52 QCOMPARE(m_axis->axisPen(), QPen());
52 QCOMPARE(m_axis->linePen(), QPen());
53 //TODO QCOMPARE(m_axis->axisPenColor(), QColor());
53 //TODO QCOMPARE(m_axis->axisPenColor(), QColor());
54 QCOMPARE(m_axis->gridLinePen(), QPen());
54 QCOMPARE(m_axis->gridLinePen(), QPen());
55 QCOMPARE(m_axis->isArrowVisible(), true);
55 QCOMPARE(m_axis->isLineVisible(), true);
56 QCOMPARE(m_axis->isGridLineVisible(), true);
56 QCOMPARE(m_axis->isGridLineVisible(), true);
57 QCOMPARE(m_axis->isVisible(), false);
57 QCOMPARE(m_axis->isVisible(), false);
58 QCOMPARE(m_axis->labelsAngle(), 0);
58 QCOMPARE(m_axis->labelsAngle(), 0);
59 QCOMPARE(m_axis->labelsBrush(), QBrush());
59 QCOMPARE(m_axis->labelsBrush(), QBrush());
60 //TODO QCOMPARE(m_axis->labelsColor(), QColor());
60 //TODO QCOMPARE(m_axis->labelsColor(), QColor());
61 QCOMPARE(m_axis->labelsFont(), QFont());
61 QCOMPARE(m_axis->labelsFont(), QFont());
62 QCOMPARE(m_axis->labelsPen(), QPen());
62 QCOMPARE(m_axis->labelsPen(), QPen());
63 QCOMPARE(m_axis->labelsVisible(), true);
63 QCOMPARE(m_axis->labelsVisible(), true);
64 QCOMPARE(m_axis->orientation(), Qt::Orientation(0));
64 QCOMPARE(m_axis->orientation(), Qt::Orientation(0));
65 m_axis->setArrowVisible(false);
65 m_axis->setLineVisible(false);
66 m_axis->setAxisPen(QPen());
66 m_axis->setLinePen(QPen());
67 m_axis->setAxisPenColor(QColor());
67 m_axis->setLinePenColor(QColor());
68 m_axis->setGridLinePen(QPen());
68 m_axis->setGridLinePen(QPen());
69 m_axis->setGridLineVisible(false);
69 m_axis->setGridLineVisible(false);
70 m_axis->setLabelsAngle(-1);
70 m_axis->setLabelsAngle(-1);
71 m_axis->setLabelsBrush(QBrush());
71 m_axis->setLabelsBrush(QBrush());
72 m_axis->setLabelsColor(QColor());
72 m_axis->setLabelsColor(QColor());
73 m_axis->setLabelsFont(QFont());
73 m_axis->setLabelsFont(QFont());
74 m_axis->setLabelsPen(QPen());
74 m_axis->setLabelsPen(QPen());
75 m_axis->setLabelsVisible(false);
75 m_axis->setLabelsVisible(false);
76 m_axis->setMax(QVariant());
76 m_axis->setMax(QVariant());
77 m_axis->setMin(QVariant());
77 m_axis->setMin(QVariant());
78 m_axis->setRange(QVariant(), QVariant());
78 m_axis->setRange(QVariant(), QVariant());
79 m_axis->setShadesBorderColor(QColor());
79 m_axis->setShadesBorderColor(QColor());
80 m_axis->setShadesBrush(QBrush());
80 m_axis->setShadesBrush(QBrush());
81 m_axis->setShadesColor(QColor());
81 m_axis->setShadesColor(QColor());
82 m_axis->setShadesPen(QPen());
82 m_axis->setShadesPen(QPen());
83 m_axis->setShadesVisible(false);
83 m_axis->setShadesVisible(false);
84 m_axis->setVisible(false);
84 m_axis->setVisible(false);
85 //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor());
85 //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor());
86 //TODO QCOMPARE(m_axis->shadesBrush(), QBrush());
86 //TODO QCOMPARE(m_axis->shadesBrush(), QBrush());
87 //TODO QCOMPARE(m_axis->shadesColor(), QColor());
87 //TODO QCOMPARE(m_axis->shadesColor(), QColor());
88 QCOMPARE(m_axis->shadesPen(), QPen());
88 QCOMPARE(m_axis->shadesPen(), QPen());
89 QCOMPARE(m_axis->shadesVisible(), false);
89 QCOMPARE(m_axis->shadesVisible(), false);
90 m_axis->show();
90 m_axis->show();
91 m_axis->hide();
91 m_axis->hide();
92 }
92 }
93
93
94 void tst_QAbstractAxis::axisPen_data()
94 void tst_QAbstractAxis::axisPen_data()
95 {
95 {
96 QTest::addColumn<QPen>("axisPen");
96 QTest::addColumn<QPen>("axisPen");
97 QTest::newRow("null") << QPen();
97 QTest::newRow("null") << QPen();
98 QTest::newRow("blue") << QPen(Qt::blue);
98 QTest::newRow("blue") << QPen(Qt::blue);
99 QTest::newRow("black") << QPen(Qt::black);
99 QTest::newRow("black") << QPen(Qt::black);
100 QTest::newRow("red") << QPen(Qt::red);
100 QTest::newRow("red") << QPen(Qt::red);
101 }
101 }
102
102
103 void tst_QAbstractAxis::axisPen()
103 void tst_QAbstractAxis::axisPen()
104 {
104 {
105 QFETCH(QPen, axisPen);
105 QFETCH(QPen, axisPen);
106
106
107 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
107 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
108 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
108 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
109 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
109 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
110 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
110 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
111 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
111 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
112 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
112 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
113 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
113 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
114 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
114 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
115 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
115 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
116
116
117 m_axis->setAxisPen(axisPen);
117 m_axis->setLinePen(axisPen);
118 QCOMPARE(m_axis->axisPen(), axisPen);
118 QCOMPARE(m_axis->linePen(), axisPen);
119
119
120 QCOMPARE(spy0.count(), 0);
120 QCOMPARE(spy0.count(), 0);
121 QCOMPARE(spy1.count(), 0);
121 QCOMPARE(spy1.count(), 0);
122 QCOMPARE(spy2.count(), 0);
122 QCOMPARE(spy2.count(), 0);
123 QCOMPARE(spy3.count(), 0);
123 QCOMPARE(spy3.count(), 0);
124 QCOMPARE(spy4.count(), 0);
124 QCOMPARE(spy4.count(), 0);
125 QCOMPARE(spy5.count(), 0);
125 QCOMPARE(spy5.count(), 0);
126 QCOMPARE(spy6.count(), 0);
126 QCOMPARE(spy6.count(), 0);
127 QCOMPARE(spy7.count(), 0);
127 QCOMPARE(spy7.count(), 0);
128 QCOMPARE(spy8.count(), 0);
128 QCOMPARE(spy8.count(), 0);
129
129
130 m_chart->setAxisX(m_axis, m_series);
130 m_chart->setAxisX(m_axis, m_series);
131 m_view->show();
131 m_view->show();
132 QTest::qWaitForWindowShown(m_view);
132 QTest::qWaitForWindowShown(m_view);
133 //TODO QCOMPARE(m_axis->axisPen(), axisPen);
133 //TODO QCOMPARE(m_axis->axisPen(), axisPen);
134 }
134 }
135
135
136 void tst_QAbstractAxis::axisPenColor_data()
136 void tst_QAbstractAxis::axisPenColor_data()
137 {
137 {
138 }
138 }
139
139
140 void tst_QAbstractAxis::axisPenColor()
140 void tst_QAbstractAxis::axisPenColor()
141 {
141 {
142 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
142 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
143 }
143 }
144
144
145 void tst_QAbstractAxis::gridLinePen_data()
145 void tst_QAbstractAxis::gridLinePen_data()
146 {
146 {
147
147
148 QTest::addColumn<QPen>("gridLinePen");
148 QTest::addColumn<QPen>("gridLinePen");
149 QTest::newRow("null") << QPen();
149 QTest::newRow("null") << QPen();
150 QTest::newRow("blue") << QPen(Qt::blue);
150 QTest::newRow("blue") << QPen(Qt::blue);
151 QTest::newRow("black") << QPen(Qt::black);
151 QTest::newRow("black") << QPen(Qt::black);
152 QTest::newRow("red") << QPen(Qt::red);
152 QTest::newRow("red") << QPen(Qt::red);
153
153
154 }
154 }
155
155
156 void tst_QAbstractAxis::gridLinePen()
156 void tst_QAbstractAxis::gridLinePen()
157 {
157 {
158 QFETCH(QPen, gridLinePen);
158 QFETCH(QPen, gridLinePen);
159
159
160 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
160 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
161 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
161 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
162 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
162 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
163 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
163 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
164 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
164 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
165 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
165 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
166 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
166 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
167 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
167 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
168 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
168 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
169
169
170 m_axis->setGridLinePen(gridLinePen);
170 m_axis->setGridLinePen(gridLinePen);
171 QCOMPARE(m_axis->gridLinePen(), gridLinePen);
171 QCOMPARE(m_axis->gridLinePen(), gridLinePen);
172
172
173 QCOMPARE(spy0.count(), 0);
173 QCOMPARE(spy0.count(), 0);
174 QCOMPARE(spy1.count(), 0);
174 QCOMPARE(spy1.count(), 0);
175 QCOMPARE(spy2.count(), 0);
175 QCOMPARE(spy2.count(), 0);
176 QCOMPARE(spy3.count(), 0);
176 QCOMPARE(spy3.count(), 0);
177 QCOMPARE(spy4.count(), 0);
177 QCOMPARE(spy4.count(), 0);
178 QCOMPARE(spy5.count(), 0);
178 QCOMPARE(spy5.count(), 0);
179 QCOMPARE(spy6.count(), 0);
179 QCOMPARE(spy6.count(), 0);
180 QCOMPARE(spy7.count(), 0);
180 QCOMPARE(spy7.count(), 0);
181 QCOMPARE(spy8.count(), 0);
181 QCOMPARE(spy8.count(), 0);
182
182
183 m_chart->setAxisX(m_axis, m_series);
183 m_chart->setAxisX(m_axis, m_series);
184 m_view->show();
184 m_view->show();
185 QTest::qWaitForWindowShown(m_view);
185 QTest::qWaitForWindowShown(m_view);
186 //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen);
186 //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen);
187 }
187 }
188
188
189 void tst_QAbstractAxis::arrowVisible_data()
189 void tst_QAbstractAxis::arrowVisible_data()
190 {
190 {
191 QTest::addColumn<bool>("arrowVisible");
191 QTest::addColumn<bool>("arrowVisible");
192 QTest::newRow("true") << true;
192 QTest::newRow("true") << true;
193 QTest::newRow("false") << false;
193 QTest::newRow("false") << false;
194 }
194 }
195
195
196 void tst_QAbstractAxis::arrowVisible()
196 void tst_QAbstractAxis::arrowVisible()
197 {
197 {
198 QFETCH(bool, arrowVisible);
198 QFETCH(bool, arrowVisible);
199
199
200 m_axis->setArrowVisible(!arrowVisible);
200 m_axis->setLineVisible(!arrowVisible);
201
201
202 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
202 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
203 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
203 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
204 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
204 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
205 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
205 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
206 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
206 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
207 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
207 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
208 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
208 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
209 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
209 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
210 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
210 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
211
211
212 m_axis->setArrowVisible(arrowVisible);
212 m_axis->setLineVisible(arrowVisible);
213 QCOMPARE(m_axis->isArrowVisible(), arrowVisible);
213 QCOMPARE(m_axis->isLineVisible(), arrowVisible);
214
214
215 QCOMPARE(spy0.count(), 1);
215 QCOMPARE(spy0.count(), 1);
216 QCOMPARE(spy1.count(), 0);
216 QCOMPARE(spy1.count(), 0);
217 QCOMPARE(spy2.count(), 0);
217 QCOMPARE(spy2.count(), 0);
218 QCOMPARE(spy3.count(), 0);
218 QCOMPARE(spy3.count(), 0);
219 QCOMPARE(spy4.count(), 0);
219 QCOMPARE(spy4.count(), 0);
220 QCOMPARE(spy5.count(), 0);
220 QCOMPARE(spy5.count(), 0);
221 QCOMPARE(spy6.count(), 0);
221 QCOMPARE(spy6.count(), 0);
222 QCOMPARE(spy7.count(), 0);
222 QCOMPARE(spy7.count(), 0);
223 QCOMPARE(spy8.count(), 0);
223 QCOMPARE(spy8.count(), 0);
224
224
225 m_chart->setAxisX(m_axis, m_series);
225 m_chart->setAxisX(m_axis, m_series);
226 m_view->show();
226 m_view->show();
227 QTest::qWaitForWindowShown(m_view);
227 QTest::qWaitForWindowShown(m_view);
228 QCOMPARE(m_axis->isArrowVisible(), arrowVisible);
228 QCOMPARE(m_axis->isLineVisible(), arrowVisible);
229 }
229 }
230
230
231 void tst_QAbstractAxis::gridLineVisible_data()
231 void tst_QAbstractAxis::gridLineVisible_data()
232 {
232 {
233 QTest::addColumn<bool>("gridLineVisible");
233 QTest::addColumn<bool>("gridLineVisible");
234 QTest::newRow("true") << true;
234 QTest::newRow("true") << true;
235 QTest::newRow("false") << false;
235 QTest::newRow("false") << false;
236 }
236 }
237
237
238 void tst_QAbstractAxis::gridLineVisible()
238 void tst_QAbstractAxis::gridLineVisible()
239 {
239 {
240 QFETCH(bool, gridLineVisible);
240 QFETCH(bool, gridLineVisible);
241
241
242 m_axis->setGridLineVisible(!gridLineVisible);
242 m_axis->setGridLineVisible(!gridLineVisible);
243
243
244 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
244 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
245 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
245 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
246 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
246 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
247 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
247 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
248 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
248 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
249 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
249 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
250 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
250 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
251 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
251 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
252 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
252 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
253
253
254 m_axis->setGridLineVisible(gridLineVisible);
254 m_axis->setGridLineVisible(gridLineVisible);
255 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
255 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
256
256
257 QCOMPARE(spy0.count(), 0);
257 QCOMPARE(spy0.count(), 0);
258 QCOMPARE(spy1.count(), 0);
258 QCOMPARE(spy1.count(), 0);
259 QCOMPARE(spy2.count(), 1);
259 QCOMPARE(spy2.count(), 1);
260 QCOMPARE(spy3.count(), 0);
260 QCOMPARE(spy3.count(), 0);
261 QCOMPARE(spy4.count(), 0);
261 QCOMPARE(spy4.count(), 0);
262 QCOMPARE(spy5.count(), 0);
262 QCOMPARE(spy5.count(), 0);
263 QCOMPARE(spy6.count(), 0);
263 QCOMPARE(spy6.count(), 0);
264 QCOMPARE(spy7.count(), 0);
264 QCOMPARE(spy7.count(), 0);
265 QCOMPARE(spy8.count(), 0);
265 QCOMPARE(spy8.count(), 0);
266
266
267 m_chart->setAxisX(m_axis, m_series);
267 m_chart->setAxisX(m_axis, m_series);
268 m_view->show();
268 m_view->show();
269 QTest::qWaitForWindowShown(m_view);
269 QTest::qWaitForWindowShown(m_view);
270 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
270 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
271
271
272 }
272 }
273
273
274 void tst_QAbstractAxis::visible_data()
274 void tst_QAbstractAxis::visible_data()
275 {
275 {
276 QTest::addColumn<bool>("visible");
276 QTest::addColumn<bool>("visible");
277 QTest::newRow("true") << true;
277 QTest::newRow("true") << true;
278 QTest::newRow("false") << false;
278 QTest::newRow("false") << false;
279 }
279 }
280
280
281 void tst_QAbstractAxis::visible()
281 void tst_QAbstractAxis::visible()
282 {
282 {
283 QFETCH(bool, visible);
283 QFETCH(bool, visible);
284
284
285 m_axis->setVisible(!visible);
285 m_axis->setVisible(!visible);
286
286
287 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
287 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
288 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
288 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
289 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
289 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
290 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
290 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
291 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
291 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
292 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
292 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
293 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
293 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
294 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
294 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
295 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
295 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
296
296
297 m_axis->setVisible(visible);
297 m_axis->setVisible(visible);
298 QCOMPARE(m_axis->isVisible(), visible);
298 QCOMPARE(m_axis->isVisible(), visible);
299
299
300 QCOMPARE(spy0.count(), 0);
300 QCOMPARE(spy0.count(), 0);
301 QCOMPARE(spy1.count(), 0);
301 QCOMPARE(spy1.count(), 0);
302 QCOMPARE(spy2.count(), 0);
302 QCOMPARE(spy2.count(), 0);
303 QCOMPARE(spy3.count(), 0);
303 QCOMPARE(spy3.count(), 0);
304 QCOMPARE(spy4.count(), 0);
304 QCOMPARE(spy4.count(), 0);
305 QCOMPARE(spy5.count(), 0);
305 QCOMPARE(spy5.count(), 0);
306 QCOMPARE(spy6.count(), 0);
306 QCOMPARE(spy6.count(), 0);
307 QCOMPARE(spy7.count(), 0);
307 QCOMPARE(spy7.count(), 0);
308 QCOMPARE(spy8.count(), 1);
308 QCOMPARE(spy8.count(), 1);
309
309
310 m_chart->setAxisX(m_axis, m_series);
310 m_chart->setAxisX(m_axis, m_series);
311 m_view->show();
311 m_view->show();
312 QTest::qWaitForWindowShown(m_view);
312 QTest::qWaitForWindowShown(m_view);
313 QCOMPARE(m_axis->isVisible(), true);
313 QCOMPARE(m_axis->isVisible(), true);
314 }
314 }
315
315
316 void tst_QAbstractAxis::labelsAngle_data()
316 void tst_QAbstractAxis::labelsAngle_data()
317 {
317 {
318 QTest::addColumn<int>("labelsAngle");
318 QTest::addColumn<int>("labelsAngle");
319 QTest::newRow("0") << 0;
319 QTest::newRow("0") << 0;
320 QTest::newRow("45") << 45;
320 QTest::newRow("45") << 45;
321 QTest::newRow("90") << 90;
321 QTest::newRow("90") << 90;
322 }
322 }
323
323
324 void tst_QAbstractAxis::labelsAngle()
324 void tst_QAbstractAxis::labelsAngle()
325 {
325 {
326 QFETCH(int, labelsAngle);
326 QFETCH(int, labelsAngle);
327
327
328 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
328 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
329 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
329 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
330 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
330 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
331 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
331 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
332 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
332 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
333 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
333 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
334 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
334 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
335 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
335 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
336 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
336 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
337
337
338 m_axis->setLabelsAngle(labelsAngle);
338 m_axis->setLabelsAngle(labelsAngle);
339 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
339 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
340
340
341 QCOMPARE(spy0.count(), 0);
341 QCOMPARE(spy0.count(), 0);
342 QCOMPARE(spy1.count(), 0);
342 QCOMPARE(spy1.count(), 0);
343 QCOMPARE(spy2.count(), 0);
343 QCOMPARE(spy2.count(), 0);
344 QCOMPARE(spy3.count(), 0);
344 QCOMPARE(spy3.count(), 0);
345 QCOMPARE(spy4.count(), 0);
345 QCOMPARE(spy4.count(), 0);
346 QCOMPARE(spy5.count(), 0);
346 QCOMPARE(spy5.count(), 0);
347 QCOMPARE(spy6.count(), 0);
347 QCOMPARE(spy6.count(), 0);
348 QCOMPARE(spy7.count(), 0);
348 QCOMPARE(spy7.count(), 0);
349 QCOMPARE(spy8.count(), 0);
349 QCOMPARE(spy8.count(), 0);
350
350
351 m_chart->setAxisX(m_axis, m_series);
351 m_chart->setAxisX(m_axis, m_series);
352 m_view->show();
352 m_view->show();
353 QTest::qWaitForWindowShown(m_view);
353 QTest::qWaitForWindowShown(m_view);
354 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
354 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
355 }
355 }
356
356
357 void tst_QAbstractAxis::labelsBrush_data()
357 void tst_QAbstractAxis::labelsBrush_data()
358 {
358 {
359 QTest::addColumn<QBrush>("labelsBrush");
359 QTest::addColumn<QBrush>("labelsBrush");
360 QTest::newRow("null") << QBrush();
360 QTest::newRow("null") << QBrush();
361 QTest::newRow("blue") << QBrush(Qt::blue);
361 QTest::newRow("blue") << QBrush(Qt::blue);
362 QTest::newRow("black") << QBrush(Qt::black);
362 QTest::newRow("black") << QBrush(Qt::black);
363
363
364 }
364 }
365
365
366 void tst_QAbstractAxis::labelsBrush()
366 void tst_QAbstractAxis::labelsBrush()
367 {
367 {
368
368
369 QFETCH(QBrush, labelsBrush);
369 QFETCH(QBrush, labelsBrush);
370
370
371 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
371 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
372 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
372 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
373 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
373 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
374 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
374 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
375 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
375 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
376 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
376 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
377 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
377 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
378 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
378 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
379 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
379 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
380
380
381 m_axis->setLabelsBrush(labelsBrush);
381 m_axis->setLabelsBrush(labelsBrush);
382 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
382 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
383
383
384 QCOMPARE(spy0.count(), 0);
384 QCOMPARE(spy0.count(), 0);
385 QCOMPARE(spy1.count(), 0);
385 QCOMPARE(spy1.count(), 0);
386 QCOMPARE(spy2.count(), 0);
386 QCOMPARE(spy2.count(), 0);
387 QCOMPARE(spy3.count(), 0);
387 QCOMPARE(spy3.count(), 0);
388 QCOMPARE(spy4.count(), 0);
388 QCOMPARE(spy4.count(), 0);
389 QCOMPARE(spy5.count(), 0);
389 QCOMPARE(spy5.count(), 0);
390 //TODO QCOMPARE(spy6.count(), 0);
390 //TODO QCOMPARE(spy6.count(), 0);
391 QCOMPARE(spy7.count(), 0);
391 QCOMPARE(spy7.count(), 0);
392 QCOMPARE(spy8.count(), 0);
392 QCOMPARE(spy8.count(), 0);
393
393
394 m_view->show();
394 m_view->show();
395 QTest::qWaitForWindowShown(m_view);
395 QTest::qWaitForWindowShown(m_view);
396 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
396 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
397
397
398 }
398 }
399
399
400 void tst_QAbstractAxis::labelsColor_data()
400 void tst_QAbstractAxis::labelsColor_data()
401 {
401 {
402
402
403 }
403 }
404
404
405 void tst_QAbstractAxis::labelsColor()
405 void tst_QAbstractAxis::labelsColor()
406 {
406 {
407 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
407 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
408 }
408 }
409
409
410 void tst_QAbstractAxis::labelsFont_data()
410 void tst_QAbstractAxis::labelsFont_data()
411 {
411 {
412 QTest::addColumn<QFont>("labelsFont");
412 QTest::addColumn<QFont>("labelsFont");
413 QTest::newRow("null") << QFont();
413 QTest::newRow("null") << QFont();
414 QTest::newRow("serif") << QFont("SansSerif");
414 QTest::newRow("serif") << QFont("SansSerif");
415 }
415 }
416
416
417 void tst_QAbstractAxis::labelsFont()
417 void tst_QAbstractAxis::labelsFont()
418 {
418 {
419
419
420 QFETCH(QFont, labelsFont);
420 QFETCH(QFont, labelsFont);
421
421
422 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
422 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
423 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
423 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
424 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
424 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
425 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
425 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
426 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
426 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
427 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
427 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
428 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
428 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
429 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
429 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
430 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
430 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
431
431
432 m_axis->setLabelsFont(labelsFont);
432 m_axis->setLabelsFont(labelsFont);
433 QCOMPARE(m_axis->labelsFont(), labelsFont);
433 QCOMPARE(m_axis->labelsFont(), labelsFont);
434
434
435 QCOMPARE(spy0.count(), 0);
435 QCOMPARE(spy0.count(), 0);
436 QCOMPARE(spy1.count(), 0);
436 QCOMPARE(spy1.count(), 0);
437 QCOMPARE(spy2.count(), 0);
437 QCOMPARE(spy2.count(), 0);
438 QCOMPARE(spy3.count(), 0);
438 QCOMPARE(spy3.count(), 0);
439 QCOMPARE(spy4.count(), 0);
439 QCOMPARE(spy4.count(), 0);
440 QCOMPARE(spy5.count(), 0);
440 QCOMPARE(spy5.count(), 0);
441 QCOMPARE(spy6.count(), 0);
441 QCOMPARE(spy6.count(), 0);
442 QCOMPARE(spy7.count(), 0);
442 QCOMPARE(spy7.count(), 0);
443 QCOMPARE(spy8.count(), 0);
443 QCOMPARE(spy8.count(), 0);
444
444
445 m_view->show();
445 m_view->show();
446 QTest::qWaitForWindowShown(m_view);
446 QTest::qWaitForWindowShown(m_view);
447 QCOMPARE(m_axis->labelsFont(), labelsFont);
447 QCOMPARE(m_axis->labelsFont(), labelsFont);
448
448
449 }
449 }
450
450
451 void tst_QAbstractAxis::labelsPen_data()
451 void tst_QAbstractAxis::labelsPen_data()
452 {
452 {
453 QTest::addColumn<QPen>("labelsPen");
453 QTest::addColumn<QPen>("labelsPen");
454 QTest::newRow("null") << QPen();
454 QTest::newRow("null") << QPen();
455 QTest::newRow("blue") << QPen(Qt::blue);
455 QTest::newRow("blue") << QPen(Qt::blue);
456 QTest::newRow("black") << QPen(Qt::black);
456 QTest::newRow("black") << QPen(Qt::black);
457 QTest::newRow("red") << QPen(Qt::red);
457 QTest::newRow("red") << QPen(Qt::red);
458 }
458 }
459
459
460 void tst_QAbstractAxis::labelsPen()
460 void tst_QAbstractAxis::labelsPen()
461 {
461 {
462 QFETCH(QPen, labelsPen);
462 QFETCH(QPen, labelsPen);
463
463
464 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
464 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
465 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
465 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
466 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
466 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
467 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
467 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
468 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
468 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
469 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
469 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
470 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
470 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
471 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
471 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
472 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
472 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
473
473
474 m_axis->setLabelsPen(labelsPen);
474 m_axis->setLabelsPen(labelsPen);
475 QCOMPARE(m_axis->labelsPen(), labelsPen);
475 QCOMPARE(m_axis->labelsPen(), labelsPen);
476
476
477 QCOMPARE(spy0.count(), 0);
477 QCOMPARE(spy0.count(), 0);
478 QCOMPARE(spy1.count(), 0);
478 QCOMPARE(spy1.count(), 0);
479 QCOMPARE(spy2.count(), 0);
479 QCOMPARE(spy2.count(), 0);
480 QCOMPARE(spy3.count(), 0);
480 QCOMPARE(spy3.count(), 0);
481 QCOMPARE(spy4.count(), 0);
481 QCOMPARE(spy4.count(), 0);
482 QCOMPARE(spy5.count(), 0);
482 QCOMPARE(spy5.count(), 0);
483 QCOMPARE(spy6.count(), 0);
483 QCOMPARE(spy6.count(), 0);
484 QCOMPARE(spy7.count(), 0);
484 QCOMPARE(spy7.count(), 0);
485 QCOMPARE(spy8.count(), 0);
485 QCOMPARE(spy8.count(), 0);
486
486
487 m_chart->setAxisX(m_axis, m_series);
487 m_chart->setAxisX(m_axis, m_series);
488 m_view->show();
488 m_view->show();
489 QTest::qWaitForWindowShown(m_view);
489 QTest::qWaitForWindowShown(m_view);
490 //TODO QCOMPARE(m_axis->labelsPen(), labelsPen);
490 //TODO QCOMPARE(m_axis->labelsPen(), labelsPen);
491 }
491 }
492
492
493 void tst_QAbstractAxis::labelsVisible_data()
493 void tst_QAbstractAxis::labelsVisible_data()
494 {
494 {
495 QTest::addColumn<bool>("labelsVisible");
495 QTest::addColumn<bool>("labelsVisible");
496 QTest::newRow("true") << true;
496 QTest::newRow("true") << true;
497 QTest::newRow("false") << false;
497 QTest::newRow("false") << false;
498 }
498 }
499
499
500 void tst_QAbstractAxis::labelsVisible()
500 void tst_QAbstractAxis::labelsVisible()
501 {
501 {
502 QFETCH(bool, labelsVisible);
502 QFETCH(bool, labelsVisible);
503
503
504 m_axis->setLabelsVisible(!labelsVisible);
504 m_axis->setLabelsVisible(!labelsVisible);
505
505
506 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
506 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
507 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
507 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
508 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
508 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
509 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
509 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
510 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
510 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
511 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
511 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
512 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
512 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
513 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
513 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
514 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
514 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
515
515
516 m_axis->setLabelsVisible(labelsVisible);
516 m_axis->setLabelsVisible(labelsVisible);
517 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
517 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
518
518
519 QCOMPARE(spy0.count(), 0);
519 QCOMPARE(spy0.count(), 0);
520 QCOMPARE(spy1.count(), 0);
520 QCOMPARE(spy1.count(), 0);
521 QCOMPARE(spy2.count(), 0);
521 QCOMPARE(spy2.count(), 0);
522 QCOMPARE(spy3.count(), 0);
522 QCOMPARE(spy3.count(), 0);
523 QCOMPARE(spy4.count(), 1);
523 QCOMPARE(spy4.count(), 1);
524 QCOMPARE(spy5.count(), 0);
524 QCOMPARE(spy5.count(), 0);
525 QCOMPARE(spy6.count(), 0);
525 QCOMPARE(spy6.count(), 0);
526 QCOMPARE(spy7.count(), 0);
526 QCOMPARE(spy7.count(), 0);
527 QCOMPARE(spy8.count(), 0);
527 QCOMPARE(spy8.count(), 0);
528
528
529 m_chart->setAxisX(m_axis, m_series);
529 m_chart->setAxisX(m_axis, m_series);
530 m_view->show();
530 m_view->show();
531 QTest::qWaitForWindowShown(m_view);
531 QTest::qWaitForWindowShown(m_view);
532 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
532 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
533 }
533 }
534
534
535 void tst_QAbstractAxis::orientation_data()
535 void tst_QAbstractAxis::orientation_data()
536 {
536 {
537 QTest::addColumn<Qt::Orientation>("orientation");
537 QTest::addColumn<Qt::Orientation>("orientation");
538 QTest::newRow("Vertical") << Qt::Vertical;
538 QTest::newRow("Vertical") << Qt::Vertical;
539 QTest::newRow("Horizontal") << Qt::Horizontal;
539 QTest::newRow("Horizontal") << Qt::Horizontal;
540 }
540 }
541
541
542 void tst_QAbstractAxis::orientation()
542 void tst_QAbstractAxis::orientation()
543 {
543 {
544 QFETCH(Qt::Orientation, orientation);
544 QFETCH(Qt::Orientation, orientation);
545
545
546 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
546 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
547 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
547 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
548 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
548 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
549 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
549 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
550 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
550 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
551 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
551 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
552 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
552 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
553 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
553 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
554 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
554 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
555
555
556 if(orientation==Qt::Vertical){
556 if(orientation==Qt::Vertical){
557 m_chart->setAxisY(m_axis,m_series);
557 m_chart->setAxisY(m_axis,m_series);
558 }else{
558 }else{
559 m_chart->setAxisX(m_axis,m_series);
559 m_chart->setAxisX(m_axis,m_series);
560 }
560 }
561 QCOMPARE(m_axis->orientation(), orientation);
561 QCOMPARE(m_axis->orientation(), orientation);
562
562
563 QCOMPARE(spy0.count(), 0);
563 QCOMPARE(spy0.count(), 0);
564 QCOMPARE(spy1.count(), 0);
564 QCOMPARE(spy1.count(), 0);
565 QCOMPARE(spy2.count(), 0);
565 QCOMPARE(spy2.count(), 0);
566 QCOMPARE(spy3.count(), 0);
566 QCOMPARE(spy3.count(), 0);
567 QCOMPARE(spy4.count(), 0);
567 QCOMPARE(spy4.count(), 0);
568 QCOMPARE(spy5.count(), 0);
568 QCOMPARE(spy5.count(), 0);
569 QCOMPARE(spy6.count(), 0);
569 QCOMPARE(spy6.count(), 0);
570 QCOMPARE(spy7.count(), 0);
570 QCOMPARE(spy7.count(), 0);
571 QCOMPARE(spy8.count(), 1);
571 QCOMPARE(spy8.count(), 1);
572
572
573 m_view->show();
573 m_view->show();
574 QTest::qWaitForWindowShown(m_view);
574 QTest::qWaitForWindowShown(m_view);
575 QCOMPARE(m_axis->orientation(), orientation);
575 QCOMPARE(m_axis->orientation(), orientation);
576 }
576 }
577
577
578 void tst_QAbstractAxis::setMax_data()
578 void tst_QAbstractAxis::setMax_data()
579 {
579 {
580 //just check if it does not crash
580 //just check if it does not crash
581 QTest::addColumn<QVariant>("max");
581 QTest::addColumn<QVariant>("max");
582 QTest::newRow("something") << QVariant("something");
582 QTest::newRow("something") << QVariant("something");
583 QTest::newRow("1.0") << QVariant(1.0);
583 QTest::newRow("1.0") << QVariant(1.0);
584 }
584 }
585
585
586 void tst_QAbstractAxis::setMax()
586 void tst_QAbstractAxis::setMax()
587 {
587 {
588 QFETCH(QVariant, max);
588 QFETCH(QVariant, max);
589 m_axis->setMax(max);
589 m_axis->setMax(max);
590 }
590 }
591
591
592 void tst_QAbstractAxis::setMin_data()
592 void tst_QAbstractAxis::setMin_data()
593 {
593 {
594 //just check if it does not crash
594 //just check if it does not crash
595 QTest::addColumn<QVariant>("min");
595 QTest::addColumn<QVariant>("min");
596 QTest::newRow("something") << QVariant("something");
596 QTest::newRow("something") << QVariant("something");
597 QTest::newRow("1.0") << QVariant(1.0);
597 QTest::newRow("1.0") << QVariant(1.0);
598 }
598 }
599
599
600 // public void setMin(QVariant const& min)
600 // public void setMin(QVariant const& min)
601 void tst_QAbstractAxis::setMin()
601 void tst_QAbstractAxis::setMin()
602 {
602 {
603 QFETCH(QVariant, min);
603 QFETCH(QVariant, min);
604 m_axis->setMin(min);
604 m_axis->setMin(min);
605 }
605 }
606
606
607 void tst_QAbstractAxis::setRange_data()
607 void tst_QAbstractAxis::setRange_data()
608 {
608 {
609 //just check if it does not crash
609 //just check if it does not crash
610 QTest::addColumn<QVariant>("min");
610 QTest::addColumn<QVariant>("min");
611 QTest::addColumn<QVariant>("max");
611 QTest::addColumn<QVariant>("max");
612 QTest::newRow("something") << QVariant("something0") << QVariant("something1");
612 QTest::newRow("something") << QVariant("something0") << QVariant("something1");
613 QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0);
613 QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0);
614 }
614 }
615
615
616 // public void setRange(QVariant const& min, QVariant const& max)
616 // public void setRange(QVariant const& min, QVariant const& max)
617 void tst_QAbstractAxis::setRange()
617 void tst_QAbstractAxis::setRange()
618 {
618 {
619
619
620 QFETCH(QVariant, min);
620 QFETCH(QVariant, min);
621 QFETCH(QVariant, max);
621 QFETCH(QVariant, max);
622 m_axis->setRange(min,max);
622 m_axis->setRange(min,max);
623 }
623 }
624
624
625 void tst_QAbstractAxis::shadesBorderColor_data()
625 void tst_QAbstractAxis::shadesBorderColor_data()
626 {
626 {
627
627
628 }
628 }
629
629
630 void tst_QAbstractAxis::shadesBorderColor()
630 void tst_QAbstractAxis::shadesBorderColor()
631 {
631 {
632 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
632 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
633 }
633 }
634
634
635 void tst_QAbstractAxis::shadesBrush_data()
635 void tst_QAbstractAxis::shadesBrush_data()
636 {
636 {
637 QTest::addColumn<QBrush>("shadesBrush");
637 QTest::addColumn<QBrush>("shadesBrush");
638 QTest::newRow("null") << QBrush();
638 QTest::newRow("null") << QBrush();
639 QTest::newRow("blue") << QBrush(Qt::blue);
639 QTest::newRow("blue") << QBrush(Qt::blue);
640 QTest::newRow("black") << QBrush(Qt::black);
640 QTest::newRow("black") << QBrush(Qt::black);
641 }
641 }
642
642
643 void tst_QAbstractAxis::shadesBrush()
643 void tst_QAbstractAxis::shadesBrush()
644 {
644 {
645 QFETCH(QBrush, shadesBrush);
645 QFETCH(QBrush, shadesBrush);
646
646
647 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
647 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
648 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
648 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
649 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
649 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
650 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
650 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
651 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
651 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
652 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
652 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
653 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
653 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
654 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
654 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
655 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
655 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
656
656
657 m_axis->setShadesBrush(shadesBrush);
657 m_axis->setShadesBrush(shadesBrush);
658 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
658 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
659
659
660 QCOMPARE(spy0.count(), 0);
660 QCOMPARE(spy0.count(), 0);
661 QCOMPARE(spy1.count(), 0);
661 QCOMPARE(spy1.count(), 0);
662 QCOMPARE(spy2.count(), 0);
662 QCOMPARE(spy2.count(), 0);
663 QCOMPARE(spy3.count(), 0);
663 QCOMPARE(spy3.count(), 0);
664 QCOMPARE(spy4.count(), 0);
664 QCOMPARE(spy4.count(), 0);
665 QCOMPARE(spy5.count(), 0);
665 QCOMPARE(spy5.count(), 0);
666 //TODO QCOMPARE(spy6.count(), 0);
666 //TODO QCOMPARE(spy6.count(), 0);
667 QCOMPARE(spy7.count(), 0);
667 QCOMPARE(spy7.count(), 0);
668 QCOMPARE(spy8.count(), 0);
668 QCOMPARE(spy8.count(), 0);
669
669
670 m_view->show();
670 m_view->show();
671 QTest::qWaitForWindowShown(m_view);
671 QTest::qWaitForWindowShown(m_view);
672 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
672 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
673 }
673 }
674
674
675 void tst_QAbstractAxis::shadesColor_data()
675 void tst_QAbstractAxis::shadesColor_data()
676 {
676 {
677 }
677 }
678
678
679 // public QColor shadesColor() const
679 // public QColor shadesColor() const
680 void tst_QAbstractAxis::shadesColor()
680 void tst_QAbstractAxis::shadesColor()
681 {
681 {
682 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
682 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
683 }
683 }
684
684
685 void tst_QAbstractAxis::shadesPen_data()
685 void tst_QAbstractAxis::shadesPen_data()
686 {
686 {
687 QTest::addColumn<QPen>("shadesPen");
687 QTest::addColumn<QPen>("shadesPen");
688 QTest::newRow("null") << QPen();
688 QTest::newRow("null") << QPen();
689 QTest::newRow("blue") << QPen(Qt::blue);
689 QTest::newRow("blue") << QPen(Qt::blue);
690 QTest::newRow("black") << QPen(Qt::black);
690 QTest::newRow("black") << QPen(Qt::black);
691 QTest::newRow("red") << QPen(Qt::red);
691 QTest::newRow("red") << QPen(Qt::red);
692 }
692 }
693
693
694 void tst_QAbstractAxis::shadesPen()
694 void tst_QAbstractAxis::shadesPen()
695 {
695 {
696 QFETCH(QPen, shadesPen);
696 QFETCH(QPen, shadesPen);
697
697
698 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
698 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
699 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
699 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
700 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
700 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
701 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
701 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
702 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
702 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
703 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
703 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
704 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
704 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
705 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
705 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
706 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
706 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
707
707
708 m_axis->setShadesPen(shadesPen);
708 m_axis->setShadesPen(shadesPen);
709 QCOMPARE(m_axis->shadesPen(), shadesPen);
709 QCOMPARE(m_axis->shadesPen(), shadesPen);
710
710
711 QCOMPARE(spy0.count(), 0);
711 QCOMPARE(spy0.count(), 0);
712 QCOMPARE(spy1.count(), 0);
712 QCOMPARE(spy1.count(), 0);
713 QCOMPARE(spy2.count(), 0);
713 QCOMPARE(spy2.count(), 0);
714 QCOMPARE(spy3.count(), 0);
714 QCOMPARE(spy3.count(), 0);
715 QCOMPARE(spy4.count(), 0);
715 QCOMPARE(spy4.count(), 0);
716 QCOMPARE(spy5.count(), 0);
716 QCOMPARE(spy5.count(), 0);
717 QCOMPARE(spy6.count(), 0);
717 QCOMPARE(spy6.count(), 0);
718 QCOMPARE(spy7.count(), 0);
718 QCOMPARE(spy7.count(), 0);
719 QCOMPARE(spy8.count(), 0);
719 QCOMPARE(spy8.count(), 0);
720
720
721 m_chart->setAxisX(m_axis, m_series);
721 m_chart->setAxisX(m_axis, m_series);
722 m_view->show();
722 m_view->show();
723 QTest::qWaitForWindowShown(m_view);
723 QTest::qWaitForWindowShown(m_view);
724 QCOMPARE(m_axis->shadesPen(), shadesPen);
724 QCOMPARE(m_axis->shadesPen(), shadesPen);
725 }
725 }
726
726
727 void tst_QAbstractAxis::shadesVisible_data()
727 void tst_QAbstractAxis::shadesVisible_data()
728 {
728 {
729 QTest::addColumn<bool>("shadesVisible");
729 QTest::addColumn<bool>("shadesVisible");
730 QTest::newRow("true") << true;
730 QTest::newRow("true") << true;
731 QTest::newRow("false") << false;
731 QTest::newRow("false") << false;
732 }
732 }
733
733
734 void tst_QAbstractAxis::shadesVisible()
734 void tst_QAbstractAxis::shadesVisible()
735 {
735 {
736 QFETCH(bool, shadesVisible);
736 QFETCH(bool, shadesVisible);
737
737
738 m_axis->setShadesVisible(!shadesVisible);
738 m_axis->setShadesVisible(!shadesVisible);
739
739
740 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
740 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
741 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
741 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
742 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
742 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
743 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
743 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
744 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
744 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
745 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
745 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
746 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
746 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
747 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
747 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
748 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
748 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
749
749
750 m_axis->setShadesVisible(shadesVisible);
750 m_axis->setShadesVisible(shadesVisible);
751 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
751 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
752
752
753 QCOMPARE(spy0.count(), 0);
753 QCOMPARE(spy0.count(), 0);
754 QCOMPARE(spy1.count(), 0);
754 QCOMPARE(spy1.count(), 0);
755 QCOMPARE(spy2.count(), 0);
755 QCOMPARE(spy2.count(), 0);
756 QCOMPARE(spy3.count(), 0);
756 QCOMPARE(spy3.count(), 0);
757 QCOMPARE(spy4.count(), 0);
757 QCOMPARE(spy4.count(), 0);
758 QCOMPARE(spy5.count(), 0);
758 QCOMPARE(spy5.count(), 0);
759 QCOMPARE(spy6.count(), 0);
759 QCOMPARE(spy6.count(), 0);
760 QCOMPARE(spy7.count(), 1);
760 QCOMPARE(spy7.count(), 1);
761 QCOMPARE(spy8.count(), 0);
761 QCOMPARE(spy8.count(), 0);
762
762
763 m_chart->setAxisX(m_axis, m_series);
763 m_chart->setAxisX(m_axis, m_series);
764 m_view->show();
764 m_view->show();
765 QTest::qWaitForWindowShown(m_view);
765 QTest::qWaitForWindowShown(m_view);
766 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
766 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
767 }
767 }
768
768
769 void tst_QAbstractAxis::show_data()
769 void tst_QAbstractAxis::show_data()
770 {
770 {
771
771
772 }
772 }
773
773
774 void tst_QAbstractAxis::show()
774 void tst_QAbstractAxis::show()
775 {
775 {
776 m_axis->hide();
776 m_axis->hide();
777 QCOMPARE(m_axis->isVisible(), false);
777 QCOMPARE(m_axis->isVisible(), false);
778
778
779 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
779 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
780 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
780 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
781 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
781 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
782 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
782 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
783 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
783 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
784 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
784 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
785 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
785 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
786 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
786 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
787 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
787 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
788
788
789 m_axis->show();
789 m_axis->show();
790
790
791 QCOMPARE(spy0.count(), 0);
791 QCOMPARE(spy0.count(), 0);
792 QCOMPARE(spy1.count(), 0);
792 QCOMPARE(spy1.count(), 0);
793 QCOMPARE(spy2.count(), 0);
793 QCOMPARE(spy2.count(), 0);
794 QCOMPARE(spy3.count(), 0);
794 QCOMPARE(spy3.count(), 0);
795 QCOMPARE(spy4.count(), 0);
795 QCOMPARE(spy4.count(), 0);
796 QCOMPARE(spy5.count(), 0);
796 QCOMPARE(spy5.count(), 0);
797 QCOMPARE(spy6.count(), 0);
797 QCOMPARE(spy6.count(), 0);
798 QCOMPARE(spy7.count(), 0);
798 QCOMPARE(spy7.count(), 0);
799 QCOMPARE(spy8.count(), 1);
799 QCOMPARE(spy8.count(), 1);
800 QCOMPARE(m_axis->isVisible(), true);
800 QCOMPARE(m_axis->isVisible(), true);
801 }
801 }
802
802
803 void tst_QAbstractAxis::hide_data()
803 void tst_QAbstractAxis::hide_data()
804 {
804 {
805
805
806 }
806 }
807
807
808 void tst_QAbstractAxis::hide()
808 void tst_QAbstractAxis::hide()
809 {
809 {
810 m_axis->show();
810 m_axis->show();
811 QCOMPARE(m_axis->isVisible(),true);
811 QCOMPARE(m_axis->isVisible(),true);
812
812
813 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
813 QSignalSpy spy0(m_axis, SIGNAL(arrowVisibleChanged(bool)));
814 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
814 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
815 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
815 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
816 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
816 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
817 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
817 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
818 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
818 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
819 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
819 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
820 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
820 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
821 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
821 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
822
822
823 m_axis->hide();
823 m_axis->hide();
824
824
825 QCOMPARE(spy0.count(), 0);
825 QCOMPARE(spy0.count(), 0);
826 QCOMPARE(spy1.count(), 0);
826 QCOMPARE(spy1.count(), 0);
827 QCOMPARE(spy2.count(), 0);
827 QCOMPARE(spy2.count(), 0);
828 QCOMPARE(spy3.count(), 0);
828 QCOMPARE(spy3.count(), 0);
829 QCOMPARE(spy4.count(), 0);
829 QCOMPARE(spy4.count(), 0);
830 QCOMPARE(spy5.count(), 0);
830 QCOMPARE(spy5.count(), 0);
831 QCOMPARE(spy6.count(), 0);
831 QCOMPARE(spy6.count(), 0);
832 QCOMPARE(spy7.count(), 0);
832 QCOMPARE(spy7.count(), 0);
833 QCOMPARE(spy8.count(), 1);
833 QCOMPARE(spy8.count(), 1);
834 QCOMPARE(m_axis->isVisible(),false);
834 QCOMPARE(m_axis->isVisible(),false);
835 }
835 }
836
836
837
837
838
838
839
839
840
840
841
841
842
842
843
843
844
844
845
845
846
846
847
847
General Comments 0
You need to be logged in to leave comments. Login now